From 753dbacdecc5d737afcd09b6f1c4809aa2a3d2fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Wed, 19 Jun 2019 14:30:01 +0200 Subject: [PATCH] SONAR-12218 remove DB migrations before 8.0 --- .../ComputeEngineContainerImplTest.java | 2 +- .../MigrationConfigurationModule.java | 38 - .../DefaultOrganizationUuidProvider.java | 2 +- .../DefaultOrganizationUuidProviderImpl.java | 2 +- .../version/v56/CreateInitialSchema.java | 924 ----------- .../db/migration/version/v56/DbVersion56.java | 32 - .../version/v56/PopulateInitialSchema.java | 126 -- .../migration/version/v56/package-info.java | 24 - .../migration/version/v561/DbVersion561.java | 30 - .../UpdateUsersExternalIdentityWhenEmpty.java | 69 - .../migration/version/v561/package-info.java | 24 - .../AddAnalysisUuidColumnToCeActivity.java | 45 - .../v60/AddAnalysisUuidColumnToEvents.java | 45 - .../v60/AddAnalysisUuidColumnToMeasures.java | 45 - .../version/v60/AddBColumnsToProjects.java | 55 - ...AnalysisUuidColumnToDuplicationsIndex.java | 46 - .../v60/AddComponentUuidColumnToMeasures.java | 45 - .../AddComponentUuidColumnsToSnapshots.java | 46 - .../v60/AddIndexOnAnalysisUuidOfMeasures.java | 46 - .../AddIndexOnComponentUuidOfMeasures.java | 44 - .../v60/AddLastUsedColumnToRulesProfiles.java | 44 - .../v60/AddProfileKeyToActivities.java | 44 - .../v60/AddUniqueIndexOnUuidOfSnapshots.java | 44 - .../v60/AddUserUpdatedAtToRulesProfiles.java | 44 - .../version/v60/AddUuidColumnToSnapshots.java | 45 - .../version/v60/AddUuidColumnsToProjects.java | 47 - .../v60/AddUuidPathColumnToProjects.java | 44 - .../v60/CleanEventsWithoutAnalysisUuid.java | 45 - .../v60/CleanEventsWithoutSnapshotId.java | 45 - .../CleanMeasuresWithNullAnalysisUuid.java | 45 - .../v60/CleanOrphanRowsInProjects.java | 48 - .../v60/CleanOrphanRowsInSnapshots.java | 62 - .../v60/CleanUsurperRootComponents.java | 156 -- .../CreatePermTemplatesCharacteristics.java | 66 - .../v60/CreateTemporaryIndicesFor1211.java | 51 - .../db/migration/version/v60/DbVersion60.java | 110 -- ...nsIndexRowsWithoutComponentOrAnalysis.java | 61 - .../DeleteOrphanMeasuresWithoutComponent.java | 45 - .../v60/DropIdColumnsFromProjects.java | 44 - .../v60/DropIdColumnsFromSnapshots.java | 44 - ...icationsIndexSidFromDuplicationsIndex.java | 39 - .../DropIndexEventsSnapshotIdFromEvents.java | 39 - .../v60/DropIndexOnSnapshotIdOfMeasures.java | 39 - .../DropIndexProjectsRootIdFromProjects.java | 39 - .../DropIndexProjectsUuidFromProjects.java | 39 - .../DropIndicesOnTreeColumnsOfSnapshots.java | 46 - .../v60/DropProjectIdColumnFromMeasures.java | 41 - .../v60/DropRememberMeColumnsFromUsers.java | 40 - ...DropResourceIndexRidFromResourceIndex.java | 41 - .../DropSnapshotIdColumnFromCeActivity.java | 44 - .../v60/DropSnapshotIdColumnFromEvents.java | 40 - .../v60/DropSnapshotIdColumnFromMeasures.java | 40 - ...napshotIdColumnsFromDuplicationsIndex.java | 41 - .../DropSnapshotProjectIdFromSnapshots.java | 46 - .../v60/DropTemporaryIndicesOf1210.java | 46 - .../v60/DropTreeColumnsFromSnapshots.java | 41 - .../version/v60/DropTreesOfSnapshots.java | 50 - .../v60/DropUnusedMeasuresColumns.java | 58 - .../FixProjectUuidOfDeveloperProjects.java | 53 - .../v60/MakeAnalysisUuidNotNullOnEvents.java | 59 - .../MakeAnalysisUuidNotNullOnMeasures.java | 45 - ...nalysisUuidNotNullOnDuplicationsIndex.java | 66 - ...omponentUuidColumnsNotNullOnSnapshots.java | 70 - .../MakeComponentUuidNotNullOnMeasures.java | 45 - .../MakeProfileKeyNotNullOnActivities.java | 44 - .../v60/MakeUuidColumnNotNullOnSnapshots.java | 45 - .../v60/MakeUuidColumnsNotNullOnProjects.java | 55 - .../MakeUuidPathColumnNotNullOnProjects.java | 44 - .../migration/version/v60/Migration1223.java | 43 - ...opulateAnalysisUuidColumnOnCeActivity.java | 54 - .../v60/PopulateAnalysisUuidOnEvents.java | 55 - .../v60/PopulateAnalysisUuidOnMeasures.java | 74 - ...uidAndAnalysisUuidOfDuplicationsIndex.java | 81 - ...pulateComponentUuidColumnsOfSnapshots.java | 85 - .../v60/PopulateComponentUuidOfMeasures.java | 54 - ...PopulateLastUsedColumnOfRulesProfiles.java | 90 -- .../v60/PopulateProfileKeyOfActivities.java | 66 - .../PopulateUserUpdatedAtOfRulesProfiles.java | 91 -- .../v60/PopulateUuidColumnOnSnapshots.java | 55 - .../v60/PopulateUuidColumnsOfProjects.java | 167 -- .../v60/PopulateUuidPathColumnOnProjects.java | 169 -- ...RecreateIndexProjectsUuidFromProjects.java | 43 - .../v60/RemoveUsersPasswordWhenNotLocal.java | 50 - ...rilyDropIndexOfAnalysisUuidOnMeasures.java | 44 - .../migration/version/v60/package-info.java | 23 - .../version/v61/AddBUuidPathToProjects.java | 44 - .../v61/AddErrorColumnsToCeActivity.java | 46 - .../v61/CopyActivitiesToQprofileChanges.java | 68 - .../version/v61/CreateTableCeTaskInput.java | 47 - .../v61/CreateTableInternalProperties.java | 49 - .../version/v61/CreateTableProperties2.java | 69 - .../v61/CreateTableQprofileChanges.java | 49 - .../v61/CreateTableRuleRepositories.java | 46 - .../v61/CreateTableScannerContext.java | 47 - .../db/migration/version/v61/DbVersion61.java | 56 - .../version/v61/DeleteProjectDashboards.java | 74 - .../version/v61/DeleteReportsFromCeQueue.java | 47 - .../v61/DropIsGlobalFromDashboards.java | 40 - .../version/v61/DropTableActivities.java | 46 - .../version/v61/DropTableProperties.java | 46 - .../migration/version/v61/Migration1304.java | 39 - .../version/v61/PopulateTableProperties2.java | 84 - .../RemoveViewsDefinitionFromProperties.java | 86 -- .../RenameTableProperties2ToProperties.java | 56 - .../v61/ShrinkModuleUuidPathOfProjects.java | 44 - .../migration/version/v61/package-info.java | 23 - .../v62/AddIsRootColumnOnTableUsers.java | 41 - .../v62/AddOrganizationUuidToGroupRoles.java | 46 - .../v62/AddOrganizationUuidToGroups.java | 46 - ...OrganizationUuidToPermissionTemplates.java | 46 - .../v62/AddOrganizationUuidToUserRoles.java | 46 - .../v62/CreateDefaultOrganization.java | 86 -- .../version/v62/CreateTableOrganizations.java | 62 - .../v62/CreateTableWebhookDeliveries.java | 77 - .../db/migration/version/v62/DbVersion62.java | 54 - .../v62/DeletePermissionShareDashboard.java | 51 - .../version/v62/DropIssueFiltersTables.java | 47 - .../version/v62/DropMeasureFiltersTables.java | 47 - .../v62/DropRelatedDashboardTables.java | 48 - ...nizationUuidInUniqueIndexOfGroupRoles.java | 56 - ...keOrganizationUuidNotNullOnGroupRoles.java | 45 - .../MakeOrganizationUuidNotNullOnGroups.java | 45 - ...ationUuidNotNullOnPermissionTemplates.java | 45 - ...akeOrganizationUuidNotNullOnUserRoles.java | 45 - .../MakeRootColumnNotNullOnTableUsers.java | 40 - .../v62/PopulateIsRootColumnOnTableUsers.java | 81 - .../PopulateOrganizationUuidOfGroupRoles.java | 61 - .../v62/PopulateOrganizationUuidOfGroups.java | 67 - ...OrganizationUuidOfPermissionTemplates.java | 67 - .../PopulateOrganizationUuidOfUserRoles.java | 61 - ...UpdateQualityGateConditionsOnCoverage.java | 237 --- .../migration/version/v62/package-info.java | 23 - .../v63/AddColumnGuardedToOrganizations.java | 44 - ...ultPermTemplateColumnsToOrganizations.java | 53 - .../AddIndexOnOrganizationUuidOfProjects.java | 47 - .../v63/AddOrganizationUuidToProjects.java | 46 - .../version/v63/AddUserIdToOrganizations.java | 45 - .../version/v63/AddUuidToEvents.java | 45 - .../db/migration/version/v63/DbVersion63.java | 56 - .../v63/DeleteMeasuresHavingNoValue.java | 56 - .../version/v63/DeleteUselessProperties.java | 59 - .../version/v63/DropTableResourceIndex.java | 60 - ...lumnGuardedOfOrganizationsNotNullable.java | 44 - .../v63/MakeDefaultOrganizationGuarded.java | 43 - .../MakeIndexOnOrganizationsKeeUnique.java | 57 - ...OrganizationUuidOfProjectsNotNullable.java | 42 - .../version/v63/MakeUuidNotNullOnEvents.java | 54 - .../PopulateColumnGuardedOfOrganizations.java | 46 - ...ultPermTemplateColumnsOfOrganizations.java | 147 -- .../PopulateOrganizationUuidToProjects.java | 63 - .../v63/PopulateUuidColumnOfEvents.java | 55 - .../version/v63/UnsetUserRootFlags.java | 51 - .../migration/version/v63/package-info.java | 24 - ...CeActivityWorkerUuidAndExecutionCount.java | 52 - ...AddCeQueueWorkerUuidAndExecutionCount.java | 52 - .../v64/AddColumnNewProjectPrivate.java | 43 - .../version/v64/AddColumnProjectsPrivate.java | 43 - .../v64/AddDefaultGroupIdToOrganizations.java | 44 - .../v64/AddIndexLoadedTemplatesType.java | 46 - .../v64/AddIndexOnActiveRuleParameters.java | 43 - .../AddQualityProfileOrganizationUuid.java | 47 - .../version/v64/AddTagsToProjects.java | 45 - .../v64/CleanLoadedTemplateOrphans.java | 37 - .../v64/CleanOrphanRowsInGroupsUsers.java | 48 - ...CreateMembersGroupsInEachOrganization.java | 92 -- .../v64/CreateOrganizationMembersTable.java | 47 - .../version/v64/CreateRulesMetadata.java | 101 -- .../db/migration/version/v64/DbVersion64.java | 76 - .../v64/DeleteDefaultGroupSetting.java | 39 - ...rmissionTemplatesLinkedToRemovedUsers.java | 47 - .../v64/DropMetadataColumnsFromRules.java | 44 - .../DropUniqueIndexOnQualityProfileKey.java | 41 - ...nQualityProfileOrganizationUuidAndKey.java | 42 - .../v64/ExtendLoadedTemplateTypeColumn.java | 44 - ...keCeActivityExecutionCountNotNullable.java | 49 - .../MakeCeQueueExecutionCountNotNullable.java | 48 - ...akeColumnNewProjectPrivateNotNullable.java | 43 - .../MakeColumnProjectsPrivateNotNullable.java | 43 - ...keComponentsPrivateBasedOnPermissions.java | 282 ---- .../v64/MakeProjectUuidNotNullable.java | 65 - .../v64/MakeQualityProfileKeyUnique.java | 50 - ...tyProfileOrganizationUuidAndKeyUnique.java | 55 - ...ityProfileOrganizationUuidNotNullable.java | 47 - ...teColumnDefaultGroupIdOfOrganizations.java | 63 - .../v64/PopulateColumnProjectsPrivate.java | 51 - .../v64/PopulateOrganizationMembersTable.java | 82 - .../version/v64/PopulateRulesMetadata.java | 128 -- .../PurgeComponentsWithoutProjectUuid.java | 81 - .../version/v64/RestoreSonarUsersGroups.java | 211 --- .../v64/SetAllUsersIntoSonarUsersGroup.java | 56 - .../v64/SetCopyComponentUuidOnLocalViews.java | 99 -- .../v64/SetNewProjectPrivateToFalse.java | 38 - ...etOrganizationMembersIntoMembersGroup.java | 56 - ...alityProfileOrganizationUuidToDefault.java | 43 - ...ateProjectInDefaultPermissionTemplate.java | 188 --- .../SupportProjectVisibilityInTemplates.java | 55 - ...UpgradeQualityTemplateLoadedTemplates.java | 69 - .../migration/version/v64/package-info.java | 24 - .../v65/AddBuiltInFlagToRulesProfiles.java | 44 - .../v65/AddIndexOnEsQueueCreatedAt.java | 47 - ...ndexRulesProfileUuidOnQProfileChanges.java | 53 - .../version/v65/AddUsersOnboarded.java | 43 - .../v65/CleanOrphanRowsInGroupRoles.java | 71 - .../v65/CleanOrphanRowsInManualMeasures.java | 86 -- .../v65/CleanOrphanRowsInProjectLinks.java | 76 - .../v65/CleanOrphanRowsInProperties.java | 85 - .../v65/CleanOrphanRowsInUserRoles.java | 71 - .../version/v65/CreateEsQueueTable.java | 72 - .../v65/CreateTableDefaultQProfiles.java | 81 - .../version/v65/CreateTableOrgQProfiles.java | 103 -- .../db/migration/version/v65/DbVersion65.java | 67 - .../v65/DeleteCeWorkerCountSetting.java | 38 - .../v65/DeleteLoadedTemplatesOnQProfiles.java | 45 - .../v65/DeleteOrphansFromRulesProfiles.java | 51 - .../v65/DropIndexEventsComponentUuid.java | 40 - .../DropIndexManualMeasuresComponentUuid.java | 40 - .../DropIsDefaultColumnFromRulesProfiles.java | 73 - .../v65/DropOrgColumnsFromRulesProfiles.java | 42 - .../version/v65/DropTableAuthors.java | 38 - ...reIssueProjectUuidConsistencyOnIssues.java | 57 - .../MakeEventsComponentUuidNotNullable.java | 46 - ...anualMeasuresComponentUuidNotNullable.java | 46 - ...MakeRulesProfilesIsBuiltInNotNullable.java | 48 - .../v65/MakeUsersOnboardedNotNullable.java | 46 - .../v65/PopulateEventsComponentUuid.java | 83 - .../version/v65/PopulateOrgQProfiles.java | 65 - .../v65/PopulateTableDefaultQProfiles.java | 126 -- .../version/v65/PopulateUsersOnboarded.java | 44 - .../version/v65/PurgeDeveloperData.java | 109 -- .../v65/RecreateIndexEventsComponentUuid.java | 49 - ...reateIndexManualMeasuresComponentUuid.java | 49 - ...eyToRulesProfileUuidOnQProfileChanges.java | 51 - .../v65/SetRulesProfilesIsBuiltInToFalse.java | 46 - ...IsBuiltInToTrueForDefaultOrganization.java | 77 - ...eOrgQProfilesToPointToBuiltInProfiles.java | 124 -- .../migration/version/v65/package-info.java | 24 - .../v66/AddBranchColumnToProjectsTable.java | 44 - .../AddErrorTypeColumnToCeActivityTable.java | 45 - .../v66/AddIndexOnProjectBranchesKey.java | 52 - .../version/v66/AddPluginKeyToRules.java | 45 - .../v66/CreateTableCeTaskCharacteristics.java | 83 - .../version/v66/CreateTablePlugins.java | 81 - .../v66/CreateTableProjectBranches.java | 76 - .../v66/CreateTableQProfileEditGroups.java | 82 - .../v66/CreateTableQProfileEditUsers.java | 82 - .../db/migration/version/v66/DbVersion66.java | 44 - .../v66/DeleteLeakSettingsOnViews.java | 47 - .../v66/FixEmptyIdentityProviderInUsers.java | 55 - .../v66/PopulateMainProjectBranches.java | 62 - .../version/v66/PurgeTableProperties.java | 68 - .../migration/version/v66/package-info.java | 24 - .../AddAnalysisUuidToWebhookDeliveries.java | 48 - .../version/v67/CleanupDisabledUsers.java | 66 - .../version/v67/CopyDeprecatedServerId.java | 63 - .../v67/CreateTableAnalysisProperties.java | 87 -- .../db/migration/version/v67/DbVersion67.java | 39 - .../version/v67/DropOldLicenses.java | 51 - ...ratePreviousAnalysisToPreviousVersion.java | 48 - ...AnalysisUuidColumnOnWebhookDeliveries.java | 56 - ...idColumnToNullableOnWebhookDeliveries.java | 46 - .../migration/version/v67/package-info.java | 24 - ...DefaultQualityGateUuidToOrganizations.java | 45 - .../version/v70/AddHomepageToUsers.java | 50 - .../v70/AddIsBuiltInToQualityGates.java | 44 - .../v70/AddLiveMeasuresMetricIndex.java | 59 - .../version/v70/AddSnapshotIsLastIndex.java | 47 - .../version/v70/AddUuidToQualityGates.java | 44 - ...iateQualityGatesToDefaultOrganization.java | 61 - .../version/v70/CreateBuiltInQualityGate.java | 62 - .../v70/CreateOrgQualityGatesTable.java | 82 - .../version/v70/CreateTableLiveMeasures.java | 109 -- .../v70/CreateTempTableLiveMeasuresP.java | 52 - .../db/migration/version/v70/DbVersion70.java | 65 - .../version/v70/DeleteFileMeasures.java | 48 - .../DeleteGlobalSonarQualityGateSetting.java | 45 - .../version/v70/DeletePersonMeasures.java | 87 -- .../v70/DropIndexOnPersonMeasures.java | 40 - .../version/v70/DropLoadedTemplatesTable.java | 37 - .../version/v70/DropSnapshotIsLastIndex.java | 40 - .../v70/DropTempTableLiveMeasuresP.java | 40 - .../DropUniqueIndexOnQualityGatesName.java | 40 - .../MakeQualityGatesIsBuiltInNotNullable.java | 48 - .../MakeUuidNotNullableOnQualityGates.java | 56 - .../v70/PopulateDefaultQualityGate.java | 63 - .../version/v70/PopulateLiveMeasures.java | 255 --- .../version/v70/PopulateOrgQualityGates.java | 71 - .../v70/PopulateQualityGatesIsBuiltIn.java | 55 - .../v70/PopulateUuidOnQualityGates.java | 55 - ...alSonarQualityGateSettingToDefaultOrg.java | 78 - .../v70/RemoveQualityGateLoadedTemplates.java | 47 - .../v70/RenameOldSonarQubeWayQualityGate.java | 63 - ...yGateUuidAsNotNullableInOrganizations.java | 46 - .../migration/version/v70/package-info.java | 24 - .../v71/AddKeyTypeInProjectBranches.java | 46 - ...AddPullRequestBinaryInProjectBranches.java | 46 - .../migration/version/v71/AddRuleScope.java | 45 - ...AddWebhookKeyToWebhookDeliveriesTable.java | 58 - .../v71/CleanBrokenProjectToQGReferences.java | 72 - .../v71/CleanCeChildTablesOrphans.java | 56 - .../v71/CreateDeprecatedRuleKeysTable.java | 103 -- .../version/v71/CreateTableProjectLinks2.java | 77 - .../version/v71/CreateWebhooksTable.java | 121 -- .../db/migration/version/v71/DbVersion71.java | 56 - .../v71/DeleteMeasuresOfProjectCopies.java | 43 - ...teSettingsDefinedInSonarDotProperties.java | 127 -- .../version/v71/DropTableProjectLinks.java | 38 - .../IncreaseBranchTypeSizeForPullRequest.java | 45 - ...keKeyTypeNotNullableInProjectBranches.java | 46 - .../v71/MakeScopeNotNullableInRules.java | 46 - .../v71/MigrateWebhooksToWebhooksTable.java | 292 ---- .../v71/PopulateTableProjectLinks2.java | 112 -- ...enameTableProjectLinks2ToProjectLinks.java | 56 - .../v71/ReplaceIndexInProjectBranches.java | 74 - .../SetKeyTypeToBranchInProjectBranches.java | 53 - .../version/v71/SetRuleScopeToMain.java | 50 - .../UpdatePermissionTooLongTemplateKeys.java | 66 - .../version/v71/UseRuleIdInQPChangesData.java | 85 - .../migration/version/v71/package-info.java | 24 - .../version/v72/AddExternalIdToUsers.java | 46 - .../version/v72/AddFileSourceLineCount.java | 42 - .../v72/AddHashMethodToUsersTable.java | 45 - .../AddLineHashesVersionToFileSources.java | 44 - .../v72/AddOrganizationUuidToUsers.java | 47 - .../version/v72/AddRuleExternal.java | 45 - .../migration/version/v72/AddUUIDtoUsers.java | 48 - .../v72/AddUniqueIndexOnRulesParameters.java | 59 - .../version/v72/AddUniqueIndexesOnUsers.java | 62 - .../v72/CreateAlmAppInstallsTable.java | 109 -- .../v72/CreateProjectMappingsTable.java | 103 -- .../db/migration/version/v72/DbVersion72.java | 62 - .../v72/DropUserIdFromOrganizations.java | 37 - .../FixDuplicationInExternalLoginOnUsers.java | 56 - .../v72/IncreaseCryptedPasswordSize.java | 45 - .../MakeFileSourceLineCountNotNullable.java | 43 - .../MakeSomeColumnsOfUsersNotNullable.java | 72 - .../v72/PopulateFileSourceLineCount.java | 65 - .../v72/PopulateHashMethodOnUsers.java | 44 - .../v72/PopulateOrganizationUuidOnUsers.java | 55 - .../version/v72/PopulateUUIDOnUsers.java | 58 - .../v72/PurgeDuplicateRulesParameters.java | 75 - .../version/v72/PurgeOrphansForCE.java | 65 - ...xternalIdentityToExternalLoginOnUsers.java | 46 - ...enameLoginToUserUuidOnTableUserTokens.java | 69 - ...ginToNoteUserUuidOnTableRulesMetadata.java | 48 - ...LoginToSubmitterUuidOnTableCeActivity.java | 52 - ...terLoginToSubmitterUuidOnTableCeQueue.java | 46 - ...rLoginToUserUuidOnTableManualMeasures.java | 48 - ...LoginToUserUuidOnTableQProfileChanges.java | 46 - ...uesFromExternalColumnsAndLoginOfUsers.java | 82 - .../migration/version/v72/package-info.java | 24 - .../v73/AddFromHotspotFlagToIssues.java | 47 - .../v73/AddIndexOnOrganizationMembers.java | 47 - .../v73/AddSecurityStandardsToRules.java | 49 - .../v73/AddSubscriptionToOrganizations.java | 48 - .../v73/CreateProjectAlmBindingsTable.java | 121 -- .../db/migration/version/v73/DbVersion73.java | 46 - ...MissingQualityProfilesOnOrganizations.java | 172 --- ...opulateHotspotAdminPermissionOnGroups.java | 70 - ...nPermissionOnTemplatesCharacteristics.java | 74 - ...tspotAdminPermissionOnTemplatesGroups.java | 74 - ...otspotAdminPermissionOnTemplatesUsers.java | 74 - ...PopulateHotspotAdminPermissionOnUsers.java | 70 - .../v73/PopulateMainApplicationBranches.java | 65 - .../PopulateSubscriptionOnOrganizations.java | 84 - ...ubscriptionOnOrganizationsNotNullable.java | 47 - .../migration/version/v73/package-info.java | 24 - .../v74/AddAdHocColumnsInInRulesMetadata.java | 62 - ...dPortfolioCreatorToSonarAdministrator.java | 81 - ...ultPermTemplateColumnsToOrganizations.java | 55 - .../version/v74/AddIsAdHocToRules.java | 47 - .../v74/AddTmpColumnsToCeActivity.java | 31 - .../version/v74/AddTmpColumnsToCeQueue.java | 31 - .../version/v74/AddTmpColumnsToCeTable.java | 70 - .../v74/AddTmpLastKeyColumnsToCeActivity.java | 105 -- .../v74/CleanOrphanRowsInCeTables.java | 66 - ...ationsAndPortfoliosCreatorPermissions.java | 102 -- .../version/v74/CreateCeTaskMessage.java | 83 - .../db/migration/version/v74/DbVersion74.java | 55 - ...aultPermTemplateViewFromOrganizations.java | 39 - ...eMainComponentUuidColumnsToCeActivity.java | 30 - ...lizeMainComponentUuidColumnsToCeQueue.java | 28 - ...lizeMainComponentUuidColumnsToCeTable.java | 91 -- ...inalizeMainLastKeyColumnsToCeActivity.java | 146 -- ...IncreaseOrganizationsKeeAndNameLength.java | 56 - ...ateDefaultPermTemplateOnOrganizations.java | 57 - .../version/v74/PopulateIsAdHocOnRules.java | 54 - ...PopulateNullValuesOfIsExternalOnRules.java | 54 - .../v74/PopulateTmpColumnsToCeActivity.java | 95 -- .../v74/PopulateTmpColumnsToCeQueue.java | 135 -- ...PopulateTmpLastKeyColumnsToCeActivity.java | 74 - ...sExternalAndIsAdHocNotNullableInRules.java | 50 - .../migration/version/v74/package-info.java | 24 - .../version/v75/AddEventComponentChanges.java | 133 -- .../AddIsOwnerUserColumnInAlmAppInstall.java | 46 - ...ddUserExternalIdColumnInAlmAppInstall.java | 58 - .../CreateOrganizationsAlmBindingsTable.java | 114 -- .../db/migration/version/v75/DbVersion75.java | 36 - ...sOwnerUserNotNullableInAlmAppInstalls.java | 46 - .../migration/version/v75/package-info.java | 24 - .../AddUniqueIndexInUserPropertiesTable.java | 58 - ...niqueIndexOnExternalLoginInUsersTable.java | 57 - .../v76/CreateUserPropertiesTable.java | 94 -- .../db/migration/version/v76/DbVersion76.java | 41 - .../v76/DeleteModuleAndFolderMeasures.java | 59 - .../v76/DeleteUselessOnboardingSetting.java | 52 - .../version/v76/DeleteUselessProperty.java | 45 - .../version/v76/FixDirectionOfMetrics.java | 59 - .../version/v76/MigrateModuleProperties.java | 125 -- ...igrateNoMoreUsedQualityGateConditions.java | 428 ----- .../migration/version/v76/package-info.java | 24 - .../version/v77/AddBuildStringToSnapshot.java | 50 - .../AddLastConnectionDateToUserTokens.java | 46 - .../v77/AddLastConnectionDateToUsers.java | 46 - .../AddManualBaselineToProjectBranches.java | 53 - .../AddMembersSyncFlagToOrgAlmBinding.java | 46 - .../db/migration/version/v77/DbVersion77.java | 42 - .../DeleteFavoritesExceedingOneHundred.java | 135 -- ...itesOnNotSupportedComponentQualifiers.java | 50 - .../DeleteTestDataTypeFromFileSources.java | 47 - .../v77/DropDataTypeFromFileSources.java | 63 - .../v77/DropElasticsearchIndexTests.java | 43 - .../version/v77/TruncateEsQueue.java | 39 - .../migration/version/v77/package-info.java | 24 - .../v78/AddIndexToOrgQProfileParentUuid.java | 52 - ...dSecurityFieldsToElasticsearchIndices.java | 55 - .../version/v78/AddSnapshotRevision.java | 47 - .../version/v78/AddWebhooksSecret.java | 47 - ...reateInternalComponentPropertiesTable.java | 106 -- .../db/migration/version/v78/DbVersion78.java | 40 - ...nsOnNewAndResolvedIssuesNotifications.java | 49 - .../version/v78/MigrateRevision.java | 50 - .../v78/RemoveOrphansFromProjectBranches.java | 47 - .../v78/UpdateSecurityHotspotsStatuses.java | 242 --- .../migration/version/v78/package-info.java | 24 - .../version/v79/CreateInitialSchema.java | 1375 +++++++++++++++++ .../db/migration/version/v79/DbVersion79.java | 8 +- .../v79/MigrateVstsProviderToAzureDevOps.java | 65 - .../version/v79/PopulateInitialSchema.java | 276 ++++ .../v79/PopulateInstallDateAndVersion.java | 90 -- .../version/v79/ReindexIssuesAndRules.java | 49 - ...oveQGConditionsOnSecurityReviewRating.java | 48 - ...ateEnvAndSystemVarsFromScannerContext.java | 59 - .../MigrationConfigurationModuleTest.java | 2 +- ...faultOrganizationUuidProviderImplTest.java | 2 +- .../TestDefaultOrganizationUuidProvider.java | 3 +- .../version/v56/DbVersion56Test.java | 47 - .../v56/PopulateInitialSchemaTest.java | 131 -- .../version/v561/DbVersion561Test.java | 47 - ...ateUsersExternalIdentityWhenEmptyTest.java | 102 -- ...AddAnalysisUuidColumnToCeActivityTest.java | 82 - .../AddAnalysisUuidColumnToEventsTest.java | 77 - .../AddAnalysisUuidColumnToMeasuresTest.java | 78 - .../v60/AddBColumnsToProjectsTest.java | 87 -- ...ysisUuidColumnToDuplicationsIndexTest.java | 83 - .../AddComponentUuidColumnToMeasuresTest.java | 75 - ...ddComponentUuidColumnsToSnapshotsTest.java | 76 - ...AddIndexOnComponentUuidOfMeasuresTest.java | 50 - .../AddLastUsedColumnToRulesProfilesTest.java | 74 - .../v60/AddProfileKeyToActivitiesTest.java | 72 - .../AddUniqueIndexOnUuidOfSnapshotsTest.java | 49 - .../AddUserUpdatedAtToRulesProfilesTest.java | 74 - .../v60/AddUuidColumnToSnapshotsTest.java | 74 - .../v60/AddUuidColumnsToProjectsTest.java | 67 - .../CleanEventsWithoutAnalysisUuidTest.java | 90 -- .../v60/CleanEventsWithoutSnapshotIdTest.java | 89 -- ...CleanMeasuresWithNullAnalysisUuidTest.java | 87 -- .../v60/CleanOrphanRowsInSnapshotsTest.java | 160 -- .../v60/CleanUsurperRootComponentsTest.java | 365 ----- ...reatePermTemplatesCharacteristicsTest.java | 55 - .../CreateTemporaryIndicesFor1211Test.java | 56 - .../version/v60/DbVersion60Test.java | 48 - ...eteOrphanMeasuresWithoutComponentTest.java | 89 -- .../v60/DropIdColumnsFromProjectsTest.java | 50 - .../v60/DropIdColumnsFromSnapshotsTest.java | 50 - ...ionsIndexSidFromDuplicationsIndexTest.java | 57 - ...opIndexProjectsRootIdFromProjectsTest.java | 58 - ...DropIndexProjectsUuidFromProjectsTest.java | 58 - .../DropProjectIdColumnFromMeasuresTest.java | 48 - .../DropRememberMeColumnsFromUsersTest.java | 48 - ...ResourceIndexRidFromResourceIndexTest.java | 58 - ...ropSnapshotIdColumnFromCeActivityTest.java | 48 - .../DropSnapshotIdColumnFromEventsTest.java | 48 - .../DropSnapshotIdColumnFromMeasuresTest.java | 48 - ...ropSnapshotProjectIdFromSnapshotsTest.java | 60 - .../v60/DropTemporaryIndicesOf1210Test.java | 59 - .../v60/DropTreeColumnsFromSnapshotsTest.java | 50 - .../version/v60/DropTreesOfSnapshotsTest.java | 91 -- .../v60/DropUnusedMeasuresColumnsTest.java | 50 - ...FixProjectUuidOfDeveloperProjectsTest.java | 110 -- ...MakeAnalysisUuidNotNullOnMeasuresTest.java | 87 -- ...sisUuidNotNullOnDuplicationsIndexTest.java | 111 -- ...nentUuidColumnsNotNullOnSnapshotsTest.java | 92 -- ...akeComponentUuidNotNullOnMeasuresTest.java | 92 -- ...MakeProfileKeyNotNullOnActivitiesTest.java | 78 - .../MakeUuidColumnNotNullOnSnapshotsTest.java | 85 - .../MakeUuidColumnsNotNullOnProjectsTest.java | 101 -- .../version/v60/Migration1223Test.java | 76 - ...ateAnalysisUuidColumnOnCeActivityTest.java | 113 -- .../v60/PopulateAnalysisUuidOnEventsTest.java | 136 -- .../PopulateAnalysisUuidOnMeasuresTest.java | 122 -- ...ndAnalysisUuidOfDuplicationsIndexTest.java | 119 -- ...teComponentUuidColumnsOfSnapshotsTest.java | 119 -- .../PopulateComponentUuidOfMeasuresTest.java | 121 -- ...lateLastUsedColumnOfRulesProfilesTest.java | 134 -- .../PopulateProfileKeyOfActivitiesTest.java | 112 -- ...ulateUserUpdatedAtOfRulesProfilesTest.java | 120 -- .../PopulateUuidColumnOnSnapshotsTest.java | 94 -- .../PopulateUuidColumnsOfProjectsTest.java | 114 -- .../PopulateUuidPathColumnOnProjectsTest.java | 173 --- ...eateIndexProjectsUuidFromProjectsTest.java | 54 - .../RemoveUsersPasswordWhenNotLocalTest.java | 112 -- .../v61/AddErrorColumnsToCeActivityTest.java | 85 - .../CopyActivitiesToQprofileChangesTest.java | 136 -- .../v61/CreateTableCeTaskInputTest.java | 62 - .../CreateTableInternalPropertiesTest.java | 64 - .../v61/CreateTableProperties2Test.java | 67 - .../v61/CreateTableQprofileChangesTest.java | 64 - .../v61/CreateTableRuleRepositoriesTest.java | 62 - .../v61/CreateTableScannerContextTest.java | 62 - .../version/v61/DbVersion61Test.java | 47 - .../v61/DeleteProjectDashboardsTest.java | 139 -- .../v61/DeleteReportsFromCeQueueTest.java | 59 - .../v61/DropIsGlobalFromDashboardsTest.java | 49 - .../version/v61/Migration1304Test.java | 78 - .../v61/PopulateTableProperties2Test.java | 403 ----- ...moveViewsDefinitionFromPropertiesTest.java | 97 -- .../v62/AddIsRootColumnOnTableUsersTest.java | 53 - .../AddOrganizationUuidToGroupRolesTest.java | 57 - .../v62/AddOrganizationUuidToGroupsTest.java | 55 - ...nizationUuidToPermissionTemplatesTest.java | 56 - .../AddOrganizationUuidToUserRolesTest.java | 57 - .../v62/CreateDefaultOrganizationTest.java | 193 --- .../v62/CreateTableOrganizationsTest.java | 68 - .../v62/CreateTableWebhookDeliveriesTest.java | 76 - .../version/v62/DbVersion62Test.java | 46 - .../DeletePermissionShareDashboardTest.java | 73 - .../v62/DropIssueFiltersTableTest.java | 51 - .../v62/DropMeasureFiltersTableTest.java | 51 - .../v62/DropRelatedDashboardTablesTest.java | 55 - ...ganizationUuidNotNullOnGroupRolesTest.java | 85 - ...keOrganizationUuidNotNullOnGroupsTest.java | 84 - ...nUuidNotNullOnPermissionTemplatesTest.java | 86 -- ...rganizationUuidNotNullOnUserRolesTest.java | 85 - ...MakeRootColumnNotNullOnTableUsersTest.java | 51 - .../PopulateIsRootColumnOnTableUsersTest.java | 195 --- ...ulateOrganizationUuidOfGroupRolesTest.java | 76 - .../PopulateOrganizationUuidOfGroupsTest.java | 91 -- ...nizationUuidOfPermissionTemplatesTest.java | 77 - ...pulateOrganizationUuidOfUserRolesTest.java | 76 - ...teQualityGateConditionsOnCoverageTest.java | 379 ----- .../AddColumnGuardedToOrganizationsTest.java | 55 - ...ermTemplateColumnsToOrganizationsTest.java | 56 - ...IndexOnOrganizationUuidOfProjectsTest.java | 53 - .../AddOrganizationUuidToProjectsTest.java | 55 - .../v63/AddUserIdToOrganizationsTest.java | 56 - .../version/v63/AddUuidToEventsTest.java | 57 - .../version/v63/DbVersion63Test.java | 47 - .../v63/DeleteMeasuresHavingNoValueTest.java | 163 -- .../v63/DeleteUselessPropertiesTest.java | 162 -- .../v63/DropTableResourceIndexTest.java | 48 - ...GuardedOfOrganizationsNotNullableTest.java | 82 - .../MakeDefaultOrganizationGuardedTest.java | 124 -- ...nOrganizationsKeeUniqueReentranceTest.java | 80 - ...MakeIndexOnOrganizationsKeeUniqueTest.java | 79 - ...nizationUuidOfProjectsNotNullableTest.java | 85 - .../v63/MakeUuidNotNullOnEventsTest.java | 86 -- ...ulateColumnGuardedOfOrganizationsTest.java | 96 -- ...ermTemplateColumnsOfOrganizationsTest.java | 298 ---- ...opulateOrganizationUuidToProjectsTest.java | 112 -- .../v63/PopulateUuidColumnOfEventsTest.java | 92 -- .../version/v63/UnsetUserRootFlagsTest.java | 87 -- ...tivityWorkerUuidAndExecutionCountTest.java | 54 - ...eQueueWorkerUuidAndExecutionCountTest.java | 54 - .../v64/AddColumnNewProjectPrivateTest.java | 52 - .../v64/AddColumnProjectsPrivateTest.java | 52 - .../AddDefaultGroupIdToOrganizationsTest.java | 56 - .../v64/AddIndexLoadedTemplatesTypeTest.java | 54 - .../AddIndexOnActiveRuleParametersTest.java | 55 - ...AddQualityProfileOrganizationUuidTest.java | 42 - .../version/v64/AddTagsToProjectsTest.java | 56 - .../v64/CleanLoadedTemplateOrphansTest.java | 66 - .../v64/CleanOrphanRowsInGroupsUsersTest.java | 115 -- ...teMembersGroupsInEachOrganizationTest.java | 324 ---- .../CreateOrganizationMembersTableTest.java | 61 - .../version/v64/CreateRulesMetadataTest.java | 70 - .../version/v64/DbVersion64Test.java | 39 - .../v64/DeleteDefaultGroupSettingTest.java | 87 -- ...sionTemplatesLinkedToRemovedUsersTest.java | 134 -- .../v64/DropMetadataColumnsFromRulesTest.java | 49 - ...ropUniqueIndexOnQualityProfileKeyTest.java | 39 - ...lityProfileOrganizationUuidAndKeyTest.java | 40 - .../ExtendLoadedTemplateTypeColumnTest.java | 78 - ...ActivityExecutionCountNotNullableTest.java | 93 -- ...eCeQueueExecutionCountNotNullableTest.java | 88 -- ...olumnNewProjectPrivateNotNullableTest.java | 42 - ...eColumnProjectsPrivateNotNullableTest.java | 42 - ...mponentsPrivateBasedOnPermissionsTest.java | 492 ------ .../v64/MakeProjectUuidNotNullableTest.java | 79 - .../v64/MakeQualityProfileKeyUniqueTest.java | 40 - ...ofileOrganizationUuidAndKeyUniqueTest.java | 39 - ...lumnDefaultGroupIdOfOrganizationsTest.java | 179 --- .../PopulateColumnProjectsPrivateTest.java | 101 -- .../PopulateOrganizationMembersTableTest.java | 311 ---- .../v64/PopulateRulesMetadataTest.java | 291 ---- ...PurgeComponentsWithoutProjectUuidTest.java | 360 ----- .../v64/RestoreSonarUsersGroupsTest.java | 362 ----- .../SetAllUsersIntoSonarUsersGroupTest.java | 132 -- .../SetCopyComponentUuidOnLocalViewsTest.java | 209 --- .../v64/SetNewProjectPrivateToFalseTest.java | 53 - ...ganizationMembersIntoMembersGroupTest.java | 173 --- ...yProfileOrganizationUuidToDefaultTest.java | 60 - ...fileOrganizationUuidToNotNullableTest.java | 42 - ...rojectInDefaultPermissionTemplateTest.java | 281 ---- ...pportProjectVisibilityInTemplatesTest.java | 189 --- ...adeQualityTemplateLoadedTemplatesTest.java | 156 -- .../AddBuiltInFlagToRulesProfilesTest.java | 56 - .../v65/AddIndexOnEsQueueCreatedAtTest.java | 41 - ...RulesProfileUuidOnQProfileChangesTest.java | 44 - .../version/v65/AddUsersOnboardedTest.java | 43 - .../v65/CleanOrphanRowsInGroupRolesTest.java | 188 --- .../CleanOrphanRowsInManualMeasuresTest.java | 152 -- .../CleanOrphanRowsInProjectLinksTest.java | 115 -- .../v65/CleanOrphanRowsInPropertiesTest.java | 142 -- .../v65/CleanOrphanRowsInUserRolesTest.java | 176 --- .../version/v65/CreateEsQueueTableTest.java | 55 - .../v65/CreateTableDefaultQProfilesTest.java | 65 - .../v65/CreateTableOrgQProfilesTest.java | 70 - .../version/v65/DbVersion65Test.java | 39 - .../v65/DeleteCeWorkerCountSettingTest.java | 82 - .../DeleteLoadedTemplatesOnQProfilesTest.java | 73 - .../DeleteOrphansFromRulesProfilesTest.java | 276 ---- .../v65/DropIndexEventsComponentUuidTest.java | 45 - ...pIndexManualMeasuresComponentUuidTest.java | 45 - ...pIsDefaultColumnFromRulesProfilesTest.java | 43 - .../DropOrgColumnsFromRulesProfilesTest.java | 45 - .../version/v65/DropTableAuthorsTest.java | 49 - ...sueProjectUuidConsistencyOnIssuesTest.java | 115 -- ...akeEventsComponentUuidNotNullableTest.java | 69 - ...lMeasuresComponentUuidNotNullableTest.java | 66 - ...RulesProfilesIsBuiltInNotNullableTest.java | 60 - .../MakeUsersOnboardedNotNullableTest.java | 63 - .../v65/PopulateEventsComponentUuidTest.java | 129 -- .../version/v65/PopulateOrgQProfilesTest.java | 116 -- .../PopulateTableDefaultQProfilesTest.java | 111 -- .../v65/PopulateUsersOnboardedTest.java | 68 - .../version/v65/PurgeDeveloperDataTest.java | 238 --- .../RecreateIndexEventsComponentUuidTest.java | 44 - ...eIndexManualMeasuresComponentUuidTest.java | 44 - ...RulesProfileUuidOnQProfileChangesTest.java | 45 - .../SetRulesProfilesIsBuiltInToFalseTest.java | 103 -- ...iltInToTrueForDefaultOrganizationTest.java | 157 -- ...QProfilesToPointToBuiltInProfilesTest.java | 200 --- ...dErrorTypeColumnToCeActivityTableTest.java | 55 - .../version/v66/AddPluginKeyToRulesTest.java | 53 - .../CreateTableCeTaskCharacteristicsTest.java | 61 - .../version/v66/CreateTablePluginsTest.java | 68 - .../v66/CreateTableProjectBranchesTest.java | 66 - .../CreateTableQProfileEditGroupsTest.java | 66 - .../v66/CreateTableQProfileEditUsersTest.java | 66 - .../version/v66/DbVersion66Test.java | 41 - .../v66/DeleteLeakSettingsOnViewsTest.java | 139 -- .../FixEmptyIdentityProviderInUsersTest.java | 105 -- .../v66/PopulateMainProjectBranchesTest.java | 124 -- .../version/v66/PurgeTablePropertiesTest.java | 95 -- ...ddAnalysisUuidToWebhookDeliveriesTest.java | 55 - .../version/v67/CleanupDisabledUsersTest.java | 227 --- .../v67/CopyDeprecatedServerIdTest.java | 89 -- .../CreateTableAnalysisPropertiesTest.java | 54 - .../version/v67/DbVersion67Test.java | 41 - .../version/v67/DropOldLicensesTest.java | 80 - ...PreviousAnalysisToPreviousVersionTest.java | 105 -- ...ysisUuidColumnOnWebhookDeliveriesTest.java | 110 -- ...lumnToNullableOnWebhookDeliveriesTest.java | 55 - ...ultQualityGateUuidToOrganizationsTest.java | 55 - .../version/v70/AddHomepageToUsersTest.java | 61 - .../v70/AddIsBuiltInToQualityGatesTest.java | 56 - .../v70/AddLiveMeasuresMetricIndexTest.java | 45 - .../v70/AddSnapshotIsLastIndexTest.java | 52 - .../v70/AddUuidToQualityGatesTest.java | 54 - ...QualityGatesToDefaultOrganizationTest.java | 152 -- .../v70/CreateBuiltInQualityGateTest.java | 86 -- .../v70/CreateOrgQualityGatesTableTest.java | 64 - .../v70/CreateTableLiveMeasuresTest.java | 58 - .../v70/CreateTempTableLiveMeasuresPTest.java | 52 - .../version/v70/DbVersion70Test.java | 41 - .../version/v70/DeleteFileMeasuresTest.java | 127 -- ...leteGlobalSonarQualityGateSettingTest.java | 100 -- .../version/v70/DeletePersonMeasuresTest.java | 126 -- .../v70/DropIndexOnPersonMeasuresTest.java | 48 - .../v70/DropLoadedTemplatesTableTest.java | 48 - .../v70/DropSnapshotIsLastIndexTest.java | 47 - .../v70/DropTempTableLiveMeasuresPTest.java | 51 - ...DropUniqueIndexOnQualityGatesNameTest.java | 51 - ...eQualityGatesIsBuiltInNotNullableTest.java | 57 - ...MakeUuidNotNullableOnQualityGatesTest.java | 55 - .../v70/PopulateDefaultQualityGateTest.java | 146 -- .../version/v70/PopulateLiveMeasuresTest.java | 288 ---- .../v70/PopulateOrgQualityGatesTest.java | 145 -- .../PopulateQualityGatesIsBuiltInTest.java | 123 -- .../v70/PopulateUuidOnQualityGatesTest.java | 125 -- ...narQualityGateSettingToDefaultOrgTest.java | 162 -- .../RemoveQualityGateLoadedTemplatesTest.java | 92 -- .../RenameOldSonarQubeWayQualityGateTest.java | 145 -- ...eUuidAsNotNullableInOrganizationsTest.java | 57 - .../v71/AddKeyTypeInProjectBranchesTest.java | 56 - ...ullRequestBinaryInProjectBranchesTest.java | 57 - .../version/v71/AddRuleScopeTest.java | 54 - ...ebhookKeyToWebhookDeliveriesTableTest.java | 93 -- .../CleanBrokenProjectToQGReferencesTest.java | 154 -- .../v71/CleanCeChildTablesOrphansTest.java | 183 --- .../CreateDeprecatedRuleKeysTableTest.java | 65 - .../v71/CreateTableProjectLinks2Test.java | 66 - .../version/v71/CreateWebhooksTableTest.java | 59 - .../version/v71/DbVersion71Test.java | 41 - .../DeleteMeasuresOfProjectCopiesTest.java | 104 -- ...ttingsDefinedInSonarDotPropertiesTest.java | 130 -- .../v71/DropTableProjectLinksTest.java | 49 - ...reaseBranchTypeSizeForPullRequestTest.java | 67 - ...yTypeNotNullableInProjectBranchesTest.java | 61 - .../v71/MakeScopeNotNullableInRulesTest.java | 56 - .../MigrateWebhooksToWebhooksTableTest.java | 454 ------ .../v71/PopulateTableProjectLinks2Test.java | 208 --- ...eTableProjectLinks2ToProjectLinksTest.java | 57 - .../ReplaceIndexInProjectBranchesTest.java | 87 -- ...tKeyTypeToBranchInProjectBranchesTest.java | 108 -- .../version/v71/SetRuleScopeToMainTest.java | 92 -- ...datePermissionTooLongTemplateKeysTest.java | 107 -- .../v71/UseRuleIdInQPChangesDataTest.java | 195 --- .../version/v72/AddExternalIdToUsersTest.java | 55 - .../v72/AddFileSourceLineCountTest.java | 55 - .../v72/AddHashMethodToUsersTableTest.java | 54 - ...AddLineHashesVersionToFileSourcesTest.java | 53 - .../v72/AddOrganizationUuidToUsersTest.java | 55 - .../version/v72/AddRuleExternalTest.java | 58 - .../version/v72/AddUUIDtoUsersTest.java | 59 - .../AddUniqueIndexOnRulesParametersTest.java | 53 - .../v72/AddUniqueIndexesOnUsersTest.java | 55 - .../v72/CreateAlmAppInstallsTableTest.java | 69 - .../v72/CreateProjectMappingsTableTest.java | 66 - .../version/v72/DbVersion72Test.java | 40 - .../v72/DropUserIdFromOrganizationsTest.java | 54 - ...DuplicationInExternalLoginOnUsersTest.java | 99 -- .../v72/IncreaseCryptedPasswordSizeTest.java | 64 - ...akeFileSourceLineCountNotNullableTest.java | 61 - ...MakeSomeColumnsOfUsersNotNullableTest.java | 61 - .../v72/PopulateFileSourceLineCountTest.java | 89 -- .../v72/PopulateHashMethodOnUsersTest.java | 101 -- .../PopulateOrganizationUuidOnUsersTest.java | 130 -- .../version/v72/PopulateUUIDOnUsersTest.java | 135 -- .../PurgeDuplicateRulesParametersTest.java | 92 -- .../version/v72/PurgeOrphansForCETest.java | 215 --- ...nalIdentityToExternalLoginOnUsersTest.java | 57 - ...eLoginToUserUuidOnTableUserTokensTest.java | 58 - ...oNoteUserUuidOnTableRulesMetadataTest.java | 56 - ...nToSubmitterUuidOnTableCeActivityTest.java | 62 - ...oginToSubmitterUuidOnTableCeQueueTest.java | 56 - ...inToUserUuidOnTableManualMeasuresTest.java | 56 - ...nToUserUuidOnTableQProfileChangesTest.java | 55 - ...romExternalColumnsAndLoginOfUsersTest.java | 121 -- .../v73/AddFromHotspotFlagToIssuesTest.java | 55 - .../AddIndexOnOrganizationMembersTest.java | 55 - .../v73/AddSecurityStandardsToRulesTest.java | 56 - .../AddSubscriptionToOrganizationsTest.java | 55 - .../CreateProjectAlmBindingsTableTest.java | 71 - .../version/v73/DbVersion73Test.java | 40 - ...ingQualityProfilesOnOrganizationsTest.java | 204 --- ...ateHotspotAdminPermissionOnGroupsTest.java | 77 - ...missionOnTemplatesCharacteristicsTest.java | 95 -- ...tAdminPermissionOnTemplatesGroupsTest.java | 87 -- ...otAdminPermissionOnTemplatesUsersTest.java | 87 -- ...lateHotspotAdminPermissionOnUsersTest.java | 77 - .../PopulateMainApplicationBranchesTest.java | 126 -- ...pulateSubscriptionOnOrganizationsTest.java | 186 --- ...riptionOnOrganizationsNotNullableTest.java | 53 - .../AddAdHocColumnsInInRulesMetadataTest.java | 60 - ...tfolioCreatorToSonarAdministratorTest.java | 148 -- ...ermTemplateColumnsToOrganizationsTest.java | 55 - .../version/v74/AddIsAdHocToRulesTest.java | 55 - .../v74/AddTmpColumnsToCeActivityTest.java | 56 - .../v74/AddTmpColumnsToCeQueueTest.java | 56 - .../AddTmpLastKeyColumnsToCeActivityTest.java | 62 - .../v74/CleanOrphanRowsInCeTablesTest.java | 193 --- ...nsAndPortfoliosCreatorPermissionsTest.java | 213 --- .../version/v74/CreateCeTaskMessageTest.java | 68 - .../version/v74/DbVersion74Test.java | 40 - ...PermTemplateViewFromOrganizationsTest.java | 54 - ...nComponentUuidColumnsToCeActivityTest.java | 63 - ...MainComponentUuidColumnsToCeQueueTest.java | 63 - ...izeMainLastKeyColumnsToCeActivityTest.java | 72 - ...easeOrganizationsKeeAndNameLengthTest.java | 55 - ...efaultPermTemplateOnOrganizationsTest.java | 109 -- .../v74/PopulateIsAdHocOnRulesTest.java | 120 -- ...lateNullValuesOfIsExternalOnRulesTest.java | 105 -- .../PopulateTmpColumnsToCeActivityTest.java | 222 --- .../v74/PopulateTmpColumnsToCeQueueTest.java | 216 --- ...lateTmpLastKeyColumnsToCeActivityTest.java | 116 -- .../db/migration/version/v74/Row.java | 67 - ...ernalAndIsAdHocNotNullableInRulesTest.java | 54 - .../v75/AddEventComponentChangesTest.java | 75 - ...dIsOwnerUserColumnInAlmAppInstallTest.java | 56 - ...erExternalIdColumnInAlmAppInstallTest.java | 57 - ...eateOrganizationsAlmBindingsTableTest.java | 66 - .../version/v75/DbVersion75Test.java | 40 - ...erUserNotNullableInAlmAppInstallsTest.java | 53 - ...dUniqueIndexInUserPropertiesTableTest.java | 55 - ...eIndexOnExternalLoginInUsersTableTest.java | 54 - .../v76/CreateUserPropertiesTableTest.java | 63 - .../version/v76/DbVersion76Test.java | 41 - .../DeleteModuleAndFolderMeasuresTest.java | 139 -- .../DeleteUselessOnboardingSettingTest.java | 67 - .../v76/DeleteUselessPropertyTest.java | 108 -- .../v76/FixDirectionOfMetricsTest.java | 101 -- .../v76/MigrateModulePropertiesTest.java | 201 --- ...teNoMoreUsedQualityGateConditionsTest.java | 311 ---- .../v77/AddBuildStringToSnapshotTest.java | 58 - ...AddLastConnectionDateToUserTokensTest.java | 58 - .../v77/AddLastConnectionDateToUsersTest.java | 58 - ...ddManualBaselineToProjectBranchesTest.java | 56 - ...AddMembersSyncFlagToOrgAlmBindingTest.java | 56 - .../version/v77/DbVersion77Test.java | 42 - ...eleteFavoritesExceedingOneHundredTest.java | 183 --- ...OnNotSupportedComponentQualifiersTest.java | 126 -- ...DeleteTestDataTypeFromFileSourcesTest.java | 82 - .../v77/DropDataTypeFromFileSourcesTest.java | 58 - .../v77/DropElasticsearchIndexTestsTest.java | 60 - .../version/v77/TruncateEsQueueTest.java | 85 - .../AddIndexToOrgQProfileParentUuidTest.java | 54 - ...urityFieldsToElasticsearchIndicesTest.java | 57 - .../version/v78/AddSnapshotRevisionTest.java | 55 - .../version/v78/AddWebhooksSecretTest.java | 55 - ...eInternalComponentPropertiesTableTest.java | 62 - .../version/v78/DbVersion78Test.java | 41 - ...NewAndResolvedIssuesNotificationsTest.java | 89 -- .../version/v78/MigrateRevisionTest.java | 94 -- .../RemoveOrphansFromProjectBranchesTest.java | 104 -- .../UpdateSecurityHotspotsStatusesTest.java | 233 --- .../{v56 => v79}/CreateInitialSchemaTest.java | 45 +- .../version/v79/DbVersion79Test.java | 16 +- .../MigrateVstsProviderToAzureDevOpsTest.java | 105 -- .../v79/PopulateInitialSchemaTest.java | 257 +++ .../PopulateInstallDateAndVersionTest.java | 126 -- .../v79/ReindexIssuesAndRulesTest.java | 61 - ...GConditionsOnSecurityReviewRatingTest.java | 120 -- ...nvAndSystemVarsFromScannerContextTest.java | 113 -- .../internal_properties.sql | 0 .../v56/PopulateInitialSchemaTest/v56.sql | 47 - .../schema.sql | 17 - .../old_ce_activity.sql | 17 - .../events_before_6-0.sql | 12 - .../old_measures.sql | 18 - .../old_projects.sql | 23 - .../duplications_index_5.6.sql | 9 - .../project_measures_5.6.sql | 29 - .../old_snapshots.sql | 33 - .../rules_profiles.sql | 13 - .../activities.sql | 10 - .../rules_profiles.sql | 12 - .../old_snapshots.sql | 32 - .../old_projects.sql | 22 - .../in_progress_events.sql | 15 - .../in_progress_events.sql | 15 - .../in_progress_measures.sql | 20 - ...progress_snapshots_and_children_tables.sql | 101 -- .../complete_schema.sql | 668 -------- .../empty.sql | 0 .../in_progress_project_measures.sql | 32 - .../in_progress_snapshots.sql | 33 - .../projects_5.6.sql | 23 - .../in_progress_measures.sql | 20 - .../in_progress_duplications_index.sql | 11 - .../in_progress_snapshots.sql | 34 - .../in_progress_project_measures.sql | 32 - .../activities.sql | 11 - .../in_progress_snapshots.sql | 34 - .../in_progress_projects.sql | 25 - .../in_progress_ce_activity.sql | 52 - .../in_progress_events_with_snapshots.sql | 48 - .../old_measures.sql | 54 - .../in_progress_measures_with_snapshots.sql | 45 - .../in_progress_snapshots_with_projects.sql | 57 - .../in_progress_measures_with_projects.sql | 65 - .../rules_profiles.sql | 84 - .../activities.sql | 11 - .../schema.sql | 25 - .../in_progress_snapshots.sql | 34 - .../in_progress_projects.sql | 25 - .../in_progress_projects_and_snapshots.sql | 58 - .../schema.sql | 15 - .../old_ce_activity.sql | 17 - .../schema.sql | 22 - .../v61/CreateTableCeTaskInputTest/empty.sql | 0 .../empty.sql | 0 .../v61/CreateTableProperties2Test/empty.sql | 0 .../CreateTableQprofileChangesTest/empty.sql | 0 .../CreateTableRuleRepositoriesTest/empty.sql | 0 .../DeleteProjectDashboardsTest/schema.sql | 39 - .../DeleteReportsFromCeQueueTest/schema.sql | 11 - .../properties_and_properties_2_tables.sql | 20 - .../properties_and_internal_properties.sql | 17 - .../table_users.sql | 17 - .../previous-group_roles.sql | 6 - .../previous-groups.sql | 7 - .../previous-permission_templates.sql | 9 - .../previous-user_roles.sql | 10 - .../organizations_and_internal_properties.sql | 21 - .../CreateTableOrganizationsTest/empty.sql | 0 .../empty.sql | 0 .../roles.sql | 18 - .../v62/DropIssueFiltersTableTest/schema.sql | 20 - .../DropMeasureFiltersTableTest/schema.sql | 20 - .../DropRelatedDashboardTablesTest/schema.sql | 47 - .../in_progress_group_roles.sql | 11 - .../in_progress_groups.sql | 8 - .../in_progress_permission_templates.sql | 10 - .../in_progress_user_roles.sql | 7 - .../users_with_nullable_root.sql | 18 - .../users_and_permissions_tables.sql | 52 - .../group_roles.sql | 21 - .../user_groups.sql | 16 - .../permission_templates.sql | 18 - .../user_roles.sql | 15 - .../schema.sql | 40 - .../previous-organizations.sql | 14 - .../previous-organizations.sql | 10 - .../projects.sql | 42 - .../previous-projects.sql | 41 - .../previous-organizations.sql | 15 - .../AddUuidToEventsTest/previous-events.sql | 11 - .../project_measures.sql | 21 - .../properties.sql | 11 - .../v63/DropTableResourceIndexTest/schema.sql | 12 - .../organizations_with_nullable_guarded.sql | 15 - .../organizations_and_internal_properties.sql | 24 - .../organizations_with_unique_index.sql | 16 - .../organizations_with_non_unique_index.sql | 16 - .../projects_with_nullable_organization.sql | 42 - .../in_progress_events.sql | 12 - .../organizations.sql | 15 - .../properties_and_organizations.sql | 47 - .../projects_with_nullable_organization.sql | 42 - .../in_progress_events.sql | 12 - .../in_progress_users.sql | 18 - .../ce_activity.sql | 23 - .../ce_queue.sql | 14 - ...ons_without_new_project_private_column.sql | 17 - .../projects_without_private_column.sql | 44 - .../previous-organizations.sql | 16 - .../loaded_templates_without_index.sql | 5 - .../active_rule_parameters_without_index.sql | 7 - .../initial.sql | 14 - .../previous-projects.sql | 44 - .../loaded-templates.sql | 5 - .../initial.sql | 26 - .../initial.sql | 66 - .../empty.sql | 0 .../v64/CreateRulesMetadataTest/empty.sql | 0 .../DeleteDefaultGroupSettingTest/initial.sql | 11 - .../initial.sql | 27 - .../rules.sql | 31 - .../initial.sql | 15 - .../initial.sql | 15 - .../loaded-templates.sql | 5 - .../ce_activity.sql | 25 - .../ce_queue.sql | 16 - ...th_nullable_new_project_private_column.sql | 18 - .../projects_with_nullable_private_column.sql | 45 - ...rojects_and_group_roles_and_user_roles.sql | 93 -- .../projects_with_nullable_project_uuid.sql | 44 - .../initial.sql | 14 - .../initial.sql | 14 - .../initial.sql | 35 - .../projects_with_nullable_private_column.sql | 45 - .../initial.sql | 77 - ...d_organization_and_internal_properties.sql | 73 - .../projects_and_children_tables.sql | 242 --- .../RestoreSonarUsersGroupsTest/initial.sql | 65 - .../initial.sql | 36 - .../in_progress_projects.sql | 43 - .../initial.sql | 18 - .../initial.sql | 61 - .../initial.sql | 15 - .../initial.sql | 15 - ...ns_and_groups_and_permission_templates.sql | 55 - .../permission_templates_and_groups.sql | 19 - ...ternal_properties_and_loaded_templates.sql | 32 - .../rules_profiles_6_4.sql | 15 - .../initial.sql | 9 - .../initial.sql | 9 - .../users_without_onboarded_column.sql | 18 - .../group_roles_and_projects.sql | 55 - .../manual_measures_and_projects.sql | 58 - .../project_links_and_projects.sql | 53 - .../properties_and_projects.sql | 57 - .../user_roles_and_projects.sql | 55 - .../v65/CreateEsQueueTableTest/empty.sql | 0 .../CreateTableDefaultQProfilesTest/empty.sql | 0 .../v65/CreateTableOrgQProfilesTest/empty.sql | 0 .../properties.sql | 11 - .../initial.sql | 6 - .../initial.sql | 57 - .../events.sql | 15 - .../manual_measures.sql | 12 - .../initial.sql | 16 - .../initial.sql | 15 - .../v65/DropTableAuthorsTest/authors.sql | 8 - .../issues_and_projects.sql | 83 - .../events.sql | 15 - .../manual_measures.sql | 11 - .../initial.sql | 16 - .../users_with_nullable_onboarded_column.sql | 19 - .../events_and_snapshots.sql | 44 - .../v65/PopulateOrgQProfilesTest/initial.sql | 29 - .../initial.sql | 26 - .../users_with_onboarded_column.sql | 19 - .../projects_and_child_tables.sql | 147 -- .../events.sql | 14 - .../manual_measures.sql | 11 - .../initial.sql | 9 - .../initial.sql | 16 - .../initial.sql | 34 - .../initial.sql | 33 - .../ce_activity_6_5.sql | 21 - .../old_snapshots.sql | 29 - .../v66/AddPluginKeyToRulesTest/rules_6_5.sql | 23 - .../empty.sql | 0 .../v66/CreateTablePluginsTest/empty.sql | 0 .../CreateTableProjectBranchesTest/empty.sql | 0 .../empty.sql | 0 .../empty.sql | 0 .../settings_and_projects.sql | 57 - .../users.sql | 19 - .../initial.sql | 17 - .../initial.sql | 58 - .../PurgeTablePropertiesTest/properties.sql | 11 - .../initial.sql | 16 - .../v67/CleanupDisabledUsersTest/users.sql | 19 - .../CopyDeprecatedServerIdTest/properties.sql | 11 - .../empty.sql | 0 .../v67/DropOldLicensesTest/properties.sql | 11 - .../properties.sql | 11 - .../initial.sql | 46 - .../initial.sql | 17 - .../organizations.sql | 18 - .../v70/AddHomepageToUsersTest/initial.sql | 19 - .../quality_gates.sql | 7 - .../live_measures.sql | 14 - .../AddSnapshotIsLastIndexTest/snapshots.sql | 28 - .../quality_gates.sql | 8 - .../org_quality_gates.sql | 46 - .../quality_gates.sql | 9 - .../CreateOrgQualityGatesTableTest/empty.sql | 0 .../v70/CreateTableLiveMeasuresTest/empty.sql | 0 .../empty.sql | 0 .../v70/DeleteFileMeasuresTest/initial.sql | 98 -- .../properties.sql | 11 - .../initial.sql | 98 -- .../v70/DeletePersonMeasuresTest/initial.sql | 98 -- .../DropIndexOnPersonMeasuresTest/initial.sql | 21 - .../loaded_templates.sql | 6 - .../DropSnapshotIsLastIndexTest/snapshots.sql | 29 - .../live_measures_p.sql | 4 - .../quality_gates.sql | 10 - .../quality_gates.sql | 8 - .../quality_gates.sql | 9 - .../organizations.sql | 29 - .../v70/PopulateLiveMeasuresTest/initial.sql | 121 -- .../org_quality_gates.sql | 37 - .../quality_gates.sql | 8 - .../quality_gates.sql | 9 - .../initial.sql | 58 - .../loaded_templates.sql | 6 - .../quality_gates.sql | 8 - .../organizations.sql | 19 - .../project_branches.sql | 11 - .../project_branches.sql | 12 - .../version/v71/AddRuleScopeTest/rules.sql | 24 - .../webhook-deliveries.sql | 18 - .../properties_and_quality_gates.sql | 21 - .../ce_tables.sql | 69 - .../empty.sql | 0 .../CreateTableProjectLinks2Test/empty.sql | 0 .../v71/CreateWebhooksTableTest/empty.sql | 0 .../initial.sql | 68 - .../properties.sql | 11 - .../project_links.sql | 7 - .../project_branches.sql | 11 - .../project_branches.sql | 12 - .../MakeScopeNotNullableInRulesTest/rules.sql | 25 - .../migrate_webhooks.sql | 76 - .../project_links2.sql | 64 - .../project_links2.sql | 9 - .../project_branches.sql | 12 - .../project_branches.sql | 12 - .../v71/SetRuleScopeToMainTest/rules.sql | 25 - .../templates.sql | 10 - .../rules_and_qprofile_changes.sql | 34 - .../v72/AddExternalIdToUsersTest/users.sql | 22 - .../file_sources.sql | 16 - .../AddHashMethodToUsersTableTest/users.sql | 21 - .../fileSources.sql | 17 - .../AddOrganizationUuidToUsersTest/users.sql | 26 - .../version/v72/AddRuleExternalTest/rules.sql | 25 - .../version/v72/AddUUIDtoUsers/users.sql | 22 - .../rules_parameters.sql | 9 - .../v72/AddUniqueIndexesOnUsersTest/users.sql | 23 - .../CreateAlmAppInstallsTableTest/empty.sql | 0 .../CreateProjectMappingsTableTest/empty.sql | 0 .../organizations.sql | 19 - .../users.sql | 23 - .../IncreaseCryptedPasswordSizeTest/users.sql | 21 - .../file_sources.sql | 17 - .../users.sql | 23 - .../file_sources.sql | 17 - .../PopulateHashMethodOnUsersTest/users.sql | 22 - .../schema.sql | 47 - .../v72/PopulateUUIDOnUsersTest/users.sql | 23 - .../rules_parameters_etc.sql | 18 - .../version/v72/PurgeOrphansForCETest/ce.sql | 75 - .../users.sql | 23 - .../issues.sql | 37 - .../user_tokens.sql | 9 - .../rules_metadata.sql | 15 - .../ce_activity.sql | 27 - .../ce_queue.sql | 16 - .../manual_measures.sql | 12 - .../qprofile_changes.sql | 9 - .../users.sql | 23 - .../AddFromHotspotFlagToIssuesTest/issues.sql | 37 - .../organization_members.sql | 6 - .../AddSecurityStandardsToRulesTest/rules.sql | 26 - .../organizations.sql | 19 - .../empty.sql | 0 .../schema.sql | 59 - .../group_roles.sql | 9 - .../perm_tpl_characteristics.sql | 9 - .../perm_templates_groups.sql | 8 - .../perm_templates_users.sql | 8 - .../user_roles.sql | 9 - .../schema.sql | 61 - .../schema.sql | 67 - .../organizations.sql | 19 - .../rules_metadata.sql | 16 - .../group_roles_and_internal_properties.sql | 36 - .../previous-organizations.sql | 20 - .../v74/AddIsAdHocToRulesTest/rules.sql | 27 - .../ce_activity.sql | 26 - .../AddTmpColumnsToCeQueueTest/ce_queue.sql | 16 - .../ce_activity.sql | 30 - .../ce_tables.sql | 83 - .../perm_templates_groups.sql | 49 - .../v74/CreateCeTaskMessageTest/empty.sql | 0 .../organizations.sql | 22 - .../ce_activity.sql | 38 - .../ce_queue.sql | 20 - .../ce_activity.sql | 36 - .../organizations.sql | 20 - .../organizations.sql | 22 - .../v74/PopulateIsAdHocOnRulesTest/rules.sql | 28 - .../rules.sql | 27 - .../ce_activity.sql | 87 -- .../ce_queue.sql | 77 - .../ce_activity.sql | 38 - .../rules.sql | 28 - .../AddEventComponentChangesTest/empty.sql | 0 .../almAppInstalls.sql | 12 - .../almAppInstalls.sql | 13 - .../almAppInstalls.sql | 15 - .../user_properties.sql | 10 - .../users.sql | 27 - .../project_measures.sql | 67 - .../properties.sql | 11 - .../DeleteUselessPropertyTest/properties.sql | 11 - .../v76/FixDirectionOfMetricsTest/metrics.sql | 19 - .../MigrateModulePropertiesTest/schema.sql | 35 - .../qg-schema.sql | 41 - .../snapshots.sql | 29 - .../user_tokens.sql | 9 - .../users.sql | 28 - .../initial.sql | 16 - .../org_alm_binding.sql | 12 - .../schema.sql | 59 - .../schema.sql | 59 - .../file_sources.sql | 18 - .../file_sources.sql | 18 - .../v77/TruncateEsQueueTest/es_queue.sql | 11 - .../org_qprofiles.sql | 14 - .../v78/AddSnapshotRevisionTest/snapshots.sql | 29 - .../v78/AddWebhooksSecretTest/webhooks.sql | 13 - .../schema.sql | 11 - .../v78/MigrateRevisionTest/snapshots.sql | 45 - .../project_and_project_branches.sql | 62 - .../schema.sql | 81 - .../CreateInitialSchemaTest/empty.sql | 0 .../properties.sql | 12 - .../v79/PopulateInitialSchemaTest/v79.sql | 968 ++++++++++++ .../schema.sql | 39 - .../quality_gate_conditions.sql | 31 - .../ce_scanner_context.sql | 8 - 1198 files changed, 2927 insertions(+), 74426 deletions(-) rename server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/{v63 => }/DefaultOrganizationUuidProvider.java (96%) rename server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/{v63 => }/DefaultOrganizationUuidProviderImpl.java (97%) delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchema.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/DbVersion56.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchema.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/DbVersion561.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmpty.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEvents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnAnalysisUuidOfMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivities.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidPathColumnToProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotId.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristics.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponent.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexEventsSnapshotIdFromEvents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexOnSnapshotIdOfMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEvents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnsFromDuplicationsIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumns.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnEvents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivities.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidPathColumnNotNullOnProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/Migration1223.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEvents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivities.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshots.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocal.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/AddBUuidPathToProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChanges.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInput.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChanges.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositories.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContext.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DbVersion61.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboards.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropIsGlobalFromDashboards.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropTableActivities.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropTableProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/Migration1304.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RenameTableProperties2ToProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/ShrinkModuleUuidPathOfProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganization.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveries.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DbVersion62.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboard.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTables.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTables.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTables.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/IncludeOrganizationUuidInUniqueIndexOfGroupRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverage.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEvents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DbVersion63.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValue.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuarded.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUnique.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEvents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEvents.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlags.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCount.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCount.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivate.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivate.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesType.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParameters.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjects.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphans.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganization.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadata.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DbVersion64.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSetting.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKey.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKey.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUnique.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUnique.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivate.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadata.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroup.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViews.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalse.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroup.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefault.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplate.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAt.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChanges.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboarded.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinks.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSetting.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropTableAuthors.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssues.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboarded.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperData.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChanges.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalse.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganization.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfiles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddBranchColumnToProjectsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddIndexOnProjectBranchesKey.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristics.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTablePlugins.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViews.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PurgeTableProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveries.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerId.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DropOldLicenses.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersion.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveries.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganization.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGate.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresP.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSetting.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndex.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresP.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesName.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGate.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltIn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrg.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGate.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddRuleScope.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferences.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphans.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DbVersion71.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopies.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinks.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequest.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinks.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMain.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeys.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesData.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCount.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSources.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddRuleExternal.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParameters.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/DbVersion72.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSize.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCount.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParameters.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCE.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokens.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueue.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChanges.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssues.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/DbVersion73.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristics.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadata.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueue.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTables.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessage.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueue.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLength.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueue.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivity.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChanges.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstall.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstall.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/CreateOrganizationsAlmBindingsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/DbVersion75.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstalls.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/CreateUserPropertiesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSetting.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessProperty.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetrics.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateModuleProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshot.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokens.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBinding.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundred.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSources.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSources.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropElasticsearchIndexTests.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueue.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddSecurityFieldsToElasticsearchIndices.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevision.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecret.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/CreateInternalComponentPropertiesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/DbVersion78.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/MigrateRevision.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranches.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatuses.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/package-info.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchema.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOps.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchema.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersion.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/ReindexIssuesAndRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRating.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContext.java rename server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/{v63 => }/DefaultOrganizationUuidProviderImplTest.java (97%) rename server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/{v63 => }/TestDefaultOrganizationUuidProvider.java (94%) delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/DbVersion56Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/DbVersion561Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEventsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumnsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DbVersion61Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DropIsGlobalFromDashboardsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/Migration1304Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DbVersion62Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DbVersion63Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueReentranceTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCountTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCountTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivateTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivateTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesTypeTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParametersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjectsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphansTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganizationTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadataTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DbVersion64Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSettingTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKeyTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUniqueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUniqueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivateTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroupTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalseTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroupTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefaultTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplateTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAtTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboardedTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinksTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInPropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSettingTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropTableAuthorsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssuesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboardedTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperDataTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalseTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfilesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristicsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTablePluginsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PurgeTablePropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerIdTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisPropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DropOldLicensesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersionTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganizationTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGateTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresPTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSettingTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndexTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresPTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesNameTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGateTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltInTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrgTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddRuleScopeTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferencesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphansTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DbVersion71Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotPropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinksTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequestTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinksTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMainTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeysTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesDataTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCountTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSourcesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddRuleExternalTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParametersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/DbVersion72Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSizeTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCountTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParametersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCETest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokensTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChangesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssuesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/DbVersion73Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadataTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTablesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessageTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLengthTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivityTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/Row.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChangesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstallTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstallTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/CreateOrganizationsAlmBindingsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/DbVersion75Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/CreateUserPropertiesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSettingTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessPropertyTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetricsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshotTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokensTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBindingTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundredTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSourcesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSourcesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropElasticsearchIndexTestsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueueTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddSecurityFieldsToElasticsearchIndicesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevisionTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecretTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/CreateInternalComponentPropertiesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/DbVersion78Test.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/MigrateRevisionTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranchesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest.java rename server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/{v56 => v79}/CreateInitialSchemaTest.java (73%) delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOpsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchemaTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersionTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/ReindexIssuesAndRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRatingTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContextTest.java rename server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/{v63 => }/DefaultOrganizationUuidProviderImplTest/internal_properties.sql (100%) delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest/v56.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest/old_ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest/events_before_6-0.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest/old_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest/project_measures_5.6.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest/old_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest/rules_profiles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest/activities.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest/rules_profiles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest/old_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest/old_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest/in_progress_events.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest/in_progress_events.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest/in_progress_snapshots_and_children_tables.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest/in_progress_project_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest/in_progress_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest/in_progress_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest/in_progress_project_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest/activities.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest/in_progress_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest/in_progress_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest/in_progress_ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest/in_progress_events_with_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest/in_progress_snapshots_with_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest/in_progress_measures_with_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest/rules_profiles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest/activities.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest/in_progress_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest/in_progress_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest/in_progress_projects_and_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest/old_ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test/properties_and_properties_2_tables.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest/properties_and_internal_properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest/table_users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest/previous-group_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest/previous-groups.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest/previous-permission_templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest/previous-user_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest/organizations_and_internal_properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest/roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest/in_progress_group_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest/in_progress_groups.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest/in_progress_permission_templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest/in_progress_user_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest/users_with_nullable_root.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest/users_and_permissions_tables.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest/group_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest/user_groups.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest/permission_templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest/user_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest/previous-organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest/previous-organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest/projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest/previous-projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest/previous-organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest/previous-events.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest/project_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest/organizations_with_nullable_guarded.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest/organizations_and_internal_properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueReentranceTest/organizations_with_unique_index.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueTest/organizations_with_non_unique_index.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest/projects_with_nullable_organization.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest/in_progress_events.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest/properties_and_organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest/projects_with_nullable_organization.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest/in_progress_events.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest/in_progress_users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCountTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCountTest/ce_queue.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivateTest/organizations_without_new_project_private_column.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivateTest/projects_without_private_column.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizationsTest/previous-organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesTypeTest/loaded_templates_without_index.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParametersTest/active_rule_parameters_without_index.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuidTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjectsTest/previous-projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphansTest/loaded-templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsersTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganizationTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTableTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadataTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSettingTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsersTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRulesTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKeyTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumnTest/loaded-templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullableTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullableTest/ce_queue.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullableTest/organizations_with_nullable_new_project_private_column.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullableTest/projects_with_nullable_private_column.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissionsTest/projects_and_group_roles_and_user_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullableTest/projects_with_nullable_project_uuid.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUniqueTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUniqueTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizationsTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivateTest/projects_with_nullable_private_column.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest/rules_and_rules_metadata_and_organization_and_internal_properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuidTest/projects_and_children_tables.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroupsTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroupTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest/in_progress_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalseTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroupTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefaultTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToNotNullableTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplateTest/organizations_and_groups_and_permission_templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplatesTest/permission_templates_and_groups.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplatesTest/organizations_internal_properties_and_loaded_templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfilesTest/rules_profiles_6_4.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAtTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboardedTest/users_without_onboarded_column.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRolesTest/group_roles_and_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasuresTest/manual_measures_and_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinksTest/project_links_and_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInPropertiesTest/properties_and_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRolesTest/user_roles_and_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTableTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfilesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfilesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSettingTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfilesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfilesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuidTest/events.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuidTest/manual_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfilesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfilesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropTableAuthorsTest/authors.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssuesTest/issues_and_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullableTest/events.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullableTest/manual_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullableTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullableTest/users_with_nullable_onboarded_column.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuidTest/events_and_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfilesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfilesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboardedTest/users_with_onboarded_column.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperDataTest/projects_and_child_tables.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuidTest/events.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuidTest/manual_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalseTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfilesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTableTest/ce_activity_6_5.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddIncrementalColumnToSnapshotsTableTest/old_snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRulesTest/rules_6_5.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristicsTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTablePluginsTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranchesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroupsTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsersTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest/settings_and_projects.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/MakeAnalysisUuidNotNullOnWebhookDeliveriesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PurgeTablePropertiesTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerIdTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisPropertiesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/DropOldLicensesTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersionTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizationsTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsersTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndexTest/live_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndexTest/snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGatesTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganizationTest/org_quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGateTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTableTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasuresTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresPTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasuresTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSettingTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeletePersonAndFileMeasuresTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasuresTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasuresTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTableTest/loaded_templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndexTest/snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresPTest/live_measures_p.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesNameTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullableTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGatesTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGateTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGates/org_quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltInTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGatesTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrgTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplatesTest/loaded_templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest/quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranchesTest/project_branches.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranchesTest/project_branches.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddRuleScopeTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTableTest/webhook-deliveries.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferencesTest/properties_and_quality_gates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphansTest/ce_tables.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTableTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2Test/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTableTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopiesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotPropertiesTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinksTest/project_links.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequestTest/project_branches.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranchesTest/project_branches.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRulesTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTableTest/migrate_webhooks.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2Test/project_links2.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinksTest/project_links2.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranchesTest/project_branches.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranchesTest/project_branches.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMainTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeysTest/templates.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesDataTest/rules_and_qprofile_changes.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCountTest/file_sources.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTableTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSourcesTest/fileSources.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddRuleExternalTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParametersTest/rules_parameters.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTableTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTableTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizationsTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSizeTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullableTest/file_sources.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCountTest/file_sources.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParametersTest/rules_parameters_etc.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCETest/ce.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameIssuesAssigneeToAssigneeUuidTest/issues.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokensTest/user_tokens.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest/rules_metadata.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest/ce_queue.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasuresTest/manual_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChangesTest/qprofile_changes.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssuesTest/issues.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembersTest/organization_members.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRulesTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizationsTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTableTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizationsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroupsTest/group_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest/perm_tpl_characteristics.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroupsTest/perm_templates_groups.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsersTest/perm_templates_users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsersTest/user_roles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranchesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizationsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullableTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadataTest/rules_metadata.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest/group_roles_and_internal_properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizationsTest/previous-organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRulesTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivityTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueueTest/ce_queue.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivityTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTablesTest/ce_tables.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissionsTest/perm_templates_groups.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessageTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest/ce_queue.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLengthTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizationsTest/organizations.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRulesTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRulesTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivityTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueueTest/ce_queue.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivityTest/ce_activity.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRulesTest/rules.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChangesTest/empty.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstallTest/almAppInstalls.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstallTest/almAppInstalls.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest/almAppInstalls.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTableTest/user_properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTableTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasuresTest/project_measures.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSettingTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteUselessPropertyTest/properties.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetricsTest/metrics.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditionsTest/qg-schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshotTest/snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokensTest/user_tokens.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsersTest/users.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranchesTest/initial.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBindingTest/org_alm_binding.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundredTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSourcesTest/file_sources.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSourcesTest/file_sources.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueueTest/es_queue.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuidTest/org_qprofiles.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevisionTest/snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecretTest/webhooks.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/MigrateRevisionTest/snapshots.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranchesTest/project_and_project_branches.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest/schema.sql rename server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/{v56 => v79}/CreateInitialSchemaTest/empty.sql (100%) delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOpsTest/properties.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchemaTest/v79.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersionTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRatingTest/quality_gate_conditions.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContextTest/ce_scanner_context.sql diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index 68361fe5b64..4de5acb9b21 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -122,7 +122,7 @@ public class ComputeEngineContainerImplTest { ); assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize( CONTAINER_ITSELF - + 25 // MigrationConfigurationModule + + 6 // MigrationConfigurationModule + 16 // level 2 ); assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( 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 7bd362aaf87..fc1127987c3 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 @@ -24,25 +24,6 @@ import org.sonar.server.platform.db.migration.history.MigrationHistoryImpl; import org.sonar.server.platform.db.migration.history.MigrationHistoryMeddler; import org.sonar.server.platform.db.migration.step.MigrationStepRegistryImpl; import org.sonar.server.platform.db.migration.step.MigrationStepsProvider; -import org.sonar.server.platform.db.migration.version.v56.DbVersion56; -import org.sonar.server.platform.db.migration.version.v561.DbVersion561; -import org.sonar.server.platform.db.migration.version.v60.DbVersion60; -import org.sonar.server.platform.db.migration.version.v61.DbVersion61; -import org.sonar.server.platform.db.migration.version.v62.DbVersion62; -import org.sonar.server.platform.db.migration.version.v63.DbVersion63; -import org.sonar.server.platform.db.migration.version.v64.DbVersion64; -import org.sonar.server.platform.db.migration.version.v65.DbVersion65; -import org.sonar.server.platform.db.migration.version.v66.DbVersion66; -import org.sonar.server.platform.db.migration.version.v67.DbVersion67; -import org.sonar.server.platform.db.migration.version.v70.DbVersion70; -import org.sonar.server.platform.db.migration.version.v71.DbVersion71; -import org.sonar.server.platform.db.migration.version.v72.DbVersion72; -import org.sonar.server.platform.db.migration.version.v73.DbVersion73; -import org.sonar.server.platform.db.migration.version.v74.DbVersion74; -import org.sonar.server.platform.db.migration.version.v75.DbVersion75; -import org.sonar.server.platform.db.migration.version.v76.DbVersion76; -import org.sonar.server.platform.db.migration.version.v77.DbVersion77; -import org.sonar.server.platform.db.migration.version.v78.DbVersion78; import org.sonar.server.platform.db.migration.version.v79.DbVersion79; import org.sonar.server.platform.db.migration.version.v80.DbVersion80; @@ -51,25 +32,6 @@ public class MigrationConfigurationModule extends Module { protected void configureModule() { add( // DbVersion implementations - DbVersion56.class, - DbVersion561.class, - DbVersion60.class, - DbVersion61.class, - DbVersion62.class, - DbVersion63.class, - DbVersion64.class, - DbVersion65.class, - DbVersion66.class, - DbVersion67.class, - DbVersion70.class, - DbVersion71.class, - DbVersion72.class, - DbVersion73.class, - DbVersion74.class, - DbVersion75.class, - DbVersion76.class, - DbVersion77.class, - DbVersion78.class, DbVersion79.class, DbVersion80.class, diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProvider.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProvider.java similarity index 96% rename from server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProvider.java rename to server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProvider.java index 680300c382c..744d1fd6d4d 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProvider.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProvider.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v63; +package org.sonar.server.platform.db.migration.version; import java.sql.SQLException; import org.sonar.server.platform.db.migration.step.DataChange; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProviderImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProviderImpl.java similarity index 97% rename from server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProviderImpl.java rename to server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProviderImpl.java index bb4ecc426ca..361d0f472cb 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProviderImpl.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProviderImpl.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v63; +package org.sonar.server.platform.db.migration.version; import java.sql.SQLException; import org.sonar.server.platform.db.migration.step.DataChange; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchema.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchema.java deleted file mode 100644 index 54e7faf925f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchema.java +++ /dev/null @@ -1,924 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v56; - -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.BooleanColumnDef; -import org.sonar.server.platform.db.migration.def.ColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.def.IntegerColumnDef; -import org.sonar.server.platform.db.migration.def.TinyIntColumnDef; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -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.BlobColumnDef.newBlobColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.ClobColumnDef.newClobColumnDefBuilder; -import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.ColumnFlag.AUTO_INCREMENT; -import static org.sonar.server.platform.db.migration.def.DecimalColumnDef.newDecimalColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.IntegerColumnDef.newIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.TimestampColumnDef.newTimestampColumnDefBuilder; - -public class CreateInitialSchema extends DdlChange { - - public CreateInitialSchema(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - createActiveDashboards(context); - createActiveRuleParameters(context); - createActiveRules(context); - createActivities(context); - createAuthors(context); - createCeActivity(context); - createCeQueue(context); - createDashboards(context); - createDuplicationsIndex(context); - createEvents(context); - createFileSources(context); - createGroupRoles(context); - createGroups(context); - createGroupsUsers(context); - createIssueChanges(context); - createIssueFilterFavourites(context); - createIssueFilters(context); - createIssues(context); - createLoadedTemplates(context); - createManualMeasures(context); - createMeasureFilterFavourites(context); - createMeasureFilters(context); - createMetrics(context); - createNotifications(context); - createPermissionTemplates(context); - createPermTemplatesGroups(context); - createPermTemplatesUsers(context); - createProjectLinks(context); - createProjectMeasures(context); - createProjectQprofiles(context); - createProjects(context); - createProperties(context); - createQualityGateConditions(context); - createQualityGates(context); - createResourceIndex(context); - createRules(context); - createRulesParameters(context); - createRulesProfiles(context); - createSnapshots(context); - createUserRoles(context); - createUserTokens(context); - createUsers(context); - createWidgetProperties(context); - createWidgets(context); - } - - private void createUserTokens(Context context) throws SQLException { - VarcharColumnDef loginCol = newLenientVarcharBuilder("login").setLimit(255).setIsNullable(false).build(); - VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); - VarcharColumnDef tokenHashCol = newLenientVarcharBuilder("token_hash").setLimit(255).setIsNullable(false).build(); - context.execute( - newTableBuilder("user_tokens") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(loginCol) - .addColumn(nameCol) - .addColumn(tokenHashCol) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .build()); - addIndex(context, "user_tokens", "user_tokens_login_name", true, loginCol, nameCol); - addIndex(context, "user_tokens", "user_tokens_token_hash", true, tokenHashCol); - } - - private void createCeActivity(Context context) throws SQLException { - VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(40).setIsNullable(false).build(); - VarcharColumnDef isLastKeyCol = newLenientVarcharBuilder("is_last_key").setLimit(55).setIsNullable(false).build(); - BooleanColumnDef isLastCol = newBooleanColumnDefBuilder().setColumnName("is_last").setIsNullable(false).build(); - VarcharColumnDef statusCol = newLenientVarcharBuilder("status").setLimit(15).setIsNullable(false).build(); - VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(40).build(); - context.execute( - newTableBuilder("ce_activity") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(uuidCol) - .addColumn(newLenientVarcharBuilder("task_type").setLimit(15).setIsNullable(false).build()) - .addColumn(componentUuidCol) - .addColumn(statusCol) - .addColumn(isLastCol) - .addColumn(isLastKeyCol) - .addColumn(newLenientVarcharBuilder("submitter_login").setLimit(255).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("submitted_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("started_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("executed_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("execution_time_ms").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("snapshot_id").build()) - .build()); - addIndex(context, "ce_activity", "ce_activity_component_uuid", false, componentUuidCol); - addIndex(context, "ce_activity", "ce_activity_islast_status", false, isLastCol, statusCol); - addIndex(context, "ce_activity", "ce_activity_islastkey", false, isLastKeyCol); - addIndex(context, "ce_activity", "ce_activity_uuid", true, uuidCol); - } - - private void createCeQueue(Context context) throws SQLException { - VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(40).setIsNullable(false).build(); - VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(40).build(); - context.execute( - newTableBuilder("ce_queue") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(uuidCol) - .addColumn(newLenientVarcharBuilder("task_type").setLimit(15).setIsNullable(false).build()) - .addColumn(componentUuidCol) - .addColumn(newLenientVarcharBuilder("status").setLimit(15).build()) - .addColumn(newLenientVarcharBuilder("submitter_login").setLimit(255).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("started_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) - .build()); - addIndex(context, "ce_queue", "ce_queue_component_uuid", false, componentUuidCol); - addIndex(context, "ce_queue", "ce_queue_uuid", true, uuidCol); - } - - private void createFileSources(Context context) throws SQLException { - VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(50).setIsNullable(false).build(); - BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build(); - VarcharColumnDef dataTypeCol = newLenientVarcharBuilder("data_type").setLimit(20).build(); - VarcharColumnDef fileUuidCol = newLenientVarcharBuilder("file_uuid").setLimit(50).setIsNullable(false).build(); - context.execute( - newTableBuilder("file_sources") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(projectUuidCol) - .addColumn(fileUuidCol) - .addColumn(newClobColumnDefBuilder().setColumnName("line_hashes").build()) - .addColumn(newLenientVarcharBuilder("data_hash").setLimit(50).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(updatedAtCol) - .addColumn(newLenientVarcharBuilder("src_hash").setLimit(50).build()) - .addColumn(newBlobColumnDefBuilder().setColumnName("binary_data").build()) - .addColumn(dataTypeCol) - .addColumn(newLenientVarcharBuilder("revision").setLimit(100).build()) - .build()); - addIndex(context, "file_sources", "file_sources_project_uuid", false, projectUuidCol); - addIndex(context, "file_sources", "file_sources_updated_at", false, updatedAtCol); - addIndex(context, "file_sources", "file_sources_uuid_type", true, fileUuidCol, dataTypeCol); - } - - private void createActivities(Context context) throws SQLException { - VarcharColumnDef keeCol = newLenientVarcharBuilder("log_key").setLimit(255).build(); - context.execute( - newTableBuilder("activities") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("data_field").build()) - .addColumn(newLenientVarcharBuilder("log_type").setLimit(50).build()) - .addColumn(newLenientVarcharBuilder("log_action").setLimit(50).build()) - .addColumn(newLenientVarcharBuilder("log_message").setLimit(4000).build()) - .addColumn(keeCol) - .build()); - - addIndex(context, "activities", "activities_log_key", true, keeCol); - } - - private void createPermTemplatesGroups(Context context) throws SQLException { - context.execute( - newTableBuilder("perm_templates_groups") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newIntegerColumnDefBuilder().setColumnName("group_id").build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("permission_reference").setLimit(64).setIsNullable(false).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) - .build()); - } - - private void createPermTemplatesUsers(Context context) throws SQLException { - context.execute( - newTableBuilder("perm_templates_users") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(false).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("permission_reference").setLimit(64).setIsNullable(false).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) - .build()); - } - - private void createPermissionTemplates(Context context) throws SQLException { - context.execute( - newTableBuilder("permission_templates") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("kee").setLimit(100).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) - .addColumn(newLenientVarcharBuilder("key_pattern").setLimit(500).build()) - .build()); - } - - private void createIssueFilterFavourites(Context context) throws SQLException { - VarcharColumnDef loginCol = newLenientVarcharBuilder("user_login").setLimit(255).setIsNullable(false).build(); - context.execute( - newTableBuilder("issue_filter_favourites") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(loginCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("issue_filter_id").setIsNullable(false).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .build()); - addIndex(context, "issue_filter_favourites", "issue_filter_favs_user", false, loginCol); - } - - private void createIssueFilters(Context context) throws SQLException { - VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); - context.execute( - newTableBuilder("issue_filters") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(nameCol) - .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("shared").setIsNullable(false).setDefaultValue(false).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("data").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) - .build()); - addIndex(context, "issue_filters", "issue_filters_name", false, nameCol); - } - - private void createIssueChanges(Context context) throws SQLException { - VarcharColumnDef issueKeyCol = newLenientVarcharBuilder("issue_key").setLimit(50).setIsNullable(false).build(); - VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(50).build(); - context.execute( - newTableBuilder("issue_changes") - .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(keeCol) - .addColumn(issueKeyCol) - .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) - .addColumn(newLenientVarcharBuilder("change_type").setLimit(20).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("change_data").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_change_creation_date").build()) - .build()); - addIndex(context, "issue_changes", "issue_changes_issue_key", false, issueKeyCol); - addIndex(context, "issue_changes", "issue_changes_kee", false, keeCol); - } - - private void createIssues(Context context) throws SQLException { - VarcharColumnDef assigneeCol = newLenientVarcharBuilder("assignee").setLimit(255).build(); - VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(50).build(); - BigIntegerColumnDef issueCreationDateCol = newBigIntegerColumnDefBuilder().setColumnName("issue_creation_date").build(); - VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(50).setIsNullable(false).build(); - VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(50).build(); - VarcharColumnDef resolutionCol = newLenientVarcharBuilder("resolution").setLimit(20).build(); - IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").build(); - BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").build(); - context.execute( - newTableBuilder("issues") - .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(keeCol) - .addColumn(ruleIdCol) - .addColumn(newLenientVarcharBuilder("severity").setLimit(10).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("manual_severity").setIsNullable(false).build()) - // unit has been fixed in SonarQube 5.6 (see migration 1151, SONAR-7493) - .addColumn(newLenientVarcharBuilder("message").setIgnoreOracleUnit(false).setLimit(4000).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("line").build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("gap").setPrecision(30).setScale(20).build()) - .addColumn(newLenientVarcharBuilder("status").setLimit(20).build()) - .addColumn(resolutionCol) - .addColumn(newLenientVarcharBuilder("checksum").setLimit(1000).build()) - .addColumn(newLenientVarcharBuilder("reporter").setLimit(255).build()) - .addColumn(assigneeCol) - .addColumn(newLenientVarcharBuilder("author_login").setLimit(255).build()) - .addColumn(newLenientVarcharBuilder("action_plan_key").setLimit(50).build()) - .addColumn(newLenientVarcharBuilder("issue_attributes").setLimit(4000).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("effort").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(updatedAtCol) - .addColumn(issueCreationDateCol) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_update_date").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_close_date").build()) - .addColumn(newLenientVarcharBuilder("tags").setLimit(4000).build()) - .addColumn(componentUuidCol) - .addColumn(projectUuidCol) - .addColumn(newBlobColumnDefBuilder().setColumnName("locations").build()) - .addColumn(new TinyIntColumnDef.Builder().setColumnName("issue_type").build()) - .build()); - addIndex(context, "issues", "issues_assignee", false, assigneeCol); - addIndex(context, "issues", "issues_component_uuid", false, componentUuidCol); - addIndex(context, "issues", "issues_creation_date", false, issueCreationDateCol); - addIndex(context, "issues", "issues_kee", true, keeCol); - addIndex(context, "issues", "issues_project_uuid", false, projectUuidCol); - addIndex(context, "issues", "issues_resolution", false, resolutionCol); - addIndex(context, "issues", "issues_rule_id", false, ruleIdCol); - addIndex(context, "issues", "issues_updated_at", false, updatedAtCol); - } - - private void createMeasureFilterFavourites(Context context) throws SQLException { - IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(false).build(); - context.execute( - newTableBuilder("measure_filter_favourites") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(userIdCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("measure_filter_id").setIsNullable(false).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .build()); - addIndex(context, "measure_filter_favourites", "measure_filter_favs_userid", false, userIdCol); - } - - private void createMeasureFilters(Context context) throws SQLException { - VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); - context.execute( - newTableBuilder("measure_filters") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(nameCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("user_id").build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("shared").setDefaultValue(false).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("data").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) - .build()); - addIndex(context, "measure_filters", "measure_filters_name", false, nameCol); - } - - private void createAuthors(Context context) throws SQLException { - VarcharColumnDef loginCol = newLenientVarcharBuilder("login").setLimit(255).build(); - context.execute( - newTableBuilder("authors") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newIntegerColumnDefBuilder().setColumnName("person_id").setIsNullable(false).build()) - .addColumn(loginCol) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) - .build()); - addIndex(context, "authors", "uniq_author_logins", true, loginCol); - } - - private void createResourceIndex(Context context) throws SQLException { - VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(400).setIsNullable(false).build(); - IntegerColumnDef resourceIdCol = newIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(false).build(); - context.execute( - newTableBuilder("resource_index") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(keeCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("position").setIsNullable(false).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("name_size").setIsNullable(false).build()) - .addColumn(resourceIdCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("root_project_id").setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("qualifier").setLimit(10).setIsNullable(false).build()) - .build()); - addIndex(context, "resource_index", "resource_index_key", false, keeCol); - addIndex(context, "resource_index", "resource_index_rid", false, resourceIdCol); - } - - private void createLoadedTemplates(Context context) throws SQLException { - context.execute( - newTableBuilder("loaded_templates") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newLenientVarcharBuilder("kee").setLimit(200).build()) - .addColumn(newLenientVarcharBuilder("template_type").setLimit(15).build()) - .build()); - } - - private void createMetrics(Context context) throws SQLException { - VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(64).setIsNullable(false).build(); - context.execute( - newTableBuilder("metrics") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(nameCol) - .addColumn(newLenientVarcharBuilder("description").setLimit(255).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("direction").setIsNullable(false).setDefaultValue(0).build()) - .addColumn(newLenientVarcharBuilder("domain").setLimit(64).build()) - .addColumn(newLenientVarcharBuilder("short_name").setLimit(64).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("qualitative").setDefaultValue(false).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("val_type").setLimit(8).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("user_managed").setDefaultValue(false).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("enabled").setDefaultValue(true).build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("worst_value").setPrecision(38).setScale(20).build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("best_value").setPrecision(38).setScale(20).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("optimized_best_value").build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("hidden").build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("delete_historical_data").build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("decimal_scale").build()) - .build()); - addIndex(context, "metrics", "metrics_unique_name", true, nameCol); - } - - private void createDashboards(Context context) throws SQLException { - context.execute( - newTableBuilder("dashboards") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newIntegerColumnDefBuilder().setColumnName("user_id").build()) - .addColumn(newLenientVarcharBuilder("name").setLimit(256).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(1000).build()) - .addColumn(newLenientVarcharBuilder("column_layout").setLimit(20).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("shared").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("is_global").build()) - .build()); - } - - private void createUsers(Context context) throws SQLException { - VarcharColumnDef loginCol = newLenientVarcharBuilder("login").setLimit(255).build(); - BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").build(); - context.execute( - newTableBuilder("users") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(loginCol) - .addColumn(newLenientVarcharBuilder("name").setLimit(200).build()) - .addColumn(newLenientVarcharBuilder("email").setLimit(100).build()) - .addColumn(newLenientVarcharBuilder("crypted_password").setLimit(40).build()) - .addColumn(newLenientVarcharBuilder("salt").setLimit(40).build()) - .addColumn(newLenientVarcharBuilder("remember_token").setLimit(500).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("remember_token_expires_at").build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("active").setDefaultValue(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(updatedAtCol) - .addColumn(newLenientVarcharBuilder("scm_accounts").setLimit(4000).build()) - .addColumn(newLenientVarcharBuilder("external_identity").setLimit(255).build()) - .addColumn(newLenientVarcharBuilder("external_identity_provider").setLimit(100).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("user_local").build()) - .build()); - addIndex(context, "users", "users_login", true, loginCol); - addIndex(context, "users", "users_updated_at", false, updatedAtCol); - } - - private void createActiveRuleParameters(Context context) throws SQLException { - context.execute( - newTableBuilder("active_rule_parameters") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newIntegerColumnDefBuilder().setColumnName("active_rule_id").setIsNullable(false).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("rules_parameter_id").setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("value").setLimit(4000).build()) - .addColumn(newLenientVarcharBuilder("rules_parameter_key").setLimit(128).build()) - .build()); - } - - private void createActiveRules(Context context) throws SQLException { - IntegerColumnDef profileIdCol = newIntegerColumnDefBuilder().setColumnName("profile_id").setIsNullable(false).build(); - IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(false).build(); - context.execute( - newTableBuilder("active_rules") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(profileIdCol) - .addColumn(ruleIdCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("failure_level").setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("inheritance").setLimit(10).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) - .build()); - addIndex(context, "active_rules", "uniq_profile_rule_ids", true, profileIdCol, ruleIdCol); - } - - private void createUserRoles(Context context) throws SQLException { - IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").build(); - IntegerColumnDef resourceIdCol = newIntegerColumnDefBuilder().setColumnName("resource_id").build(); - context.execute( - newTableBuilder("user_roles") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(userIdCol) - .addColumn(resourceIdCol) - .addColumn(newLenientVarcharBuilder("role").setLimit(64).setIsNullable(false).build()) - .build()); - addIndex(context, "user_roles", "user_roles_resource", false, resourceIdCol); - addIndex(context, "user_roles", "user_roles_user", false, userIdCol); - } - - private void createActiveDashboards(Context context) throws SQLException { - IntegerColumnDef dashboardIdCol = newIntegerColumnDefBuilder().setColumnName("dashboard_id").setIsNullable(false).build(); - IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").build(); - context.execute( - newTableBuilder("active_dashboards") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(dashboardIdCol) - .addColumn(userIdCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("order_index").build()) - .build()); - addIndex(context, "active_dashboards", "active_dashboards_dashboardid", false, dashboardIdCol); - addIndex(context, "active_dashboards", "active_dashboards_userid", false, userIdCol); - } - - private void createNotifications(Context context) throws SQLException { - context.execute( - newTableBuilder("notifications") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newBlobColumnDefBuilder().setColumnName("data").build()) - .build()); - } - - private void createSnapshots(Context context) throws SQLException { - IntegerColumnDef projectIdCol = newIntegerColumnDefBuilder().setColumnName("project_id").setIsNullable(false).build(); - IntegerColumnDef rootProjectIdCol = newIntegerColumnDefBuilder().setColumnName("root_project_id").setIsNullable(true).build(); - IntegerColumnDef parentSnapshotIdCol = newIntegerColumnDefBuilder().setColumnName("parent_snapshot_id").setIsNullable(true).build(); - VarcharColumnDef qualifierCol = newLenientVarcharBuilder("qualifier").setLimit(10).setIsNullable(true).build(); - IntegerColumnDef rootSnapshotIdCol = newIntegerColumnDefBuilder().setColumnName("root_snapshot_id").setIsNullable(true).build(); - context.execute( - newTableBuilder("snapshots") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(projectIdCol) - .addColumn(parentSnapshotIdCol) - .addColumn(newLenientVarcharBuilder("status").setLimit(4).setIsNullable(false).setDefaultValue("U").build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("islast").setIsNullable(false).setDefaultValue(false).build()) - .addColumn(newLenientVarcharBuilder("scope").setLimit(3).setIsNullable(true).build()) - .addColumn(qualifierCol) - .addColumn(rootSnapshotIdCol) - .addColumn(newLenientVarcharBuilder("version").setLimit(500).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("path").setLimit(500).setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("depth").setIsNullable(true).build()) - .addColumn(rootProjectIdCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("purge_status").setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period1_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period1_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period2_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period2_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period3_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period3_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period4_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period4_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period5_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("period5_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("build_date").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period1_date").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period2_date").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period3_date").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period4_date").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period5_date").setIsNullable(true).build()) - .build()); - addIndex(context, "snapshots", "snapshot_project_id", false, projectIdCol); - addIndex(context, "snapshots", "snapshots_parent", false, parentSnapshotIdCol); - addIndex(context, "snapshots", "snapshots_qualifier", false, qualifierCol); - addIndex(context, "snapshots", "snapshots_root", false, rootSnapshotIdCol); - addIndex(context, "snapshots", "snapshots_root_project_id", false, rootProjectIdCol); - } - - private void createGroups(Context context) throws SQLException { - context.execute( - newTableBuilder("groups") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newLenientVarcharBuilder("name").setLimit(500).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(200).setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) - .build()); - } - - private void createWidgets(Context context) throws SQLException { - IntegerColumnDef dashboardId = newIntegerColumnDefBuilder().setColumnName("dashboard_id").setIsNullable(false).build(); - VarcharColumnDef widgetKey = newLenientVarcharBuilder("widget_key").setLimit(256).setIsNullable(false).build(); - context.execute( - newTableBuilder("widgets") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(dashboardId) - .addColumn(widgetKey) - .addColumn(newLenientVarcharBuilder("name").setLimit(256).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(1000).setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("column_index").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("row_index").setIsNullable(true).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("configured").setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build()) - .build()); - addIndex(context, "widgets", "widgets_dashboards", false, dashboardId); - addIndex(context, "widgets", "widgets_widgetkey", false, widgetKey); - } - - private void createProjectQprofiles(Context context) throws SQLException { - VarcharColumnDef projectUuid = newLenientVarcharBuilder("project_uuid").setLimit(50).setIsNullable(false).build(); - VarcharColumnDef profileKey = newLenientVarcharBuilder("profile_key").setLimit(50).setIsNullable(false).build(); - context.execute( - newTableBuilder("project_qprofiles") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(projectUuid) - .addColumn(profileKey) - .build()); - addIndex(context, "project_qprofiles", "uniq_project_qprofiles", true, projectUuid, profileKey); - } - - private void createRulesProfiles(Context context) throws SQLException { - VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(255).setIsNullable(false).build(); - context.execute( - newTableBuilder("rules_profiles") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) - .addColumn(keeCol) - .addColumn(newLenientVarcharBuilder("parent_kee").setLimit(255).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("rules_updated_at").setLimit(100).setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("is_default").setIsNullable(false).build()) - .build()); - addIndex(context, "rules_profiles", "uniq_qprof_key", true, keeCol); - } - - private void createRulesParameters(Context context) throws SQLException { - IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(false).build(); - context.execute( - newTableBuilder("rules_parameters") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(ruleIdCol) - .addColumn(newLenientVarcharBuilder("name").setLimit(128).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(4000).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("param_type").setLimit(512).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("default_value").setLimit(4000).setIsNullable(true).build()) - .build()); - addIndex(context, "rules_parameters", "rules_parameters_rule_id", false, ruleIdCol); - } - - private void createGroupsUsers(Context context) throws SQLException { - BigIntegerColumnDef userIdCol = newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build(); - BigIntegerColumnDef groupIdCol = newBigIntegerColumnDefBuilder().setColumnName("group_id").setIsNullable(true).build(); - context.execute( - newTableBuilder("groups_users") - .addColumn(userIdCol) - .addColumn(groupIdCol) - .build()); - addIndex(context, "groups_users", "index_groups_users_on_user_id", false, userIdCol); - addIndex(context, "groups_users", "index_groups_users_on_group_id", false, groupIdCol); - addIndex(context, "groups_users", "groups_users_unique", true, groupIdCol, userIdCol); - } - - private void createProjectMeasures(Context context) throws SQLException { - IntegerColumnDef personIdCol = newIntegerColumnDefBuilder().setColumnName("person_id").build(); - IntegerColumnDef metricIdCol = newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(false).build(); - IntegerColumnDef snapshotIdCol = newIntegerColumnDefBuilder().setColumnName("snapshot_id").setIsNullable(true).build(); - context.execute( - newTableBuilder("project_measures") - .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newDecimalColumnDefBuilder().setColumnName("value").setPrecision(38).setScale(20).build()) - .addColumn(metricIdCol) - .addColumn(snapshotIdCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("rules_category_id").setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("text_value").setLimit(4000).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("tendency").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("measure_date").build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("project_id").build()) - .addColumn(newLenientVarcharBuilder("alert_status").setLimit(5).build()) - .addColumn(newLenientVarcharBuilder("alert_text").setLimit(4000).build()) - .addColumn(newLenientVarcharBuilder("url").setLimit(2000).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("rule_priority").build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("characteristic_id").build()) - .addColumn(personIdCol) - .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_1").setPrecision(38).setScale(20).build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_2").setPrecision(38).setScale(20).build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_3").setPrecision(38).setScale(20).build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_4").setPrecision(38).setScale(20).build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_5").setPrecision(38).setScale(20).build()) - .addColumn(newBlobColumnDefBuilder().setColumnName("measure_data").build()) - .build()); - addIndex(context, "project_measures", "measures_sid_metric", false, snapshotIdCol, metricIdCol); - addIndex(context, "project_measures", "measures_person", false, personIdCol); - } - - private void createManualMeasures(Context context) throws SQLException { - VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(50).build(); - context.execute( - newTableBuilder("manual_measures") - .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(false).build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("value").setPrecision(38).setScale(20).build()) - .addColumn(newLenientVarcharBuilder("text_value").setLimit(4000).build()) - .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) - .addColumn(componentUuidCol) - .build()); - addIndex(context, "manual_measures", "manual_measures_component_uuid", false, componentUuidCol); - } - - private void createProjects(Context context) throws SQLException { - VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(400).build(); - VarcharColumnDef moduleUuidCol = newLenientVarcharBuilder("module_uuid").setLimit(50).build(); - VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(50).build(); - VarcharColumnDef qualifierCol = newLenientVarcharBuilder("qualifier").setLimit(10).build(); - IntegerColumnDef rootIdCol = newIntegerColumnDefBuilder().setColumnName("root_id").build(); - VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(50).build(); - context.execute( - newTableBuilder("projects") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newLenientVarcharBuilder("name").setLimit(2000).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(2000).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("enabled").setDefaultValue(true).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("scope").setLimit(3).build()) - .addColumn(qualifierCol) - .addColumn(keeCol) - .addColumn(rootIdCol) - .addColumn(newLenientVarcharBuilder("language").setLimit(20).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("copy_resource_id").build()) - .addColumn(newLenientVarcharBuilder("long_name").setLimit(2000).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("person_id").build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newLenientVarcharBuilder("path").setLimit(2000).build()) - .addColumn(newLenientVarcharBuilder("deprecated_kee").setLimit(400).build()) - .addColumn(uuidCol) - .addColumn(projectUuidCol) - .addColumn(moduleUuidCol) - .addColumn(newLenientVarcharBuilder("module_uuid_path").setLimit(4000).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("authorization_updated_at").build()) - .build()); - addIndex(context, "projects", "projects_kee", true, keeCol); - addIndex(context, "projects", "projects_module_uuid", false, moduleUuidCol); - addIndex(context, "projects", "projects_project_uuid", false, projectUuidCol); - addIndex(context, "projects", "projects_qualifier", false, qualifierCol); - addIndex(context, "projects", "projects_root_id", false, rootIdCol); - addIndex(context, "projects", "projects_uuid", true, uuidCol); - } - - private void createGroupRoles(Context context) throws SQLException { - IntegerColumnDef groupIdCol = newIntegerColumnDefBuilder().setColumnName("group_id").setIsNullable(true).build(); - IntegerColumnDef resourceIdCol = newIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build(); - VarcharColumnDef roleCol = newLenientVarcharBuilder("role").setLimit(64).setIsNullable(false).build(); - context.execute( - newTableBuilder("group_roles") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(groupIdCol) - .addColumn(resourceIdCol) - .addColumn(roleCol) - .build()); - addIndex(context, "group_roles", "group_roles_resource", false, resourceIdCol); - addIndex(context, "group_roles", "uniq_group_roles", true, groupIdCol, resourceIdCol, roleCol); - } - - private void createRules(Context context) throws SQLException { - VarcharColumnDef pluginRuleKeyCol = newLenientVarcharBuilder("plugin_rule_key").setLimit(200).setIsNullable(false).build(); - VarcharColumnDef pluginNameCol = newLenientVarcharBuilder("plugin_name").setLimit(255).setIsNullable(false).build(); - context.execute( - newTableBuilder("rules") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newLenientVarcharBuilder("name").setLimit(200).setIsNullable(true).build()) - .addColumn(pluginRuleKeyCol) - .addColumn(newLenientVarcharBuilder("plugin_config_key").setLimit(200).setIsNullable(true).build()) - .addColumn(pluginNameCol) - .addColumn(newClobColumnDefBuilder().setColumnName("description").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("priority").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("status").setLimit(40).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("note_created_at").setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("note_updated_at").setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("note_user_login").setLimit(255).setIsNullable(true).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("note_data").setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("remediation_function").setLimit(200).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("def_remediation_function").setLimit(20).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("remediation_gap_mult").setLimit(20).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("def_remediation_gap_mult").setLimit(20).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("remediation_base_effort").setLimit(20).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("def_remediation_base_effort").setLimit(20).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("gap_description").setLimit(4000).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("tags").setLimit(4000).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("system_tags").setLimit(4000).setIsNullable(true).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("is_template").setIsNullable(false).setDefaultValue(false).build()) - .addColumn(newLenientVarcharBuilder("description_format").setLimit(20).setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) - .addColumn(new TinyIntColumnDef.Builder().setColumnName("rule_type").setIsNullable(true).build()) - .build()); - addIndex(context, "rules", "rules_repo_key", true, pluginRuleKeyCol, pluginNameCol); - } - - private void createWidgetProperties(Context context) throws SQLException { - IntegerColumnDef widgetIdCol = newIntegerColumnDefBuilder().setColumnName("widget_id").setIsNullable(false).build(); - context.execute( - newTableBuilder("widget_properties") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(widgetIdCol) - .addColumn(newLenientVarcharBuilder("kee").setLimit(100).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("text_value").setLimit(4000).setIsNullable(true).build()) - .build()); - addIndex(context, "widget_properties", "widget_properties_widgets", false, widgetIdCol); - } - - private void createEvents(Context context) throws SQLException { - VarcharColumnDef componentUuid = newLenientVarcharBuilder("component_uuid").setLimit(50).setIsNullable(true).build(); - IntegerColumnDef snapshotId = newIntegerColumnDefBuilder().setColumnName("snapshot_id").setIsNullable(true).build(); - context.execute( - newTableBuilder("events") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newLenientVarcharBuilder("name").setLimit(400).setIsNullable(true).build()) - .addColumn(snapshotId) - .addColumn(newLenientVarcharBuilder("category").setLimit(50).build()) - .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) - .addColumn(newLenientVarcharBuilder("event_data").setLimit(4000).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("event_date").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(componentUuid) - .build()); - addIndex(context, "events", "events_component_uuid", false, componentUuid); - addIndex(context, "events", "events_snapshot_id", false, snapshotId); - } - - private void createQualityGates(Context context) throws SQLException { - VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); - context.execute( - newTableBuilder("quality_gates") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(nameCol) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) - .build()); - addIndex(context, "quality_gates", "uniq_quality_gates", true, nameCol); - } - - private void createQualityGateConditions(Context context) throws SQLException { - context.execute( - newTableBuilder("quality_gate_conditions") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newIntegerColumnDefBuilder().setColumnName("qgate_id").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("period").setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("operator").setLimit(3).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("value_error").setLimit(64).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("value_warning").setLimit(64).setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) - .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) - .build()); - } - - private void createProperties(Context context) throws SQLException { - VarcharColumnDef propKey = newLenientVarcharBuilder("prop_key").setLimit(512).setIsNullable(true).build(); - context.execute( - newTableBuilder("properties") - // do not define as primary key on purpose -> already set in org.sonar.db.version.v61.CreateTableProperties2 - .addColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build()) - .addColumn(propKey) - .addColumn(newIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("text_value").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build()) - .build()); - addIndex(context, "properties", "properties_key", false, propKey); - } - - private void createProjectLinks(Context context) throws SQLException { - context.execute( - newTableBuilder("project_links") - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newLenientVarcharBuilder("link_type").setLimit(20).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("name").setLimit(128).setIsNullable(true).build()) - .addColumn(newLenientVarcharBuilder("href").setLimit(2048).setIsNullable(false).build()) - .addColumn(newLenientVarcharBuilder("component_uuid").setLimit(2048).setIsNullable(true).build()) - .build()); - } - - private void createDuplicationsIndex(Context context) throws SQLException { - VarcharColumnDef hashCol = newLenientVarcharBuilder("hash").setLimit(50).setIsNullable(false).build(); - IntegerColumnDef snapshotIdCol = newIntegerColumnDefBuilder().setColumnName("snapshot_id").setIsNullable(false).build(); - context.execute( - newTableBuilder("duplications_index") - .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newIntegerColumnDefBuilder().setColumnName("project_snapshot_id").setIsNullable(false).build()) - .addColumn(snapshotIdCol) - .addColumn(hashCol) - .addColumn(newIntegerColumnDefBuilder().setColumnName("index_in_file").setIsNullable(false).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("start_line").setIsNullable(false).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("end_line").setIsNullable(false).build()) - .build()); - addIndex(context, "duplications_index", "duplications_index_hash", false, hashCol); - addIndex(context, "duplications_index", "duplications_index_sid", false, snapshotIdCol); - } - - private void addIndex(Context context, String table, String index, boolean unique, ColumnDef... columns) throws SQLException { - CreateIndexBuilder builder = new CreateIndexBuilder() - .setTable(table) - .setName(index) - .setUnique(unique); - for (ColumnDef column : columns) { - builder.addColumn(column); - } - context.execute(builder.build()); - } - - private static VarcharColumnDef.Builder newLenientVarcharBuilder(String column) { - return new VarcharColumnDef.Builder().setColumnName(column).setIgnoreOracleUnit(true); - } - - private CreateTableBuilder newTableBuilder(String tableName) { - return new CreateTableBuilder(getDialect(), tableName); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/DbVersion56.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/DbVersion56.java deleted file mode 100644 index 36db61c869e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/DbVersion56.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v56; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion56 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1, "Create initial schema", CreateInitialSchema.class) - .add(2, "Populate initial schema", PopulateInitialSchema.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchema.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchema.java deleted file mode 100644 index 0853c5313b9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchema.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v56; - -import java.sql.SQLException; -import java.util.Date; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.Upsert; - -public class PopulateInitialSchema extends DataChange { - - private static final String ADMINS_GROUP = "sonar-administrators"; - private static final String USERS_GROUP = "sonar-users"; - private static final String ADMIN_USER = "admin"; - - private final System2 system2; - - public PopulateInitialSchema(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - insertGroups(context); - insertGroupRoles(context); - insertAdminUser(context); - insertGroupMemberships(context); - - } - - private void insertGroups(Context context) throws SQLException { - truncateTable(context, "groups"); - - Date now = new Date(system2.now()); - Upsert upsert = context.prepareUpsert("insert into groups (name, description, created_at, updated_at) values (?, ?, ?, ?)"); - upsert.setString(1, ADMINS_GROUP) - .setString(2, "System administrators") - .setDate(3, now) - .setDate(4, now) - .addBatch(); - upsert.setString(1, USERS_GROUP) - .setString(2, "Any new users created will automatically join this group") - .setDate(3, now) - .setDate(4, now) - .addBatch(); - upsert - .execute() - .commit(); - } - - private static void insertGroupRoles(Context context) throws SQLException { - truncateTable(context, "group_roles"); - - // admin group - Upsert upsert = context.prepareUpsert("insert into group_roles (group_id, resource_id, role) values ((select id from groups where name='" + ADMINS_GROUP + "'), null, ?)"); - upsert.setString(1, "admin").addBatch(); - upsert.setString(1, "profileadmin").addBatch(); - upsert.setString(1, "gateadmin").addBatch(); - upsert.setString(1, "shareDashboard").addBatch(); - upsert.setString(1, "provisioning").addBatch(); - upsert - .execute() - .commit(); - - // anyone - upsert = context.prepareUpsert("insert into group_roles (group_id, resource_id, role) values (null, null, ?)"); - upsert.setString(1, "scan").addBatch(); - upsert.setString(1, "provisioning").addBatch(); - upsert - .execute() - .commit(); - } - - private void insertAdminUser(Context context) throws SQLException { - truncateTable(context, "users"); - - long now = system2.now(); - context.prepareUpsert("insert into users " + - "(login, name, email, external_identity, external_identity_provider, user_local, crypted_password, salt, " + - "created_at, updated_at, remember_token, remember_token_expires_at) " + - "values ('" + ADMIN_USER + "', 'Administrator', null, 'admin', 'sonarqube', ?, " + - "'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', ?, ?, null, null)") - .setBoolean(1, true) - .setLong(2, now) - .setLong(3, now) - .execute() - .commit(); - } - - private static void insertGroupMemberships(Context context) throws SQLException { - truncateTable(context, "groups_users"); - - Upsert upsert = context.prepareUpsert("insert into groups_users (user_id, group_id) values " + - "((select id from users where login='" + ADMIN_USER + "'), (select id from groups where name=?))"); - upsert.setString(1, ADMINS_GROUP).addBatch(); - upsert.setString(1, USERS_GROUP).addBatch(); - upsert - .execute() - .commit(); - } - - private static void truncateTable(Context context, String table) throws SQLException { - context.prepareUpsert("truncate table " + table).execute().commit(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/package-info.java deleted file mode 100644 index 0783f643080..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v56/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v56; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/DbVersion561.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/DbVersion561.java deleted file mode 100644 index 9624b1e9acc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/DbVersion561.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v561; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion561 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry.add(1153, "Populate columns USERS.EXTERNAL_IDENTITY_*", UpdateUsersExternalIdentityWhenEmpty.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmpty.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmpty.java deleted file mode 100644 index 5a6cc319956..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmpty.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v561; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -/** - * Update USERS.EXTERNAL_IDENTITY_PROVIDER to 'sonarqube' and USERS.EXTERNAL_IDENTITY to user's login when one of this 2 columns is null - */ -public class UpdateUsersExternalIdentityWhenEmpty extends DataChange { - - private final System2 system2; - - public UpdateUsersExternalIdentityWhenEmpty(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT u.id, u.login FROM users u WHERE external_identity_provider IS NULL OR external_identity IS NULL"); - massUpdate.update("UPDATE users SET external_identity_provider=?, external_identity=?, updated_at=? WHERE id=?"); - massUpdate.rowPluralName("users"); - massUpdate.execute(new MigrationHandler(system2.now())); - } - - private static class MigrationHandler implements MassUpdate.Handler { - - private final long now; - - public MigrationHandler(long now) { - this.now = now; - } - - @Override - public boolean handle(Select.Row row, SqlStatement update) throws SQLException { - update.setString(1, "sonarqube"); - update.setString(2, row.getString(2)); - update.setLong(3, now); - update.setLong(4, row.getLong(1)); - return true; - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/package-info.java deleted file mode 100644 index ea10aa5cea9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v561/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v561; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivity.java deleted file mode 100644 index db9de2106b3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivity.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddAnalysisUuidColumnToCeActivity extends DdlChange { - - private static final String TABLE_CE_ACTIVITY = "ce_activity"; - - public AddAnalysisUuidColumnToCeActivity(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_CE_ACTIVITY) - .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEvents.java deleted file mode 100644 index 48a76bf0e83..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEvents.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddAnalysisUuidColumnToEvents extends DdlChange { - - private static final String TABLE_EVENTS = "events"; - - public AddAnalysisUuidColumnToEvents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS) - .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasures.java deleted file mode 100644 index 81bb882d6dc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasures.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddAnalysisUuidColumnToMeasures extends DdlChange { - - private static final String TABLE_MEASURES = "project_measures"; - - public AddAnalysisUuidColumnToMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES) - .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjects.java deleted file mode 100644 index efed8de66a3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjects.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddBColumnsToProjects extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - - public AddBColumnsToProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_PROJECTS) - .addColumn(newBooleanColumnDefBuilder().setColumnName("b_changed").build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_copy_component_uuid").setLimit(50).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_description").setLimit(2000).setIgnoreOracleUnit(true).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("b_enabled").build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_language").setLimit(20).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_long_name").setLimit(500).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid").setLimit(50).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid_path").setLimit(1500).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_name").setLimit(500).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_path").setLimit(2000).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_qualifier").setLimit(10).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java deleted file mode 100644 index 78a525437a3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex extends DdlChange { - - private static final String TABLE_PUBLICATIONS_INDEX = "duplications_index"; - - public AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_PUBLICATIONS_INDEX) - .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasures.java deleted file mode 100644 index 3ed49bc4977..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasures.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddComponentUuidColumnToMeasures extends DdlChange { - - private static final String TABLE_MEASURES = "project_measures"; - - public AddComponentUuidColumnToMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES) - .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshots.java deleted file mode 100644 index 1629a530008..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshots.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddComponentUuidColumnsToSnapshots extends DdlChange { - - private static final String TABLE_SNAPSHOTS = "snapshots"; - - public AddComponentUuidColumnsToSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS) - .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnAnalysisUuidOfMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnAnalysisUuidOfMeasures.java deleted file mode 100644 index 343e78d4b4e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnAnalysisUuidOfMeasures.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.newVarcharColumnDefBuilder; - -public class AddIndexOnAnalysisUuidOfMeasures extends DdlChange { - - public AddIndexOnAnalysisUuidOfMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - // this index must be present for the performance of next migration - context.execute(new CreateIndexBuilder() - .setTable("project_measures") - .setName("measures_analysis_metric") - .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(50).setIgnoreOracleUnit(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasures.java deleted file mode 100644 index d56cc5a3c53..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasures.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddIndexOnComponentUuidOfMeasures extends DdlChange { - - public AddIndexOnComponentUuidOfMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("project_measures") - .setName("measures_component_uuid") - .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(50).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfiles.java deleted file mode 100644 index 22212f422e8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfiles.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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; - -public class AddLastUsedColumnToRulesProfiles extends DdlChange { - - private static final String TABLE_QUALITY_PROFILES = "rules_profiles"; - - public AddLastUsedColumnToRulesProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_QUALITY_PROFILES) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("last_used").setIsNullable(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivities.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivities.java deleted file mode 100644 index 6f3ba4f7abc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivities.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddProfileKeyToActivities extends DdlChange { - - private static final String TABLE_ACTIVITIES = "activities"; - - public AddProfileKeyToActivities(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_ACTIVITIES) - .addColumn(newVarcharColumnDefBuilder().setColumnName("profile_key").setLimit(255).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshots.java deleted file mode 100644 index 6a1079e46a0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshots.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddUniqueIndexOnUuidOfSnapshots extends DdlChange { - - public AddUniqueIndexOnUuidOfSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("snapshots") - .setName("analyses_uuid") - .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(50).setIgnoreOracleUnit(true).build()) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfiles.java deleted file mode 100644 index d32c73414ff..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfiles.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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; - -public class AddUserUpdatedAtToRulesProfiles extends DdlChange { - - private static final String TABLE_QUALITY_PROFILES = "rules_profiles"; - - public AddUserUpdatedAtToRulesProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_QUALITY_PROFILES) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_updated_at").setIsNullable(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshots.java deleted file mode 100644 index 378ed58516d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshots.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidColumnToSnapshots extends DdlChange { - - private static final String TABLE_SNAPSHOTS = "snapshots"; - - public AddUuidColumnToSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_SNAPSHOTS) - .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjects.java deleted file mode 100644 index f7d76b38a20..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjects.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidColumnsToProjects extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - - public AddUuidColumnsToProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_PROJECTS) - .addColumn(newVarcharColumnDefBuilder().setColumnName("root_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("copy_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("developer_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidPathColumnToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidPathColumnToProjects.java deleted file mode 100644 index 8814010210f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidPathColumnToProjects.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddUuidPathColumnToProjects extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - - public AddUuidPathColumnToProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_PROJECTS) - .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid_path").setLimit(1500).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuid.java deleted file mode 100644 index 814ea122164..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuid.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class CleanEventsWithoutAnalysisUuid extends DataChange { - - public CleanEventsWithoutAnalysisUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT distinct snapshot_id from events e where e.snapshot_id is not null and e.analysis_uuid is null"); - massUpdate.update("DELETE from events WHERE snapshot_id=?"); - massUpdate.rowPluralName("no analysis uuid events"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotId.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotId.java deleted file mode 100644 index c9da31dbca0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotId.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class CleanEventsWithoutSnapshotId extends DataChange { - - public CleanEventsWithoutSnapshotId(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT e.id from events e where e.snapshot_id is null"); - massUpdate.update("DELETE from events WHERE id=?"); - massUpdate.rowPluralName("no snapshot id events"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuid.java deleted file mode 100644 index 2a9c60c7775..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuid.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class CleanMeasuresWithNullAnalysisUuid extends DataChange { - - public CleanMeasuresWithNullAnalysisUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from project_measures where analysis_uuid is null"); - massUpdate.update("delete from project_measures where id=?"); - massUpdate.rowPluralName("measures"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInProjects.java deleted file mode 100644 index 20f65335652..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInProjects.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class CleanOrphanRowsInProjects extends DataChange { - - public CleanOrphanRowsInProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT p.id from projects p where p.root_uuid is null" + - " or (p.copy_resource_id is not null and p.copy_component_uuid is null)" + - " or (p.person_id is not null and p.developer_uuid is null)"); - massUpdate.update("DELETE from projects WHERE id=?"); - massUpdate.rowPluralName("orphan projects"); - massUpdate.execute((row, update) -> { - long projectId = row.getLong(1); - update.setLong(1, projectId); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshots.java deleted file mode 100644 index b29904f27dd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshots.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class CleanOrphanRowsInSnapshots extends DataChange { - - public CleanOrphanRowsInSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT sn.id, sn.project_id, sn.root_project_id from snapshots sn where sn.component_uuid is null or sn.root_component_uuid is null"); - massUpdate.update("DELETE from duplications_index WHERE snapshot_id=? or project_snapshot_id=?"); - massUpdate.update("DELETE from project_measures WHERE snapshot_id=?"); - massUpdate.update("DELETE from ce_activity WHERE snapshot_id=?"); - massUpdate.update("DELETE from events WHERE snapshot_id=?"); - massUpdate.update("DELETE from snapshots WHERE id=?"); - massUpdate.rowPluralName("snapshots"); - massUpdate.execute((row, update, updateIndex) -> { - long snapshotId = row.getLong(1); - switch (updateIndex) { - case 0: - update.setLong(1, snapshotId); - update.setLong(2, snapshotId); - return true; - case 1: - case 2: - case 3: - case 4: - update.setLong(1, snapshotId); - return true; - default: - throw new IllegalArgumentException("Unsupported update index " + updateIndex); - } - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponents.java deleted file mode 100644 index 7e5d12c37bd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponents.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class CleanUsurperRootComponents extends DataChange { - - public CleanUsurperRootComponents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - // fix snapshots which don't have the scope and/or qualifier of their associated component - fixSnapshotScopeAndQualifier(context); - // delete components declaring themselves as root in table PROJECTS but which don't have a root scope and/or qualifier - cleanUsurperRootComponents(context); - // components which has snapshots reference a component as root which is not a root - cleanSnapshotWithIncorrectRoot(context); - } - - private static void fixSnapshotScopeAndQualifier(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " sn.id,p.scope,p.qualifier" + - " from" + - " snapshots sn, projects p" + - " where" + - " p.uuid = sn.component_uuid" + - " and (p.qualifier<>sn.qualifier or p.scope<>sn.scope)"); - massUpdate.update("update snapshots set scope=?,qualifier=? where id=?"); - massUpdate.rowPluralName("snapshots with inconsistent scope or qualifier"); - massUpdate.execute((row, update) -> { - long snapshotId = row.getLong(1); - String scope = row.getString(2); - String qualifier = row.getString(3); - - update.setString(1, scope); - update.setString(2, qualifier); - update.setLong(3, snapshotId); - - return true; - }); - } - - private static void cleanUsurperRootComponents(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select p.id,p.uuid from projects p " + - " where" + - " p.project_uuid = p.uuid" + - " and not (" + - " p.scope = 'PRJ'" + - " and p.qualifier in ('TRK', 'VW', 'DEV')" + - " )"); - massUpdate.update("delete from duplications_index where snapshot_id in (select id from snapshots where component_uuid=?)"); - massUpdate.update("delete from project_measures where component_uuid=?"); - massUpdate.update("delete from ce_activity where component_uuid=?"); - massUpdate.update("delete from events where component_uuid=?"); - massUpdate.update("delete from project_links where component_uuid=?"); - massUpdate.update("delete from snapshots where component_uuid=? or root_component_uuid=?"); - massUpdate.update("delete from issues where component_uuid=? or project_uuid=?"); - massUpdate.update("delete from file_sources where file_uuid=? or project_uuid=?"); - massUpdate.update("delete from group_roles where resource_id=?"); - massUpdate.update("delete from user_roles where resource_id=?"); - massUpdate.update("delete from properties where resource_id=?"); - massUpdate.update("delete from widgets where resource_id=?"); - massUpdate.update("delete from projects where uuid=?"); - massUpdate.rowPluralName("usurper root components"); - massUpdate.execute((row, update, updateIndex) -> { - long componentId = row.getLong(1); - String componentUuid = row.getString(2); - switch (updateIndex) { - case 0: - case 1: - case 2: - case 3: - case 4: - update.setString(1, componentUuid); - return true; - case 5: - case 6: - case 7: - update.setString(1, componentUuid); - update.setString(2, componentUuid); - return true; - case 8: - case 9: - case 10: - case 11: - update.setLong(1, componentId); - return true; - case 12: - update.setString(1, componentUuid); - return true; - default: - throw new IllegalArgumentException("Unsupported update index " + updateIndex); - } - }); - } - - private static void cleanSnapshotWithIncorrectRoot(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " sn.id" + - " from " + - " projects p, snapshots sn" + - " where" + - " p.uuid = sn.root_component_uuid" + - " and not (" + - " p.scope = 'PRJ'" + - " and p.qualifier in ('TRK', 'VW', 'DEV')" + - " )"); - massUpdate.update("DELETE from ce_activity WHERE snapshot_id=?"); - massUpdate.update("DELETE from events WHERE snapshot_id=?"); - massUpdate.update("DELETE from project_measures WHERE snapshot_id=?"); - massUpdate.update("DELETE from duplications_index WHERE project_snapshot_id=?"); - massUpdate.update("DELETE from snapshots WHERE id=?"); - massUpdate.rowPluralName("snapshots with incorrect root"); - massUpdate.execute((row, update, updateIndex) -> { - long snapshotId = row.getLong(1); - switch (updateIndex) { - case 0: - case 1: - case 2: - case 3: - case 4: - update.setLong(1, snapshotId); - return true; - default: - throw new IllegalArgumentException("Unsupported update index " + updateIndex); - } - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristics.java deleted file mode 100644 index 1ddc99ded10..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristics.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; -import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.ColumnFlag.AUTO_INCREMENT; -import static org.sonar.server.platform.db.migration.def.IntegerColumnDef.newIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreatePermTemplatesCharacteristics extends DdlChange { - - private static final String TABLE_NAME = "perm_tpl_characteristics"; - - public CreatePermTemplatesCharacteristics(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - IntegerColumnDef templateIdColumn = newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build(); - VarcharColumnDef permissionKeyColumn = newVarcharColumnDefBuilder().setColumnName("permission_key").setLimit(64).setIsNullable(false).setIgnoreOracleUnit(true).build(); - context.execute( - new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(templateIdColumn) - .addColumn(permissionKeyColumn) - .addColumn(newBooleanColumnDefBuilder().setColumnName("with_project_creator").setIsNullable(false).setDefaultValue(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("uniq_perm_tpl_charac") - .setUnique(true) - .addColumn(templateIdColumn) - .addColumn(permissionKeyColumn) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211.java deleted file mode 100644 index ee02d2e885a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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; - -public class CreateTemporaryIndicesFor1211 extends DdlChange { - - static final String INDEX_ON_CE_ACTIVITY = "ce_activity_snapshot_id"; - static final String INDEX_ON_DUPLICATIONS_INDEX = "dup_index_psid"; - - public CreateTemporaryIndicesFor1211(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("ce_activity") - .setName(INDEX_ON_CE_ACTIVITY) - .addColumn(newIntegerColumnDefBuilder().setColumnName("snapshot_id").build()) - .build()); - context.execute(new CreateIndexBuilder() - .setTable("duplications_index") - .setName(INDEX_ON_DUPLICATIONS_INDEX) - .addColumn(newIntegerColumnDefBuilder().setColumnName("project_snapshot_id").build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60.java deleted file mode 100644 index 510de2a2d11..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.util.stream.Stream; -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion60 implements DbVersion { - @Override - public Stream getSupportComponents() { - return Stream.of( - // Migration1223 - FixProjectUuidOfDeveloperProjects.class, - CleanUsurperRootComponents.class); - } - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1200, "Create table PERM_TPL_CHARACTERISTICS", CreatePermTemplatesCharacteristics.class) - .add(1205, "Drop index resource_index_rid from RESOURCE_INDEX", DropResourceIndexRidFromResourceIndex.class) - .add(1207, "Drop unused columns on PROJECT_MEASURES", DropUnusedMeasuresColumns.class) - .add(1208, "Add columns SNAPSHOTS.*COMPONENT_UUID", AddComponentUuidColumnsToSnapshots.class) - .add(1209, "Populate column SNAPSHOTS.*COMPONENT_UUID", PopulateComponentUuidColumnsOfSnapshots.class) - .add(1210, "Create temporary indices for migration 1211", CreateTemporaryIndicesFor1211.class) - .add(1211, "Clean orphan rows in SNAPSHOTS", CleanOrphanRowsInSnapshots.class) - .add(1212, "Drop temporary indices for migration 1211", DropTemporaryIndicesOf1210.class) - .add(1213, "Make column SNAPSHOTS.UUID not nullable", MakeComponentUuidColumnsNotNullOnSnapshots.class) - .add(1214, "Drop columns SNAPSHOTS.SNAPSHOT_*_ID", DropSnapshotProjectIdFromSnapshots.class) - .add(1215, "Drop columns SNAPSHOTS.*_ID", DropIdColumnsFromSnapshots.class) - .add(1216, "Add column PROJECT_MEASURES.COMPONENT_UUID", AddComponentUuidColumnToMeasures.class) - .add(1217, "Populate column PROJECT_MEASURES.COMPONENT_UUID", PopulateComponentUuidOfMeasures.class) - .add(1218, "Delete orphan measures without component", DeleteOrphanMeasuresWithoutComponent.class) - .add(1219, "Make column PROJECT_MEASURES.COMPONENT_UUID not nullable", MakeComponentUuidNotNullOnMeasures.class) - .add(1220, "Drop column PROJECT_MEASURES.PROJECT_ID", DropProjectIdColumnFromMeasures.class) - .add(1221, "Add index measures_component_uuid", AddIndexOnComponentUuidOfMeasures.class) - .add(1222, "Drop columns USERS.REMEMBER_TOKEN_*", DropRememberMeColumnsFromUsers.class) - .add(1223, "Clean orphan rows and fix incorrect data in table PROJECTS", Migration1223.class) - .add(1224, "Add columns PROJECTS.*_UUID", AddUuidColumnsToProjects.class) - .add(1225, "Populate columns PROJECTS.*_UUID", PopulateUuidColumnsOfProjects.class) - .add(1226, "Clean orphan rows in table PROJECTS", CleanOrphanRowsInProjects.class) - .add(1227, "Drop index projects_uuid", DropIndexProjectsUuidFromProjects.class) - .add(1228, "Make columns PROJECTS.*_UUID not nullable", MakeUuidColumnsNotNullOnProjects.class) - .add(1229, "Recreate index projects_uuid", RecreateIndexProjectsUuidFromProjects.class) - .add(1230, "Drop index projects_root_id", DropIndexProjectsRootIdFromProjects.class) - .add(1231, "Drop columns PROJECTS.*_ID", DropIdColumnsFromProjects.class) - .add(1232, "Add column SNAPSHOTS.UUID", AddUuidColumnToSnapshots.class) - .add(1233, "Populate column SNAPSHOTS.UUID", PopulateUuidColumnOnSnapshots.class) - .add(1234, "Make column SNAPSHOTS.UUID not nullable", MakeUuidColumnNotNullOnSnapshots.class) - .add(1235, "Add unique index analyses_uuid", AddUniqueIndexOnUuidOfSnapshots.class) - .add(1236, "Add column CE_ACTIVITY.ANALYSIS_UUID", AddAnalysisUuidColumnToCeActivity.class) - .add(1237, "Populate column CE_ACTIVITY.ANALYSIS_UUID", PopulateAnalysisUuidColumnOnCeActivity.class) - .add(1238, "Drop column CE_ACTIVITY.SNAPSHOT_ID", DropSnapshotIdColumnFromCeActivity.class) - .add(1239, "Add columns DUPLICATION_INDEX.*_UUID", AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.class) - .add(1240, "Populate columns DUPLICATION_INDEX.*_UUID", PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.class) - .add(1241, "Clean orphan rows in table DUPLICATION_INDEX", DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.class) - .add(1242, "Make columns DUPLICATION_INDEX.*_UUID not nullable", MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.class) - .add(1243, "Drop index duplications_index_sid", DropIndexDuplicationsIndexSidFromDuplicationsIndex.class) - .add(1244, "Drop columns DUPLICATION_INDEX.*SNAPSHOT_ID", DropSnapshotIdColumnsFromDuplicationsIndex.class) - .add(1246, "Add column RULES_PROFILES.LAST_USED", AddLastUsedColumnToRulesProfiles.class) - .add(1247, "Populate column RULES_PROFILES.LAST_USED", PopulateLastUsedColumnOfRulesProfiles.class) - .add(1248, "Add column EVENTS.ANALYSIS_UUID", AddAnalysisUuidColumnToEvents.class) - .add(1249, "Populate column EVENTS.ANALYSIS_UUID", PopulateAnalysisUuidOnEvents.class) - .add(1250, "Clean events without analysis_uuid", CleanEventsWithoutAnalysisUuid.class) - .add(1251, "Clean events without snapshot_id", CleanEventsWithoutSnapshotId.class) - .add(1252, "Make column EVENTS.ANALYSIS_UUID not nullable", MakeAnalysisUuidNotNullOnEvents.class) - .add(1253, "Drop index events_snapshot_id", DropIndexEventsSnapshotIdFromEvents.class) - .add(1254, "Drop columns EVENTS.SNAPSHOT_ID", DropSnapshotIdColumnFromEvents.class) - .add(1256, "Add column PROJECTS.UUID_PATH", AddUuidPathColumnToProjects.class) - .add(1257, "Populate column PROJECTS.UUID_PATH", PopulateUuidPathColumnOnProjects.class) - .add(1258, "Make column PROJECTS.UUID_PATH not nullable", MakeUuidPathColumnNotNullOnProjects.class) - .add(1259, "Remove password of non local users", RemoveUsersPasswordWhenNotLocal.class) - .add(1260, "Add column ACTIVITIES.PROFILE_KEY", AddProfileKeyToActivities.class) - .add(1261, "Populate column ACTIVITIES.PROFILE_KEY", PopulateProfileKeyOfActivities.class) - .add(1262, "Make column ACTIVITIES.PROFILE_KEY not nullable", MakeProfileKeyNotNullOnActivities.class) - .add(1263, "Add column RULES_PROFILES.USER_UPDATED_AT", AddUserUpdatedAtToRulesProfiles.class) - .add(1264, "Populate column RULES_PROFILES.USER_UPDATED_AT", PopulateUserUpdatedAtOfRulesProfiles.class) - .add(1265, "Add column PROJECT_MEASURES.ANALYSIS_UUID", AddAnalysisUuidColumnToMeasures.class) - .add(1266, "Add index measures_analysis_metric", AddIndexOnAnalysisUuidOfMeasures.class) - .add(1267, "Populate column PROJECT_MEASURES.ANALYSIS_UUID", PopulateAnalysisUuidOnMeasures.class) - .add(1268, "Clean orphan measures", CleanMeasuresWithNullAnalysisUuid.class) - .add(1269, "Temporary drop of index measures_analysis_metric", TemporarilyDropIndexOfAnalysisUuidOnMeasures.class) - .add(1270, "Make column PROJECT_MEASURES.ANALYSIS_UUID not nullable", MakeAnalysisUuidNotNullOnMeasures.class) - .add(1271, "Restore index measures_analysis_metric", AddIndexOnAnalysisUuidOfMeasures.class) - .add(1272, "Delete snapshots but the one of root components", DropTreesOfSnapshots.class) - .add(1273, "Drop indices on tree columns of table SNAPSHOTS", DropIndicesOnTreeColumnsOfSnapshots.class) - .add(1274, "Drop tree columns of table SNAPSHOTS", DropTreeColumnsFromSnapshots.class) - .add(1275, "Drop index measures_sid_metric", DropIndexOnSnapshotIdOfMeasures.class) - .add(1276, "Drop column PROJECT_MEASURES.SNAPSHOT_ID", DropSnapshotIdColumnFromMeasures.class) - .add(1277, "Add columns PROJECTS.B_*", AddBColumnsToProjects.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java deleted file mode 100644 index 4595bca4e02..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis extends DataChange { - - public DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - deleteRowsWithoutComponentUuid(context); - deleteRowsWithoutAnalysisUuid(context); - } - - private static void deleteRowsWithoutComponentUuid(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT id from duplications_index where component_uuid is null"); - massUpdate.update("DELETE from duplications_index WHERE id=?"); - massUpdate.rowPluralName("duplications index rows without component"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - - private static void deleteRowsWithoutAnalysisUuid(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT distinct project_snapshot_id from duplications_index where analysis_uuid is null"); - massUpdate.update("DELETE from duplications_index WHERE project_snapshot_id=?"); - massUpdate.rowPluralName("duplications index rows without analysis"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponent.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponent.java deleted file mode 100644 index ced85ff6d1d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponent.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class DeleteOrphanMeasuresWithoutComponent extends DataChange { - - public DeleteOrphanMeasuresWithoutComponent(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT id from project_measures where component_uuid is null"); - massUpdate.update("DELETE from project_measures WHERE id=?"); - massUpdate.rowPluralName("measures"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjects.java deleted file mode 100644 index 32916f8580b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjects.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropIdColumnsFromProjects extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - - public DropIdColumnsFromProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new DropColumnsBuilder( - getDialect(), TABLE_PROJECTS, - "root_id", "copy_resource_id", "person_id") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshots.java deleted file mode 100644 index 674260860e8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshots.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropIdColumnsFromSnapshots extends DdlChange { - - private static final String TABLE_SNAPSHOTS = "snapshots"; - - public DropIdColumnsFromSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new DropColumnsBuilder( - getDatabase().getDialect(), TABLE_SNAPSHOTS, - "project_id", "root_project_id") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java deleted file mode 100644 index 1099a2ccea7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropIndexDuplicationsIndexSidFromDuplicationsIndex extends DdlChange { - public DropIndexDuplicationsIndexSidFromDuplicationsIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("duplications_index") - .setName("duplications_index_sid") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexEventsSnapshotIdFromEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexEventsSnapshotIdFromEvents.java deleted file mode 100644 index 5b26498fcb8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexEventsSnapshotIdFromEvents.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropIndexEventsSnapshotIdFromEvents extends DdlChange { - public DropIndexEventsSnapshotIdFromEvents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("events") - .setName("events_snapshot_id") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexOnSnapshotIdOfMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexOnSnapshotIdOfMeasures.java deleted file mode 100644 index 2acae7a26c3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexOnSnapshotIdOfMeasures.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropIndexOnSnapshotIdOfMeasures extends DdlChange { - public DropIndexOnSnapshotIdOfMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("project_measures") - .setName("measures_sid_metric") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjects.java deleted file mode 100644 index aef39742773..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjects.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropIndexProjectsRootIdFromProjects extends DdlChange { - public DropIndexProjectsRootIdFromProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("projects") - .setName("projects_root_id") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjects.java deleted file mode 100644 index 52d7b901e76..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjects.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropIndexProjectsUuidFromProjects extends DdlChange { - public DropIndexProjectsUuidFromProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("projects") - .setName("projects_uuid") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java deleted file mode 100644 index b089af1c52e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropIndicesOnTreeColumnsOfSnapshots extends DdlChange { - public DropIndicesOnTreeColumnsOfSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - dropIndex(context, "snapshots_qualifier"); - dropIndex(context, "snapshots_root"); - dropIndex(context, "snapshots_parent"); - dropIndex(context, "snapshot_root_component"); - } - - private void dropIndex(Context context, String index) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("snapshots") - .setName(index) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasures.java deleted file mode 100644 index 9c21887271b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasures.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropProjectIdColumnFromMeasures extends DdlChange { - - private static final String TABLE_MEASURES = "project_measures"; - - public DropProjectIdColumnFromMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new DropColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES, "project_id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsers.java deleted file mode 100644 index af36332d3b5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsers.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropRememberMeColumnsFromUsers extends DdlChange { - - private static final String TABLE_USERS = "users"; - - public DropRememberMeColumnsFromUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_USERS, "remember_token", "remember_token_expires_at").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndex.java deleted file mode 100644 index 88b6d996788..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndex.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropResourceIndexRidFromResourceIndex extends DdlChange { - - public DropResourceIndexRidFromResourceIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("resource_index") - .setName("resource_index_rid") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivity.java deleted file mode 100644 index ccfb6aa497c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivity.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropSnapshotIdColumnFromCeActivity extends DdlChange { - - private static final String TABLE_CE_ACTIVITY = "ce_activity"; - - public DropSnapshotIdColumnFromCeActivity(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new DropColumnsBuilder( - getDatabase().getDialect(), TABLE_CE_ACTIVITY, - "snapshot_id") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEvents.java deleted file mode 100644 index 2806acdbd7a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEvents.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropSnapshotIdColumnFromEvents extends DdlChange { - - private static final String TABLE_EVENTS = "events"; - - public DropSnapshotIdColumnFromEvents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS, "snapshot_id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasures.java deleted file mode 100644 index 404fddb7c6b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasures.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropSnapshotIdColumnFromMeasures extends DdlChange { - - private static final String TABLE = "project_measures"; - - public DropSnapshotIdColumnFromMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDatabase().getDialect(), TABLE, "snapshot_id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnsFromDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnsFromDuplicationsIndex.java deleted file mode 100644 index 348e17c9721..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnsFromDuplicationsIndex.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropSnapshotIdColumnsFromDuplicationsIndex extends DdlChange { - - private static final String TABLE_DUPLICATIONS_INDEX = "duplications_index"; - - public DropSnapshotIdColumnsFromDuplicationsIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new DropColumnsBuilder(getDialect(), TABLE_DUPLICATIONS_INDEX, "project_snapshot_id", "snapshot_id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshots.java deleted file mode 100644 index 3f4f82416b5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshots.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropSnapshotProjectIdFromSnapshots extends DdlChange { - - private static final String TABLE_SNAPSHOTS = "snapshots"; - - public DropSnapshotProjectIdFromSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_SNAPSHOTS) - .setName("snapshot_project_id") - .build()); - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_SNAPSHOTS) - .setName("snapshots_root_project_id") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210.java deleted file mode 100644 index f23475e2fdd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropTemporaryIndicesOf1210 extends DdlChange { - - public DropTemporaryIndicesOf1210(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("ce_activity") - .setName(CreateTemporaryIndicesFor1211.INDEX_ON_CE_ACTIVITY) - .build()); - - context.execute(new DropIndexBuilder(getDialect()) - .setTable("duplications_index") - .setName(CreateTemporaryIndicesFor1211.INDEX_ON_DUPLICATIONS_INDEX) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshots.java deleted file mode 100644 index 05408cca7a3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshots.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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 DropTreeColumnsFromSnapshots extends DdlChange { - - private static final String TABLE = "snapshots"; - - public DropTreeColumnsFromSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - String[] columns = {"parent_snapshot_id", "scope", "qualifier", "root_snapshot_id", "path", "depth", "root_component_uuid"}; - context.execute(new DropColumnsBuilder(getDatabase().getDialect(), TABLE, columns).build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshots.java deleted file mode 100644 index 601396342bf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshots.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class DropTreesOfSnapshots extends DataChange { - - public DropTreesOfSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from snapshots where depth > 0"); - massUpdate.update("delete from snapshots where id=?"); - massUpdate.rowPluralName("snapshots"); - massUpdate.execute(DropTreesOfSnapshots::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - update.setLong(1, id); - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumns.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumns.java deleted file mode 100644 index 613303fbc3c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumns.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import com.google.common.annotations.VisibleForTesting; -import java.sql.SQLException; -import java.util.List; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -/** - * Drop the following columns from the project_measures table : - * - rule_category_id - * - tendency - * - url - * - measure_date - * - url - * - rule_priority - * - rule_id - * - Characteristic_id - */ -public class DropUnusedMeasuresColumns extends DdlChange { - - public DropUnusedMeasuresColumns(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(generateSql()); - } - - @VisibleForTesting - List generateSql() { - return new DropColumnsBuilder(getDatabase().getDialect(), "project_measures", - "rules_category_id", "tendency", "measure_date", "url", "rule_priority", "characteristic_id", "rule_id") - .build(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjects.java deleted file mode 100644 index fc9b210805f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjects.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class FixProjectUuidOfDeveloperProjects extends DataChange { - - public FixProjectUuidOfDeveloperProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct p.person_id,d.uuid from projects p, projects d where p.qualifier = 'DEV_PRJ' and p.project_uuid != d.uuid and d.id = p.person_id"); - massUpdate.update("update projects set project_uuid = ? where person_id = ? and qualifier = 'DEV_PRJ' and project_uuid != ?"); - massUpdate.rowPluralName("developers with incorrect project_uuid"); - massUpdate.execute(FixProjectUuidOfDeveloperProjects::handleComponent); - } - - private static boolean handleComponent(Select.Row row, SqlStatement update) throws SQLException { - long personId = row.getLong(1); - String developerUuid = row.getString(2); - update.setString(1, developerUuid); - update.setLong(2, personId); - update.setString(3, developerUuid); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnEvents.java deleted file mode 100644 index 90fdce146b2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnEvents.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeAnalysisUuidNotNullOnEvents extends DdlChange { - - private static final String TABLE_EVENTS = "events"; - - public MakeAnalysisUuidNotNullOnEvents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef analysisUuidColumn = newVarcharColumnDefBuilder() - .setColumnName("analysis_uuid") - .setLimit(UUID_VARCHAR_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS) - .updateColumn(analysisUuidColumn) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_EVENTS) - .setName("events_analysis") - .addColumn(analysisUuidColumn) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasures.java deleted file mode 100644 index 8570bbd3be4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasures.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeAnalysisUuidNotNullOnMeasures extends DdlChange { - - private static final String TABLE_MEASURES = "project_measures"; - - public MakeAnalysisUuidNotNullOnMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java deleted file mode 100644 index d5c76b82db9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex extends DdlChange { - - private static final String TABLE_DUPLICATIONS_INDEX = "duplications_index"; - - public MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef analysisUuid = newUuidColumn("analysis_uuid"); - VarcharColumnDef componentUuid = newUuidColumn("component_uuid"); - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_DUPLICATIONS_INDEX) - .updateColumn(componentUuid) - .updateColumn(analysisUuid) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_DUPLICATIONS_INDEX) - .setName("duplication_analysis_component") - .addColumn(analysisUuid) - .addColumn(componentUuid) - .build()); - } - - private static VarcharColumnDef newUuidColumn(String columnName) { - return newVarcharColumnDefBuilder() - .setColumnName(columnName) - .setLimit(UUID_VARCHAR_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java deleted file mode 100644 index 3f420c206ad..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeComponentUuidColumnsNotNullOnSnapshots extends DdlChange { - - private static final String TABLE_SNAPSHOTS = "snapshots"; - - public MakeComponentUuidColumnsNotNullOnSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef componentUuid = newUuidColumn("component_uuid"); - VarcharColumnDef rootComponentUuid = newUuidColumn("root_component_uuid"); - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS) - .updateColumn(componentUuid) - .updateColumn(rootComponentUuid) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_SNAPSHOTS) - .setName("snapshot_component") - .addColumn(componentUuid) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_SNAPSHOTS) - .setName("snapshot_root_component") - .addColumn(rootComponentUuid) - .build()); - } - - private static VarcharColumnDef newUuidColumn(String columnName) { - return newVarcharColumnDefBuilder() - .setColumnName(columnName) - .setLimit(UUID_VARCHAR_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasures.java deleted file mode 100644 index 5d1be273f4a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasures.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeComponentUuidNotNullOnMeasures extends DdlChange { - - private static final String TABLE_MEASURES = "project_measures"; - - public MakeComponentUuidNotNullOnMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivities.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivities.java deleted file mode 100644 index 8c9ab8f1398..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivities.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 MakeProfileKeyNotNullOnActivities extends DdlChange { - - private static final String TABLE_ACTIVITIES = "activities"; - - public MakeProfileKeyNotNullOnActivities(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_ACTIVITIES) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("profile_key").setLimit(255).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshots.java deleted file mode 100644 index 2ef9972cf02..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshots.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeUuidColumnNotNullOnSnapshots extends DdlChange { - - private static final String TABLE_SNAPSHOTS = "snapshots"; - - public MakeUuidColumnNotNullOnSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjects.java deleted file mode 100644 index df2f5794598..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjects.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeUuidColumnsNotNullOnProjects extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - - public MakeUuidColumnsNotNullOnProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef rootUuid = newVarcharColumnDefBuilder().setColumnName("root_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_PROJECTS) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .updateColumn(rootUuid) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_PROJECTS) - .setName("projects_root_uuid") - .addColumn(rootUuid) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidPathColumnNotNullOnProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidPathColumnNotNullOnProjects.java deleted file mode 100644 index 6a77e622fee..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidPathColumnNotNullOnProjects.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 MakeUuidPathColumnNotNullOnProjects extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - - public MakeUuidPathColumnNotNullOnProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_PROJECTS) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid_path").setLimit(1500).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/Migration1223.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/Migration1223.java deleted file mode 100644 index be05a40e288..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/Migration1223.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -/** - * This migration step is a substitute for the Ruby migration file which called two java migrations: - * {@link FixProjectUuidOfDeveloperProjects} and {@link CleanUsurperRootComponents}. - */ -public class Migration1223 implements MigrationStep { - private final FixProjectUuidOfDeveloperProjects projectUuidOfDeveloperProjects; - private final CleanUsurperRootComponents cleanUsurperRootComponents; - - public Migration1223(FixProjectUuidOfDeveloperProjects projectUuidOfDeveloperProjects, CleanUsurperRootComponents cleanUsurperRootComponents) { - this.projectUuidOfDeveloperProjects = projectUuidOfDeveloperProjects; - this.cleanUsurperRootComponents = cleanUsurperRootComponents; - } - - @Override - public void execute() throws SQLException { - projectUuidOfDeveloperProjects.execute(); - cleanUsurperRootComponents.execute(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivity.java deleted file mode 100644 index a02eebae355..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivity.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateAnalysisUuidColumnOnCeActivity extends DataChange { - - public PopulateAnalysisUuidColumnOnCeActivity(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT a.id, s.uuid from ce_activity a inner join snapshots s on s.id=a.snapshot_id where a.snapshot_id is not null and a.analysis_uuid is null"); - massUpdate.update("UPDATE ce_activity SET analysis_uuid=? WHERE id=?"); - massUpdate.rowPluralName("ce_activity"); - massUpdate.execute(PopulateAnalysisUuidColumnOnCeActivity::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - String analysisUuid = row.getString(2); - - update.setString(1, analysisUuid); - update.setLong(2, id); - - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEvents.java deleted file mode 100644 index 0b4ad09a303..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEvents.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateAnalysisUuidOnEvents extends DataChange { - - public PopulateAnalysisUuidOnEvents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT distinct e.snapshot_id, s.uuid from events e" + - " inner join snapshots s on s.id=e.snapshot_id and s.scope = 'PRJ' and s.qualifier in ('TRK', 'DEV', 'VW')" + - " where e.snapshot_id is not null and e.analysis_uuid is null"); - massUpdate.update("UPDATE events SET analysis_uuid=? WHERE snapshot_id=? and analysis_uuid is null"); - massUpdate.rowPluralName("analysis uuid of root component events"); - massUpdate.execute(PopulateAnalysisUuidOnEvents::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long snapshotId = row.getLong(1); - String snapshotUuid = row.getString(2); - - update.setString(1, snapshotUuid); - update.setLong(2, snapshotId); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasures.java deleted file mode 100644 index 2cf0e06f607..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasures.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class PopulateAnalysisUuidOnMeasures extends DataChange { - - public PopulateAnalysisUuidOnMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - Map rootSnapshotUuids = loadRootSnapshotUuids(context); - - - MassUpdate massUpdate = context.prepareMassUpdate(); - // mysql can take hours if the 2 requests are merged into a single one - massUpdate.select("select distinct m.snapshot_id as sId, s.root_snapshot_id as rootSid " + - "from project_measures m " + - "inner join snapshots s on m.snapshot_id = s.id " + - "where m.analysis_uuid is null" - ); - massUpdate.update("update project_measures set analysis_uuid=? where snapshot_id = ? and analysis_uuid is null"); - massUpdate.rowPluralName("measures"); - massUpdate.execute((row, update) -> handleRow(row, update, rootSnapshotUuids)); - } - - private static Map loadRootSnapshotUuids(Context context) throws SQLException { - Map snapshotUuidsByIds = new HashMap<>(); - context.prepareSelect("select distinct id, uuid from snapshots where depth=0") - .scroll(row -> snapshotUuidsByIds.put(row.getLong(1), row.getString(2))); - return snapshotUuidsByIds; - } - - private static boolean handleRow(Select.Row row, SqlStatement update, Map rootSnapshotUuids) throws SQLException { - long snapshotId = row.getLong(1); - Long rootSnapshotId = row.getNullableLong(2); - String analysisUuid = rootSnapshotUuids.get(rootSnapshotId == null ? snapshotId : rootSnapshotId); - if (analysisUuid == null) { - return false; - } - - update.setString(1, analysisUuid); - update.setLong(2, snapshotId); - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java deleted file mode 100644 index 43bff57922b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex extends DataChange { - - public PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - populateComponentUuid(context); - populateAnalysisUuid(context); - } - - private static void populateComponentUuid(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct di.snapshot_id, s.component_uuid from duplications_index di" + - " inner join snapshots s on s.id=di.snapshot_id" + - " where di.component_uuid is null"); - massUpdate.update("UPDATE duplications_index SET component_uuid=? WHERE snapshot_id=? and component_uuid is null"); - massUpdate.rowPluralName("component uuid of duplications_index entries"); - massUpdate.execute(PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex::handleComponentUuid); - } - - private static boolean handleComponentUuid(Select.Row row, SqlStatement update) throws SQLException { - long snapshotId = row.getLong(1); - String componentUuid = row.getString(2); - - update.setString(1, componentUuid); - update.setLong(2, snapshotId); - - return true; - } - - private static void populateAnalysisUuid(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct di.project_snapshot_id, s.uuid from duplications_index di" + - " inner join snapshots s on s.id=di.project_snapshot_id" + - " where di.analysis_uuid is null"); - massUpdate.update("UPDATE duplications_index SET analysis_uuid=? WHERE project_snapshot_id=? and analysis_uuid is null"); - massUpdate.rowPluralName("analysis uuid of duplications_index entries"); - massUpdate.execute(PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex::handleAnalysisUuid); - } - - private static boolean handleAnalysisUuid(Select.Row row, SqlStatement update) throws SQLException { - long projectSnapshotId = row.getLong(1); - String snapshotUuid = row.getString(2); - - update.setString(1, snapshotUuid); - update.setLong(2, projectSnapshotId); - - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshots.java deleted file mode 100644 index 91dd43e5a2c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshots.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateComponentUuidColumnsOfSnapshots extends DataChange { - - public PopulateComponentUuidColumnsOfSnapshots(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - Map componentUuidById = buildComponentUuidMap(context); - if (componentUuidById.isEmpty()) { - return; - } - - populateUuidColumns(context, componentUuidById); - } - - private static Map buildComponentUuidMap(Context context) throws SQLException { - Map componentUuidById = new HashMap<>(); - context.prepareSelect("select distinct p.id, p.uuid from projects p" + - " join snapshots sn1 on sn1.project_id = p.id and sn1.component_uuid is null") - .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); - context.prepareSelect("select distinct p.id, p.uuid from projects p" + - " join snapshots sn2 on sn2.root_project_id = p.id and sn2.root_component_uuid is null") - .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); - return componentUuidById; - } - - private static void populateUuidColumns(Context context, Map componentUuidById) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT sn.id, sn.project_id, sn.root_project_id from snapshots sn where sn.component_uuid is null or sn.root_component_uuid is null"); - massUpdate.update("UPDATE snapshots SET component_uuid=?, root_component_uuid=? WHERE id=?"); - massUpdate.rowPluralName("snapshots"); - massUpdate.execute((row, update) -> handle(componentUuidById, row, update)); - } - - private static boolean handle(Map componentUuidById, Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - long componentId = row.getLong(2); - long rootProjectId = row.getLong(3); - - String componentUuid = componentUuidById.get(componentId); - String rootComponentUuid = componentUuidById.get(rootProjectId); - - if (componentUuid == null && rootComponentUuid == null) { - return false; - } - - update.setString(1, componentUuid); - update.setString(2, rootComponentUuid); - update.setLong(3, id); - - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasures.java deleted file mode 100644 index 9113c9755fa..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasures.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateComponentUuidOfMeasures extends DataChange { - - public PopulateComponentUuidOfMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct pm.snapshot_id, s.component_uuid from project_measures pm inner join snapshots s on s.id=pm.snapshot_id where pm.component_uuid is null"); - massUpdate.update("UPDATE project_measures SET component_uuid=? WHERE snapshot_id=? and component_uuid is null"); - massUpdate.rowPluralName("measures"); - massUpdate.execute(this::handle); - } - - public boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long snapshotId = row.getLong(1); - String componentUuid = row.getString(2); - - update.setString(1, componentUuid); - update.setLong(2, snapshotId); - - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfiles.java deleted file mode 100644 index c1b265e42d2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfiles.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateLastUsedColumnOfRulesProfiles extends DataChange { - - private static final Pattern PATTERN_QP_KEY = Pattern.compile("\"key\"\\s*:\\s*\"(.*?)\""); - - public PopulateLastUsedColumnOfRulesProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - Map lastAnalysisDatesByQualityProfileKey = buildQualityProfilesMap(context); - if (lastAnalysisDatesByQualityProfileKey.isEmpty()) { - return; - } - - populateLastUsedColumn(context, lastAnalysisDatesByQualityProfileKey); - } - - private static Map buildQualityProfilesMap(Context context) throws SQLException { - Map lastAnalysisDatesByQPKeys = new HashMap<>(); - - context.prepareSelect("select s.created_at, pm.text_value " + - "from project_measures pm " + - " inner join snapshots s on pm.snapshot_id = s.id " + - " inner join metrics m on pm.metric_id=m.id " + - "where s.islast=? " + - " and m.name='quality_profiles' " + - "order by s.created_at ") - .setBoolean(1, true) - .scroll(row -> { - long analysisDate = row.getLong(1); - String json = row.getString(2); - Matcher matcher = PATTERN_QP_KEY.matcher(json); - while (matcher.find()) { - lastAnalysisDatesByQPKeys.put(matcher.group(1), analysisDate); - } - }); - return lastAnalysisDatesByQPKeys; - } - - private static void populateLastUsedColumn(Context context, Map lastAnalysisDatesByQualityProfileKey) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id, kee from rules_profiles where last_used is null"); - massUpdate.update("update rules_profiles set last_used=? where id=?"); - massUpdate.rowPluralName("rules_profiles"); - massUpdate.execute((row, update) -> handle(lastAnalysisDatesByQualityProfileKey, row, update)); - } - - private static boolean handle(Map lastAnalysisDatesByQualityProfileKey, Select.Row row, SqlStatement update) throws SQLException { - int qualityProfileId = row.getInt(1); - String qualityProfileKey = row.getString(2); - - update.setLong(1, lastAnalysisDatesByQualityProfileKey.get(qualityProfileKey)); - update.setInt(2, qualityProfileId); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivities.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivities.java deleted file mode 100644 index 4a0e6be9f31..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivities.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.Map; -import org.sonar.api.utils.KeyValueFormat; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.apache.commons.lang.StringUtils.isBlank; - -public class PopulateProfileKeyOfActivities extends DataChange { - - public PopulateProfileKeyOfActivities(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id, data_field from activities where profile_key is null"); - massUpdate.update("update activities set profile_key=?, data_field=? where id=?"); - massUpdate.rowPluralName("activities"); - massUpdate.execute(PopulateProfileKeyOfActivities::handle); - - // SONAR-8534 delete orphans - context.prepareUpsert("delete from activities where profile_key is null") - .execute() - .commit(); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - int id = row.getInt(1); - String data = row.getString(2); - Map fields = KeyValueFormat.parse(data); - String profileKey = fields.remove("profileKey"); - if (isBlank(profileKey)) { - return false; - } - update.setString(1, profileKey); - update.setString(2, KeyValueFormat.format(fields)); - update.setInt(3, id); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfiles.java deleted file mode 100644 index 353090dcd96..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfiles.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import com.google.common.base.Throwables; -import java.sql.SQLException; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.annotation.CheckForNull; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateUserUpdatedAtOfRulesProfiles extends DataChange { - - private static final String SQL_SELECT_PROFILES_NOT_UPDATED = "select kee from rules_profiles where user_updated_at is null"; - - public PopulateUserUpdatedAtOfRulesProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - Map userUpdatedAtByProfileKeys = buildUserUpdatedAtMap(context); - populateUserUpdatedAtColumn(context, userUpdatedAtByProfileKeys); - } - - private static Map buildUserUpdatedAtMap(Context context) throws SQLException { - Map lastAnalysisDatesByQPKeys = new HashMap<>(); - List profileKeys = context.prepareSelect(SQL_SELECT_PROFILES_NOT_UPDATED).list(row -> row.getString(1)); - profileKeys.forEach(profileKey -> lastAnalysisDatesByQPKeys.put(profileKey, getUserUpdateAt(context, profileKey))); - - return lastAnalysisDatesByQPKeys; - } - - @CheckForNull - private static Long getUserUpdateAt(Context context, String profileKey) { - try { - return context.prepareSelect("select created_at as \"createdAt\" " + - "from activities " + - "where user_login is not null " + - " and profile_key=? " + - "order by created_at DESC ") - .setString(1, profileKey) - .get(row -> { - Date userUpdatedAt = row.getNullableDate(1); - return userUpdatedAt == null ? null : userUpdatedAt.getTime(); - }); - } catch (SQLException e) { - throw Throwables.propagate(e); - } - } - - private static void populateUserUpdatedAtColumn(Context context, Map userUpdatedAdByProfileKey) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select(SQL_SELECT_PROFILES_NOT_UPDATED); - massUpdate.update("update rules_profiles set user_updated_at=? where kee=?"); - massUpdate.rowPluralName("quality profiles"); - massUpdate.execute((row, update) -> handle(userUpdatedAdByProfileKey, row, update)); - } - - private static boolean handle(Map userUpdatedAtByProfileKey, Select.Row row, SqlStatement update) throws SQLException { - String profileKey = row.getString(1); - - update.setLong(1, userUpdatedAtByProfileKey.get(profileKey)); - update.setString(2, profileKey); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshots.java deleted file mode 100644 index f2672057687..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshots.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateUuidColumnOnSnapshots extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateUuidColumnOnSnapshots(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT s.id from snapshots s where s.uuid is null"); - massUpdate.update("UPDATE snapshots SET uuid=? WHERE id=?"); - massUpdate.rowPluralName("snapshots"); - massUpdate.execute(this::handle); - } - - private boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - update.setString(1, uuidFactory.create()); - update.setLong(2, id); - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjects.java deleted file mode 100644 index ee2394395cf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjects.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateUuidColumnsOfProjects extends DataChange { - private static final Logger LOG = Loggers.get(PopulateUuidColumnsOfProjects.class); - - public PopulateUuidColumnsOfProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - - Map componentUuidById = buildComponentUuidMap(context); - if (componentUuidById.isEmpty()) { - return; - } - - populateRootUuidColumnForRoots(context); - populateRootUuidColumnForSubnodes(context, componentUuidById); - populateCopyComponentUuidColumn(context, componentUuidById); - populatePersonUuidColumn(context, componentUuidById); - } - - private static Map buildComponentUuidMap(Context context) throws SQLException { - Map componentUuidById = new HashMap<>(); - // rootId for root nodes (ie. column root_id is null) - context.prepareSelect("select distinct p1.id, p1.uuid from projects p1" + - " where p1.root_id is null and p1.root_uuid is null") - .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); - // rootId for other nodes (ie. column root_id is not null) - context.prepareSelect("select distinct p1.id, p1.uuid from projects p1" + - " join projects p2 on p1.id = p2.root_id" + - " where p2.root_uuid is null") - .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); - // copyResourceId - context.prepareSelect("select distinct p1.id, p1.uuid from projects p1" + - " join projects p2 on p1.id = p2.copy_resource_id" + - " where p2.copy_resource_id is not null and p2.copy_component_uuid is null") - .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); - // person_id - context.prepareSelect("select distinct p1.id, p1.uuid from projects p1" + - " join projects p2 on p1.id = p2.person_id" + - " where p2.person_id is not null and p2.developer_uuid is null") - .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); - return componentUuidById; - } - - private static void populateRootUuidColumnForRoots(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT distinct p.id from projects p where p.root_id is null and p.root_uuid is null"); - massUpdate.update("UPDATE projects SET root_uuid=uuid WHERE id=? and root_id is null and root_uuid is null"); - massUpdate.rowPluralName("root uuid of root components"); - massUpdate.execute(PopulateUuidColumnsOfProjects::handleRootIdUpdateForRootNodes); - } - - private static boolean handleRootIdUpdateForRootNodes(Select.Row row, SqlStatement update) throws SQLException { - long rootId = row.getLong(1); - - update.setLong(1, rootId); - - return true; - } - - private static void populateRootUuidColumnForSubnodes(Context context, Map componentUuidById) throws SQLException { - // update all rows with specific root_id which have no root_uuid yet in a single update - // this will be efficient as root_id is indexed - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT distinct p.root_id from projects p where p.root_id is not null and p.root_uuid is null"); - massUpdate.update("UPDATE projects SET root_uuid=? WHERE root_id=? and root_uuid is null"); - massUpdate.rowPluralName("root uuid of non-root components"); - massUpdate.execute((row, update) -> handleRootIdUpdateForSubNodes(componentUuidById, row, update)); - } - - private static boolean handleRootIdUpdateForSubNodes(Map componentUuidById, Select.Row row, SqlStatement update) throws SQLException { - long rootId = row.getLong(1); - String rootUuid = componentUuidById.get(rootId); - - if (rootUuid == null) { - LOG.trace("No UUID found for rootId={}", rootUuid); - return false; - } - - update.setString(1, rootUuid); - update.setLong(2, rootId); - - return true; - } - - private static void populateCopyComponentUuidColumn(Context context, Map componentUuidById) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT p.id, p.copy_resource_id from projects p where p.copy_resource_id is not null and p.copy_component_uuid is null"); - massUpdate.update("UPDATE projects SET copy_component_uuid=? WHERE id=?"); - massUpdate.rowPluralName("copy component uuid of components"); - massUpdate.execute((row, update) -> handleCopyComponentUuidUpdate(componentUuidById, row, update)); - } - - private static boolean handleCopyComponentUuidUpdate(Map componentUuidById, Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - long copyResourceId = row.getLong(2); - - String copyComponentUuid = componentUuidById.get(copyResourceId); - if (copyComponentUuid == null) { - LOG.trace("No UUID found for copyResourceId={}", copyResourceId); - return false; - } - - update.setString(1, copyComponentUuid); - update.setLong(2, id); - - return true; - } - - private static void populatePersonUuidColumn(Context context, Map componentUuidById) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT p.id, p.person_id from projects p where p.person_id is not null and p.developer_uuid is null"); - massUpdate.update("UPDATE projects SET developer_uuid=? WHERE id=?"); - massUpdate.rowPluralName("person uuid of components"); - massUpdate.execute((row, update) -> handleDeveloperUuuidUpdate(componentUuidById, row, update)); - } - - private static boolean handleDeveloperUuuidUpdate(Map componentUuidById, Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - long personId = row.getLong(2); - - String developerUuid = componentUuidById.get(personId); - if (developerUuid == null) { - LOG.trace("No UUID found for personId={}", personId); - return false; - } - - update.setString(1, developerUuid); - update.setLong(2, id); - - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjects.java deleted file mode 100644 index 4c8e033c3ef..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjects.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import javax.annotation.Nullable; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.util.stream.Collectors.toCollection; - -public class PopulateUuidPathColumnOnProjects extends DataChange { - - private static final Logger LOG = Loggers.get(PopulateUuidPathColumnOnProjects.class); - private static final Joiner PATH_JOINER = Joiner.on('.'); - private static final Splitter PATH_SPLITTER = Splitter.on('.').omitEmptyStrings(); - private static final String PATH_SEPARATOR = "."; - private static final String ROOT_PATH = PATH_SEPARATOR; - - public PopulateUuidPathColumnOnProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - // group upgrades by tree of component - List rootComponentUuids = context - .prepareSelect("select distinct project_uuid from projects where uuid_path is null") - .list(row -> row.getString(1)); - for (String rootUuid : rootComponentUuids) { - handleRoot(rootUuid, context); - } - - handleOrphans(context); - } - - private static void handleRoot(String rootComponentUuid, Context context) throws SQLException { - Relations relations = new Relations(); - context - .prepareSelect("select s.id, s.path, s.component_uuid from snapshots s where s.root_component_uuid=? and s.islast=?") - .setString(1, rootComponentUuid) - .setBoolean(2, true) - .scroll(row -> { - long snapshotId = row.getLong(1); - String snapshotPath = row.getString(2); - String componentUuid = row.getString(3); - relations.add(new Snapshot(snapshotId, snapshotPath, componentUuid)); - }); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select p.uuid, p.project_uuid from projects p where p.project_uuid=? and p.uuid_path is null").setString(1, rootComponentUuid); - massUpdate.update("update projects set uuid_path=? where uuid=? and uuid_path is null"); - massUpdate.rowPluralName("components in tree of " + rootComponentUuid); - massUpdate.execute((row, update) -> handleComponent(relations, row, update)); - } - - private static void handleOrphans(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid, project_uuid from projects where uuid_path is null"); - massUpdate.update("update projects set uuid_path=? where uuid=? and uuid_path is null"); - massUpdate.rowPluralName("orphan components"); - massUpdate.execute((row, update, updateIndex) -> { - String uuid = row.getString(1); - String rootUuid = row.getString(2); - String path = uuid.equals(rootUuid) ? ROOT_PATH : (PATH_SEPARATOR + rootUuid + PATH_SEPARATOR); - update.setString(1, path); - update.setString(2, uuid); - return true; - }); - } - - private static boolean handleComponent(Relations relations, Select.Row row, SqlStatement update) throws SQLException { - String componentUuid = row.getString(1); - String rootComponentUuid = row.getString(2); - - if (componentUuid.equals(rootComponentUuid)) { - // Root component, no need to use the table SNAPSHOTS. - // Moreover it allows to support provisioned projects (zero analysis) - update.setString(1, PATH_SEPARATOR); - update.setString(2, componentUuid); - return true; - } - - Snapshot snapshot = relations.snapshotsByComponentUuid.get(componentUuid); - if (snapshot == null) { - LOG.trace("No UUID found for component UUID={}", componentUuid); - return false; - } - - List componentUuidPath = Arrays.stream(snapshot.snapshotPath) - .mapToObj(relations.snapshotsById::get) - .filter(Objects::nonNull) - .map(s -> s.componentUuid) - .collect(toCollection(ArrayList::new)); - if (componentUuidPath.size() != snapshot.snapshotPath.length) { - LOG.trace("Some component UUIDs not found for snapshots [{}]", snapshot.snapshotPath); - return false; - } - - update.setString(1, PATH_SEPARATOR + PATH_JOINER.join(componentUuidPath) + PATH_SEPARATOR); - update.setString(2, componentUuid); - return true; - } - - private static final class Relations { - private final Map snapshotsByComponentUuid = new HashMap<>(); - private final Map snapshotsById = new HashMap<>(); - - void add(Snapshot snapshot) { - snapshotsByComponentUuid.put(snapshot.componentUuid, snapshot); - snapshotsById.put(snapshot.id, snapshot); - } - } - - private static final class Snapshot { - private static final long[] EMPTY_PATH = new long[0]; - private final long id; - private final long[] snapshotPath; - private final String componentUuid; - - public Snapshot(long id, String snapshotPath, String componentUuid) { - this.id = id; - this.snapshotPath = parsePath(snapshotPath); - this.componentUuid = componentUuid; - } - - // inputs: null (on Oracle), "", "1." or "1.2.3." - private static long[] parsePath(@Nullable String snapshotPath) { - if (snapshotPath == null) { - return EMPTY_PATH; - } - return PATH_SPLITTER - .splitToList(snapshotPath) - .stream() - .mapToLong(Long::parseLong) - .toArray(); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjects.java deleted file mode 100644 index d53c67b1a38..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjects.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 RecreateIndexProjectsUuidFromProjects extends DdlChange { - - public RecreateIndexProjectsUuidFromProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("projects") - .setName("projects_uuid") - .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(50).setIgnoreOracleUnit(true).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocal.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocal.java deleted file mode 100644 index c7696943c86..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocal.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class RemoveUsersPasswordWhenNotLocal extends DataChange { - - private final System2 system2; - - public RemoveUsersPasswordWhenNotLocal(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT u.id FROM users u WHERE (u.crypted_password IS NOT NULL OR u.salt IS NOT NULL) AND u.user_local=?").setBoolean(1, false); - massUpdate.update("UPDATE users SET crypted_password=null, salt=null, updated_at=? WHERE id=?"); - massUpdate.rowPluralName("none local users with password"); - massUpdate.execute((row, update) -> { - update.setLong(1, now); - 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/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java deleted file mode 100644 index 9b4e9b6ce31..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -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; - -/** - * the index must be dropped for the compatibility of migration 1270 - * with MSSQL - */ -public class TemporarilyDropIndexOfAnalysisUuidOnMeasures extends DdlChange { - - public TemporarilyDropIndexOfAnalysisUuidOnMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("project_measures") - .setName("measures_analysis_metric") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/package-info.java deleted file mode 100644 index f42a08a0d1b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v60; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/AddBUuidPathToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/AddBUuidPathToProjects.java deleted file mode 100644 index 66d54c2f4de..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/AddBUuidPathToProjects.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddBUuidPathToProjects extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - - public AddBUuidPathToProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_PROJECTS) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_uuid_path").setLimit(1500).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivity.java deleted file mode 100644 index b5907d5de84..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivity.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.ClobColumnDef.newClobColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddErrorColumnsToCeActivity extends DdlChange { - - private static final String TABLE_CE_ACTIVITY = "ce_activity"; - - public AddErrorColumnsToCeActivity(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_CE_ACTIVITY) - .addColumn(newVarcharColumnDefBuilder().setColumnName("error_message").setLimit(1000).setIgnoreOracleUnit(true).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("error_stacktrace").setIsNullable(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChanges.java deleted file mode 100644 index 3245f56cdb8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChanges.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.Date; -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 CopyActivitiesToQprofileChanges extends DataChange { - - public CopyActivitiesToQprofileChanges(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.rowPluralName("activities"); - massUpdate - .select("select a.log_key, a.profile_key, a.created_at, a.user_login, a.log_action, a.data_field " + - "from activities a " + - "left join qprofile_changes qc on qc.kee = a.log_key " + - "where a.log_type=? " + - "and a.log_action is not null " + - "and a.profile_key is not null " + - "and a.created_at is not null " + - "and qc.kee is null") - .setString(1, "QPROFILE"); - - massUpdate.update("insert into qprofile_changes (kee, qprofile_key, created_at, user_login, change_type, change_data) values (?,?,?,?,?,?)"); - massUpdate.execute((row, update) -> { - String key = row.getString(1); - String profileKey = row.getString(2); - Date createdAt = row.getDate(3); - String login = row.getNullableString(4); - String type = row.getString(5); - String data = row.getNullableString(6); - - update.setString(1, key); - update.setString(2, profileKey); - update.setLong(3, createdAt.getTime()); - update.setString(4, login); - update.setString(5, type); - update.setString(6, data); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInput.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInput.java deleted file mode 100644 index 7016701af80..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInput.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.BlobColumnDef.newBlobColumnDefBuilder; -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 CreateTableCeTaskInput extends DdlChange { - public CreateTableCeTaskInput(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateTableBuilder(getDialect(), "ce_task_input") - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("task_uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newBlobColumnDefBuilder().setColumnName("input_data").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalProperties.java deleted file mode 100644 index 78b36690a3a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalProperties.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.BooleanColumnDef.newBooleanColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.ClobColumnDef.newClobColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.MAX_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTableInternalProperties extends DdlChange { - public CreateTableInternalProperties(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateTableBuilder(getDialect(), "internal_properties") - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("kee").setLimit(20).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("text_value").setLimit(MAX_SIZE).setIgnoreOracleUnit(true).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2.java deleted file mode 100644 index 7f682d5519c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.List; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.ClobColumnDef.newClobColumnDefBuilder; -import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.ColumnFlag.AUTO_INCREMENT; -import static org.sonar.server.platform.db.migration.def.IntegerColumnDef.newIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.MAX_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTableProperties2 extends DdlChange { - - private static final String TABLE_NAME = "properties2"; - - public CreateTableProperties2(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef propKey = newVarcharColumnDefBuilder().setColumnName("prop_key").setLimit(512).setIsNullable(false).setIgnoreOracleUnit(true).build(); - List stmts = new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(propKey) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("text_value").setLimit(MAX_SIZE).setIgnoreOracleUnit(true).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - // table with be renamed to properties in following migration, use final constraint name right away - .withPkConstraintName("pk_properties") - .build(); - context.execute(stmts); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("properties2_key") - .addColumn(propKey) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChanges.java deleted file mode 100644 index 3037a1a02b6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChanges.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.List; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.ClobColumnDef.newClobColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTableQprofileChanges extends DdlChange { - public CreateTableQprofileChanges(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - List stmts = new CreateTableBuilder(getDialect(), "qprofile_changes") - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("kee").setLimit(40).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("qprofile_key").setLimit(255).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("change_type").setLimit(20).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("user_login").setLimit(255).setIsNullable(true).setIgnoreOracleUnit(true).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("change_data").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .build(); - context.execute(stmts); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositories.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositories.java deleted file mode 100644 index 87a0975335f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositories.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.List; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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 CreateTableRuleRepositories extends DdlChange { - public CreateTableRuleRepositories(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - List stmts = new CreateTableBuilder(getDialect(), "rule_repositories") - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("kee").setLimit(200).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("language").setLimit(20).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("name").setLimit(4000).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .build(); - context.execute(stmts); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContext.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContext.java deleted file mode 100644 index dc1f590d585..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContext.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.BlobColumnDef.newBlobColumnDefBuilder; -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 CreateTableScannerContext extends DdlChange { - public CreateTableScannerContext(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateTableBuilder(getDialect(), "ce_scanner_context") - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("task_uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newBlobColumnDefBuilder().setColumnName("context_data").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DbVersion61.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DbVersion61.java deleted file mode 100644 index deb22353954..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DbVersion61.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.util.stream.Stream; -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion61 implements DbVersion { - @Override - public Stream getSupportComponents() { - return Stream.of( - // Migration1304 - ShrinkModuleUuidPathOfProjects.class, - AddBUuidPathToProjects.class); - } - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1300, "Delete project dashboards and widgets", DeleteProjectDashboards.class) - .add(1301, "Drop column DASHBOARDS.IS_GLOBAL", DropIsGlobalFromDashboards.class) - .add(1302, "Create table CE_TASK_INPUT", CreateTableCeTaskInput.class) - .add(1303, "Clear CE_QUEUE content", DeleteReportsFromCeQueue.class) - .add(1304, "Shrink column PROJECTS.MODULE_UUID_PATH", Migration1304.class) - .add(1307, "Add columns CE_ACTIVITY.ERROR_*", AddErrorColumnsToCeActivity.class) - .add(1309, "Create table CE_SCANNER_CONTEXT", CreateTableScannerContext.class) - .add(1310, "Create table INTERNAL_PROPERTIES", CreateTableInternalProperties.class) - .add(1311, "Move views config from PROPERTIES to INTERNAL_PROPERTIES", RemoveViewsDefinitionFromProperties.class) - .add(1312, "Create table PROPERTIES2", CreateTableProperties2.class) - .add(1313, "Populate table PROPERTIES2", PopulateTableProperties2.class) - .add(1314, "Drop table PROPERTIES", DropTableProperties.class) - .add(1315, "Rename table PROPERTIES2 to PROPERTIES", RenameTableProperties2ToProperties.class) - .add(1316, "Create table QPROFILE_CHANGES", CreateTableQprofileChanges.class) - .add(1317, "Populate table QPROFILE_CHANGES", CopyActivitiesToQprofileChanges.class) - .add(1318, "Drop table ACTIVITIES", DropTableActivities.class) - .add(1319, "Create table RULE_REPOSITORIES", CreateTableRuleRepositories.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboards.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboards.java deleted file mode 100644 index 35be3e84731..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboards.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -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 DeleteProjectDashboards extends DataChange { - - public DeleteProjectDashboards(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - deleteWidgetProperties(context); - deleteDashboardsAndWidgets(context); - } - - private static void deleteWidgetProperties(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT w.id " + - "FROM widgets w " + - " INNER JOIN dashboards d on w.dashboard_id=d.id " + - "WHERE d.is_global=?") - .setBoolean(1, false); - massUpdate.update("DELETE from widget_properties WHERE widget_id=?"); - massUpdate.rowPluralName("delete widget properties of project dashboards"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - - private static void deleteDashboardsAndWidgets(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT id FROM dashboards d WHERE d.is_global=?").setBoolean(1, false); - massUpdate.update("DELETE from widgets WHERE dashboard_id=?"); - massUpdate.update("DELETE from active_dashboards WHERE dashboard_id=?"); - massUpdate.update("DELETE from dashboards WHERE id=?"); - massUpdate.rowPluralName("delete project dashboards"); - massUpdate.execute((row, update, updateIndex) -> { - long dashboardId = row.getLong(1); - switch (updateIndex) { - case 0: - case 1: - case 2: - update.setLong(1, dashboardId); - return true; - default: - throw new IllegalArgumentException("Unsupported update index " + updateIndex); - } - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java deleted file mode 100644 index eafff374d55..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -/** - * SONAR-7903 - in version 6.1 analysis reports are not persisted on FS anymore - * but in DB. For simplicity of migration report files are not copied to DB. - * To avoid failures on missing reports, tasks are simply ignored and removed from - * queue. - */ -public class DeleteReportsFromCeQueue extends DataChange { - - public DeleteReportsFromCeQueue(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context - .prepareUpsert("delete from ce_queue where task_type=?") - .setString(1, "REPORT") - .execute() - .commit(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropIsGlobalFromDashboards.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropIsGlobalFromDashboards.java deleted file mode 100644 index bd90b10bb7c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropIsGlobalFromDashboards.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -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.sql.DropColumnsBuilder; - -public class DropIsGlobalFromDashboards extends DdlChange { - - private static final String TABLE_DASHBOARDS = "dashboards"; - - public DropIsGlobalFromDashboards(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_DASHBOARDS, "is_global").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropTableActivities.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropTableActivities.java deleted file mode 100644 index d517eeb38c2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropTableActivities.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -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.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; - -public class DropTableActivities extends DdlChange { - - private static final String TABLE_ACTIVITIES = "activities"; - - public DropTableActivities(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_ACTIVITIES) - .setName("activities_log_key") - .build()); - - context.execute(new DropTableBuilder(getDialect(), TABLE_ACTIVITIES).build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropTableProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropTableProperties.java deleted file mode 100644 index 72b789d094c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DropTableProperties.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -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.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; - -public class DropTableProperties extends DdlChange { - - private static final String TABLE_PROPERTIES = "properties"; - - public DropTableProperties(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_PROPERTIES) - .setName("properties_key") - .build()); - - context.execute(new DropTableBuilder(getDialect(), TABLE_PROPERTIES).build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/Migration1304.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/Migration1304.java deleted file mode 100644 index 47566eb5af1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/Migration1304.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class Migration1304 implements MigrationStep { - private final ShrinkModuleUuidPathOfProjects shrinkModuleUuidPathOfProjects; - private final AddBUuidPathToProjects addBUuidPathToProjects; - - public Migration1304(ShrinkModuleUuidPathOfProjects shrinkModuleUuidPathOfProjects, AddBUuidPathToProjects addBUuidPathToProjects) { - this.shrinkModuleUuidPathOfProjects = shrinkModuleUuidPathOfProjects; - this.addBUuidPathToProjects = addBUuidPathToProjects; - } - - @Override - public void execute() throws SQLException { - shrinkModuleUuidPathOfProjects.execute(); - addBUuidPathToProjects.execute(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2.java deleted file mode 100644 index be5eec9f704..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class PopulateTableProperties2 extends DataChange { - private final System2 system2; - - public PopulateTableProperties2(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT" + - " p.prop_key, p.resource_id, p.text_value, p.user_id" + - " from properties p" + - " left outer join properties2 p2" + - " on p2.prop_key=p.prop_key" + - " and (p2.resource_id=p.resource_id or (p2.resource_id is null and p.resource_id is null))" + - " and (p2.user_id=p.user_id or (p2.user_id is null and p.user_id is null))" + - " where" + - " p2.id is null" + - " order by p.id"); - massUpdate.update("insert into properties2" + - " (prop_key, resource_id, user_id, is_empty, text_value, clob_value, created_at)" + - " values " + - " (?, ?, ?, ?, ?, ?, ?)"); - massUpdate.rowPluralName("copy data from table properties into table properties2"); - massUpdate.execute(this::handle); - } - - private boolean handle(Select.Row row, SqlStatement update) throws SQLException { - String key = row.getString(1); - Integer resourceId = row.getNullableInt(2); - String value = row.getNullableString(3); - Integer userId = row.getNullableInt(4); - - update.setString(1, key); - update.setInt(2, resourceId); - update.setInt(3, userId); - if (value == null || value.isEmpty()) { - update.setBoolean(4, true); - update.setString(5, null); - update.setString(6, null); - } else if (value.length() > 4000) { - update.setBoolean(4, false); - update.setString(5, null); - update.setString(6, value); - } else { - update.setBoolean(4, false); - update.setString(5, value); - update.setString(6, null); - } - update.setLong(7, system2.now()); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromProperties.java deleted file mode 100644 index 0370ad27b8f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromProperties.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.Upsert; - -public class RemoveViewsDefinitionFromProperties extends DataChange { - - private static final String VIEWS_DEFINITION_PROPERTY_KEY = "views.def"; - private static final int VARCHAR_MAX_LENGTH = 4000; - - private final System2 system2; - - public RemoveViewsDefinitionFromProperties(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - String property = context - .prepareSelect("select text_value from properties where prop_key=?") - .setString(1, VIEWS_DEFINITION_PROPERTY_KEY) - .get(row -> row.getNullableString(1)); - Integer hasInternalProperty = context - .prepareSelect("select 1 from internal_properties where kee=?") - .setString(1, VIEWS_DEFINITION_PROPERTY_KEY) - .get(row -> row.getNullableInt(1)); - - if (hasInternalProperty == null) { - addToInternalProperties(context, property); - } - deleteFromProperties(context); - } - - private void addToInternalProperties(Context context, @Nullable String property) throws SQLException { - if (property != null) { - boolean mustBeStoredInClob = property.length() > VARCHAR_MAX_LENGTH; - try (Upsert insert = context.prepareUpsert("insert into internal_properties" + - " (kee, is_empty, " + (mustBeStoredInClob ? "clob_value" : "text_value") + ", created_at)" + - " values" + - " (?,?,?,?)")) { - long now = system2.now(); - insert - .setString(1, VIEWS_DEFINITION_PROPERTY_KEY) - .setBoolean(2, false) - .setString(3, property) - .setLong(4, now) - .execute() - .commit(); - } - } - } - - private static void deleteFromProperties(Context context) throws SQLException { - try (Upsert delete = context.prepareUpsert("delete from properties where prop_key=?")) { - delete - .setString(1, VIEWS_DEFINITION_PROPERTY_KEY) - .execute() - .commit(); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RenameTableProperties2ToProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RenameTableProperties2ToProperties.java deleted file mode 100644 index 62f23a562c7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RenameTableProperties2ToProperties.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.sql.RenameTableBuilder; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RenameTableProperties2ToProperties extends DdlChange { - - public RenameTableProperties2ToProperties(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("properties2") - .setName("properties2_key") - .build()); - - context.execute(new RenameTableBuilder(getDialect()) - .setName("properties2") - .setNewName("properties") - .build()); - - context.execute(new CreateIndexBuilder() - .setTable("properties") - .setName("properties_key") - .addColumn(newVarcharColumnDefBuilder().setColumnName("prop_key").setLimit(512).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/ShrinkModuleUuidPathOfProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/ShrinkModuleUuidPathOfProjects.java deleted file mode 100644 index 8b8eef7a76e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/ShrinkModuleUuidPathOfProjects.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 ShrinkModuleUuidPathOfProjects extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - - public ShrinkModuleUuidPathOfProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_PROJECTS) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("module_uuid_path").setLimit(1500).setIsNullable(true).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/package-info.java deleted file mode 100644 index d726645c104..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v61; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsers.java deleted file mode 100644 index 3a80f611eb4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsers.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddIsRootColumnOnTableUsers extends DdlChange { - public AddIsRootColumnOnTableUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new AddColumnsBuilder(getDialect(), "users") - .addColumn(newBooleanColumnDefBuilder().setColumnName("is_root").setIsNullable(true).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRoles.java deleted file mode 100644 index ff867305a4c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRoles.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddOrganizationUuidToGroupRoles extends DdlChange { - - public AddOrganizationUuidToGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(true) - .setLimit(40) - .setIgnoreOracleUnit(true) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), "group_roles").addColumn(column).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroups.java deleted file mode 100644 index 2efdc1ace22..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroups.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddOrganizationUuidToGroups extends DdlChange { - - public AddOrganizationUuidToGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(true) - .setIgnoreOracleUnit(true) - .setLimit(40) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), "groups").addColumn(column).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplates.java deleted file mode 100644 index 0309052f879..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplates.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddOrganizationUuidToPermissionTemplates extends DdlChange { - - public AddOrganizationUuidToPermissionTemplates(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(true) - .setIgnoreOracleUnit(true) - .setLimit(40) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), "permission_templates").addColumn(column).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRoles.java deleted file mode 100644 index 21d6f950e30..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRoles.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddOrganizationUuidToUserRoles extends DdlChange { - - public AddOrganizationUuidToUserRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(true) - .setIgnoreOracleUnit(true) - .setLimit(40) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), "user_roles").addColumn(column).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganization.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganization.java deleted file mode 100644 index 3a6f662099b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganization.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -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.Select; - -public class CreateDefaultOrganization extends DataChange { - private static final String KEY_DEFAULT_ORGANIZATION = "default-organization"; - private static final String INTERNAL_PROPERTY_DEFAULT_ORGANIZATION = "organization.default"; - - private final System2 system2; - private final UuidFactory uuidFactory; - - public CreateDefaultOrganization(Database db, System2 system2, UuidFactory uuidFactory) { - super(db); - this.system2 = system2; - this.uuidFactory = uuidFactory; - } - - @Override - public void execute(Context context) throws SQLException { - String uuid = createDefaultOrganization(context); - saveDefaultOrganizationUuid(context, uuid); - } - - private String createDefaultOrganization(Context context) throws SQLException { - Select select = context.prepareSelect("select uuid from organizations where kee=?"); - select.setString(1, KEY_DEFAULT_ORGANIZATION); - String uuid = select.get(row -> row.getNullableString(1)); - if (uuid == null) { - uuid = uuidFactory.create(); - long now = system2.now(); - context.prepareUpsert("insert into organizations" + - " (uuid, kee, name, created_at, updated_at)" + - " values" + - " (?, ?, ?, ?, ?)") - .setString(1, uuid) - .setString(2, KEY_DEFAULT_ORGANIZATION) - .setString(3, "Default Organization") - .setLong(4, now) - .setLong(5, now) - .execute() - .commit(); - } - return uuid; - } - - private void saveDefaultOrganizationUuid(Context context, String uuid) throws SQLException { - Select select = context.prepareSelect("select kee from internal_properties where kee=?"); - select.setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION); - if (select.get(row -> row.getNullableString(1)) == null) { - context.prepareUpsert("insert into internal_properties" + - " (kee, is_empty, text_value, created_at)" + - " values" + - " (?, ?, ?, ?)") - .setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION) - .setBoolean(2, false) - .setString(3, uuid) - .setLong(4, system2.now()) - .execute() - .commit(); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizations.java deleted file mode 100644 index bfe0bccde6c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizations.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTableOrganizations extends DdlChange { - - private static final String TABLE_NAME = "organizations"; - - public CreateTableOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef keeColumn = newVarcharColumnDefBuilder().setColumnName("kee").setLimit(32).setIsNullable(false).setIgnoreOracleUnit(true).build(); - context.execute( - new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(keeColumn) - .addColumn(newVarcharColumnDefBuilder().setColumnName("name").setLimit(64).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("description").setLimit(256).setIsNullable(true).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("url").setLimit(256).setIsNullable(true).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("avatar_url").setLimit(256).setIsNullable(true).setIgnoreOracleUnit(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("organization_key") - .addColumn(keeColumn) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveries.java deleted file mode 100644 index 52e10f19923..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveries.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -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.BooleanColumnDef.newBooleanColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.ClobColumnDef.newClobColumnDefBuilder; -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 CreateTableWebhookDeliveries extends DdlChange { - - private static final String TABLE_NAME = "webhook_deliveries"; - - public CreateTableWebhookDeliveries(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef componentUuidColumn = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build(); - VarcharColumnDef ceTaskUuidColumn = newVarcharColumnDefBuilder().setColumnName("ce_task_uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build(); - - context.execute( - new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(componentUuidColumn) - .addColumn(ceTaskUuidColumn) - .addColumn(newVarcharColumnDefBuilder().setColumnName("name").setLimit(100).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("url").setLimit(2000).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("success").setIsNullable(false).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("http_status").setIsNullable(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("duration_ms").setIsNullable(true).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("payload").setIsNullable(false).build()) - .addColumn(newClobColumnDefBuilder().setColumnName("error_stacktrace").setIsNullable(true).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .build()); - - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("component_uuid") - .addColumn(componentUuidColumn) - .build()); - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("ce_task_uuid") - .addColumn(ceTaskUuidColumn) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DbVersion62.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DbVersion62.java deleted file mode 100644 index 4141a3bc19b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DbVersion62.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion62 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1400, "Create table ORGANIZATIONS", CreateTableOrganizations.class) - .add(1401, "Create default organization", CreateDefaultOrganization.class) - .add(1402, "Delete permission shareDashboard", DeletePermissionShareDashboard.class) - .add(1403, "Add column GROUPS.ORGANIZATION_UUID", AddOrganizationUuidToGroups.class) - .add(1404, "Add column USERS.IS_ROOT", AddIsRootColumnOnTableUsers.class) - .add(1405, "Populate column USERS.IS_ROOT", PopulateIsRootColumnOnTableUsers.class) - .add(1406, "Make column USERS.IS_ROOT not nullable", MakeRootColumnNotNullOnTableUsers.class) - .add(1407, "Populate column GROUPS.ORGANIZATION_UUID", PopulateOrganizationUuidOfGroups.class) - .add(1408, "Make column GROUPS.ORGANIZATION_UUID not nullable", MakeOrganizationUuidNotNullOnGroups.class) - .add(1409, "Add column USER_ROLES.ORGANIZATION_UUID", AddOrganizationUuidToUserRoles.class) - .add(1410, "Populate column USER_ROLES.ORGANIZATION_UUID", PopulateOrganizationUuidOfUserRoles.class) - .add(1411, "Make column USER_ROLES.ORGANIZATION_UUID not nullable", MakeOrganizationUuidNotNullOnUserRoles.class) - .add(1412, "Add column PERMISSION_TEMPLATES.ORGANIZATION_UUID", AddOrganizationUuidToPermissionTemplates.class) - .add(1413, "Populate column PERMISSION_TEMPLATES.ORGANIZATION_UUID", PopulateOrganizationUuidOfPermissionTemplates.class) - .add(1414, "Make column PERMISSION_TEMPLATES.ORGANIZATION_UUID not nullable", MakeOrganizationUuidNotNullOnPermissionTemplates.class) - .add(1415, "Add column GROUP_ROLES.ORGANIZATION_UUID", AddOrganizationUuidToGroupRoles.class) - .add(1416, "Populate column GROUP_ROLES.ORGANIZATION_UUID", PopulateOrganizationUuidOfGroupRoles.class) - .add(1417, "Make column GROUP_ROLES.ORGANIZATION_UUID not nullable", MakeOrganizationUuidNotNullOnGroupRoles.class) - .add(1418, "Add ORGANIZATION_UUID to index uniq_group_roles", IncludeOrganizationUuidInUniqueIndexOfGroupRoles.class) - .add(1419, "Update qualigate conditions on coverage", UpdateQualityGateConditionsOnCoverage.class) - .add(1420, "Drop tables related to dashboards", DropRelatedDashboardTables.class) - .add(1421, "Drop tables related to measure filters", DropMeasureFiltersTables.class) - .add(1422, "Drop tables related to issue filters", DropIssueFiltersTables.class) - .add(1423, "Create table WEBHOOK_DELIVERIES", CreateTableWebhookDeliveries.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboard.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboard.java deleted file mode 100644 index 98866374815..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboard.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -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 DeletePermissionShareDashboard extends DataChange { - - private static final String PERMISSION = "shareDashboard"; - - public DeletePermissionShareDashboard(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - deleteFromTable(context, "group_roles"); - deleteFromTable(context, "user_roles"); - } - - private static void deleteFromTable(Context context, String tableName) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from " + tableName + " where role=?").setString(1, PERMISSION); - massUpdate.update("delete from " + tableName + " where id=?"); - massUpdate.rowPluralName(tableName); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTables.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTables.java deleted file mode 100644 index 9670a7e68cc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTables.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.util.List; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.sonar.core.util.stream.MoreCollectors.toList; - -public class DropIssueFiltersTables extends DdlChange { - - public DropIssueFiltersTables(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - List tables = asList("issue_filters", "issue_filter_favourites"); - Loggers.get(getClass()).info("Removing tables {}", tables); - context.execute(tables - .stream() - .flatMap(table -> new DropTableBuilder(getDialect(), table).build().stream()) - .collect(toList())); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTables.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTables.java deleted file mode 100644 index 2ac5e7dd5e1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTables.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.util.List; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.sonar.core.util.stream.MoreCollectors.toList; - -public class DropMeasureFiltersTables extends DdlChange { - - public DropMeasureFiltersTables(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - List tables = asList("measure_filters", "measure_filter_favourites"); - Loggers.get(getClass()).info("Removing tables {}", tables); - context.execute(tables - .stream() - .flatMap(table -> new DropTableBuilder(getDialect(), table).build().stream()) - .collect(toList())); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTables.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTables.java deleted file mode 100644 index af295268822..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTables.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.util.List; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.sonar.core.util.stream.MoreCollectors.toList; - -public class DropRelatedDashboardTables extends DdlChange { - - public DropRelatedDashboardTables(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - List tablesToDrop = asList("widget_properties", "widgets", "active_dashboards", "dashboards"); - Loggers.get(getClass()).info("Removing tables {}", tablesToDrop); - context.execute(tablesToDrop - .stream() - .flatMap(table -> new DropTableBuilder(getDialect(), table).build().stream()) - .collect(toList())); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/IncludeOrganizationUuidInUniqueIndexOfGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/IncludeOrganizationUuidInUniqueIndexOfGroupRoles.java deleted file mode 100644 index 16bf180ac8b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/IncludeOrganizationUuidInUniqueIndexOfGroupRoles.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -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.newVarcharColumnDefBuilder; - -public class IncludeOrganizationUuidInUniqueIndexOfGroupRoles extends DdlChange { - - private static final String TABLE_GROUP_ROLES = "group_roles"; - - public IncludeOrganizationUuidInUniqueIndexOfGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_GROUP_ROLES) - .setName("uniq_group_roles") - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_GROUP_ROLES) - .setName("uniq_group_roles") - .setUnique(true) - .addColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(40).setIgnoreOracleUnit(true).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("group_id").build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("resource_id").build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("role").setLimit(64).setIgnoreOracleUnit(true).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRoles.java deleted file mode 100644 index c0c787c2513..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRoles.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeOrganizationUuidNotNullOnGroupRoles extends DdlChange { - - private static final String TABLE = "group_roles"; - - public MakeOrganizationUuidNotNullOnGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroups.java deleted file mode 100644 index 260fd2eb3ab..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroups.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeOrganizationUuidNotNullOnGroups extends DdlChange { - - private static final String TABLE = "groups"; - - public MakeOrganizationUuidNotNullOnGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplates.java deleted file mode 100644 index 7fccba16d15..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplates.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeOrganizationUuidNotNullOnPermissionTemplates extends DdlChange { - - private static final String TABLE = "permission_templates"; - - public MakeOrganizationUuidNotNullOnPermissionTemplates(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRoles.java deleted file mode 100644 index 0121e56a7fd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRoles.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeOrganizationUuidNotNullOnUserRoles extends DdlChange { - - private static final String TABLE = "user_roles"; - - public MakeOrganizationUuidNotNullOnUserRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsers.java deleted file mode 100644 index fb3f8fd2070..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsers.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class MakeRootColumnNotNullOnTableUsers extends DdlChange { - public MakeRootColumnNotNullOnTableUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), "users") - .updateColumn(newBooleanColumnDefBuilder().setColumnName("is_root").setIsNullable(false).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsers.java deleted file mode 100644 index 3691c95ff93..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsers.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -/** - * All users with "admin" role, either directly or via a group, are made root. All others are made non root. - */ -public class PopulateIsRootColumnOnTableUsers extends DataChange { - - private static final String ROLE_ADMIN = "admin"; - - public PopulateIsRootColumnOnTableUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - String sql = "select distinct ur.user_id as id" + - " from user_roles ur" + - " inner join users u on u.id=ur.user_id and u.active=?" + - " where" + - " ur.role = ?" + - " and ur.resource_id is null" + - " union all" + - " select distinct u.id as id" + - " from users u" + - " inner join groups_users gu on gu.user_id = u.id" + - " inner join group_roles gr on gr.group_id = gu.group_id" + - " inner join groups g on g.id = gu.group_id" + - " where" + - " gr.role = ?" + - " and gr.resource_id is null" + - " and u.active = ?"; - massUpdate.select(sql) - .setBoolean(1, true) - .setString(2, ROLE_ADMIN) - .setString(3, ROLE_ADMIN) - .setBoolean(4, true); - massUpdate.update("update users set is_root=? where id = ?"); - massUpdate.rowPluralName("Users with System Administer permission as root"); - massUpdate.execute(PopulateIsRootColumnOnTableUsers::handle); - - context.prepareUpsert("update users set is_root=? where is_root is null") - .setBoolean(1, false) - .execute() - .commit(); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - - update.setBoolean(1, true); - update.setLong(2, id); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRoles.java deleted file mode 100644 index 42ddecfeb2e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRoles.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -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; -import org.sonar.server.platform.db.migration.step.Select; - -import static com.google.common.base.Preconditions.checkState; - -public class PopulateOrganizationUuidOfGroupRoles extends DataChange { - - private static final String INTERNAL_PROPERTY_DEFAULT_ORGANIZATION = "organization.default"; - - public PopulateOrganizationUuidOfGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - String organizationUuid = selectDefaultOrganizationUuid(context); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from group_roles where organization_uuid is null"); - massUpdate.update("update group_roles set organization_uuid=? where id=?"); - massUpdate.rowPluralName("group_roles"); - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - update.setString(1, organizationUuid); - update.setLong(2, id); - return true; - }); - } - - private static String selectDefaultOrganizationUuid(Context context) throws SQLException { - Select select = context.prepareSelect("select text_value from internal_properties where kee=?"); - select.setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION); - String uuid = select.get(row -> row.getString(1)); - checkState(uuid != null, "Default organization uuid is missing"); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroups.java deleted file mode 100644 index 6f2be9c2a36..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroups.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.Date; -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; - -import static com.google.common.base.Preconditions.checkState; - -public class PopulateOrganizationUuidOfGroups extends DataChange { - - private static final String INTERNAL_PROPERTY_DEFAULT_ORGANIZATION = "organization.default"; - - private final System2 system2; - - public PopulateOrganizationUuidOfGroups(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - String organizationUuid = selectDefaultOrganizationUuid(context); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from groups where organization_uuid is null"); - massUpdate.update("update groups set organization_uuid=?, updated_at=? where id=?"); - massUpdate.rowPluralName("groups"); - massUpdate.execute((row, update) -> { - int groupId = row.getInt(1); - update.setString(1, organizationUuid); - update.setDate(2, new Date(system2.now())); - update.setInt(3, groupId); - return true; - }); - } - - private static String selectDefaultOrganizationUuid(Context context) throws SQLException { - Select select = context.prepareSelect("select text_value from internal_properties where kee=?"); - select.setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION); - String uuid = select.get(row -> row.getString(1)); - checkState(uuid != null, "Default organization uuid is missing"); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplates.java deleted file mode 100644 index 9f7cdc67ae2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplates.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.Date; -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; - -import static com.google.common.base.Preconditions.checkState; - -public class PopulateOrganizationUuidOfPermissionTemplates extends DataChange { - - private static final String INTERNAL_PROPERTY_DEFAULT_ORGANIZATION = "organization.default"; - - private final System2 system2; - - public PopulateOrganizationUuidOfPermissionTemplates(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - String organizationUuid = selectDefaultOrganizationUuid(context); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from permission_templates where organization_uuid is null"); - massUpdate.update("update permission_templates set organization_uuid=?, updated_at=? where id=?"); - massUpdate.rowPluralName("permission_templates"); - massUpdate.execute((row, update) -> { - int groupId = row.getInt(1); - update.setString(1, organizationUuid); - update.setDate(2, new Date(system2.now())); - update.setInt(3, groupId); - return true; - }); - } - - private static String selectDefaultOrganizationUuid(Context context) throws SQLException { - Select select = context.prepareSelect("select text_value from internal_properties where kee=?"); - select.setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION); - String uuid = select.get(row -> row.getString(1)); - checkState(uuid != null, "Default organization uuid is missing"); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRoles.java deleted file mode 100644 index 62af7bd0cd2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRoles.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -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; -import org.sonar.server.platform.db.migration.step.Select; - -import static com.google.common.base.Preconditions.checkState; - -public class PopulateOrganizationUuidOfUserRoles extends DataChange { - - private static final String INTERNAL_PROPERTY_DEFAULT_ORGANIZATION = "organization.default"; - - public PopulateOrganizationUuidOfUserRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - String organizationUuid = selectDefaultOrganizationUuid(context); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from user_roles where organization_uuid is null"); - massUpdate.update("update user_roles set organization_uuid=? where id=?"); - massUpdate.rowPluralName("user_roles"); - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - update.setString(1, organizationUuid); - update.setLong(2, id); - return true; - }); - } - - private static String selectDefaultOrganizationUuid(Context context) throws SQLException { - Select select = context.prepareSelect("select text_value from internal_properties where kee=?"); - select.setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION); - String uuid = select.get(row -> row.getString(1)); - checkState(uuid != null, "Default organization uuid is missing"); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverage.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverage.java deleted file mode 100644 index 425eaf591eb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverage.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Multimap; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.Upsert; - -import static java.util.Objects.requireNonNull; -import static org.apache.commons.lang.StringUtils.repeat; -import static org.sonar.core.util.stream.MoreCollectors.index; -import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; - -/** - * Migrate every quality gates that have conditions on related coverage metrics. - * - * If there's a condition on {@link CoreMetrics#OVERALL_COVERAGE}, it will be updated to {@link CoreMetrics#COVERAGE}, - * conditions on {@link CoreMetrics#IT_COVERAGE} are removed. - * Else if there's condition on {@link CoreMetrics#COVERAGE}, it will be kept and conditions on {@link CoreMetrics#IT_COVERAGE} are removed. - * Then If there's condition on {@link CoreMetrics#IT_COVERAGE}, it will be updated to {@link CoreMetrics#COVERAGE} - * - * Same strategy is applied on new_XXX, (it_|overall_)lines_to_cover, (it_|overall_)uncovered_lines, etc. related coverage metrics. - */ -public class UpdateQualityGateConditionsOnCoverage extends DataChange { - - private static final Logger LOGGER = Loggers.get(UpdateQualityGateConditionsOnCoverage.class); - - private static final List COVERAGE_METRIC_KEYS = ImmutableList.of( - "coverage", "lines_to_cover", "uncovered_lines", "line_coverage", "conditions_to_cover", "uncovered_conditions", "branch_coverage"); - - private static final String OVERALL_PREFIX = "overall_"; - private static final String IT_PREFIX = "it_"; - private static final String NEW_PREFIX = "new_"; - - public UpdateQualityGateConditionsOnCoverage(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - List metrics = selectMetrics(context); - if (metrics.isEmpty()) { - return; - } - List qualityGateIds = context.prepareSelect("select id from quality_gates").list(Select.LONG_READER); - if (qualityGateIds.isEmpty()) { - return; - } - LOGGER.info("Migrating {} quality gates", qualityGateIds.size()); - new Migration(context, metrics, qualityGateIds).execute(); - } - - private static class Migration { - private final Context context; - private final Map metricsByMetricKeys; - private final List metricIds; - private final List qualityGateIds; - - Migration(Context context, List metrics, List qualityGateIds) { - this.context = context; - this.metricsByMetricKeys = metrics.stream().collect(uniqueIndex(Metric::getKey, Function.identity())); - this.metricIds = metrics.stream().map(Metric::getId).collect(Collectors.toList()); - this.qualityGateIds = qualityGateIds; - } - - public void execute() { - qualityGateIds.forEach(this::processQualityGate); - } - - private void processQualityGate(long qualityGateId) { - List qualityGateConditions = selectQualityGateConditions(qualityGateId, metricIds); - Multimap qualityGateConditionsByMetricId = qualityGateConditions.stream() - .collect(index(QualityGateCondition::getMetricId, Function.identity())); - COVERAGE_METRIC_KEYS.forEach(metric -> { - processConditions(metric, OVERALL_PREFIX + metric, IT_PREFIX + metric, qualityGateConditionsByMetricId, qualityGateId); - processConditions(NEW_PREFIX + metric, NEW_PREFIX + OVERALL_PREFIX + metric, NEW_PREFIX + IT_PREFIX + metric, qualityGateConditionsByMetricId, qualityGateId); - }); - } - - private void processConditions(String coverageMetricKey, String overallMetricKey, String itMetricKey, Multimap qualityGateConditionsByMetricId, - long qualityGateId) { - try { - Collection conditionsOnCoverage = getConditionsByMetricKey(coverageMetricKey, qualityGateConditionsByMetricId); - Collection conditionsOnOverallCoverage = getConditionsByMetricKey(overallMetricKey, qualityGateConditionsByMetricId); - Collection conditionsOnItCoverage = getConditionsByMetricKey(itMetricKey, qualityGateConditionsByMetricId); - if (conditionsOnCoverage.isEmpty() && conditionsOnOverallCoverage.isEmpty() && conditionsOnItCoverage.isEmpty()) { - return; - } - if (!conditionsOnOverallCoverage.isEmpty()) { - removeQualityGateConditions(conditionsOnCoverage); - removeQualityGateConditions(conditionsOnItCoverage); - updateQualityGateConditions(conditionsOnOverallCoverage, coverageMetricKey); - } else if (!conditionsOnCoverage.isEmpty()) { - removeQualityGateConditions(conditionsOnItCoverage); - } else { - updateQualityGateConditions(conditionsOnItCoverage, coverageMetricKey); - } - } catch (SQLException e) { - throw new IllegalStateException(String.format("Fail to update quality gate conditions of quality gate %s", qualityGateId), e); - } - } - - private Collection getConditionsByMetricKey(String metricKey, Multimap qualityGateConditionsByMetricId) { - Metric metric = metricsByMetricKeys.get(metricKey); - if (metric == null) { - return Collections.emptyList(); - } - return qualityGateConditionsByMetricId.get(metric.getId()); - } - - private List selectQualityGateConditions(long qualityGateId, List metricIds) { - try { - Select select = context.prepareSelect("select qgc.id, qgc.metric_id " + - "from quality_gate_conditions qgc " + - "where qgc.qgate_id=? and qgc.metric_id in (" + repeat("?", " , ", metricIds.size()) + ")") - .setLong(1, qualityGateId); - for (int i = 0; i < metricIds.size(); i++) { - select.setLong(i + 2, metricIds.get(i)); - } - return select.list(QualityGateCondition::new); - } catch (SQLException e) { - throw new IllegalStateException(String.format("Fail to select quality gate conditions of quality gate %s", qualityGateId), e); - } - } - - private void updateQualityGateConditions(Collection conditions, String metricKey) throws SQLException { - Upsert upsert = context.prepareUpsert("update quality_gate_conditions set metric_id=? where id=?"); - conditions.forEach(condition -> { - try { - upsert - .setLong(1, metricsByMetricKeys.get(metricKey).getId()) - .setLong(2, condition.getId()) - .execute() - .commit(); - } catch (SQLException e) { - Throwables.propagate(e); - } - }); - } - - private void removeQualityGateConditions(Collection conditions) throws SQLException { - if (conditions.isEmpty()) { - return; - } - Upsert upsert = context.prepareUpsert("delete from quality_gate_conditions where id=?"); - conditions.forEach(condition -> { - try { - upsert.setLong(1, condition.getId()) - .execute() - .commit(); - } catch (SQLException e) { - Throwables.propagate(e); - } - }); - } - } - - private static List selectMetrics(Context context) throws SQLException { - List metricKeys = new ArrayList<>(COVERAGE_METRIC_KEYS); - metricKeys.addAll(COVERAGE_METRIC_KEYS.stream().map(metricKey -> IT_PREFIX + metricKey).collect(Collectors.toList())); - metricKeys.addAll(COVERAGE_METRIC_KEYS.stream().map(metricKey -> OVERALL_PREFIX + metricKey).collect(Collectors.toList())); - metricKeys.addAll(metricKeys.stream().map(metricKey -> NEW_PREFIX + metricKey).collect(Collectors.toList())); - Select select = context.prepareSelect("select id, name from metrics where name in (" + repeat("?", ",", metricKeys.size()) + ")"); - for (int i = 0; i < metricKeys.size(); i++) { - select.setString(i + 1, metricKeys.get(i)); - } - return select.list(Metric::new); - } - - private static class QualityGateCondition { - private final long id; - private final long metricId; - - QualityGateCondition(Select.Row row) throws SQLException { - this.id = requireNonNull(row.getLong(1)); - this.metricId = requireNonNull(row.getLong(2)); - } - - long getId() { - return id; - } - - long getMetricId() { - return metricId; - } - } - - private static class Metric { - private final long id; - private final String key; - - Metric(Select.Row row) throws SQLException { - this.id = requireNonNull(row.getLong(1)); - this.key = requireNonNull(row.getString(2)); - } - - long getId() { - return id; - } - - String getKey() { - return key; - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/package-info.java deleted file mode 100644 index f8029b1eb50..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v62; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizations.java deleted file mode 100644 index ff6703c1d2b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizations.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddColumnGuardedToOrganizations extends DdlChange { - public AddColumnGuardedToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new AddColumnsBuilder(getDialect(), "organizations") - .addColumn( - BooleanColumnDef.newBooleanColumnDefBuilder() - .setColumnName("guarded") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizations.java deleted file mode 100644 index 56a1f76332b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizations.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -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 AddDefaultPermTemplateColumnsToOrganizations extends DdlChange { - public AddDefaultPermTemplateColumnsToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new AddColumnsBuilder(getDialect(), "organizations") - .addColumn( - newVarcharColumnDefBuilder() - .setColumnName("default_perm_template_project") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build()) - .addColumn( - newVarcharColumnDefBuilder() - .setColumnName("default_perm_template_view") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjects.java deleted file mode 100644 index e15953cebd9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjects.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddIndexOnOrganizationUuidOfProjects extends DdlChange { - public AddIndexOnOrganizationUuidOfProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("projects") - .setName("projects_organization") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjects.java deleted file mode 100644 index 1aaad2808d3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjects.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddOrganizationUuidToProjects extends DdlChange { - - public AddOrganizationUuidToProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), "projects").addColumn(column).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizations.java deleted file mode 100644 index d5bcb1efab9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizations.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.IntegerColumnDef.newIntegerColumnDefBuilder; - -public class AddUserIdToOrganizations extends DdlChange { - public AddUserIdToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new AddColumnsBuilder(getDialect(), "organizations") - .addColumn( - newIntegerColumnDefBuilder() - .setColumnName("user_id") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEvents.java deleted file mode 100644 index 132bba64b94..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEvents.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidToEvents extends DdlChange { - - public AddUuidToEvents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setLimit(40) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), "events").addColumn(column).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DbVersion63.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DbVersion63.java deleted file mode 100644 index bafe8b799fa..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DbVersion63.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.util.stream.Stream; -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion63 implements DbVersion { - @Override - public Stream getSupportComponents() { - return Stream.of(DefaultOrganizationUuidProviderImpl.class); - } - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1500, "Add Events.UUID", AddUuidToEvents.class) - .add(1501, "Populate Events.UUID", PopulateUuidColumnOfEvents.class) - .add(1502, "Make Events.UUID not nullable", MakeUuidNotNullOnEvents.class) - .add(1503, "Add PROJECTS.ORGANIZATION_UUID", AddOrganizationUuidToProjects.class) - .add(1504, "Populate PROJECTS.ORGANIZATION_UUID", PopulateOrganizationUuidToProjects.class) - .add(1505, "Make PROJECTS.ORGANIZATION_UUID not nullable", MakeOrganizationUuidOfProjectsNotNullable.class) - .add(1506, "Add index on PROJECTS.ORGANIZATION_UUID", AddIndexOnOrganizationUuidOfProjects.class) - .add(1507, "Drop table RESOURCE_INDEX", DropTableResourceIndex.class) - .add(1508, "Add columns ORGANIZATIONS.DEFAULT_PERM_TEMPLATE_*", AddDefaultPermTemplateColumnsToOrganizations.class) - .add(1509, "Populate columns ORGANIZATIONS.DEFAULT_PERM_TEMPLATE_*", PopulateDefaultPermTemplateColumnsOfOrganizations.class) - .add(1510, "Add ORGANIZATIONS.GUARDED", AddColumnGuardedToOrganizations.class) - .add(1511, "Populate ORGANIZATIONS.GUARDED", PopulateColumnGuardedOfOrganizations.class) - .add(1512, "Make ORGANIZATIONS.GUARDED not nullable", MakeColumnGuardedOfOrganizationsNotNullable.class) - .add(1513, "Make default organization guarded", MakeDefaultOrganizationGuarded.class) - .add(1514, "Delete some entries in PROPERTIES", DeleteUselessProperties.class) - .add(1515, "Unset user root flags", UnsetUserRootFlags.class) - .add(1516, "Add ORGANIZATIONS.USER_ID", AddUserIdToOrganizations.class) - .add(1517, "Delete PROJECT_MEASURES rows having no value", DeleteMeasuresHavingNoValue.class) - .add(1518, "Make index on ORGANIZATIONS.KEE unique", MakeIndexOnOrganizationsKeeUnique.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValue.java deleted file mode 100644 index 0eb73a8e3d0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValue.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -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; - -/** - * Delete measures having no value in order to remove measures related to periods 2 to 5. - *
- * Here are some example of measures to remove : - *
    - *
  • VALUE=[null], TEXT_VALUE=[null], MEASURE_DATA=[null], VARIATION_VALUE_1=[null], VARIATION_VALUE_2=[null], VARIATION_VALUE_3=[null]
  • - *
  • VALUE=[null], TEXT_VALUE=[null], MEASURE_DATA=[null], VARIATION_VALUE_1=[null], VARIATION_VALUE_2=20, VARIATION_VALUE_3=[null]
  • - *
  • VALUE=[null], TEXT_VALUE=[null], MEASURE_DATA=[null], VARIATION_VALUE_1=[null], VARIATION_VALUE_2=10, VARIATION_VALUE_3=15
  • - *
- */ -public class DeleteMeasuresHavingNoValue extends DataChange { - - public DeleteMeasuresHavingNoValue(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT pm.id FROM project_measures pm " + - "WHERE pm.value IS NULL AND pm.text_value IS NULL AND pm.variation_value_1 IS NULL AND pm.measure_data IS NULL "); - massUpdate.update("DELETE FROM project_measures WHERE id=?"); - massUpdate.rowPluralName("measures"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessProperties.java deleted file mode 100644 index 6bdf61b2846..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessProperties.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -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; - -/** - * Remove the following settings from the PROPERTIES table : - * - Settings about period 2 to 5 (sonar.timemachine.periodX + sonar.timemachine.periodX.VW + etc.) - * - sonar.technicalDebt.hoursInDay - * - sonar.authenticator.createUser - */ -public class DeleteUselessProperties extends DataChange { - - public DeleteUselessProperties(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("useless settings"); - massUpdate.select("SELECT id FROM properties WHERE " + - "prop_key LIKE ? OR prop_key LIKE ? OR prop_key LIKE ? OR prop_key LIKE ? OR " + - "prop_key IN (?, ?)") - .setString(1, "sonar.timemachine.period2%") - .setString(2, "sonar.timemachine.period3%") - .setString(3, "sonar.timemachine.period4%") - .setString(4, "sonar.timemachine.period5%") - .setString(5, "sonar.technicalDebt.hoursInDay") - .setString(6, "sonar.authenticator.createUser"); - massUpdate.update("DELETE FROM properties WHERE id=?"); - massUpdate.execute((row, update) -> { - long propertyId = row.getLong(1); - update.setLong(1, propertyId); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndex.java deleted file mode 100644 index 8724db97bcf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndex.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -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.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTableResourceIndex extends DdlChange { - - private static final String TABLE_RESOURCE_INDEX = "resource_index"; - - public DropTableResourceIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_RESOURCE_INDEX) - .setName("resource_index_key") - .build()); - - try { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_RESOURCE_INDEX) - .setName("resource_index_component") - .build()); - } catch (Exception e) { - // migrating from 5.6. The migration 1204 MakeUuidColumnsNotNullOnResourceIndex, - // introduced in 6.0, has been dropped in 6.7 for performance reasons. There was no need to - // alter the table resource_index while it's dropped later in 6.3. - // As a consequence this index may not exist when upgrading from 6.1+. - // Note that the "delete index if exists" is still not supported by Oracle and MSSQL < 2016, - // that's why an exception is raised if the index does not exist. - } - - context.execute(new DropTableBuilder(getDialect(), TABLE_RESOURCE_INDEX).build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullable.java deleted file mode 100644 index ecd7345dfeb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class MakeColumnGuardedOfOrganizationsNotNullable extends DdlChange { - public MakeColumnGuardedOfOrganizationsNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new AlterColumnsBuilder(getDialect(), "organizations") - .updateColumn( - BooleanColumnDef.newBooleanColumnDefBuilder() - .setColumnName("guarded") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuarded.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuarded.java deleted file mode 100644 index f9faf8de0ed..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuarded.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class MakeDefaultOrganizationGuarded extends DataChange { - private final DefaultOrganizationUuidProvider defaultOrganizationUuid; - - public MakeDefaultOrganizationGuarded(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) { - super(db); - this.defaultOrganizationUuid = defaultOrganizationUuid; - } - - @Override - protected void execute(Context context) throws SQLException { - String uuid = this.defaultOrganizationUuid.getAndCheck(context); - context.prepareUpsert("update organizations set guarded=? where uuid=?") - .setBoolean(1, true) - .setString(2, uuid) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUnique.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUnique.java deleted file mode 100644 index 2223ce74ea6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUnique.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeIndexOnOrganizationsKeeUnique extends DdlChange { - - private static final String TABLE_ORGANIZATIONS = "organizations"; - private static final String INDEX_NAME = "organization_key"; - - public MakeIndexOnOrganizationsKeeUnique(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_ORGANIZATIONS) - .setName(INDEX_NAME) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_ORGANIZATIONS) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("kee") - .setLimit(32) - .setIsNullable(false) - .build()) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullable.java deleted file mode 100644 index 9c63b0ad0bd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeOrganizationUuidOfProjectsNotNullable extends DdlChange { - - public MakeOrganizationUuidOfProjectsNotNullable(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), "projects") - .updateColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEvents.java deleted file mode 100644 index 9d474257fd3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEvents.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -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 MakeUuidNotNullOnEvents extends DdlChange { - - private static final String TABLE = "events"; - - public MakeUuidNotNullOnEvents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef uuidColumn = newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).build(); - context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE) - .updateColumn(uuidColumn) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("events_uuid") - .setUnique(true) - .addColumn(uuidColumn) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizations.java deleted file mode 100644 index 32b740d5f29..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizations.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -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 PopulateColumnGuardedOfOrganizations extends DataChange { - public PopulateColumnGuardedOfOrganizations(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from organizations where guarded is null"); - massUpdate.update("update organizations set guarded=? where uuid=?"); - massUpdate.rowPluralName("organizations"); - massUpdate.execute((row, statement) -> { - String organizationUuid = row.getString(1); - - statement.setBoolean(1, false); - statement.setString(2, organizationUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizations.java deleted file mode 100644 index 468e4102bfd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizations.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Nullable; -import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static com.google.common.base.MoreObjects.firstNonNull; -import static com.google.common.base.Preconditions.checkState; - -/** - * Populate the columns DEFAULT_PERM_TEMPLATE, DEFAULT_PERM_TEMPLATE_PROJECT and DEFAULT_PERM_TEMPLATE_VIEW of table - * ORGANIZATIONS, for the default organization exclusively, from the properties holding the default permissions template - * uuids. These properties are then deleted. - * - *

- * This migration ensures it can run but failing if: - *

    - *
  • there is more than one organizations (because we can't populate the column for those extra organizations)
  • - *
  • the global default permission template can't be found (because an organization must have at least this default template)
  • - *
- *

- */ -public class PopulateDefaultPermTemplateColumnsOfOrganizations extends DataChange { - private static final String DEFAULT_TEMPLATE_PROPERTY = "sonar.permission.template.default"; - private static final String DEFAULT_PROJECT_TEMPLATE_PROPERTY = "sonar.permission.template.TRK.default"; - private static final String DEFAULT_VIEW_TEMPLATE_PROPERTY = "sonar.permission.template.VW.default"; - private static final String DEFAULT_DEV_TEMPLATE_PROPERTY = "sonar.permission.template.DEV.default"; - - private final DefaultOrganizationUuidProvider defaultOrganizationUuid; - private final UuidFactory uuidFactory; - - public PopulateDefaultPermTemplateColumnsOfOrganizations(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid, UuidFactory uuidFactory) { - super(db); - this.defaultOrganizationUuid = defaultOrganizationUuid; - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - String defaultOrganizationUuid = this.defaultOrganizationUuid.getAndCheck(context); - ensureOnlyDefaultOrganizationExists(context, defaultOrganizationUuid); - - Map defaultTemplateProperties = retrieveDefaultTemplateProperties(context); - - String globalDefaultTemplate = defaultTemplateProperties.get(DEFAULT_TEMPLATE_PROPERTY); - if (globalDefaultTemplate == null || globalDefaultTemplate.isEmpty()) { - // DB has just been created, default template of default organization will be populated by a startup task - return; - } - String projectDefaultTemplate = updateKeeIfRequired(context, - firstNonNull(defaultTemplateProperties.get(DEFAULT_PROJECT_TEMPLATE_PROPERTY), globalDefaultTemplate)); - String viewDefaultTemplate = updateKeeIfRequired(context, - defaultTemplateProperties.get(DEFAULT_VIEW_TEMPLATE_PROPERTY)); - - Loggers.get(PopulateDefaultPermTemplateColumnsOfOrganizations.class) - .debug("Setting default templates on default organization '{}': project='{}', view='{}'", - defaultOrganizationUuid, projectDefaultTemplate, viewDefaultTemplate); - - context.prepareUpsert("update organizations set" + - " default_perm_template_project=?," + - " default_perm_template_view=?" + - " where" + - " uuid=?") - .setString(1, projectDefaultTemplate) - .setString(2, viewDefaultTemplate) - .setString(3, defaultOrganizationUuid) - .execute() - .commit(); - - // delete properties - context.prepareUpsert("delete from properties where prop_key in (?,?,?,?)") - .setString(1, DEFAULT_TEMPLATE_PROPERTY) - .setString(2, DEFAULT_PROJECT_TEMPLATE_PROPERTY) - .setString(3, DEFAULT_VIEW_TEMPLATE_PROPERTY) - .setString(4, DEFAULT_DEV_TEMPLATE_PROPERTY) - .execute() - .commit(); - } - - /** - * SONAR-10407 Ensure that the kee length is not greater than 40 - * In this case, we must update the kee to a UUID - */ - private String updateKeeIfRequired(Context context, @Nullable String kee) throws SQLException { - if (kee == null || kee.length() <= VarcharColumnDef.UUID_SIZE) { - return kee; - } - - String newKee = uuidFactory.create(); - context.prepareUpsert("update permission_templates set kee=? where kee=?") - .setString(1, newKee) - .setString(2, kee) - .execute(); - return newKee; - } - - private static void ensureOnlyDefaultOrganizationExists(Context context, String defaultOrganizationUuid) throws SQLException { - Integer otherOrganizationCount = context.prepareSelect("select count(*) from organizations where uuid <> ?") - .setString(1, defaultOrganizationUuid) - .get(row -> row.getInt(1)); - checkState(otherOrganizationCount == 0, - "Can not migrate DB if more than one organization exists. Remove all organizations but the default one which uuid is '%s'", - defaultOrganizationUuid); - } - - private static Map retrieveDefaultTemplateProperties(Context context) throws SQLException { - Map templates = new HashMap<>(3); - context.prepareSelect("select prop_key,is_empty,text_value from properties where prop_key in (?,?,?)") - .setString(1, DEFAULT_TEMPLATE_PROPERTY) - .setString(2, DEFAULT_PROJECT_TEMPLATE_PROPERTY) - .setString(3, DEFAULT_VIEW_TEMPLATE_PROPERTY) - .scroll(row -> { - String key = row.getString(1); - boolean isEmpty = row.getBoolean(2); - String textValue = row.getString(3); - if (!isEmpty) { - templates.put(key, textValue); - } - }); - return templates; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjects.java deleted file mode 100644 index cc159a80dd6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjects.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -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 PopulateOrganizationUuidToProjects extends DataChange { - private final DefaultOrganizationUuidProvider defaultOrganizationUuid; - - public PopulateOrganizationUuidToProjects(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) { - super(db); - this.defaultOrganizationUuid = defaultOrganizationUuid; - } - - @Override - protected void execute(Context context) throws SQLException { - String organizationUuid = defaultOrganizationUuid.get(context); - - // update rows by component tree - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from projects where organization_uuid is null and project_uuid = uuid"); - massUpdate.update("update projects set organization_uuid=? where project_uuid=?"); - massUpdate.rowPluralName("project trees"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - update.setString(1, organizationUuid); - update.setString(2, uuid); - return true; - }); - - // update rows lefts without organization_uuid, just in case we have orphan rows (aka. bad data) in DB - massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from projects where organization_uuid is null"); - massUpdate.update("update projects set organization_uuid=? where uuid=?"); - massUpdate.rowPluralName("components"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - update.setString(1, organizationUuid); - update.setString(2, uuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEvents.java deleted file mode 100644 index 89aed698a1a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEvents.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateUuidColumnOfEvents extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateUuidColumnOfEvents(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT e.id from events e where e.uuid is null"); - massUpdate.update("UPDATE events SET uuid=? WHERE id=?"); - massUpdate.rowPluralName("events"); - massUpdate.execute(this::handle); - } - - private boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - update.setString(1, uuidFactory.create()); - update.setLong(2, id); - return true; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlags.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlags.java deleted file mode 100644 index f163016600e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlags.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -/** - * Organizations and root users were not production-ready - * in versions prior to 6.3. For this reason they should not - * be enabled. This migration unsets the root flag from - * users. - */ -public class UnsetUserRootFlags extends DataChange { - - private final System2 system2; - - public UnsetUserRootFlags(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("update users set is_root=?, updated_at=? where is_root=?") - .setBoolean(1, false) - .setLong(2, system2.now()) - .setBoolean(3, true) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/package-info.java deleted file mode 100644 index 8309e598bbc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v63/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v63; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCount.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCount.java deleted file mode 100644 index b7097f09450..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCount.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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.IntegerColumnDef.newIntegerColumnDefBuilder; - -public class AddCeActivityWorkerUuidAndExecutionCount extends DdlChange { - - private static final String TABLE_CE_ACTIVITY = "ce_activity"; - - public AddCeActivityWorkerUuidAndExecutionCount(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_CE_ACTIVITY) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("worker_uuid") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build()) - .addColumn(newIntegerColumnDefBuilder() - .setColumnName("execution_count") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCount.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCount.java deleted file mode 100644 index a55e4f3bce7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCount.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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.IntegerColumnDef.newIntegerColumnDefBuilder; - -public class AddCeQueueWorkerUuidAndExecutionCount extends DdlChange { - - private static final String TABLE_CE_QUEUE = "ce_queue"; - - public AddCeQueueWorkerUuidAndExecutionCount(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_CE_QUEUE) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("worker_uuid") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build()) - .addColumn(newIntegerColumnDefBuilder() - .setColumnName("execution_count") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivate.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivate.java deleted file mode 100644 index c24086badcd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivate.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddColumnNewProjectPrivate extends DdlChange { - public AddColumnNewProjectPrivate(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "organizations") - .addColumn(newBooleanColumnDefBuilder() - .setColumnName("new_project_private") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivate.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivate.java deleted file mode 100644 index 141194dce16..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivate.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddColumnProjectsPrivate extends DdlChange { - public AddColumnProjectsPrivate(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "projects") - .addColumn(newBooleanColumnDefBuilder() - .setColumnName("private") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizations.java deleted file mode 100644 index 23daecb144d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizations.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.IntegerColumnDef.newIntegerColumnDefBuilder; - -public class AddDefaultGroupIdToOrganizations extends DdlChange { - - public AddDefaultGroupIdToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "organizations") - .addColumn(newIntegerColumnDefBuilder() - .setColumnName("default_group_id") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesType.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesType.java deleted file mode 100644 index ff1566d16a1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesType.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexLoadedTemplatesType extends DdlChange { - public AddIndexLoadedTemplatesType(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateIndexBuilder() - .setTable("loaded_templates") - .setName("ix_loaded_templates_type") - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("template_type") - .setIsNullable(false) - .setLimit(64) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParameters.java deleted file mode 100644 index 73eaef40ea9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParameters.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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; - -public class AddIndexOnActiveRuleParameters extends DdlChange { - public AddIndexOnActiveRuleParameters(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateIndexBuilder() - .setTable("active_rule_parameters") - .setName("ix_arp_on_active_rule_id") - .addColumn(newIntegerColumnDefBuilder().setColumnName("active_rule_id").setIsNullable(false).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuid.java deleted file mode 100644 index e7d50c5f57b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuid.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddQualityProfileOrganizationUuid extends DdlChange { - - public AddQualityProfileOrganizationUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new AddColumnsBuilder(getDialect(), "rules_profiles") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjects.java deleted file mode 100644 index 7a3f7f08045..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjects.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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 AddTagsToProjects extends DdlChange { - - public AddTagsToProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName("tags") - .setIsNullable(true) - .setLimit(500) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), "projects").addColumn(column).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphans.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphans.java deleted file mode 100644 index 4d3e4464d98..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphans.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class CleanLoadedTemplateOrphans extends DataChange { - public CleanLoadedTemplateOrphans(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("delete from loaded_templates where template_type is null") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsers.java deleted file mode 100644 index 5a6f5bb8a73..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsers.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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 CleanOrphanRowsInGroupsUsers extends DataChange { - - public CleanOrphanRowsInGroupsUsers(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("orphan user group membership"); - massUpdate.select("SELECT gu.user_id, gu.group_id FROM groups_users gu " + - "LEFT OUTER JOIN users u ON u.id=gu.user_id " + - "WHERE u.id IS NULL or u.active=?") - .setBoolean(1, false); - massUpdate.update("DELETE FROM groups_users WHERE user_id=? AND group_id=?"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(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/v64/CreateMembersGroupsInEachOrganization.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganization.java deleted file mode 100644 index d319fe8bd8a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganization.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Date; -import org.sonar.api.utils.System2; -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 CreateMembersGroupsInEachOrganization extends DataChange { - - private static final String GROUP_MEMBERS = "Members"; - - private final System2 system2; - - public CreateMembersGroupsInEachOrganization(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - Date now = new Date(system2.now()); - if (isOrganizationEnabled(context)) { - createMembersGroup(context, now); - createPermissionTemplateGroups(context, now); - } - } - - private static void createMembersGroup(Context context, Date now) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("groups"); - massUpdate.select("SELECT o.uuid FROM organizations o " + - "WHERE NOT EXISTS (SELECT 1 FROM groups g WHERE g.organization_uuid=o.uuid AND g.name=?)").setString(1, GROUP_MEMBERS); - massUpdate.update("INSERT INTO groups (organization_uuid, name, description, created_at, updated_at) values (?, ?, ?, ?, ?)"); - massUpdate.execute((row, update) -> { - update - .setString(1, row.getString(1)) - .setString(2, GROUP_MEMBERS) - .setString(3, "All members of the organization") - .setDate(4, now) - .setDate(5, now); - return true; - }); - } - - private static void createPermissionTemplateGroups(Context context, Date now) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("permission templates on groups"); - massUpdate.select("SELECT g.id, pt.id FROM organizations o " + - "INNER JOIN permission_templates pt ON pt.kee=o.default_perm_template_project " + - "INNER JOiN groups g ON g.organization_uuid=o.uuid AND g.name=? " + - "WHERE NOT EXISTS (SELECT 1 FROM perm_templates_groups ptg WHERE ptg.group_id=g.id AND ptg.template_id=pt.id)") - .setString(1, GROUP_MEMBERS); - massUpdate.update("INSERT INTO perm_templates_groups (group_id, template_id, permission_reference, created_at, updated_at) values (?, ?, ?, ?, ?)"); - massUpdate.update("INSERT INTO perm_templates_groups (group_id, template_id, permission_reference, created_at, updated_at) values (?, ?, ?, ?, ?)"); - massUpdate.execute((row, update, updateIndex) -> { - update - .setLong(1, row.getLong(1)) - .setLong(2, row.getLong(2)) - .setString(3, updateIndex == 0 ? "user" : "codeviewer") - .setDate(4, now) - .setDate(5, now); - return true; - }); - } - - private static boolean isOrganizationEnabled(Context context) throws SQLException { - Boolean result = context.prepareSelect("SELECT text_value FROM internal_properties WHERE kee=?") - .setString(1, "organization.enabled") - .get(row -> "true".equals(row.getString(1))); - return result != null ? result : false; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTable.java deleted file mode 100644 index 50cbcbed78d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTable.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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 CreateOrganizationMembersTable extends DdlChange { - - private static final String TABLE_NAME = "organization_members"; - - public CreateOrganizationMembersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) - .addPkColumn(newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(false).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadata.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadata.java deleted file mode 100644 index 4c93b7ea175..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadata.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.ClobColumnDef; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.IntegerColumnDef.newIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateRulesMetadata extends DdlChange { - - private static final String TABLE_NAME = "rules_metadata"; - - public CreateRulesMetadata(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newIntegerColumnDefBuilder() - .setColumnName("rule_id") - .setIsNullable(false) - .build()) - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(false) - .build()) - .addColumn(ClobColumnDef.newClobColumnDefBuilder() - .setColumnName("note_data") - .setIsNullable(true) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("note_user_login") - .setLimit(255) - .setIsNullable(true) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("note_created_at") - .setIsNullable(true) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("note_updated_at") - .setIsNullable(true) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("remediation_function") - .setLimit(20) - .setIsNullable(true) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("remediation_gap_mult") - .setLimit(20) - .setIsNullable(true) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("remediation_base_effort") - .setLimit(20) - .setIsNullable(true) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("tags") - .setLimit(4000) - .setIsNullable(true) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .withPkConstraintName("pk_" + TABLE_NAME) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DbVersion64.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DbVersion64.java deleted file mode 100644 index 21011461864..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DbVersion64.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion64 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1600, "Add PROJECTS.TAGS", AddTagsToProjects.class) - .add(1601, "Set PROJECTS.COPY_COMPONENT_UUID on local views", SetCopyComponentUuidOnLocalViews.class) - .add(1602, "Add RULES_PROFILES.ORGANIZATION_UUID", AddQualityProfileOrganizationUuid.class) - .add(1603, "Set RULES_PROFILES.ORGANIZATION_UUID to default", SetQualityProfileOrganizationUuidToDefault.class) - .add(1604, "Make RULES_PROFILES.ORGANIZATION_UUID not nullable", MakeQualityProfileOrganizationUuidNotNullable.class) - .add(1605, "Drop unique index on RULES_PROFILES.KEE", DropUniqueIndexOnQualityProfileKey.class) - .add(1606, "Make RULES_PROFILES.ORGANIZATION_UUID and KEE unique", MakeQualityProfileOrganizationUuidAndKeyUnique.class) - .add(1607, "Create ORGANIZATION_MEMBERS table", CreateOrganizationMembersTable.class) - .add(1608, "Populate ORGANIZATION_MEMBERS table", PopulateOrganizationMembersTable.class) - .add(1609, "Drop unique index on RULES_PROFILES.ORGANIZATION_UUID and KEE", DropUniqueIndexOnQualityProfileOrganizationUuidAndKey.class) - .add(1610, "Make RULES_PROFILES.KEE unique", MakeQualityProfileKeyUnique.class) - .add(1611, "Clean LOADED_TEMPLATES rows without type", CleanLoadedTemplateOrphans.class) - .add(1612, "Extend size of column LOADED_TEMPLATES.TEMPLATE_TYPE", ExtendLoadedTemplateTypeColumn.class) - .add(1613, "Add index LOADED_TEMPLATES_TYPE", AddIndexLoadedTemplatesType.class) - .add(1614, "Upgrade loaded template entries for quality profiles", UpgradeQualityTemplateLoadedTemplates.class) - .add(1615, "Create table RULES_METADATA", CreateRulesMetadata.class) - .add(1616, "Populate table RULES_METADATA", PopulateRulesMetadata.class) - .add(1617, "Drop metadata columns from RULES", DropMetadataColumnsFromRules.class) - // ensure the index is made unique even on existing 6.4-SNAPSHOT instances (such as next or the developer machines) - .add(1618, "Make index on ORGANIZATIONS.KEE unique", org.sonar.server.platform.db.migration.version.v63.MakeIndexOnOrganizationsKeeUnique.class) - .add(1619, "Restore 'sonar-users' group", RestoreSonarUsersGroups.class) - .add(1620, "Delete 'sonar.defaultGroup' setting", DeleteDefaultGroupSetting.class) - .add(1621, "Set all users into 'sonar-users' group", SetAllUsersIntoSonarUsersGroup.class) - .add(1622, "Create 'Members' group in each organization", CreateMembersGroupsInEachOrganization.class) - .add(1623, "Set organization members into 'Members' group", SetOrganizationMembersIntoMembersGroup.class) - .add(1624, "Add ORGANIZATIONS.DEFAULT_GROUP_ID", AddDefaultGroupIdToOrganizations.class) - .add(1625, "Populate column ORGANIZATIONS.DEFAULT_GROUP_ID", PopulateColumnDefaultGroupIdOfOrganizations.class) - .add(1626, "Clean orphan rows in table GROUPS_USERS", CleanOrphanRowsInGroupsUsers.class) - .add(1627, "Delete permission templates linked to removed users", DeletePermissionTemplatesLinkedToRemovedUsers.class) - .add(1628, "Add columns CE_QUEUE.WORKER_UUID and EXECUTION_COUNT", AddCeQueueWorkerUuidAndExecutionCount.class) - .add(1629, "Make CE_QUEUE.EXECUTION_COUNT not nullable", MakeCeQueueExecutionCountNotNullable.class) - .add(1630, "Add columns CE_ACTIVITY.WORKER_UUID and EXECUTION_COUNT", AddCeActivityWorkerUuidAndExecutionCount.class) - .add(1631, "Make columns CE_ACTIVITY.EXECUTION_COUNT not nullable", MakeCeActivityExecutionCountNotNullable.class) - .add(1632, "Make PROJECTS.PROJECT_UUID not nullable", MakeProjectUuidNotNullable.class) - .add(1633, "Purge rows with null PROJECTS.PROJECT_UUID", PurgeComponentsWithoutProjectUuid.class) - .add(1634, "Make PROJECTS.PROJECT_UUID not nullable", MakeProjectUuidNotNullable.class) - .add(1635, "Add column PROJECTS.PRIVATE", AddColumnProjectsPrivate.class) - .add(1636, "Populate column PROJECTS.PRIVATE", PopulateColumnProjectsPrivate.class) - .add(1637, "Make column PROJECTS.PRIVATE not nullable", MakeColumnProjectsPrivateNotNullable.class) - .add(1638, "Add column ORGANIZATIONS.NEW_PROJECT_PRIVATE", AddColumnNewProjectPrivate.class) - .add(1639, "Set ORGANIZATIONS.NEW_PROJECT_PRIVATE to false", SetNewProjectPrivateToFalse.class) - .add(1640, "Make column ORGANIZATIONS.NEW_PROJECT_PRIVATE not nullable", MakeColumnNewProjectPrivateNotNullable.class) - .add(1641, "Make components private based on permissions", MakeComponentsPrivateBasedOnPermissions.class) - .add(1642, "Support private project in default permission template", SupportPrivateProjectInDefaultPermissionTemplate.class) - .add(1643, "Drop user and codeviewer perms to AnyOne in permission templates", SupportProjectVisibilityInTemplates.class) - .add(1644, "Add index on active_rule_parameters.active_rule_id", AddIndexOnActiveRuleParameters.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSetting.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSetting.java deleted file mode 100644 index 0a2fb77bf54..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSetting.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class DeleteDefaultGroupSetting extends DataChange { - - public DeleteDefaultGroupSetting(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("DELETE FROM properties WHERE prop_key=?") - .setString(1, "sonar.defaultGroup") - .execute().commit(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsers.java deleted file mode 100644 index d43655c50fd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsers.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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 DeletePermissionTemplatesLinkedToRemovedUsers extends DataChange { - - public DeletePermissionTemplatesLinkedToRemovedUsers(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("permission templates linked to removed users"); - massUpdate.select("SELECT ptu.id FROM perm_templates_users ptu " + - "LEFT OUTER JOIN users u ON u.id=ptu.user_id " + - "WHERE u.id IS NULL or u.active=?") - .setBoolean(1, false); - massUpdate.update("DELETE FROM perm_templates_users WHERE id=?"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRules.java deleted file mode 100644 index 2be5834563b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRules.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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 DropMetadataColumnsFromRules extends DdlChange { - - private static final String TABLE_RULES = "rules"; - - public DropMetadataColumnsFromRules(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder( - getDialect(), TABLE_RULES, - "note_data", "note_user_login", "note_created_at", "note_updated_at", - "remediation_function", "remediation_gap_mult", "remediation_base_effort", - "tags") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKey.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKey.java deleted file mode 100644 index b525d400c39..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKey.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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 DropUniqueIndexOnQualityProfileKey extends DdlChange { - - public DropUniqueIndexOnQualityProfileKey(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute( - new DropIndexBuilder(getDialect()) - .setTable("rules_profiles") - .setName("uniq_qprof_key") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKey.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKey.java deleted file mode 100644 index d80af3adb8b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKey.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import java.sql.SQLException; - -public class DropUniqueIndexOnQualityProfileOrganizationUuidAndKey extends DdlChange { - - public DropUniqueIndexOnQualityProfileOrganizationUuidAndKey(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute( - new DropIndexBuilder(getDialect()) - .setTable("rules_profiles") - .setName("uniq_qprof_org_and_key") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumn.java deleted file mode 100644 index b8c5681565f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumn.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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; - -public class ExtendLoadedTemplateTypeColumn extends DdlChange { - public ExtendLoadedTemplateTypeColumn(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new AlterColumnsBuilder(getDialect(), "loaded_templates") - .updateColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("template_type") - .setIsNullable(false) - .setLimit(64) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullable.java deleted file mode 100644 index 44276346d8a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullable.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.IntegerColumnDef.newIntegerColumnDefBuilder; - -public class MakeCeActivityExecutionCountNotNullable extends DdlChange { - - private static final String TABLE_CE_ACTIVITY = "ce_activity"; - - public MakeCeActivityExecutionCountNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute("update ce_activity set execution_count = 0 where execution_count is null and status = 'CANCELED'"); - context.execute("update ce_activity set execution_count = 1 where execution_count is null and status in ('SUCCESS', 'FAILED')"); - - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_CE_ACTIVITY) - .updateColumn(newIntegerColumnDefBuilder() - .setColumnName("execution_count") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullable.java deleted file mode 100644 index 4b5608c1c7d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullable.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.IntegerColumnDef.newIntegerColumnDefBuilder; - -public class MakeCeQueueExecutionCountNotNullable extends DdlChange { - - private static final String TABLE_CE_QUEUE = "ce_queue"; - - public MakeCeQueueExecutionCountNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute("update ce_queue set execution_count = 0 where execution_count is null"); - - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_CE_QUEUE) - .updateColumn(newIntegerColumnDefBuilder() - .setColumnName("execution_count") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullable.java deleted file mode 100644 index a78be329f23..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class MakeColumnNewProjectPrivateNotNullable extends DdlChange { - public MakeColumnNewProjectPrivateNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "organizations") - .updateColumn(newBooleanColumnDefBuilder() - .setColumnName("new_project_private") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullable.java deleted file mode 100644 index f46202d917b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class MakeColumnProjectsPrivateNotNullable extends DdlChange { - public MakeColumnProjectsPrivateNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "projects") - .updateColumn(newBooleanColumnDefBuilder() - .setColumnName("private") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissions.java deleted file mode 100644 index 994f37bc3bb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissions.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -/** - * This DB migration assumes the whole PROJECTS table contains only rows with private=false - * (set by {@link PopulateColumnProjectsPrivate}) and performs the following: - *
    - *
  • set private=true for any tree of component which root has neither user nor codeviewer permission for group AnyOne - * but defines at least one permission directly to a group or user
  • - *
  • removes any permission to group AnyOne for root components which are made private
  • - *
  • ensures any group or user with direct permission to a private root component also has both permissions - * user and codeviewer
  • - *
  • deletes any permission user or codeviewer for root components which stays public
  • - *
- * This DB migration of course works if PROJECTS table contains rows with private=true, but it will assume they have - * been set by a previous run of itself (ie. the DB migration is reentrant). - */ -public class MakeComponentsPrivateBasedOnPermissions extends DataChange { - - private static final String SCOPE_PROJECT = "PRJ"; - private static final String QUALIFIER_PROJECT = "TRK"; - private static final String QUALIFIER_VIEW = "VW"; - private static final String PERMISSION_USER = "user"; - private static final String PERMISSION_CODEVIEWER = "codeviewer"; - - public MakeComponentsPrivateBasedOnPermissions(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - makePrivateComponent(context); - cleanPermissionsOfPublicComponents(context); - insertUserPermissionOfPrivateRootComponent(context, PERMISSION_USER); - insertUserPermissionOfPrivateRootComponent(context, PERMISSION_CODEVIEWER); - insertGroupPermissionOfPrivateRootComponent(context, PERMISSION_USER); - insertGroupPermissionOfPrivateRootComponent(context, PERMISSION_CODEVIEWER); - } - - private static void makePrivateComponent(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid, id from projects p where " + - " p.scope = ?" + - " and p.qualifier in (?, ?)" + - " and p.private = ?" + - " and (" + - " not exists (" + - " select" + - " 1" + - " from group_roles gr" + - " where " + - " gr.resource_id = p.id" + - " and gr.group_id is null" + - " and gr.role = ?" + - " ) " + - " or not exists (" + - " select" + - " 1" + - " from group_roles gr" + - " where " + - " gr.resource_id = p.id" + - " and gr.group_id is null" + - " and gr.role = ?" + - " )" + - " )" + - // trees with only permissions to group must not be made private - " and (" + - " exists (" + - " select" + - " 1" + - " from " + - " group_roles gr2" + - " where" + - " gr2.resource_id = p.id" + - " and gr2.group_id is not null" + - " )" + - " or exists (" + - " select" + - " 1" + - " from " + - " user_roles ur" + - " where" + - " ur.resource_id = p.id" + - " )" + - ")") - .setString(1, SCOPE_PROJECT) - .setString(2, QUALIFIER_PROJECT) - .setString(3, QUALIFIER_VIEW) - .setBoolean(4, false) - .setString(5, PERMISSION_USER) - .setString(6, PERMISSION_CODEVIEWER); - massUpdate.rowPluralName("component trees to be made private"); - // make project private - massUpdate.update("update projects set private = ? where project_uuid = ?"); - // delete any permission given to group "Anyone" - massUpdate.update("delete from group_roles where resource_id = ? and group_id is null"); - massUpdate.execute(MakeComponentsPrivateBasedOnPermissions::handleMakePrivateComponent); - } - - private static boolean handleMakePrivateComponent(Select.Row row, SqlStatement update, int updateIndex) throws SQLException { - String rootUuid = row.getString(1); - long id = row.getLong(2); - switch (updateIndex) { - case 0: - update.setBoolean(1, true); - update.setString(2, rootUuid); - return true; - case 1: - update.setLong(1, id); - return true; - default: - throw new IllegalArgumentException("Unsupported update index " + updateIndex); - } - } - - private static void cleanPermissionsOfPublicComponents(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from projects p where " + - " p.scope = ?" + - " and p.qualifier in (?, ?)" + - " and p.private = ?" + - " and exists (" + - " select" + - " 1" + - " from group_roles gr" + - " where " + - " gr.resource_id = p.id" + - " and gr.role in (?, ?)" + - " union" + - " select" + - " 1" + - " from user_roles gr" + - " where " + - " gr.resource_id = p.id" + - " and gr.role in (?, ?)" + - ")") - .setString(1, SCOPE_PROJECT) - .setString(2, QUALIFIER_PROJECT) - .setString(3, QUALIFIER_VIEW) - .setBoolean(4, false) - .setString(5, PERMISSION_USER) - .setString(6, PERMISSION_CODEVIEWER) - .setString(7, PERMISSION_USER) - .setString(8, PERMISSION_CODEVIEWER); - massUpdate.rowPluralName("public component trees to clean permissions of"); - massUpdate.update("delete from group_roles where resource_id = ? and role in ('user', 'codeviewer')"); - massUpdate.update("delete from user_roles where resource_id = ? and role in ('user', 'codeviewer')"); - massUpdate.execute(MakeComponentsPrivateBasedOnPermissions::handleCleanPermissionsOfPublicComponents); - } - - private static boolean handleCleanPermissionsOfPublicComponents(Select.Row row, SqlStatement update, int updateIndex) throws SQLException { - long id = row.getLong(1); - switch (updateIndex) { - case 0: - case 1: - update.setLong(1, id); - return true; - default: - throw new IllegalArgumentException("Unsupported update index " + updateIndex); - } - } - - private static void insertUserPermissionOfPrivateRootComponent(Context context, String permission) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " distinct r1.user_id, p.organization_uuid, p.id" + - " from" + - " user_roles r1" + - " inner join projects p on" + - " p.id = r1.resource_id" + - " and p.scope = ?" + - " and p.qualifier in (?, ?)" + - " and p.private = ?" + - " where" + - " not exists (" + - " select" + - " 1" + - " from" + - " user_roles r2" + - " where " + - " r2.user_id = r1.user_id" + - " and r2.resource_id = r1.resource_id" + - " and r2.role = ?" + - ")") - .setString(1, SCOPE_PROJECT) - .setString(2, QUALIFIER_PROJECT) - .setString(3, QUALIFIER_VIEW) - .setBoolean(4, true) - .setString(5, permission); - massUpdate.rowPluralName("users of private component tree without " + permission + " permission"); - massUpdate.update("insert into user_roles" + - " (organization_uuid, user_id, resource_id, role)" + - " values" + - " (?, ?, ?, ?)"); - massUpdate.execute((row, update) -> insertUserPermission(row, update, permission)); - } - - private static boolean insertUserPermission(Select.Row row, SqlStatement update, String permission) throws SQLException { - int userId = row.getInt(1); - String organizationUuid = row.getString(2); - int resourceId = row.getInt(3); - - update.setString(1, organizationUuid); - update.setInt(2, userId); - update.setInt(3, resourceId); - update.setString(4, permission); - return true; - } - - private static void insertGroupPermissionOfPrivateRootComponent(Context context, String permission) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " distinct g1.group_id, p.organization_uuid, p.id" + - " from" + - " group_roles g1" + - " inner join projects p on" + - " p.id = g1.resource_id" + - " and p.scope = ?" + - " and p.qualifier in (?, ?)" + - " and p.private = ?" + - " where" + - " g1.group_id is not null" + - " and not exists (" + - " select" + - " 1" + - " from" + - " group_roles g2" + - " where " + - " g2.group_id = g1.group_id" + - " and g2.resource_id = g1.resource_id" + - " and g2.role = ?" + - ")") - .setString(1, SCOPE_PROJECT) - .setString(2, QUALIFIER_PROJECT) - .setString(3, QUALIFIER_VIEW) - .setBoolean(4, true) - .setString(5, permission); - massUpdate.rowPluralName("groups of private component tree without " + permission + " permission"); - massUpdate.update("insert into group_roles" + - " (organization_uuid, group_id, resource_id, role)" + - " values" + - " (?, ?, ?, ?)"); - massUpdate.execute((row, update) -> insertGroupPermission(row, update, permission)); - } - - private static boolean insertGroupPermission(Select.Row row, SqlStatement update, String permission) throws SQLException { - int groupId = row.getInt(1); - String organizationUuid = row.getString(2); - int resourceId = row.getInt(3); - - update.setString(1, organizationUuid); - update.setInt(2, groupId); - update.setInt(3, resourceId); - update.setString(4, permission); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullable.java deleted file mode 100644 index 0fb21bb9a90..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullable.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeProjectUuidNotNullable extends DdlChange { - - private static final String TABLE_PROJECTS = "projects"; - private static final String INDEX_PROJECTS_PROJECT_UUID = "projects_project_uuid"; - - public MakeProjectUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef projectUuidCol = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setLimit(50) - .setIsNullable(false) - .build(); - - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_PROJECTS) - .setName(INDEX_PROJECTS_PROJECT_UUID) - .build()); - - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_PROJECTS) - .updateColumn(projectUuidCol) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_PROJECTS) - .setName(INDEX_PROJECTS_PROJECT_UUID) - .setUnique(false).addColumn(projectUuidCol) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUnique.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUnique.java deleted file mode 100644 index 3d791a406d8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUnique.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import java.sql.SQLException; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeQualityProfileKeyUnique extends DdlChange { - - public MakeQualityProfileKeyUnique(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute( - new CreateIndexBuilder() - .setTable("rules_profiles") - .setName("uniq_qprof_key") - .addColumn( - newVarcharColumnDefBuilder() - .setColumnName("kee") - .setLimit(255) - .build()) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUnique.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUnique.java deleted file mode 100644 index 96e0d7f6883..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUnique.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 MakeQualityProfileOrganizationUuidAndKeyUnique extends DdlChange { - - public MakeQualityProfileOrganizationUuidAndKeyUnique(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute( - new CreateIndexBuilder() - .setTable("rules_profiles") - .setName("uniq_qprof_org_and_key") - .addColumn( - newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setLimit(UUID_SIZE) - .build()) - .addColumn( - newVarcharColumnDefBuilder() - .setColumnName("kee") - .setLimit(255) - .build()) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidNotNullable.java deleted file mode 100644 index 5771f423301..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidNotNullable.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeQualityProfileOrganizationUuidNotNullable extends DdlChange { - - public MakeQualityProfileOrganizationUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute( - new AlterColumnsBuilder(getDatabase().getDialect(), "rules_profiles") - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizations.java deleted file mode 100644 index a4b24a66885..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizations.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -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 PopulateColumnDefaultGroupIdOfOrganizations extends DataChange { - - private final System2 system2; - - public PopulateColumnDefaultGroupIdOfOrganizations(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - populateDefaultGroupId(context, isOrganizationEnabled(context) ? "Members" : "sonar-users"); - } - - private void populateDefaultGroupId(Context context, String groupName) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("organizations"); - massUpdate.select("SELECT o.uuid, g.id FROM organizations o " + - "INNER JOIN groups g ON g.organization_uuid=o.uuid AND g.name=? " + - "WHERE o.default_group_id IS NULL") - .setString(1, groupName); - massUpdate.update("UPDATE organizations SET default_group_id=?,updated_at=? WHERE uuid=?"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(2)); - update.setLong(2, system2.now()); - update.setString(3, row.getString(1)); - return true; - }); - } - - private static boolean isOrganizationEnabled(Context context) throws SQLException { - Boolean result = context.prepareSelect("SELECT text_value FROM internal_properties WHERE kee=?") - .setString(1, "organization.enabled") - .get(row -> "true".equals(row.getString(1))); - return result != null ? result : false; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivate.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivate.java deleted file mode 100644 index 785cf9f1d27..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivate.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class PopulateColumnProjectsPrivate extends DataChange { - public PopulateColumnProjectsPrivate(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct root_uuid from projects where private is null"); - massUpdate.update("update projects set private = ? where root_uuid = ?"); - massUpdate.rowPluralName("component tree without private flag"); - massUpdate.execute(PopulateColumnProjectsPrivate::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - String rootUuid = row.getString(1); - - update.setBoolean(1, false); - update.setString(2, rootUuid); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTable.java deleted file mode 100644 index 58150227f09..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTable.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; - -public class PopulateOrganizationMembersTable extends DataChange { - - private static final String INSERT_ORGANIZATION_MEMBERS_SQL = "INSERT INTO organization_members (user_id, organization_uuid) VALUES (?, ?)"; - - private final DefaultOrganizationUuidProvider defaultOrganizationUuid; - - public PopulateOrganizationMembersTable(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) { - super(db); - this.defaultOrganizationUuid = defaultOrganizationUuid; - } - - @Override - public void execute(Context context) throws SQLException { - associateUsersToDefaultOrganization(context); - associateUsersToOrganizationBasedOnPermission(context); - } - - private void associateUsersToDefaultOrganization(Context context) throws SQLException { - String organizationUuid = defaultOrganizationUuid.getAndCheck(context); - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("default organization members"); - massUpdate.select( - "SELECT u.id FROM users u " + - "WHERE u.active=? AND " + - "NOT EXISTS (SELECT 1 FROM organization_members om WHERE om.user_id=u.id AND om.organization_uuid=?) ") - .setBoolean(1, true) - .setString(2, organizationUuid); - massUpdate.update(INSERT_ORGANIZATION_MEMBERS_SQL); - massUpdate.execute((row, update) -> { - update.setInt(1, row.getInt(1)); - update.setString(2, organizationUuid); - return true; - }); - } - - private static void associateUsersToOrganizationBasedOnPermission(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("non default organization members"); - massUpdate.select( - "SELECT distinct ur.organization_uuid, ur.user_id FROM user_roles ur " + - "INNER JOIN users u ON u.id=ur.user_id AND u.active=? " + - "WHERE NOT EXISTS (SELECT 1 FROM organization_members om WHERE om.user_id=ur.user_id AND om.organization_uuid=ur.organization_uuid) " + - "UNION " + - "SELECT distinct g.organization_uuid, gu.user_id FROM groups_users gu " + - "INNER JOIN users u ON u.id=gu.user_id AND u.active=? " + - "INNER JOIN groups g ON g.id=gu.group_id " + - "WHERE NOT EXISTS (SELECT 1 FROM organization_members om WHERE om.user_id=gu.user_id AND om.organization_uuid=g.organization_uuid)") - .setBoolean(1, true) - .setBoolean(2, true); - massUpdate.update(INSERT_ORGANIZATION_MEMBERS_SQL); - massUpdate.execute((row, update) -> { - update.setInt(1, row.getInt(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/v64/PopulateRulesMetadata.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadata.java deleted file mode 100644 index 7f933869e0a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadata.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Date; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; - -import static java.util.Optional.ofNullable; - -public class PopulateRulesMetadata extends DataChange { - private final DefaultOrganizationUuidProvider defaultOrganizationUuid; - private final System2 system2; - - public PopulateRulesMetadata(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid, System2 system2) { - super(db); - this.defaultOrganizationUuid = defaultOrganizationUuid; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - String defaultOrganizationUuid = this.defaultOrganizationUuid.getAndCheck(context); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " id," + - " note_data," + - " note_user_login," + - " note_created_at," + - " note_updated_at," + - " remediation_function," + - " remediation_gap_mult," + - " remediation_base_effort," + - " tags," + - " created_at," + - " updated_at" + - " from" + - " rules r" + - " where" + - " not exists (select 1 from rules_metadata rm where rm.rule_id = r.id)"); - massUpdate.rowPluralName("rules metadata"); - massUpdate.update("insert into rules_metadata" + - " (" + - " rule_id," + - " organization_uuid," + - " note_data," + - " note_user_login," + - " note_created_at," + - " note_updated_at," + - " remediation_function," + - " remediation_gap_mult," + - " remediation_base_effort," + - " tags," + - " created_at," + - " updated_at" + - ")" + - "values" + - "(" + - " ?," + - " ?," + - " ?," + - " ?," + - " ?," + - " ?," + - " ?," + - " ?," + - " ?," + - " ?," + - " ?," + - " ?" + - ")"); - massUpdate.execute((row, update) -> handle(defaultOrganizationUuid, row, update)); - } - - private boolean handle(String defaultOrganizationUuid, Select.Row row, SqlStatement update) throws SQLException { - long now = system2.now(); - int ruleId = row.getInt(1); - String noteData = row.getNullableString(2); - String noteUserLogin = row.getNullableString(3); - Date noteCreatedAt = row.getNullableDate(4); - Date noteUpdatedAt = row.getNullableDate(5); - String remediationFunction = row.getNullableString(6); - String remediationGapMultiplier = row.getNullableString(7); - String remediationBaseEffort = row.getNullableString(8); - String tags = row.getNullableString(9); - Long createdAt = row.getNullableLong(10); - Long updatedAt = row.getNullableLong(11); - - update - .setInt(1, ruleId) - .setString(2, defaultOrganizationUuid) - .setString(3, noteData) - .setString(4, noteUserLogin) - .setLong(5, ofNullable(noteCreatedAt).map(Date::getTime).orElse(null)) - .setLong(6, ofNullable(noteUpdatedAt).map(Date::getTime).orElse(null)) - .setString(7, remediationFunction) - .setString(8, remediationGapMultiplier) - .setString(9, remediationBaseEffort) - .setString(10, tags) - .setLong(11, ofNullable(createdAt).orElse(now)) - .setLong(12, ofNullable(updatedAt).orElse(now)); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuid.java deleted file mode 100644 index f3e9c8d6836..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuid.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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 PurgeComponentsWithoutProjectUuid extends DataChange { - public PurgeComponentsWithoutProjectUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id,uuid from projects where project_uuid is null"); - massUpdate.rowPluralName("rows in projects without project_uuid"); - massUpdate.update("delete from duplications_index where analysis_uuid in (select uuid from snapshots where component_uuid=?)"); - massUpdate.update("delete from project_measures where component_uuid=?"); - massUpdate.update("delete from ce_activity where component_uuid=?"); - massUpdate.update("delete from events where component_uuid=?"); - massUpdate.update("delete from events where analysis_uuid in (select uuid from snapshots where component_uuid=?)"); - massUpdate.update("delete from project_links where component_uuid=?"); - massUpdate.update("delete from snapshots where component_uuid=?"); - massUpdate.update("delete from issues where component_uuid=? or project_uuid=?"); - massUpdate.update("delete from file_sources where file_uuid=? or project_uuid=?"); - massUpdate.update("delete from group_roles where resource_id=?"); - massUpdate.update("delete from user_roles where resource_id=?"); - massUpdate.update("delete from properties where resource_id=?"); - massUpdate.update("delete from projects where uuid=?"); - massUpdate.execute((row, update, updateIndex) -> { - long componentId = row.getLong(1); - String componentUuid = row.getString(2); - switch (updateIndex) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - update.setString(1, componentUuid); - return true; - case 7: - case 8: - update.setString(1, componentUuid); - update.setString(2, componentUuid); - return true; - case 9: - case 10: - case 11: - update.setLong(1, componentId); - return true; - case 12: - update.setString(1, componentUuid); - return true; - default: - throw new IllegalArgumentException("Unsupported update index " + updateIndex); - } - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroups.java deleted file mode 100644 index 9e73731efa3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroups.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Date; -import javax.annotation.CheckForNull; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; - -import static com.google.common.base.Preconditions.checkState; -import static java.lang.String.format; -import static java.util.Objects.requireNonNull; - -/** - * If sonar-users doesn't exist, create it and copy permissions from existing default group - * If it already exists, only update description if it's the wrong one - */ -public class RestoreSonarUsersGroups extends DataChange { - - private static final Logger LOG = Loggers.get(RestoreSonarUsersGroups.class); - - private static final String SONAR_USERS_NAME = "sonar-users"; - private static final String SONAR_USERS_PENDING_DESCRIPTION = ""; - private static final String SONAR_USERS_FINAL_DESCRIPTION = "Any new users created will automatically join this group"; - private static final String DEFAULT_GROUP_SETTING = "sonar.defaultGroup"; - - private final System2 system2; - private final DefaultOrganizationUuidProvider defaultOrganizationUuid; - - public RestoreSonarUsersGroups(Database db, System2 system2, DefaultOrganizationUuidProvider defaultOrganizationUuid) { - super(db); - this.system2 = system2; - this.defaultOrganizationUuid = defaultOrganizationUuid; - } - - @Override - protected void execute(Context context) throws SQLException { - Date now = new Date(system2.now()); - Group sonarUsersGroup = selectSonarUsersGroup(context); - Group defaultGroup = searchDefaultGroup(context); - if (sonarUsersGroup == null) { - createSonarUsersGroupAndCopyPermissionsFromDefaultGroup(context, defaultGroup, now); - displayWarnLog(defaultGroup); - } else { - if (SONAR_USERS_PENDING_DESCRIPTION.equals(sonarUsersGroup.getDescription())) { - copyAllPermissionsFromDefaultGroupToSonarUsers(context, sonarUsersGroup, defaultGroup, now); - } else if (!SONAR_USERS_FINAL_DESCRIPTION.equals(sonarUsersGroup.getDescription())) { - updateSonarUsersGroupDescription(context, SONAR_USERS_FINAL_DESCRIPTION, sonarUsersGroup.getId(), now); - } - if (sonarUsersGroup.getId() != defaultGroup.getId()) { - displayWarnLog(defaultGroup); - } - } - } - - private void createSonarUsersGroupAndCopyPermissionsFromDefaultGroup(Context context, Group defaultGroup, Date now) throws SQLException { - insertSonarUsersGroupWithPendingDescription(context, defaultOrganizationUuid.get(context), now); - Group sonarUsersGroupId = requireNonNull(selectSonarUsersGroup(context), format("Creation of '%s' group has failed", SONAR_USERS_NAME)); - copyAllPermissionsFromDefaultGroupToSonarUsers(context, sonarUsersGroupId, defaultGroup, now); - } - - private static void copyAllPermissionsFromDefaultGroupToSonarUsers(Context context, Group sonarUsersGroup, Group defaultGroupId, Date now) throws SQLException { - copyGlobalAndProjectPermissionsFromDefaultGroupToSonarUsers(context, defaultGroupId, sonarUsersGroup); - copyPermissionTemplatesFromDefaultGroupToSonarUsers(context, defaultGroupId, sonarUsersGroup, now); - updateSonarUsersGroupDescription(context, SONAR_USERS_FINAL_DESCRIPTION, sonarUsersGroup.getId(), now); - } - - private static void copyGlobalAndProjectPermissionsFromDefaultGroupToSonarUsers(Context context, Group defaultGroupId, Group sonarUsersGroupId) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("global and project permissions"); - massUpdate.select("SELECT gr.resource_id, gr.role, gr.organization_uuid FROM group_roles gr " + - "WHERE gr.group_id=? AND NOT EXISTS " + - "(SELECT 1 FROM group_roles gr2 WHERE gr2.resource_id=gr.resource_id AND gr2.role=gr.role AND gr2.organization_uuid=gr.organization_uuid AND gr2.group_id=?)") - .setLong(1, defaultGroupId.getId()) - .setLong(2, sonarUsersGroupId.getId()); - massUpdate.update("INSERT INTO group_roles (group_id, resource_id, role, organization_uuid) values (?, ?, ?, ?)"); - massUpdate.execute((row, update) -> { - update.setLong(1, sonarUsersGroupId.getId()); - update.setLong(2, row.getNullableLong(1)); - update.setString(3, row.getString(2)); - update.setString(4, row.getString(3)); - return true; - }); - } - - private static void copyPermissionTemplatesFromDefaultGroupToSonarUsers(Context context, Group defaultGroupId, Group sonarUsersGroupId, Date now) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("permission templates"); - massUpdate.select("SELECT ptg.template_id, ptg.permission_reference FROM perm_templates_groups ptg " + - "WHERE ptg.group_id=? AND NOT EXISTS " + - "(SELECT 1 FROM perm_templates_groups ptg2 WHERE ptg2.template_id=ptg.template_id AND ptg2.permission_reference=ptg.permission_reference AND ptg2.group_id=?)") - .setLong(1, defaultGroupId.getId()) - .setLong(2, sonarUsersGroupId.getId()); - massUpdate.update("INSERT INTO perm_templates_groups (group_id, template_id, permission_reference, created_at, updated_at) values (?, ?, ?, ?, ?)"); - massUpdate.execute((row, update) -> { - update - .setLong(1, sonarUsersGroupId.getId()) - .setLong(2, row.getLong(1)) - .setString(3, row.getString(2)) - .setDate(4, now) - .setDate(5, now); - return true; - }); - } - - private static void insertSonarUsersGroupWithPendingDescription(Context context, String organizationUuid, Date now) throws SQLException { - context.prepareUpsert("INSERT into groups (name, description, organization_uuid, created_at, updated_at) values (?, ?, ?, ?, ?)") - .setString(1, SONAR_USERS_NAME) - .setString(2, SONAR_USERS_PENDING_DESCRIPTION) - .setString(3, organizationUuid) - .setDate(4, now) - .setDate(5, now) - .execute() - .commit(); - } - - private static void updateSonarUsersGroupDescription(Context context, String description, long sonarUsersGroupId, Date now) throws SQLException { - context.prepareUpsert("UPDATE groups SET description=?, updated_at=? WHERE id=?") - .setString(1, description) - .setDate(2, now) - .setLong(3, sonarUsersGroupId) - .execute() - .commit(); - } - - private static Group searchDefaultGroup(Context context) throws SQLException { - String defaultGroupName = selectDefaultGroupNameFromProperties(context); - if (defaultGroupName == null) { - Group sonarUsersGroup = selectSonarUsersGroup(context); - checkState(sonarUsersGroup != null, "Default group setting %s is defined to a 'sonar-users' group but it doesn't exist.", DEFAULT_GROUP_SETTING); - return sonarUsersGroup; - } - Group defaultGroup = selectGroupByName(context, defaultGroupName); - checkState(defaultGroup != null, "Default group setting %s is defined to an unknown group.", DEFAULT_GROUP_SETTING); - return defaultGroup; - } - - @CheckForNull - private static Group selectSonarUsersGroup(Context context) throws SQLException { - return selectGroupByName(context, SONAR_USERS_NAME); - } - - @CheckForNull - private static String selectDefaultGroupNameFromProperties(Context context) throws SQLException { - return context.prepareSelect("SELECT is_empty,text_value FROM properties WHERE prop_key=? AND is_empty=?") - .setString(1, DEFAULT_GROUP_SETTING) - .setBoolean(2, false) - .get(row -> { - boolean isEmpty = row.getBoolean(1); - return isEmpty ? null : row.getString(2); - }); - } - - @CheckForNull - private static Group selectGroupByName(Context context, String name) throws SQLException { - return context.prepareSelect("SELECT id, name, description FROM groups WHERE name=?") - .setString(1, name) - .get(Group::new); - } - - private static void displayWarnLog(Group defaultGroup) { - LOG.warn("The default group has been updated from '{}' to '{}'. Please verify your permission schema that everything is in order", - defaultGroup.getName(), SONAR_USERS_NAME); - } - - private static class Group { - private final long id; - private final String name; - private final String description; - - Group(Select.Row row) throws SQLException { - this.id = row.getLong(1); - this.name = row.getString(2); - this.description = row.getString(3); - } - - long getId() { - return id; - } - - String getName() { - return name; - } - - public String getDescription() { - return description; - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroup.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroup.java deleted file mode 100644 index afe1bc5a517..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroup.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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 SetAllUsersIntoSonarUsersGroup extends DataChange { - - public SetAllUsersIntoSonarUsersGroup(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - long sonarUsersGroupId = selectSonarUsersGroup(context); - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("users"); - massUpdate.select("SELECT u.id FROM users u " + - "WHERE u.active=? AND NOT EXISTS " + - "(SELECT 1 FROM groups_users gu WHERE gu.user_id=u.id AND gu.group_id=?)") - .setBoolean(1, true) - .setLong(2, sonarUsersGroupId); - massUpdate.update("INSERT INTO groups_users (user_id, group_id) values (?, ?)"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - update.setLong(2, sonarUsersGroupId); - return true; - }); - } - - private static long selectSonarUsersGroup(Context context) throws SQLException { - return context.prepareSelect("SELECT id FROM groups WHERE name=?") - .setString(1, "sonar-users") - .get(row -> row.getLong(1)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViews.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViews.java deleted file mode 100644 index b3e235dd040..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViews.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -/** - * Set PROJECTS#COPY_COMPONENT_UUID on local views. - * - * Here's how local sub views are detected : - *
    - *
  • Load all root views
  • - *
  • Load all sub views not having COPY_COMPONENT_UUID set
  • - *
  • Extract last part of the sub view key and if it matches a root view key then set the COPY_COMPONENT_UUID to the matching root view uuid
  • - *
- */ -public class SetCopyComponentUuidOnLocalViews extends DataChange { - - private static final String QUALIFIER_SUB_VIEW = "SVW"; - private static final String QUALIFIER_VIEW = "VW"; - private static final String SCOPE_PROJECT = "PRJ"; - - public SetCopyComponentUuidOnLocalViews(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - Map rootUuidsByKeys = selectRootUuidsByKeys(context); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT p.kee, p.uuid FROM projects p " + - "WHERE p.qualifier = ? " + - "AND p.scope = ? " + - "AND p.copy_component_uuid IS NULL " + - "AND p.enabled = ? ") - .setString(1, QUALIFIER_SUB_VIEW) - .setString(2, SCOPE_PROJECT) - .setBoolean(3, true); - - massUpdate.update("UPDATE projects set " + - "copy_component_uuid=? " + - "WHERE uuid=?"); - massUpdate.execute((row, update) -> { - String subViewKey = row.getString(1); - int lastViewKeyIndex = subViewKey.lastIndexOf(':'); - if (lastViewKeyIndex < 0) { - return false; - } - String possibleRootViewUuid = subViewKey.substring(lastViewKeyIndex + 1); - String rootUuid = rootUuidsByKeys.get(possibleRootViewUuid); - if (rootUuid == null) { - return false; - } - update.setString(1, rootUuid); - update.setString(2, row.getString(2)); - return true; - }); - } - - private static Map selectRootUuidsByKeys(Context context) throws SQLException { - Map rootUuids = new HashMap<>(); - context.prepareSelect("SELECT p.kee, p.uuid FROM projects p " + - "WHERE p.qualifier = ? " + - "AND p.scope = ? " + - "AND p.enabled = ? ") - .setString(1, QUALIFIER_VIEW) - .setString(2, SCOPE_PROJECT) - .setBoolean(3, true) - .scroll(row -> { - String key = row.getString(1); - String uuid = row.getString(2); - rootUuids.put(key, uuid); - }); - return rootUuids; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalse.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalse.java deleted file mode 100644 index b2c78eff6b9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class SetNewProjectPrivateToFalse extends DataChange { - public SetNewProjectPrivateToFalse(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.prepareUpsert("update organizations set new_project_private=?") - .setBoolean(1, false) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroup.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroup.java deleted file mode 100644 index ccdfef403f8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroup.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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 SetOrganizationMembersIntoMembersGroup extends DataChange { - - private static final String MEMBERS_NAME = "Members"; - - public SetOrganizationMembersIntoMembersGroup(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("users not belonging to 'members' group"); - massUpdate.select("SELECT u.id, g.id FROM users u " + - "INNER JOIN organization_members om ON om.user_id=u.id " + - "INNER JOIN groups g ON g.organization_uuid=om.organization_uuid AND g.name=? " + - "WHERE u.active=? AND NOT EXISTS " + - "(SELECT 1 FROM groups_users gu " + - "INNER JOIN groups g on g.id=gu.group_id AND g.name=? " + - "WHERE gu.user_id=u.id)") - .setString(1, MEMBERS_NAME) - .setBoolean(2, true) - .setString(3, MEMBERS_NAME); - massUpdate.update("INSERT INTO groups_users (user_id, group_id) values (?, ?)"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(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/v64/SetQualityProfileOrganizationUuidToDefault.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefault.java deleted file mode 100644 index ff8b7ef084f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefault.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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.version.v63.DefaultOrganizationUuidProvider; - -public class SetQualityProfileOrganizationUuidToDefault extends DataChange { - - private final DefaultOrganizationUuidProvider defaultOrganizationUuid; - - public SetQualityProfileOrganizationUuidToDefault(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) { - super(db); - this.defaultOrganizationUuid = defaultOrganizationUuid; - } - - @Override - public void execute(Context context) throws SQLException { - context.prepareUpsert("update rules_profiles set organization_uuid=? where organization_uuid is null") - .setString(1, defaultOrganizationUuid.get(context)) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplate.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplate.java deleted file mode 100644 index 8955dc6433e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplate.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; - -import static com.google.common.base.Preconditions.checkState; - -public class SupportPrivateProjectInDefaultPermissionTemplate extends DataChange { - private static final String PERMISSION_USER = "user"; - private static final String PERMISSION_CODEVIEWER = "codeviewer"; - - private DefaultOrganizationUuidProvider defaultOrganizationUuidProvider; - - public SupportPrivateProjectInDefaultPermissionTemplate(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuidProvider) { - super(db); - this.defaultOrganizationUuidProvider = defaultOrganizationUuidProvider; - } - - @Override - protected void execute(Context context) throws SQLException { - String defaultOrganizationUuid = this.defaultOrganizationUuidProvider.get(context); - - ResolvedOrganizationProperties organizationProperties = readOrganizationProperties(context, defaultOrganizationUuid); - - int defaultGroupId = organizationProperties.defaultGroupId; - for (Integer groupId : Arrays.asList(organizationProperties.getProjectId(), organizationProperties.getViewId())) { - if (groupId != null) { - insertGroupPermissionIfNotPresent(context, defaultGroupId, groupId, PERMISSION_USER); - insertGroupPermissionIfNotPresent(context, defaultGroupId, groupId, PERMISSION_CODEVIEWER); - } - } - } - - private static void insertGroupPermissionIfNotPresent(Context context, int groupId, int templateId, String permission) throws SQLException { - if (!groupHasPermissionInTemplate(context, templateId, groupId, permission)) { - insertGroupPermission(context, templateId, groupId, permission); - } - } - - private static boolean groupHasPermissionInTemplate(Context context, int templateId, int groupId, String permission) throws SQLException { - List rows = context.prepareSelect("select 1 from perm_templates_groups where" + - " template_id = ?" + - " and group_id=?" + - " and permission_reference=?") - .setInt(1, templateId) - .setInt(2, groupId) - .setString(3, permission) - .list(row -> row.getInt(1)); - return !rows.isEmpty(); - } - - private static void insertGroupPermission(Context context, int templateId, int groupId, String permission) throws SQLException { - Date now = new Date(); - context.prepareUpsert("insert into perm_templates_groups (group_id, template_id, permission_reference, created_at, updated_at) values (?,?,?,?,?)") - .setInt(1, groupId) - .setInt(2, templateId) - .setString(3, permission) - .setDate(4, now) - .setDate(5, now) - .execute() - .commit(); - } - - private static ResolvedOrganizationProperties readOrganizationProperties(Context context, String defaultOrganizationUuid) throws SQLException { - Select select = context.prepareSelect("select default_group_id, default_perm_template_project, default_perm_template_view from organizations where uuid=?") - .setString(1, defaultOrganizationUuid); - List rows = select - .list(row -> new OrganizationProperties(row.getNullableInt(1), row.getNullableString(2), row.getNullableString(3))); - checkState(!rows.isEmpty(), "Default organization with uuid '%s' does not exist in table ORGANIZATIONS", defaultOrganizationUuid); - OrganizationProperties rawProperties = rows.iterator().next(); - checkState(rawProperties.defaultGroupId != null, "No default group id is defined for default organization (uuid=%s)", defaultOrganizationUuid); - checkState(rawProperties.projectUuid != null || rawProperties.viewUuid == null, - "Inconsistent state for default organization (uuid=%s): no project default template is defined but view default template is", defaultOrganizationUuid); - Integer projectTemplateId = getPermTemplateId(context, rawProperties.projectUuid); - Integer viewTemplateId = getViewTemplateIdOrClearReference(context, rawProperties.viewUuid, defaultOrganizationUuid); - return new ResolvedOrganizationProperties( - rawProperties.defaultGroupId, - projectTemplateId, - viewTemplateId); - } - - @CheckForNull - private static Integer getPermTemplateId(Context context, @Nullable String permissionTemplateUuid) throws SQLException { - if (permissionTemplateUuid == null) { - return null; - } - List ids = getTemplateIds(context, permissionTemplateUuid); - checkState(!ids.isEmpty(), "Permission template with uuid %s not found", permissionTemplateUuid); - checkState(ids.size() == 1, "Multiple permission templates found with uuid %s", permissionTemplateUuid); - return ids.iterator().next(); - } - - @CheckForNull - private static Integer getViewTemplateIdOrClearReference(Context context, @Nullable String permissionTemplateUuid, - String defaultOrganizationUuid) throws SQLException { - if (permissionTemplateUuid == null) { - return null; - } - List ids = getTemplateIds(context, permissionTemplateUuid); - if (ids.isEmpty()) { - clearViewTemplateReference(context, defaultOrganizationUuid); - return null; - } - checkState(ids.size() == 1, "Multiple permission templates found with uuid %s", permissionTemplateUuid); - return ids.iterator().next(); - } - - private static void clearViewTemplateReference(Context context, String defaultOrganizationUuid) throws SQLException { - context.prepareUpsert("update organizations set default_perm_template_view = null where uuid=?") - .setString(1, defaultOrganizationUuid) - .execute() - .commit(); - Loggers.get(SupportPrivateProjectInDefaultPermissionTemplate.class) - .info("Permission template with uuid %s referenced as default permission template for view does not exist. Reference cleared."); - } - - private static List getTemplateIds(Context context, @Nullable String permissionTemplateUuid) throws SQLException { - return context.prepareSelect("select id from permission_templates where kee=?") - .setString(1, permissionTemplateUuid) - .list(row -> row.getInt(1)); - } - - private static final class OrganizationProperties { - private final Integer defaultGroupId; - private final String projectUuid; - private final String viewUuid; - - private OrganizationProperties(@Nullable Integer defaultGroupId, @Nullable String projectUuid, @Nullable String viewUuid) { - this.defaultGroupId = defaultGroupId; - this.projectUuid = projectUuid; - this.viewUuid = viewUuid; - } - } - - private static final class ResolvedOrganizationProperties { - private final int defaultGroupId; - private final Integer projectId; - private final Integer viewId; - - private ResolvedOrganizationProperties(int defaultGroupId, @Nullable Integer projectId, @Nullable Integer viewId) { - this.defaultGroupId = defaultGroupId; - this.projectId = projectId; - this.viewId = viewId; - } - - int getDefaultGroupId() { - return defaultGroupId; - } - - Integer getProjectId() { - return projectId; - } - - @CheckForNull - - Integer getViewId() { - return viewId; - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplates.java deleted file mode 100644 index 45ff721dbe5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplates.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class SupportProjectVisibilityInTemplates extends DataChange { - public SupportProjectVisibilityInTemplates(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct template_id from perm_templates_groups" + - " where" + - " group_id is null" + - " and (permission_reference='user' or permission_reference='codeviewer')"); - massUpdate.update("delete from perm_templates_groups where" + - " template_id = ?" + - " and group_id is null" + - " and (permission_reference='user' or permission_reference='codeviewer')"); - massUpdate.rowPluralName("permission templates with useless permissions to group AnyOne"); - massUpdate.execute(SupportProjectVisibilityInTemplates::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - int templateId = row.getInt(1); - - update.setInt(1, templateId); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplates.java deleted file mode 100644 index 15485d6c84a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplates.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.security.MessageDigest; -import java.sql.SQLException; -import org.apache.commons.codec.digest.DigestUtils; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; - -import static java.lang.String.format; -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.commons.codec.binary.Hex.encodeHexString; - -public class UpgradeQualityTemplateLoadedTemplates extends DataChange { - private static final String QUALITY_PROFILE_TYPE = "QUALITY_PROFILE"; - - private final DefaultOrganizationUuidProvider defaultOrganizationUuid; - - public UpgradeQualityTemplateLoadedTemplates(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuid) { - super(db); - this.defaultOrganizationUuid = defaultOrganizationUuid; - } - - @Override - protected void execute(Context context) throws SQLException { - String defaultOrganizationUuid = this.defaultOrganizationUuid.getAndCheck(context); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate - .select("select id,kee from loaded_templates where template_type=?") - .setString(1, QUALITY_PROFILE_TYPE); - massUpdate.rowPluralName("loaded templates for quality profiles"); - massUpdate.update("update loaded_templates set template_type=?,kee=? where id=?"); - MessageDigest md5Digest = DigestUtils.getMd5Digest(); - massUpdate.execute((row, update) -> { - int id = row.getInt(1); - String key = row.getString(2); - - update.setString(1, computeLoadedTemplateType(key, md5Digest)); - update.setString(2, defaultOrganizationUuid); - update.setInt(3, id); - return true; - }); - } - - private static String computeLoadedTemplateType(String currentKey, MessageDigest messageDigest) { - return format("%s.%s", QUALITY_PROFILE_TYPE, encodeHexString(messageDigest.digest(currentKey.getBytes(UTF_8)))); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/package-info.java deleted file mode 100644 index ca4666543eb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v64/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v64; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfiles.java deleted file mode 100644 index baaa1534ec0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfiles.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddBuiltInFlagToRulesProfiles extends DdlChange { - - public AddBuiltInFlagToRulesProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "rules_profiles") - .addColumn(newBooleanColumnDefBuilder() - .setColumnName("is_built_in") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAt.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAt.java deleted file mode 100644 index 36c9401f968..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAt.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnEsQueueCreatedAt extends DdlChange { - - public AddIndexOnEsQueueCreatedAt(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - BigIntegerColumnDef column = BigIntegerColumnDef.newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - context.execute(new CreateIndexBuilder() - .setName("es_queue_created_at") - .setTable("es_queue") - .addColumn(column) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChanges.java deleted file mode 100644 index 5bb7864dfb7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChanges.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexRulesProfileUuidOnQProfileChanges extends DdlChange { - - private static final String TABLE_NAME = "qprofile_changes"; - private static final String COLUMN_NAME = "rules_profile_uuid"; - private static final String NEW_INDEX_NAME = "qp_changes_rules_profile_uuid"; - - public AddIndexRulesProfileUuidOnQProfileChanges(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef rulesProfileUuid = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName(COLUMN_NAME) - .setLimit(255) - .setIsNullable(false) - .build(); - - context.execute(new CreateIndexBuilder() - .setName(NEW_INDEX_NAME) - .setTable(TABLE_NAME) - .addColumn(rulesProfileUuid) - .build() - ); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboarded.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboarded.java deleted file mode 100644 index bf3463854e5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboarded.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddUsersOnboarded extends DdlChange { - public AddUsersOnboarded(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "users") - .addColumn(newBooleanColumnDefBuilder() - .setColumnName("onboarded") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRoles.java deleted file mode 100644 index e17883f221f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRoles.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class CleanOrphanRowsInGroupRoles extends DataChange { - public CleanOrphanRowsInGroupRoles(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - deleteRowsWithoutComponent(context); - deleteRowsForNonRootComponent(context); - } - - private static void deleteRowsWithoutComponent(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct gr.resource_id from group_roles gr where" + - " gr.resource_id is not null" + - " and not exists (select id from projects p where p.id = gr.resource_id)"); - massUpdate.rowPluralName("rows without component"); - massUpdate.update("delete from group_roles where resource_id = ?"); - massUpdate.execute(CleanOrphanRowsInGroupRoles::handle); - } - - private static void deleteRowsForNonRootComponent(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct gr.resource_id from group_roles gr" + - " inner join projects p on p.id = gr.resource_id" + - " where" + - " p.scope <> ?" + - " or (p.qualifier <> ? and p.qualifier <> ?)") - .setString(1, "PRJ") - .setString(2, "TRK") - .setString(3, "VW"); - massUpdate.rowPluralName("rows for non-root component"); - massUpdate.update("delete from group_roles where resource_id = ?"); - massUpdate.execute(CleanOrphanRowsInGroupRoles::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long resourceId = row.getLong(1); - - update.setLong(1, resourceId); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasures.java deleted file mode 100644 index b7eaf9ac72a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasures.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -/** - * Deletes rows from table MANUAL_MEASURES which: - *
    - *
  • has no component uuid
  • - *
  • or reference a non existing component
  • - *
  • or reference a disabled component
  • - *
  • or reference a component which is neither a project, nor a view, nor a module nor a subview
  • - *
- */ -public class CleanOrphanRowsInManualMeasures extends DataChange { - - private static final String SCOPE_PROJECT = "PRJ"; - private static final String QUALIFIER_PROJECT = "TRK"; - private static final String QUALIFIER_VIEW = "VW"; - private static final String QUALIFIER_MODULE = "BRC"; - private static final String QUALIFIER_SUBVIEW = "SVW"; - - public CleanOrphanRowsInManualMeasures(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " mm.id" + - " from manual_measures mm" + - " where" + - " mm.component_uuid is null" + - " or not exists (" + - " select" + - " 1" + - " from projects p" + - " where" + - " p.uuid = mm.component_uuid" + - " and p.scope = ?" + - " and p.qualifier in (?,?,?,?)" + - " and p.enabled = ?" + - " )") - .setString(1, SCOPE_PROJECT) - .setString(2, QUALIFIER_PROJECT) - .setString(3, QUALIFIER_VIEW) - .setString(4, QUALIFIER_MODULE) - .setString(5, QUALIFIER_SUBVIEW) - .setBoolean(6, true); - massUpdate.update("delete from manual_measures where id = ?"); - massUpdate.rowPluralName("orphan properties"); - massUpdate.execute(CleanOrphanRowsInManualMeasures::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - - update.setLong(1, id); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinks.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinks.java deleted file mode 100644 index 90a982fcca9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinks.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -/** - * Delete rows from table PROJECT_LINKS which either: - *
    - *
  • references a non existing component
  • - *
  • references a disabled component
  • - *
  • references a component which is neither a project nor a view
  • - *
- */ -public class CleanOrphanRowsInProjectLinks extends DataChange { - public CleanOrphanRowsInProjectLinks(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " pl.id" + - " from project_links pl" + - " where" + - " not exists (" + - " select" + - " 1" + - " from projects" + - " p" + - " where" + - " p.uuid = pl.component_uuid" + - " and p.scope = ?" + - " and p.qualifier in (?,?)" + - " and p.enabled = ?" + - " )") - .setString(1, "PRJ") - .setString(2, "TRK") - .setString(3, "VW") - .setBoolean(4, true); - massUpdate.update("delete from project_links where id = ?"); - massUpdate.rowPluralName("orphan project links"); - massUpdate.execute(CleanOrphanRowsInProjectLinks::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - - update.setLong(1, id); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProperties.java deleted file mode 100644 index da7d3e91ac2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProperties.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -/** - * Deletes from table PROPERTIES any row which has a non null resource_id and which either: - *
    - *
  • references to a non existing component
  • - *
  • or references to a disabled component
  • - *
  • or references a component which is neither a project, nor a view, nor a module nor a subview
  • - *
- */ -public class CleanOrphanRowsInProperties extends DataChange { - - private static final String SCOPE_PROJECT = "PRJ"; - private static final String QUALIFIER_PROJECT = "TRK"; - private static final String QUALIFIER_VIEW = "VW"; - private static final String QUALIFIER_MODULE = "BRC"; - private static final String QUALIFIER_SUBVIEW = "SVW"; - - public CleanOrphanRowsInProperties(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " s.id" + - " from properties s" + - " where" + - " s.resource_id is not null" + - " and not exists (" + - " select" + - " 1" + - " from projects p" + - " where" + - " p.id = s.resource_id" + - " and p.scope = ?" + - " and p.qualifier in (?,?,?,?)" + - " and p.enabled = ?" + - " )") - .setString(1, SCOPE_PROJECT) - .setString(2, QUALIFIER_PROJECT) - .setString(3, QUALIFIER_VIEW) - .setString(4, QUALIFIER_MODULE) - .setString(5, QUALIFIER_SUBVIEW) - .setBoolean(6, true); - massUpdate.update("delete from properties where id = ?"); - massUpdate.rowPluralName("orphan properties"); - massUpdate.execute(CleanOrphanRowsInProperties::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - - update.setLong(1, id); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRoles.java deleted file mode 100644 index efa3ebf1f76..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRoles.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class CleanOrphanRowsInUserRoles extends DataChange { - public CleanOrphanRowsInUserRoles(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - deleteRowsWithoutComponent(context); - deleteRowsForNonRootComponent(context); - } - - private static void deleteRowsWithoutComponent(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct ur.resource_id from user_roles ur where" + - " ur.resource_id is not null" + - " and not exists (select id from projects p where p.id = ur.resource_id)"); - massUpdate.rowPluralName("rows without component"); - massUpdate.update("delete from user_roles where resource_id = ?"); - massUpdate.execute(CleanOrphanRowsInUserRoles::handle); - } - - private static void deleteRowsForNonRootComponent(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct ur.resource_id from user_roles ur" + - " inner join projects p on p.id = ur.resource_id" + - " where" + - " p.scope <> ?" + - " or (p.qualifier <> ? and p.qualifier <> ?)") - .setString(1, "PRJ") - .setString(2, "TRK") - .setString(3, "VW"); - massUpdate.rowPluralName("rows for non-root component"); - massUpdate.update("delete from user_roles where resource_id = ?"); - massUpdate.execute(CleanOrphanRowsInUserRoles::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long resourceId = row.getLong(1); - - update.setLong(1, resourceId); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTable.java deleted file mode 100644 index 6d74aa3d0dc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTable.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class CreateEsQueueTable extends DdlChange { - - private static final String TABLE_NAME = "es_queue"; - - public CreateEsQueueTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(40) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("doc_type") - .setIsNullable(false) - .setLimit(40) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("doc_id") - .setIsNullable(false) - .setLimit(4000) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("doc_id_type") - .setIsNullable(true) - .setLimit(20) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("doc_routing") - .setIsNullable(true) - .setLimit(4000) - .build()) - .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .build() - ); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfiles.java deleted file mode 100644 index a9fa08e2ee3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfiles.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTableDefaultQProfiles extends DdlChange { - private static final int QUALITY_PROFILE_UUID_SIZE = 255; - - public CreateTableDefaultQProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef profileUuidColumn = newVarcharColumnDefBuilder() - .setColumnName("qprofile_uuid") - .setLimit(QUALITY_PROFILE_UUID_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - context.execute( - new CreateTableBuilder(getDialect(), "default_qprofiles") - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build()) - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("language") - .setLimit(20) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build()) - .addColumn(profileUuidColumn) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .build()); - - context.execute( - new CreateIndexBuilder() - .setTable("default_qprofiles") - .setName("uniq_default_qprofiles_uuid") - .addColumn(profileUuidColumn) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfiles.java deleted file mode 100644 index c3998fa31d5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfiles.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTableOrgQProfiles extends DdlChange { - - private static final String TABLE_NAME = "org_qprofiles"; - private static final int QUALITY_PROFILE_UUID_SIZE = 255; - - public CreateTableOrgQProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef organizationColumn = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - VarcharColumnDef rulesProfileUuid = newVarcharColumnDefBuilder() - .setColumnName("rules_profile_uuid") - .setLimit(QUALITY_PROFILE_UUID_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - context.execute( - new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setLimit(QUALITY_PROFILE_UUID_SIZE) - .setIsNullable(false) - .build()) - .addColumn(organizationColumn) - .addColumn(rulesProfileUuid) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("parent_uuid") - .setLimit(QUALITY_PROFILE_UUID_SIZE) - .setIsNullable(true) - .setIgnoreOracleUnit(true) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("last_used") - .setIsNullable(true) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("user_updated_at") - .setIsNullable(true) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .build()); - - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("qprofiles_org_uuid") - .addColumn(organizationColumn) - .build()); - - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("qprofiles_rp_uuid") - .addColumn(rulesProfileUuid) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java deleted file mode 100644 index 61cf60f838f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion65 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1700, "Drop table AUTHORS", DropTableAuthors.class) - .add(1701, "Clean orphans from USER_ROLES", CleanOrphanRowsInUserRoles.class) - .add(1702, "Clean orphans from GROUP_ROLES", CleanOrphanRowsInGroupRoles.class) - .add(1703, "Populate EVENTS.COMPONENT_UUID", PopulateEventsComponentUuid.class) - .add(1704, "Drop index EVENTS_COMPONENT_UUID", DropIndexEventsComponentUuid.class) - .add(1705, "Make EVENTS.COMPONENT_UUID not nullable", MakeEventsComponentUuidNotNullable.class) - .add(1706, "Recreate index EVENTS_COMPONENT_UUID", RecreateIndexEventsComponentUuid.class) - .add(1707, "Ensure ISSUE.PROJECT_UUID is consistent", EnsureIssueProjectUuidConsistencyOnIssues.class) - .add(1708, "Clean orphans from PROJECT_LINKS", CleanOrphanRowsInProjectLinks.class) - .add(1709, "Clean orphans from SETTINGS", CleanOrphanRowsInProperties.class) - .add(1710, "Clean orphans from MANUAL_MEASURES", CleanOrphanRowsInManualMeasures.class) - .add(1711, "Drop index MANUAL_MEASURES.COMPONENT_UUID", DropIndexManualMeasuresComponentUuid.class) - .add(1712, "Make MANUAL_MEASURES.COMPONENT_UUID not nullable", MakeManualMeasuresComponentUuidNotNullable.class) - .add(1713, "Recreate index MANUAL_MEASURES.COMPONENT_UUID", RecreateIndexManualMeasuresComponentUuid.class) - .add(1714, "Purge developer data", PurgeDeveloperData.class) - .add(1715, "Add rules_profiles.is_built_in", AddBuiltInFlagToRulesProfiles.class) - .add(1716, "Set rules_profiles.is_built_in to false", SetRulesProfilesIsBuiltInToFalse.class) - .add(1717, "Make rules_profiles.is_built_in not null", MakeRulesProfilesIsBuiltInNotNullable.class) - .add(1718, "Delete unused loaded_templates on quality profiles", DeleteLoadedTemplatesOnQProfiles.class) - .add(1719, "Create table default_qprofiles", CreateTableDefaultQProfiles.class) - .add(1720, "Populate table default_qprofiles", PopulateTableDefaultQProfiles.class) - .add(1721, "Drop rules_profiles.is_default", DropIsDefaultColumnFromRulesProfiles.class) - .add(1722, "Create table qprofiles", CreateTableOrgQProfiles.class) - .add(1723, "Populate table qprofiles", PopulateOrgQProfiles.class) - .add(1724, "Drop columns organization_uuid and parent_kee from rules_profiles", DropOrgColumnsFromRulesProfiles.class) - .add(1725, "Mark rules_profiles.is_built_in to true for default organization", SetRulesProfilesIsBuiltInToTrueForDefaultOrganization.class) - .add(1726, "Update org_qprofiles to reference built-in profiles", UpdateOrgQProfilesToPointToBuiltInProfiles.class) - .add(1727, "Delete rules_profiles orphans", DeleteOrphansFromRulesProfiles.class) - .add(1728, "Rename column qprofile_changes.qprofile_key to qprofile_changes.rules_profile_uuid", RenameQProfileKeyToRulesProfileUuidOnQProfileChanges.class) - .add(1729, "Add index on qprofile_changes.rules_profile_uuid", AddIndexRulesProfileUuidOnQProfileChanges.class) - .add(1730, "Add USERS.ONBOARDED", AddUsersOnboarded.class) - .add(1731, "Populate USERS.ONBOARDED", PopulateUsersOnboarded.class) - .add(1732, "Make USERS.ONBOARDED not nullable", MakeUsersOnboardedNotNullable.class) - .add(1733, "Create table es_queue", CreateEsQueueTable.class) - .add(1734, "Add index on es_queue.created_at", AddIndexOnEsQueueCreatedAt.class) - .add(1735, "Delete sonar.ce.workerCount setting", DeleteCeWorkerCountSetting.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSetting.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSetting.java deleted file mode 100644 index 21e1f3c3de2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSetting.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class DeleteCeWorkerCountSetting extends DataChange { - public DeleteCeWorkerCountSetting(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("delete from properties where prop_key=?") - .setString(1, "sonar.ce.workerCount") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfiles.java deleted file mode 100644 index 41c79e685b8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfiles.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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 DeleteLoadedTemplatesOnQProfiles extends DataChange { - - public DeleteLoadedTemplatesOnQProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from loaded_templates where template_type like 'QUALITY_PROFILE.%'"); - massUpdate.rowPluralName("loaded_templates"); - massUpdate.update("delete from loaded_templates where id=?"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfiles.java deleted file mode 100644 index 8503d03023c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfiles.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class DeleteOrphansFromRulesProfiles extends DataChange { - - private static final Logger LOG = Loggers.get(DeleteOrphansFromRulesProfiles.class); - - public DeleteOrphansFromRulesProfiles(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - execute(context, "rules_profiles", "delete from rules_profiles where not exists( select 1 from org_qprofiles oqp where oqp.rules_profile_uuid = kee)"); - execute(context, "active_rules", "delete from active_rules where not exists ( select 1 from rules_profiles rp where rp.id = profile_id)"); - execute(context, "active_rule_parameters", "delete from active_rule_parameters where not exists ( select 1 from active_rules ar where ar.id = active_rule_id)"); - execute(context, "qprofile_changes", "delete from qprofile_changes where not exists ( select 1 from rules_profiles rp where rp.kee = qprofile_key)"); - } - - private static void execute(Context context, String tableName, String sql) throws SQLException { - LOG.info("Deleting orphans from " + tableName); - context - .prepareUpsert(sql) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuid.java deleted file mode 100644 index adb37115847..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuid.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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 DropIndexEventsComponentUuid extends DdlChange { - - public DropIndexEventsComponentUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("events") - .setName("events_component_uuid") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuid.java deleted file mode 100644 index cb472c9953e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuid.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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 DropIndexManualMeasuresComponentUuid extends DdlChange { - - public DropIndexManualMeasuresComponentUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("manual_measures") - .setName("manual_measures_component_uuid") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfiles.java deleted file mode 100644 index c764db60eb6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfiles.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.lang.String.format; - -public class DropIsDefaultColumnFromRulesProfiles extends DdlChange { - - private static final String TABLE_NAME = "rules_profiles"; - private static final String COLUMN_NAME = "is_default"; - - public DropIsDefaultColumnFromRulesProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (getDialect().getId().equals(MsSql.ID)) { - // this should be handled automatically by DropColumnsBuilder - dropMssqlConstraints(); - } - - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, COLUMN_NAME).build()); - } - - private void dropMssqlConstraints() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection(); - PreparedStatement pstmt = connection - .prepareStatement(format("SELECT d.name " + - "FROM sys.default_constraints d " + - "INNER JOIN sys.columns AS c ON d.parent_column_id = c.column_id " + - "WHERE OBJECT_NAME(d.parent_object_id)='%s' AND c.name='%s'", TABLE_NAME, COLUMN_NAME)); - ResultSet rs = pstmt.executeQuery()) { - while (rs.next()) { - String constraintName = rs.getString(1); - dropMssqlConstraint(connection, constraintName); - } - } - } - - private static void dropMssqlConstraint(Connection connection, String constraintName) throws SQLException { - try (Statement stmt = connection.createStatement()) { - stmt.executeUpdate(format("ALTER TABLE %s DROP CONSTRAINT %s", TABLE_NAME, constraintName)); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfiles.java deleted file mode 100644 index e6e31233e5e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfiles.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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 DropOrgColumnsFromRulesProfiles extends DdlChange { - - private static final String TABLE_NAME = "rules_profiles"; - - public DropOrgColumnsFromRulesProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "parent_kee").build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "last_used").build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "user_updated_at").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropTableAuthors.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropTableAuthors.java deleted file mode 100644 index de6f91d50d0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DropTableAuthors.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTableAuthors extends DdlChange { - public DropTableAuthors(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()).setTable("authors").setName("uniq_author_logins").build()); - context.execute(new DropTableBuilder(getDialect(), "authors").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssues.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssues.java deleted file mode 100644 index f0483688989..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssues.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class EnsureIssueProjectUuidConsistencyOnIssues extends DataChange { - public EnsureIssueProjectUuidConsistencyOnIssues(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " i.id, p.project_uuid" + - " from issues i" + - " inner join projects p on" + - " p.uuid = i.component_uuid" + - " and i.project_uuid <> p.project_uuid"); - massUpdate.update("update issues set project_uuid = ? where id = ?"); - massUpdate.rowPluralName("issues with inconsistent project_uuid"); - massUpdate.execute(EnsureIssueProjectUuidConsistencyOnIssues::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long issueId = row.getLong(1); - String projectUuid = row.getString(2); - - update.setString(1, projectUuid); - update.setLong(2, issueId); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullable.java deleted file mode 100644 index f51639e6263..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullable.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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 MakeEventsComponentUuidNotNullable extends DdlChange { - - public MakeEventsComponentUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "events") - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullable.java deleted file mode 100644 index ece5426070f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullable.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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 MakeManualMeasuresComponentUuidNotNullable extends DdlChange { - - public MakeManualMeasuresComponentUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "manual_measures") - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullable.java deleted file mode 100644 index 56111ec8116..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullable.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class MakeRulesProfilesIsBuiltInNotNullable extends DdlChange { - - public MakeRulesProfilesIsBuiltInNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - BooleanColumnDef column = newBooleanColumnDefBuilder() - .setColumnName("is_built_in") - .setIsNullable(false) - .build(); - - context.execute(new AlterColumnsBuilder(getDialect(), "rules_profiles") - .updateColumn(column) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullable.java deleted file mode 100644 index d1a6273f04c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullable.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class MakeUsersOnboardedNotNullable extends DdlChange { - - public MakeUsersOnboardedNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - BooleanColumnDef column = newBooleanColumnDefBuilder() - .setColumnName("onboarded") - .setIsNullable(false) - .build(); - context.execute(new AlterColumnsBuilder(getDialect(), "users") - .updateColumn(column) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuid.java deleted file mode 100644 index 9e2c7d7b057..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuid.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class PopulateEventsComponentUuid extends DataChange { - public PopulateEventsComponentUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - populateColumnOrFixInconsistencies(context); - - deleteOrphans(context); - } - - private static void populateColumnOrFixInconsistencies(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " e.id, s.component_uuid" + - " from events e" + - " inner join snapshots s on" + - " s.uuid = e.analysis_uuid" + - " where" + - " e.component_uuid is null" + - " or e.component_uuid <> s.uuid"); - massUpdate.update("update events set component_uuid = ? where id = ?"); - massUpdate.rowPluralName("events without component_uuid"); - massUpdate.execute(PopulateEventsComponentUuid::handlePopulate); - } - - private static boolean handlePopulate(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - String projectUuid = row.getString(2); - - update.setString(1, projectUuid); - update.setLong(2, id); - - return true; - } - - private static void deleteOrphans(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from events e where" + - " e.component_uuid is null" + - " or not exists (select id from snapshots s where s.uuid = e.analysis_uuid)"); - massUpdate.update("delete from events where id = ?"); - massUpdate.rowPluralName("delete orphan events"); - massUpdate.execute(PopulateEventsComponentUuid::handleDelete); - } - - private static boolean handleDelete(Select.Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); - - update.setLong(1, id); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfiles.java deleted file mode 100644 index e18edac2283..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfiles.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -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 PopulateOrgQProfiles extends DataChange { - - private final System2 system2; - - public PopulateOrgQProfiles(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select p.kee, p.organization_uuid, p.parent_kee, p.last_used, p.user_updated_at from rules_profiles p " + - "where not exists ( select qp.uuid from org_qprofiles qp where qp.uuid = p.kee and qp.organization_uuid = p.organization_uuid )"); - massUpdate.update("insert into org_qprofiles" + - " (uuid, organization_uuid, rules_profile_uuid, parent_uuid, last_used, user_updated_at, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?, ?)"); - massUpdate.rowPluralName("org_qprofiles"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - String organizationUuid = row.getString(2); - String parentUuid = row.getString(3); - Long lastUsed = row.getNullableLong(4); - Long userUpdatedAt = row.getNullableLong(5); - - update.setString(1, uuid); - update.setString(2, organizationUuid); - update.setString(3, uuid); - update.setString(4, parentUuid); - update.setLong(5, lastUsed); - update.setLong(6, userUpdatedAt); - update.setLong(7, now); - update.setLong(8, now); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfiles.java deleted file mode 100644 index f6fae44f30f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfiles.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.HashSet; -import java.util.Set; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; - -/** - * Move the list of profiles marked as "default" from rules_profiles.is_default - * to the table default_qprofiles. - */ -public class PopulateTableDefaultQProfiles extends DataChange { - - private final System2 system2; - - public PopulateTableDefaultQProfiles(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - Set buggyOrgs = selectOrgsWithMultipleDefaultProfiles(context); - Set processedBuggyOrgs = new HashSet<>(); - long now = system2.now(); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select p.organization_uuid, p.language, p.kee from rules_profiles p " + - " where p.is_default = ? " + - " and not exists (select 1 from default_qprofiles dp where dp.organization_uuid = p.organization_uuid and dp.language = p.language)" + - " order by id") - .setBoolean(1, true); - massUpdate.update("insert into default_qprofiles" + - " (organization_uuid, language, qprofile_uuid, created_at, updated_at) values (?, ?, ?, ?, ?)"); - massUpdate.rowPluralName("default_qprofiles"); - massUpdate.execute((row, update) -> { - OrgLang pk = new OrgLang(row.getString(1), row.getString(2)); - String profileUuid = row.getString(3); - - boolean isBuggy = buggyOrgs.contains(pk); - if (isBuggy && processedBuggyOrgs.contains(pk)) { - // profile is ignored. There's already one marked as default. - return false; - } - update.setString(1, pk.orgUuid); - update.setString(2, pk.language); - update.setString(3, profileUuid); - update.setLong(4, now); - update.setLong(5, now); - if (isBuggy) { - processedBuggyOrgs.add(pk); - } - return true; - }); - } - - /** - * By design the table rules_profiles does not enforce to have a single - * profile marked as default for an organization and language. - * This method returns the buggy rows. - */ - private static Set selectOrgsWithMultipleDefaultProfiles(Context context) throws SQLException { - Select rows = context.prepareSelect("select organization_uuid, language from rules_profiles " + - " where is_default = ? " + - " group by organization_uuid, language " + - " having count(kee) > 1 ") - .setBoolean(1, true); - return new HashSet<>(rows.list(row -> new OrgLang(row.getString(1), row.getString(2)))); - } - - private static class OrgLang { - private final String orgUuid; - private final String language; - - private OrgLang(String orgUuid, String language) { - this.orgUuid = orgUuid; - this.language = language; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - OrgLang orgLang = (OrgLang) o; - if (!orgUuid.equals(orgLang.orgUuid)) { - return false; - } - return language.equals(orgLang.language); - } - - @Override - public int hashCode() { - int result = orgUuid.hashCode(); - result = 31 * result + language.hashCode(); - return result; - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboarded.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboarded.java deleted file mode 100644 index 0120cef7707..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboarded.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateUsersOnboarded extends DataChange { - - private final System2 system2; - - public PopulateUsersOnboarded(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - context.prepareUpsert("update users set onboarded=?, updated_at=?") - .setBoolean(1, true) - .setLong(2, system2.now()) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperData.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperData.java deleted file mode 100644 index 33bc1ff88a1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperData.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class PurgeDeveloperData extends DataChange { - public PurgeDeveloperData(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - purgeProjectCopies(context); - - purgeDevelopers(context); - } - - private void purgeProjectCopies(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " child.id, child.uuid" + - " from projects child" + - " inner join projects root on" + - " root.uuid = child.project_uuid" + - " and root.scope=?" + - " and root.qualifier=?" + - " where" + - " child.uuid <> child.project_uuid") - .setString(1, "PRJ") - .setString(2, "DEV"); - massUpdate.rowPluralName("purged project copies"); - massUpdate.update("delete from project_measures where component_uuid=?"); - massUpdate.update("delete from projects where uuid=?"); - massUpdate.execute(PurgeDeveloperData::handlePurgeProjectCopies); - } - - private static boolean handlePurgeProjectCopies(Select.Row row, SqlStatement update, int updateIndex) throws SQLException { - if (updateIndex < 0 || updateIndex > 1) { - throw new IllegalArgumentException("Unsupported updateIndex " + updateIndex); - } - String uuid = row.getString(2); - update.setString(1, uuid); - return true; - } - - private void purgeDevelopers(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " id, uuid" + - " from projects" + - " where" + - " scope=?" + - " and qualifier=?") - .setString(1, "PRJ") - .setString(2, "DEV"); - massUpdate.update("delete from project_measures where component_uuid=?"); - massUpdate.update("delete from ce_activity where component_uuid=?"); - massUpdate.update("delete from snapshots where component_uuid=?"); - massUpdate.update("delete from group_roles where resource_id=?"); - massUpdate.update("delete from user_roles where resource_id=?"); - massUpdate.update("delete from projects where project_uuid=?"); - massUpdate.rowPluralName("purged developers"); - massUpdate.execute(PurgeDeveloperData::handlePurgeDevelopers); - } - - private static boolean handlePurgeDevelopers(Select.Row row, SqlStatement update, int updateIndex) throws SQLException { - long id = row.getLong(1); - String uuid = row.getString(2); - switch (updateIndex) { - case 0: - case 1: - case 2: - update.setString(1, uuid); - return true; - case 3: - case 4: - update.setLong(1, id); - return true; - case 5: - update.setString(1, uuid); - return true; - default: - throw new IllegalArgumentException("Unsupported updateIndex " + updateIndex); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuid.java deleted file mode 100644 index 7f0cb6f23cc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RecreateIndexEventsComponentUuid extends DdlChange { - - public RecreateIndexEventsComponentUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("events") - .setName("events_component_uuid") - .setUnique(false) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuid.java deleted file mode 100644 index 5ef0672dc95..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RecreateIndexManualMeasuresComponentUuid extends DdlChange { - - public RecreateIndexManualMeasuresComponentUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("manual_measures") - .setName("manual_measures_component_uuid") - .setUnique(false) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChanges.java deleted file mode 100644 index 431a784e0ad..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChanges.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class RenameQProfileKeyToRulesProfileUuidOnQProfileChanges extends DdlChange { - - private static final String TABLE_NAME = "qprofile_changes"; - private static final String OLD_COLUMN = "qprofile_key"; - private static final String NEW_COLUMN = "rules_profile_uuid"; - - public RenameQProfileKeyToRulesProfileUuidOnQProfileChanges(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef newColumn = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName(NEW_COLUMN) - .setLimit(255) - .setIsNullable(false) - .build(); - - context.execute( - new RenameColumnsBuilder(getDialect(), TABLE_NAME) - .renameColumn(OLD_COLUMN, newColumn) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalse.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalse.java deleted file mode 100644 index 0d84f1eb724..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalse.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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 SetRulesProfilesIsBuiltInToFalse extends DataChange { - - public SetRulesProfilesIsBuiltInToFalse(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from rules_profiles where is_built_in is null"); - massUpdate.rowPluralName("rules_profiles"); - massUpdate.update("update rules_profiles set is_built_in=? where id=?"); - massUpdate.execute((row, update) -> { - update.setBoolean(1, false); - 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/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganization.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganization.java deleted file mode 100644 index 4a57637654f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganization.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -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; - -import static com.google.common.base.Preconditions.checkState; - -public class SetRulesProfilesIsBuiltInToTrueForDefaultOrganization extends DataChange { - private static final String PROP_DEFAULT_ORGANIZATION_UUID = "organization.default"; - private static final String PROP_ORGANIZATION_ENABLED = "organization.enabled"; - - public SetRulesProfilesIsBuiltInToTrueForDefaultOrganization(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - if (!isOrganizationEnabled(context)) { - return; - } - - String defaultOrganizationUuid = getDefaultOrganizationUuid(context); - checkState(defaultOrganizationUuid!=null, "Missing internal property: '%s'", PROP_DEFAULT_ORGANIZATION_UUID); - - MassUpdate massUpdate = context.prepareMassUpdate() - .rowPluralName("rules profiles"); - massUpdate.select("select rp.kee " + - "from rules_profiles rp " + - "inner join org_qprofiles oqp on rp.kee = oqp.rules_profile_uuid " + - "where oqp.organization_uuid = ? ") - .setString(1, defaultOrganizationUuid); - massUpdate.update("update rules_profiles " + - "set is_built_in=? " + - "where kee=?"); - massUpdate.execute((row, update) -> { - String rulesProfilesUuid = row.getString(1); - update.setBoolean(1, true); - update.setString(2, rulesProfilesUuid); - return true; - }); - } - - private static String getDefaultOrganizationUuid(Context context) throws SQLException { - return context.prepareSelect("select text_value from internal_properties where kee=?") - .setString(1, PROP_DEFAULT_ORGANIZATION_UUID) - .get(row -> row.getString(1)); - } - - private static boolean isOrganizationEnabled(Context context) throws SQLException { - String value = context.prepareSelect("select text_value from internal_properties where kee=?") - .setString(1, PROP_ORGANIZATION_ENABLED) - .get(row -> row.getNullableString(1)); - - return "true".equals(value); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfiles.java deleted file mode 100644 index 107853e8356..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfiles.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Table; -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; - -import static com.google.common.base.Preconditions.checkState; - -public class UpdateOrgQProfilesToPointToBuiltInProfiles extends DataChange { - private static final String PROP_DEFAULT_ORGANIZATION_UUID = "organization.default"; - private static final String PROP_ORGANIZATION_ENABLED = "organization.enabled"; - - public UpdateOrgQProfilesToPointToBuiltInProfiles(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - if (!isOrganizationEnabled(context)) { - return; - } - - String defaultOrganizationUuid = getDefaultOrganizationUuid(context); - BuiltInRulesProfiles builtInRulesProfiles = retrieveBuiltInRulesProfiles(context); - - MassUpdate massUpdate = context.prepareMassUpdate() - .rowPluralName("org qprofiles"); - - massUpdate.select("select oqp.uuid, rp.language, rp.name " + - " from org_qprofiles oqp " + - " inner join rules_profiles rp on rp.kee = oqp.rules_profile_uuid " + - " where oqp.organization_uuid <> ? " + - " and rp.is_built_in = ? " + - " and oqp.user_updated_at is null") - .setString(1, defaultOrganizationUuid) - .setBoolean(2, false); - - massUpdate.update("update org_qprofiles " + - "set rules_profile_uuid = ? " + - "where uuid=?"); - - massUpdate.execute((row, update) -> { - String orgQProfileUuid = row.getString(1); - String language = row.getString(2); - String name = row.getString(3); - if (!builtInRulesProfiles.contains(name, language)) { - return false; - } - - update.setString(1, builtInRulesProfiles.get(name, language)); - update.setString(2, orgQProfileUuid); - return true; - }); - } - - private static String getDefaultOrganizationUuid(Context context) throws SQLException { - String defaultOrganizationUuid = context.prepareSelect("select text_value from internal_properties where kee=?") - .setString(1, PROP_DEFAULT_ORGANIZATION_UUID) - .get(row -> row.getString(1)); - - checkState(defaultOrganizationUuid != null, "Missing internal property: '%s'", PROP_DEFAULT_ORGANIZATION_UUID); - - return defaultOrganizationUuid; - } - - private static boolean isOrganizationEnabled(Context context) throws SQLException { - String value = context.prepareSelect("select text_value from internal_properties where kee=?") - .setString(1, PROP_ORGANIZATION_ENABLED) - .get(row -> row.getNullableString(1)); - - return "true".equals(value); - } - - private static BuiltInRulesProfiles retrieveBuiltInRulesProfiles(Context context) throws SQLException { - BuiltInRulesProfiles result = new BuiltInRulesProfiles(); - - context.prepareSelect("select name, language, kee" + - " from rules_profiles " + - " where is_built_in = ? ") - .setBoolean(1, true) - .list(row -> result.put(row.getString(1), row.getString(2), row.getString(3))); - - return result; - } - - private static class BuiltInRulesProfiles { - private Table table = HashBasedTable.create(); - - private String put(String name, String language, String rulesProfileUuid) { - return table.put(name, language, rulesProfileUuid); - } - - private boolean contains(String name, String language) { - return table.contains(name, language); - } - - private String get(String name, String language) { - return table.get(name, language); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/package-info.java deleted file mode 100644 index 7d3f43d407c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v65; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddBranchColumnToProjectsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddBranchColumnToProjectsTable.java deleted file mode 100644 index 4cbc35625fe..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddBranchColumnToProjectsTable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -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; - -public class AddBranchColumnToProjectsTable extends DdlChange { - - public AddBranchColumnToProjectsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "projects") - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("main_branch_project_uuid") - .setLimit(50) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTable.java deleted file mode 100644 index 89f18a32ac0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -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; - -public class AddErrorTypeColumnToCeActivityTable extends DdlChange { - - public AddErrorTypeColumnToCeActivityTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "ce_activity") - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("error_type") - .setLimit(20) - .setIsNullable(true) - .build()) - .build()); - } -} - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddIndexOnProjectBranchesKey.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddIndexOnProjectBranchesKey.java deleted file mode 100644 index a4dee131644..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddIndexOnProjectBranchesKey.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnProjectBranchesKey extends DdlChange { - public AddIndexOnProjectBranchesKey(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateIndexBuilder() - .setTable("project_branches") - .setName("project_branches_kee") - .setUnique(true) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(50) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(255) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRules.java deleted file mode 100644 index bfe1921359e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRules.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddPluginKeyToRules extends DdlChange { - - public AddPluginKeyToRules(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "rules") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("plugin_key") - .setLimit(CreateTablePlugins.PLUGIN_KEY_MAX_SIZE) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristics.java deleted file mode 100644 index 0ee0110fad2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristics.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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 CreateTableCeTaskCharacteristics extends DdlChange { - private static final String TABLE_NAME = "ce_task_characteristics"; - - public CreateTableCeTaskCharacteristics(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef uuidColumn = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - VarcharColumnDef ceTaskUuidColumn = newVarcharColumnDefBuilder() - .setColumnName("task_uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - VarcharColumnDef keyColumn = newVarcharColumnDefBuilder() - .setColumnName("kee") - .setLimit(512) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build(); - VarcharColumnDef valueColumn = newVarcharColumnDefBuilder() - .setColumnName("text_value") - .setLimit(512) - .setIsNullable(true) - .setIgnoreOracleUnit(true) - .build(); - - context.execute( - new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(uuidColumn) - .addColumn(ceTaskUuidColumn) - .addColumn(keyColumn) - .addColumn(valueColumn) - .build()); - - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("ce_characteristics_" + ceTaskUuidColumn.getName()) - .addColumn(ceTaskUuidColumn) - .setUnique(false) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTablePlugins.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTablePlugins.java deleted file mode 100644 index 8d01c12442c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTablePlugins.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTablePlugins extends DdlChange { - - static final int PLUGIN_KEY_MAX_SIZE = 200; - private static final String TABLE_NAME = "plugins"; - - public CreateTablePlugins(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef keyColumn = newVarcharColumnDefBuilder() - .setColumnName("kee") - .setLimit(PLUGIN_KEY_MAX_SIZE) - .setIsNullable(false) - .build(); - context.execute( - new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) - .addColumn(keyColumn) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("base_plugin_key") - .setLimit(PLUGIN_KEY_MAX_SIZE) - .setIsNullable(true) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("file_hash") - .setLimit(200) - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .build()); - - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("plugins_key") - .addColumn(keyColumn) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranches.java deleted file mode 100644 index 811659f8014..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranches.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -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.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class CreateTableProjectBranches extends DdlChange { - - private static final String TABLE_NAME = "project_branches"; - - public CreateTableProjectBranches(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(50) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(50) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(255) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("branch_type") - .setIsNullable(true) - .setLimit(5) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("merge_branch_uuid") - .setIsNullable(true) - .setLimit(50) - .build()) - .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .build() - ); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroups.java deleted file mode 100644 index 343b5503089..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroups.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; - -public class CreateTableQProfileEditGroups extends DdlChange { - - private static final String TABLE_NAME = "qprofile_edit_groups"; - - public CreateTableQProfileEditGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - IntegerColumnDef groupColumn = IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("group_id") - .setIsNullable(false) - .build(); - VarcharColumnDef qProfileUuidColumn = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("qprofile_uuid") - .setIsNullable(false) - .setLimit(255) - .build(); - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(40) - .build()) - .addColumn(groupColumn) - .addColumn(qProfileUuidColumn) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .build() - ); - - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_qprofile") - .addColumn(qProfileUuidColumn) - .setUnique(false) - .build()); - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_unique") - .addColumn(groupColumn) - .addColumn(qProfileUuidColumn) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsers.java deleted file mode 100644 index e4a30279042..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsers.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; - -public class CreateTableQProfileEditUsers extends DdlChange { - - private static final String TABLE_NAME = "qprofile_edit_users"; - - public CreateTableQProfileEditUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - IntegerColumnDef userLoginColumn = IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("user_id") - .setIsNullable(false) - .build(); - VarcharColumnDef qProfileUuidColumn = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("qprofile_uuid") - .setIsNullable(false) - .setLimit(255) - .build(); - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(40) - .build()) - .addColumn(userLoginColumn) - .addColumn(qProfileUuidColumn) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .build() - ); - - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_qprofile") - .addColumn(qProfileUuidColumn) - .setUnique(false) - .build()); - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_unique") - .addColumn(userLoginColumn) - .addColumn(qProfileUuidColumn) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java deleted file mode 100644 index 4fc07e12a55..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion66 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1801, "Create table CE task characteristics", CreateTableCeTaskCharacteristics.class) - .add(1802, "Delete leak settings on views", DeleteLeakSettingsOnViews.class) - .add(1803, "Fix empty USERS.EXTERNAL_IDENTITY and USERS.EXTERNAL_IDENTITY_PROVIDER", FixEmptyIdentityProviderInUsers.class) - .add(1804, "Add rules.plugin_key", AddPluginKeyToRules.class) - .add(1805, "Create table plugins", CreateTablePlugins.class) - .add(1806, "Create table project_branches", CreateTableProjectBranches.class) - .add(1807, "Add on project_branches key", AddIndexOnProjectBranchesKey.class) - .add(1808, "Add branch column to projects table", AddBranchColumnToProjectsTable.class) - .add(1809, "Populate project_branches with existing main branches", PopulateMainProjectBranches.class) - .add(1810, "Add ce_activity.error_type", AddErrorTypeColumnToCeActivityTable.class) - .add(1811, "Create table qprofile_edit_users", CreateTableQProfileEditUsers.class) - .add(1812, "Create table qprofile_edit_groups", CreateTableQProfileEditGroups.class) - .add(1814, "Purge table properties", PurgeTableProperties.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViews.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViews.java deleted file mode 100644 index 6b4bacfd3d9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViews.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -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 DeleteLeakSettingsOnViews extends DataChange { - - public DeleteLeakSettingsOnViews(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT prop.id FROM properties prop " + - "INNER JOIN projects p ON p.id=prop.resource_id AND p.qualifier NOT IN ('TRK') " + - "WHERE prop.prop_key='sonar.leak.period' or prop.prop_key='sonar.timemachine.period1' "); - massUpdate.update("DELETE FROM properties WHERE id=?"); - massUpdate.rowPluralName("properties"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsers.java deleted file mode 100644 index 0d369869044..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsers.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -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 FixEmptyIdentityProviderInUsers extends DataChange { - - private static final String SQ_AUTHORITY = "sonarqube"; - - private final System2 system2; - - public FixEmptyIdentityProviderInUsers(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select u.id, u.login from users u " + - "where u.external_identity is null or u.external_identity_provider is null"); - massUpdate.update("update users set external_identity = ?, external_identity_provider = ?, updated_at = ? where id = ?"); - massUpdate.rowPluralName("users without external identity information"); - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, SQ_AUTHORITY); - update.setLong(3, now); - update.setLong(4, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranches.java deleted file mode 100644 index 7f4df2982ee..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranches.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -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 PopulateMainProjectBranches extends DataChange { - - private static final String MAIN_BRANCH_NAME = "master"; - - private final System2 system2; - - public PopulateMainProjectBranches(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT uuid FROM projects p " - + "WHERE p.scope='PRJ' AND p.qualifier='TRK' AND p.main_branch_project_uuid IS NULL " - + "AND NOT EXISTS (SELECT uuid FROM project_branches b WHERE b.uuid = p.uuid)"); - massUpdate.update("INSERT INTO project_branches (uuid, project_uuid, kee, branch_type, " - + "merge_branch_uuid, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)"); - massUpdate.rowPluralName("projects"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - update.setString(1, uuid); - update.setString(2, uuid); - update.setString(3, MAIN_BRANCH_NAME); - update.setString(4, "LONG"); - update.setString(5, null); - update.setLong(6, now); - update.setLong(7, now); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PurgeTableProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PurgeTableProperties.java deleted file mode 100644 index 94330a912ec..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PurgeTableProperties.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PurgeTableProperties extends DataChange { - - public PurgeTableProperties(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - deleteByKey(context, "views.analysisDelayingInMinutes"); - deleteByKey(context, "views.status"); - deleteByKeyPrefix(context, "sonar.views.license"); - deleteByKeyPrefix(context, "views.license"); - deleteByKeyPrefix(context, "masterproject."); - - deleteByKeyPrefix(context, "sonar.sqale."); - deleteByKeyPrefix(context, "sqale.license"); - deleteByKeyPrefix(context, "devcockpit."); - deleteByKeyPrefix(context, "sonar.devcockpit."); - - deleteByKey(context, "sonar.core.version"); - deleteByKey(context, "sonar.issuesdensity.weight"); - deleteByKeyPrefix(context, "sonar.reports."); - deleteByKeyPrefix(context, "sonar.report.license"); - deleteByKeyPrefix(context, "sonar.natural."); - deleteByKeyPrefix(context, "sonarsource.natural."); - deleteByKeyPrefix(context, "sonarsource.identity."); - deleteByKeyPrefix(context, "sonar.build-stability."); - } - - private static void deleteByKey(Context context, String key) throws SQLException { - context.prepareUpsert("delete from properties where prop_key = ?") - .setString(1, key) - .execute() - .commit(); - } - - private static void deleteByKeyPrefix(Context context, String key) throws SQLException { - context.prepareUpsert("delete from properties where prop_key like ?") - .setString(1, key + "%") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/package-info.java deleted file mode 100644 index 51d633b960a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v66; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveries.java deleted file mode 100644 index d0e98d93799..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveries.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -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; - -public class AddAnalysisUuidToWebhookDeliveries extends DdlChange { - - public static final String TABLE = "webhook_deliveries"; - - public static final VarcharColumnDef ANALYSIS_UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("analysis_uuid") - .setLimit(40) - .setIsNullable(true) - .build(); - - public AddAnalysisUuidToWebhookDeliveries(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(ANALYSIS_UUID_COLUMN) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsers.java deleted file mode 100644 index 120f0d93b90..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsers.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -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 CleanupDisabledUsers extends DataChange { - - private final System2 system2; - private final String falseValue; - - public CleanupDisabledUsers(Database db, System2 system2) { - super(db); - this.falseValue = db.getDialect().getFalseSqlValue(); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select u.id from users u " + - "where u.active = " + falseValue + " and " + - "( email is not null or " + - " crypted_password is not null or " + - " salt is not null or " + - " external_identity is not null or " + - " external_identity_provider is not null ) "); - massUpdate.update("update users set " + - " email = null, " + - " crypted_password = null, " + - " salt = null, " + - " external_identity = null, " + - " external_identity_provider = null, " + - " updated_at = ? " + - " where id = ?"); - massUpdate.rowPluralName("deactivated users"); - massUpdate.execute((row, update) -> { - update.setLong(1, now); - 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/v67/CopyDeprecatedServerId.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerId.java deleted file mode 100644 index 3768c4bc1fc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerId.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -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.Select; - -public class CopyDeprecatedServerId extends DataChange { - - private static final String DEPRECATED_KEY = "sonar.server_id"; - private static final String NEW_KEY = "sonar.core.id"; - - public CopyDeprecatedServerId(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - String deprecatedValue = context - .prepareSelect("select text_value from properties where prop_key = '" + DEPRECATED_KEY + "'") - .get(new Select.StringReader()); - if (deprecatedValue != null && !deprecatedValue.isEmpty()) { - deleteProperty(context, NEW_KEY); - context.prepareUpsert("insert into properties" + - " (prop_key, is_empty, text_value, created_at)" + - " values " + - " (?, ?, ?, ?)") - .setString(1, NEW_KEY) - .setBoolean(2, false) - .setString(3, deprecatedValue) - .setLong(4, System.currentTimeMillis()) - .execute() - .commit(); - } - deleteProperty(context, DEPRECATED_KEY); - } - - private static void deleteProperty(Context context, String key) throws SQLException { - context.prepareUpsert("delete from properties where prop_key = '" + key + "'") - .execute() - .commit(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisProperties.java deleted file mode 100644 index dc07ef8a224..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisProperties.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -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.BooleanColumnDef; -import org.sonar.server.platform.db.migration.def.ClobColumnDef; -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.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class CreateTableAnalysisProperties extends DdlChange { - private static final String TABLE_NAME = "analysis_properties"; - private static final String SNAPSHOT_UUID = "snapshot_uuid"; - private static final VarcharColumnDef SNAPSHOT_UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName(SNAPSHOT_UUID) - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public CreateTableAnalysisProperties(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(SNAPSHOT_UUID_COLUMN) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(512) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("text_value") - .setIsNullable(true) - .setLimit(VarcharColumnDef.MAX_SIZE) - .build()) - .addColumn(ClobColumnDef.newClobColumnDefBuilder() - .setColumnName("clob_value") - .setIsNullable(true) - .build()) - .addColumn(BooleanColumnDef.newBooleanColumnDefBuilder() - .setColumnName("is_empty") - .setIsNullable(false) - .build()) - .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .build() - ); - - context.execute(new CreateIndexBuilder() - .addColumn(SNAPSHOT_UUID_COLUMN) - .setUnique(false) - .setTable(TABLE_NAME) - .setName("ix_snapshot_uuid") - .build() - ); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java deleted file mode 100644 index 3aed8788581..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion67 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1830, "Copy deprecated server ID", CopyDeprecatedServerId.class) - .add(1831, "Add webhook_deliveries.analysis_uuid", AddAnalysisUuidToWebhookDeliveries.class) - .add(1832, "Create table ANALYSIS_PROPERTIES", CreateTableAnalysisProperties.class) - .add(1833, "Cleanup disabled users", CleanupDisabledUsers.class) - .add(1834, "Set WEBHOOK_DELIVERIES.CE_TASK_UUID as nullable", UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.class) - .add(1835, "Populate WEBHOOK_DELIVERIES.ANALYSIS_UUID", PopulateAnalysisUuidColumnOnWebhookDeliveries.class) - .add(1836, "Migrate 'previous_analysis' leak periods to 'previous_version'", MigratePreviousAnalysisToPreviousVersion.class) - .add(1837, "Drop old licenses", DropOldLicenses.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DropOldLicenses.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DropOldLicenses.java deleted file mode 100644 index e429af9d0ae..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DropOldLicenses.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -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 DropOldLicenses extends DataChange { - - private static final String LICENSE_HASH_SECURED_SUFFIX = ".licenseHash.secured"; - private static final String LICENSE_SECURED_SUFFIX = ".license.secured"; - - public DropOldLicenses(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select prop_key from properties where prop_key like ?") - .setString(1, "%" + LICENSE_HASH_SECURED_SUFFIX); - massUpdate.update("delete from properties where prop_key = ? or prop_key = ?"); - massUpdate.rowPluralName("old license properties"); - massUpdate.execute((row, update) -> { - String licenseHashKey = row.getString(1); - String licenseKey = licenseHashKey.replace(LICENSE_HASH_SECURED_SUFFIX, "") + LICENSE_SECURED_SUFFIX; - update.setString(1, licenseHashKey); - update.setString(2, licenseKey); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersion.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersion.java deleted file mode 100644 index b7e0dc901a3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersion.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -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 MigratePreviousAnalysisToPreviousVersion extends DataChange { - - public MigratePreviousAnalysisToPreviousVersion(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from properties " + - " where prop_key = 'sonar.leak.period' and text_value='previous_analysis'"); - massUpdate.update("update properties " + - " set text_value='previous_version', " + - " clob_value = null " + - " where id = ?"); - massUpdate.rowPluralName("leak periods"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveries.java deleted file mode 100644 index afdf06b5042..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveries.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class PopulateAnalysisUuidColumnOnWebhookDeliveries extends DataChange { - - public PopulateAnalysisUuidColumnOnWebhookDeliveries(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT wd.uuid, ca.analysis_uuid " + - " FROM webhook_deliveries wd " + - " INNER JOIN ce_activity ca ON ca.uuid=wd.ce_task_uuid " + - " WHERE wd.analysis_uuid IS NULL AND ca.analysis_uuid IS NOT NULL"); - massUpdate.update("UPDATE webhook_deliveries SET analysis_uuid=? WHERE uuid=?"); - massUpdate.rowPluralName("webhook_deliveries"); - massUpdate.execute(PopulateAnalysisUuidColumnOnWebhookDeliveries::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - String uuid = row.getString(1); - String analysisUuid = row.getString(2); - - update.setString(1, analysisUuid); - update.setString(2, uuid); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java deleted file mode 100644 index 5ca3cb6e185..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -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; - -public class UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries extends DdlChange { - - public static final String TABLE_WEBHOOK_DELIVERIES = "webhook_deliveries"; - - public UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_WEBHOOK_DELIVERIES) - .updateColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("ce_task_uuid") - .setLimit(40) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/package-info.java deleted file mode 100644 index 0cac353ade8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v67; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizations.java deleted file mode 100644 index 2a6570b682b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizations.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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 AddDefaultQualityGateUuidToOrganizations extends DdlChange { - public AddDefaultQualityGateUuidToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "organizations") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("default_quality_gate_uuid") - .setIsNullable(true) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsers.java deleted file mode 100644 index def7b2374ed..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsers.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddHomepageToUsers extends DdlChange { - - public AddHomepageToUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "users") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("homepage_type") - .setIsNullable(true) - .setLimit(40) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("homepage_parameter") - .setIsNullable(true) - .setLimit(40) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGates.java deleted file mode 100644 index 6235a3fbca3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGates.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddIsBuiltInToQualityGates extends DdlChange { - - public AddIsBuiltInToQualityGates(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "quality_gates") - .addColumn(newBooleanColumnDefBuilder() - .setColumnName("is_built_in") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndex.java deleted file mode 100644 index e2de5885439..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndex.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.sonar.db.Database; -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_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -/** - * Add this index only once table is populated to improve efficiency of populating the table. - */ -public class AddLiveMeasuresMetricIndex extends DdlChange { - - private static final String TABLE_NAME = "live_measures"; - - public AddLiveMeasuresMetricIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setIsNullable(false) - .setLimit(UUID_VARCHAR_SIZE) - .build()) - .addColumn(newIntegerColumnDefBuilder() - .setColumnName("metric_id") - .setIsNullable(false) - .build()) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("live_measures_component") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndex.java deleted file mode 100644 index 6402e262a32..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndex.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddSnapshotIsLastIndex extends DdlChange { - static final String TABLE_NAME = "snapshots"; - static final String INDEX_NAME = "ix_snapshot_is_last"; - - public AddSnapshotIsLastIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .setUnique(false) - .addColumn(newBooleanColumnDefBuilder().setColumnName("islast").setIsNullable(false).setDefaultValue(false).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGates.java deleted file mode 100644 index b0664802232..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGates.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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; - -public class AddUuidToQualityGates extends DdlChange { - - public AddUuidToQualityGates(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "quality_gates") - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganization.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganization.java deleted file mode 100644 index 1cf35fdfac1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganization.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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; - -import static com.google.common.base.Preconditions.checkState; - -public class AssociateQualityGatesToDefaultOrganization extends DataChange { - - private final UuidFactory uuidFactory; - - public AssociateQualityGatesToDefaultOrganization(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - String defaultOrgUuid = context.prepareSelect("select text_value from internal_properties where kee = 'organization.default'") - .get(row -> row.getString(1)); - - checkState(defaultOrgUuid != null, "Default organization uuid is missing"); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT qg.uuid from quality_gates qg " + - " WHERE qg.is_built_in = ? " + - " AND NOT EXISTS (SELECT 1 FROM org_quality_gates oqg WHERE oqg.quality_gate_uuid = qg.uuid AND oqg.organization_uuid = ?)") - .setBoolean(1, false) - .setString(2, defaultOrgUuid); - massUpdate.rowPluralName("quality gates"); - massUpdate.update("insert into org_quality_gates (uuid, quality_gate_uuid, organization_uuid) values(?, ?, ?)"); - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setString(2, row.getString(1)); - update.setString(3, defaultOrgUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGate.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGate.java deleted file mode 100644 index 4ae58f41d86..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGate.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -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; - -public class CreateBuiltInQualityGate extends DataChange { - - private static final String SONAR_WAY_QUALITY_GATE = "Sonar way"; - - private final System2 system2; - private final UuidFactory uuidFactory; - - public CreateBuiltInQualityGate(Database db, System2 system2, UuidFactory uuidFactory) { - super(db); - this.system2 = system2; - this.uuidFactory = uuidFactory; - } - - - @Override - protected void execute(Context context) throws SQLException { - Long nbOfBuiltInQualityGates = context.prepareSelect("select count(uuid) from quality_gates where is_built_in = ?") - .setBoolean(1, true) - .get(row -> row.getLong(1)); - - - if (nbOfBuiltInQualityGates == 0) { - final Date now = new Date(system2.now()); - - context.prepareUpsert("insert into quality_gates (uuid, name, is_built_in, created_at) values (?,?,?,?)") - .setString(1, uuidFactory.create()) - .setString(2, SONAR_WAY_QUALITY_GATE) - .setBoolean(3, true) - .setDate(4, now) - .execute() - .commit(); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTable.java deleted file mode 100644 index 0db787715c0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTable.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class CreateOrgQualityGatesTable extends DdlChange { - - private static final String ORG_QUALITY_GATES = "org_quality_gates"; - private static final VarcharColumnDef ORGANIZATION_UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final VarcharColumnDef QUALITY_GATE_UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("quality_gate_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private Database db; - - public CreateOrgQualityGatesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - if (!tableExists()) { - context.execute(new CreateTableBuilder(getDialect(), ORG_QUALITY_GATES) - .addPkColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(ORGANIZATION_UUID_COLUMN) - .addColumn(QUALITY_GATE_UUID_COLUMN) - .build() - ); - - context.execute(new CreateIndexBuilder() - .addColumn(ORGANIZATION_UUID_COLUMN) - .addColumn(QUALITY_GATE_UUID_COLUMN) - .setUnique(true) - .setTable(ORG_QUALITY_GATES) - .setName("uniq_org_quality_gates") - .build() - ); - } - } - - private boolean tableExists() throws SQLException { - try (Connection connection = db.getDataSource().getConnection()) { - return DatabaseUtils.tableExists(ORG_QUALITY_GATES, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasures.java deleted file mode 100644 index eb653275655..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasures.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.BlobColumnDef.newBlobColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.DecimalColumnDef.newDecimalColumnDefBuilder; -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTableLiveMeasures extends DdlChange { - - private static final String TABLE_NAME = "live_measures"; - - public CreateTableLiveMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef projectUuidCol = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(UUID_VARCHAR_SIZE) - .build(); - - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(projectUuidCol) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setIsNullable(false) - .setLimit(UUID_VARCHAR_SIZE) - .build()) - .addColumn(newIntegerColumnDefBuilder() - .setColumnName("metric_id") - .setIsNullable(false) - .build()) - .addColumn(newDecimalColumnDefBuilder() - .setColumnName("value") - .setPrecision(38) - .setScale(20) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("text_value") - .setIsNullable(true) - .setLimit(4_000) - .build()) - .addColumn(newDecimalColumnDefBuilder() - .setColumnName("variation") - .setPrecision(38) - .setScale(20) - .build()) - .addColumn(newBlobColumnDefBuilder() - .setColumnName("measure_data") - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("update_marker") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(projectUuidCol) - .setUnique(false) - .setTable(TABLE_NAME) - .setName("live_measures_project") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresP.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresP.java deleted file mode 100644 index faf4bb4fe12..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresP.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; - -public class CreateTempTableLiveMeasuresP extends DdlChange { - - static final String TABLE_NAME = "live_measures_p"; - - public CreateTempTableLiveMeasuresP(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - CreateTableBuilder builder = new CreateTableBuilder(getDialect(), TABLE_NAME); - if (!builder.tableExists(getDatabase())) { - context.execute(builder - .addPkColumn(new VarcharColumnDef.Builder() - .setColumnName("project_uuid") - .setLimit(UUID_VARCHAR_SIZE) - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .build()) - .build()); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70.java deleted file mode 100644 index 7f080c3243d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion70 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(1930, "Add QUALITY_GATES.IS_BUILT_IN", AddIsBuiltInToQualityGates.class) - .add(1931, "Populate QUALITY_GATES.IS_BUILT_IN", PopulateQualityGatesIsBuiltIn.class) - .add(1932, "Make QUALITY_GATES.IS_BUILT_IN not null", MakeQualityGatesIsBuiltInNotNullable.class) - .add(1933, "Remove quality gates loaded templates", RemoveQualityGateLoadedTemplates.class) - .add(1934, "Rename quality gate \"SonarQube way\" to \"Sonar way\"", RenameOldSonarQubeWayQualityGate.class) - .add(1935, "Drop LOADED_TEMPLATES table", DropLoadedTemplatesTable.class) - - // optimizations of migrations from 7.0 on project_measures and live_measures - .add(1936, "Delete person measures", DeletePersonMeasures.class) - .add(1937, "Drop index on project_measures.person_id", DropIndexOnPersonMeasures.class) - .add(1938, "Create table live_measures", CreateTableLiveMeasures.class) - .add(1939, "Add temporary index on SNAPSHOTS.ISLAST", AddSnapshotIsLastIndex.class) - .add(1940," Create temporary table LIVE_MEASURES_P", CreateTempTableLiveMeasuresP.class) - .add(1941, "Populate table live_measures", PopulateLiveMeasures.class) - .add(1942, "Add live_measures.metric_id index", AddLiveMeasuresMetricIndex.class) - .add(1943, "Drop temporary table LIVE_MEASURES_P", DropTempTableLiveMeasuresP.class) - .add(1944, "Drop temporary index on SNAPSHOTS.ISLAST", DropSnapshotIsLastIndex.class) - .add(1945, "Delete file measures", DeleteFileMeasures.class) - - .add(1946, "Create ORG_QUALITY_GATES table", CreateOrgQualityGatesTable.class) - .add(1947, "Add ORGANIZATIONS.DEFAULT_QUALITY_GATE_UUID", AddDefaultQualityGateUuidToOrganizations.class) - .add(1948, "Create QUALITY_GATES.UUID", AddUuidToQualityGates.class) - .add(1949, "Populate QUALITY_GATES.UUID", PopulateUuidOnQualityGates.class) - .add(1950, "Make QUALITY_GATES.UUID not nullable", MakeUuidNotNullableOnQualityGates.class) - .add(1951, "Drop unique index on QUALITY_GATES.NAME", DropUniqueIndexOnQualityGatesName.class) - .add(1952, "Create builtin quality gate if required", CreateBuiltInQualityGate.class) - .add(1953, "Populate ORG_QUALITY_GATES table", PopulateOrgQualityGates.class) - .add(1954, "Populate default quality gate on organization", PopulateDefaultQualityGate.class) - .add(1955, "Associate existing quality gates to default organization", AssociateQualityGatesToDefaultOrganization.class) - .add(1956, "Read 'sonar.qualitygate' setting and set the value to default organization", ReadGlobalSonarQualityGateSettingToDefaultOrg.class) - .add(1957, "Delete 'sonar.qualitygate' setting at global level", DeleteGlobalSonarQualityGateSetting.class) - .add(1958, "Make ORGANIZATIONS.DEFAULT_QUALITY_GATE_UUID not nullable", SetDefaultQualityGateUuidAsNotNullableInOrganizations.class) - .add(1959, "Add users.homepage_type and users.homepage_parameter", AddHomepageToUsers.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasures.java deleted file mode 100644 index 3ca285aee16..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasures.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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 DeleteFileMeasures extends DataChange { - - public DeleteFileMeasures(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select c.uuid from projects c where c.qualifier = 'UTS' or c.qualifier = 'FIL'"); - massUpdate.rowPluralName("files"); - massUpdate.update("delete from project_measures where component_uuid=?") - .setBatchSize(10); - - massUpdate.execute((row, update) -> { - String componentUuid = row.getString(1); - update.setString(1, componentUuid); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSetting.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSetting.java deleted file mode 100644 index 9684c353db5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSetting.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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 DeleteGlobalSonarQualityGateSetting extends DataChange { - - public DeleteGlobalSonarQualityGateSetting(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from properties where prop_key=? and resource_id is null") - .setString(1, "sonar.qualitygate"); - massUpdate.update("delete from properties where id=?"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasures.java deleted file mode 100644 index d50440ad9f5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasures.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -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 org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class DeletePersonMeasures extends DataChange { - - public DeletePersonMeasures(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from snapshots"); - massUpdate.rowPluralName("snapshots"); - massUpdate.update(getDeleteSql()).setBatchSize(1); - - massUpdate.execute((row, update) -> { - String analysisUuid = row.getString(1); - update.setString(1, analysisUuid); - if (getDialect().getId().equals(Oracle.ID)) { - update.setString(2, analysisUuid); - } - return true; - }); - } - - private String getDeleteSql() { - switch (getDialect().getId()) { - case MsSql.ID: - return "delete pm from project_measures pm " + - "inner join projects c on c.uuid = pm.component_uuid " + - "where pm.analysis_uuid = ? " + - "and pm.person_id is not null"; - case H2.ID: - return "delete from project_measures " + - "where id in ( " + - " select pm.id from project_measures pm " + - " inner join projects c on c.uuid = pm.component_uuid " + - " where pm.analysis_uuid = ? " + - " and pm.person_id is not null" + - ")"; - case PostgreSql.ID: - return "delete from project_measures pm " + - "using projects c " + - "where pm.analysis_uuid = ? " + - "and c.uuid = pm.component_uuid " + - "and pm.person_id is not null"; - case Oracle.ID: - return "delete from project_measures pm where exists (" + - " select 1 from project_measures pm2 " + - " inner join projects c on c.uuid = pm2.component_uuid " + - " where pm2.analysis_uuid = ? " + - " and pm.person_id is not null " + - " and pm.id = pm2.id" + - ") and pm.analysis_uuid = ?"; - default: - throw new IllegalStateException("Unsupported DB dialect: " + getDialect()); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasures.java deleted file mode 100644 index 4d9d201d4e6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasures.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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 DropIndexOnPersonMeasures extends DdlChange { - - public DropIndexOnPersonMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("project_measures") - .setName("measures_person") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTable.java deleted file mode 100644 index 4b3d9f63edf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropLoadedTemplatesTable extends DdlChange { - - public DropLoadedTemplatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropTableBuilder(getDialect(), "loaded_templates").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndex.java deleted file mode 100644 index 554a084cc5c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndex.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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 DropSnapshotIsLastIndex extends DdlChange { - public DropSnapshotIsLastIndex(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new DropIndexBuilder(getDialect()) - .setTable(AddSnapshotIsLastIndex.TABLE_NAME) - .setName(AddSnapshotIsLastIndex.INDEX_NAME) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresP.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresP.java deleted file mode 100644 index acec9071aae..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresP.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTempTableLiveMeasuresP extends DdlChange { - public DropTempTableLiveMeasuresP(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (new CreateTableBuilder(getDialect(), CreateTempTableLiveMeasuresP.TABLE_NAME).tableExists(getDatabase())) { - DropTableBuilder builder = new DropTableBuilder(getDialect(), CreateTempTableLiveMeasuresP.TABLE_NAME); - context.execute(builder.build()); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesName.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesName.java deleted file mode 100644 index d3193abfcc1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesName.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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 DropUniqueIndexOnQualityGatesName extends DdlChange { - - public DropUniqueIndexOnQualityGatesName(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("quality_gates") - .setName("uniq_quality_gates") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullable.java deleted file mode 100644 index 57833bd0690..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullable.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class MakeQualityGatesIsBuiltInNotNullable extends DdlChange { - - public MakeQualityGatesIsBuiltInNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - BooleanColumnDef column = newBooleanColumnDefBuilder() - .setColumnName("is_built_in") - .setIsNullable(false) - .build(); - - context.execute(new AlterColumnsBuilder(getDialect(), "quality_gates") - .updateColumn(column) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGates.java deleted file mode 100644 index 4267dc1531b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGates.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class MakeUuidNotNullableOnQualityGates extends DdlChange { - - private static final VarcharColumnDef UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final String TABLE_NAME = "quality_gates"; - - public MakeUuidNotNullableOnQualityGates(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(UUID_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(UUID_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("uniq_quality_gates_uuid") - .build() - ); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGate.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGate.java deleted file mode 100644 index f9987124a46..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGate.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.List; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -import static com.google.common.base.Preconditions.checkState; - -public class PopulateDefaultQualityGate extends DataChange { - - private final System2 system2; - - public PopulateDefaultQualityGate(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - List builtInQGUuids = context.prepareSelect("select uuid from quality_gates where is_built_in = ?") - .setBoolean(1, true) - .list(row -> row.getString(1)); - - checkState(!builtInQGUuids.isEmpty(), "Unable to find the builtin quality gate"); - checkState(builtInQGUuids.size() == 1, "There are too many built in quality gates, one and only one is expected"); - - final long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from organizations " + - " where default_quality_gate_uuid is null"); - massUpdate.rowPluralName("organizations"); - massUpdate.update("update organizations set default_quality_gate_uuid = ?, updated_at=? where uuid = ?"); - massUpdate.execute((row, update) -> { - update.setString(1, builtInQGUuids.get(0)); - update.setLong(2, now); - update.setString(3, row.getString(1)); - return true; - }); - - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java deleted file mode 100644 index 76405c389eb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import javax.annotation.concurrent.Immutable; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.Uuids; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SelectImpl; -import org.sonar.server.platform.db.migration.step.SqlStatement; -import org.sonar.server.platform.db.migration.step.Upsert; - -import static java.util.stream.Collectors.joining; - -public class PopulateLiveMeasures extends DataChange { - private static final Logger LOG = Loggers.get(PopulateLiveMeasures.class); - - private final System2 system2; - private final Database db; - - public PopulateLiveMeasures(Database db, System2 system2) { - super(db); - this.db = db; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - ATTEMPT attempt = isFirstAttempt(context); - if (attempt != ATTEMPT.FIRST) { - LOG.info("Retry detected (non empty table live_measures_p or live_measures). Handling it"); - } - - long now = system2.now(); - int projectBatchSize = 10; - String statement = "" + - " select" + - " s.uuid, s.component_uuid" + - " from snapshots s" + - " where" + - " s.islast = ?" + - (attempt == ATTEMPT.ONE_PROJECT_OR_MORE ? " and not exists (select 1 from live_measures_p lmp where lmp.project_uuid=s.component_uuid)" : ""); - try (Connection connection = createReadUncommittedConnection(); - Select select = SelectImpl.create(db, connection, statement).setBoolean(1, true)) { - List rows = new ArrayList<>(projectBatchSize); - select.scroll(t -> { - rows.add(new Row(t.getString(1), t.getString(2))); - if (rows.size() == projectBatchSize) { - processProjectBatch(context, rows, attempt, now); - - rows.clear(); - } - }); - - if (!rows.isEmpty()) { - processProjectBatch(context, rows, attempt, now); - } - } - } - - private static ATTEMPT isFirstAttempt(Context context) throws SQLException { - try ( - Select selectFromTempTable = context.prepareSelect("select count(1) from live_measures_p"); - Select selectFromLiveMeasures = context.prepareSelect("select count(1) from live_measures") - ) { - boolean projectsProcessed = selectFromTempTable.get(t -> t.getLong(1)) > 0; - if (projectsProcessed) { - return ATTEMPT.ONE_PROJECT_OR_MORE; - } - // we will count at most the data of one project => table should have little content => bad performance risk is low - return selectFromLiveMeasures.get(t -> t.getLong(1)) == 0 ? ATTEMPT.FIRST : ATTEMPT.PARTIAL; - } - } - - private enum ATTEMPT { - FIRST, PARTIAL, ONE_PROJECT_OR_MORE - } - - private static void processProjectBatch(Context context, List rows, ATTEMPT attempt, long now) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.rowPluralName("live measures"); - setSelect(rows, massUpdate); - massUpdate.update("delete from live_measures where project_uuid=?"); - massUpdate.update(" insert into live_measures" + - " (uuid, component_uuid, project_uuid, metric_id, value, text_value, variation, measure_data, created_at, updated_at)" + - " values" + - " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - massUpdate.update("insert into live_measures_p (project_uuid) values (?)") - // we want to commit each project finished asap to avoid restarting them over in case of interruption - .setBatchSize(1); - LiveMeasurePopulationMultiHandler handler = new LiveMeasurePopulationMultiHandler(attempt == ATTEMPT.FIRST, rows, now); - massUpdate.execute(handler); - - Set notCommittedProjectUuids = handler.notCommittedProjectUuids; - if (!notCommittedProjectUuids.isEmpty()) { - Upsert upsert = context.prepareUpsert("insert into live_measures_p (project_uuid) values (?)"); - for (String projectUuid : notCommittedProjectUuids) { - upsert.setString(1, projectUuid); - upsert.execute(); - } - upsert.commit(); - } - } - - private static void setSelect(List rows, MassUpdate massUpdate) throws SQLException { - String questionMarks = rows.stream().map(t -> "?").collect(joining(",", "(", ")")); - SqlStatement select = massUpdate.select("" + - " select" + - " p.project_uuid, pm.component_uuid, pm.metric_id, pm.value, pm.text_value, pm.variation_value_1, pm.measure_data" + - " from project_measures pm" + - " inner join projects p on p.uuid = pm.component_uuid and p.project_uuid in " + questionMarks + - " where" + - " pm.analysis_uuid in " + questionMarks + - " order by" + - " p.project_uuid"); - int i = 1; - for (Row row : rows) { - select.setString(i, row.getProjectUuid()); - i++; - } - for (Row row : rows) { - select.setString(i, row.getAnalysisUuid()); - i++; - } - } - - private static class LiveMeasurePopulationMultiHandler implements MassUpdate.MultiHandler { - private final boolean firstAttempt; - private final long now; - private final Set notCommittedProjectUuids; - private String deletePreviousProjectUuid = null; - private String currentProjectUuid = null; - - private LiveMeasurePopulationMultiHandler(boolean firstAttempt, List rows, long now) { - this.firstAttempt = firstAttempt; - this.now = now; - this.notCommittedProjectUuids = rows.stream().map(Row::getProjectUuid).collect(Collectors.toSet()); - } - - @Override - public boolean handle(Select.Row row, SqlStatement update, int updateIndex) throws SQLException { - String projectUuid = row.getString(1); - switch (updateIndex) { - case 0: - return doRentranceDelete(update, projectUuid); - case 1: - return doLiveMeasureInsert(row, update, projectUuid); - case 2: - return doComponentDoneInsert(update, projectUuid); - default: - throw new IllegalStateException("Unsupported update index" + updateIndex); - } - } - - private boolean doRentranceDelete(SqlStatement update, String projectUuid) throws SQLException { - if (firstAttempt) { - return false; - } - - if (deletePreviousProjectUuid == null || !deletePreviousProjectUuid.equals(projectUuid)) { - update.setString(1, projectUuid); - deletePreviousProjectUuid = projectUuid; - return true; - } - return false; - } - - private boolean doLiveMeasureInsert(Select.Row row, SqlStatement update, String projectUuid) throws SQLException { - update.setString(1, Uuids.create()); - update.setString(2, row.getString(2)); - update.setString(3, projectUuid); - update.setInt(4, row.getInt(3)); - update.setDouble(5, row.getNullableDouble(4)); - update.setString(6, row.getNullableString(5)); - update.setDouble(7, row.getNullableDouble(6)); - update.setBytes(8, row.getNullableBytes(7)); - update.setLong(9, now); - update.setLong(10, now); - return true; - } - - /** - * When currentProjectUuid changes, we know we are done will all the measures for this component and therefor - * can insert it into live_measures_p. - *

- * This requires statement selecting measures to be sorted by project_uuid and then component_uuid. - */ - private boolean doComponentDoneInsert(SqlStatement update, String projectUuid) throws SQLException { - if (currentProjectUuid == null || currentProjectUuid.equals(projectUuid)) { - this.currentProjectUuid = projectUuid; - return false; - } - update.setString(1, currentProjectUuid); - this.notCommittedProjectUuids.remove(currentProjectUuid); - this.currentProjectUuid = projectUuid; - return true; - } - - } - - @Immutable - private static final class Row { - private final String analysisUuid; - private final String projectUuid; - - private Row(String analysisUuid, String projectUuid) { - this.analysisUuid = analysisUuid; - this.projectUuid = projectUuid; - } - - public String getAnalysisUuid() { - return analysisUuid; - } - - public String getProjectUuid() { - return projectUuid; - } - - @Override - public String toString() { - return "Row{" + - "analysisUuid='" + analysisUuid + '\'' + - ", projectUuid='" + projectUuid + '\'' + - '}'; - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGates.java deleted file mode 100644 index b412cbff3f3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGates.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.List; -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; - -import static com.google.common.base.Preconditions.checkState; - -public class PopulateOrgQualityGates extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateOrgQualityGates(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - public void execute(Context context) throws SQLException { - Long nbOfOrganizations = context.prepareSelect("select count(uuid) from organizations") - .get(row -> row.getLong(1)); - if (nbOfOrganizations == 0) { - // No need for a migration - return; - } - - List builtInQGUuids = context.prepareSelect("select uuid from quality_gates where is_built_in = ?") - .setBoolean(1, true) - .list(row -> row.getString(1)); - - checkState(!builtInQGUuids.isEmpty(), "Unable to find the builtin quality gate"); - checkState(builtInQGUuids.size() == 1, "There are too many built in quality gates, one and only one is expected"); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from organizations o " + - " where " + - " not exists (select 1 from org_quality_gates oqg where oqg.quality_gate_uuid = ? and oqg.organization_uuid = o.uuid)") - .setString(1, builtInQGUuids.get(0)); - - massUpdate.rowPluralName("organizations"); - massUpdate.update("insert into org_quality_gates (uuid, quality_gate_uuid, organization_uuid) values(?, ?, ?)"); - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setString(2, builtInQGUuids.get(0)); - update.setString(3, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltIn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltIn.java deleted file mode 100644 index 909b3c618a5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltIn.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import org.sonar.api.utils.System2; -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 PopulateQualityGatesIsBuiltIn extends DataChange { - - private static final String SONARQUBE_WAY_QUALITY_GATE = "SonarQube way"; - - private final System2 system2; - - public PopulateQualityGatesIsBuiltIn(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id, name from quality_gates where is_built_in is null"); - massUpdate.rowPluralName("quality_gates"); - massUpdate.update("update quality_gates set is_built_in=?, updated_at=? where id=?"); - massUpdate.execute((row, update) -> { - String name = row.getString(2); - update.setBoolean(1, SONARQUBE_WAY_QUALITY_GATE.equals(name)); - update.setDate(2, new Date(system2.now())); - update.setLong(3, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGates.java deleted file mode 100644 index 6c9171a88ef..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGates.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -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 PopulateUuidOnQualityGates extends DataChange { - - private final System2 system2; - private final UuidFactory uuidFactory; - - public PopulateUuidOnQualityGates(Database db, System2 system2, UuidFactory uuidFactory) { - super(db); - this.system2 = system2; - this.uuidFactory = uuidFactory; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id, name from quality_gates where uuid is null"); - massUpdate.rowPluralName("quality gates"); - massUpdate.update("update quality_gates set uuid=?, updated_at=? where id=?"); - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setDate(2, new Date(system2.now())); - update.setLong(3, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrg.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrg.java deleted file mode 100644 index 9f6f23b13d0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrg.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import javax.annotation.CheckForNull; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -import static com.google.common.base.Preconditions.checkState; -import static java.lang.Long.parseLong; - -public class ReadGlobalSonarQualityGateSettingToDefaultOrg extends DataChange { - - private static final Logger LOGGER = Loggers.get(ReadGlobalSonarQualityGateSettingToDefaultOrg.class); - private final System2 system2; - - public ReadGlobalSonarQualityGateSettingToDefaultOrg(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - String defaultOrgUuid = getDefaultOrgUuid(context); - String defaultQualityGate = getDefaultQualityGate(context); - if (defaultQualityGate == null) { - LOGGER.info("No default quality gate set"); - return; - } - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from quality_gates where id=?") - .setLong(1, parseLong(defaultQualityGate)); - massUpdate.update("update organizations set default_quality_gate_uuid = ?, updated_at = ? where uuid=?"); - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - update.setLong(2, system2.now()); - update.setString(3, defaultOrgUuid); - return true; - }); - } - - private static String getDefaultOrgUuid(Context context) throws SQLException { - String defaultOrgUuid = context.prepareSelect("select text_value from internal_properties where kee = 'organization.default'") - .get(row -> row.getString(1)); - checkState(defaultOrgUuid != null, "Default organization uuid is missing"); - return defaultOrgUuid; - } - - @CheckForNull - private static String getDefaultQualityGate(Context context) throws SQLException { - return context.prepareSelect("select text_value from properties where prop_key=? and resource_id is null") - .setString(1, "sonar.qualitygate") - .get(row -> row.getNullableString(1)); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplates.java deleted file mode 100644 index fcc5df9e4a8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplates.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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 RemoveQualityGateLoadedTemplates extends DataChange { - - public RemoveQualityGateLoadedTemplates(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT id " + - "FROM loaded_templates " + - "WHERE template_type = ?") - .setString(1, "QUALITY_GATE"); - massUpdate.update("DELETE from loaded_templates WHERE id=?"); - massUpdate.rowPluralName("delete loaded templates for quality gate"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGate.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGate.java deleted file mode 100644 index ee86399eafb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGate.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -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 RenameOldSonarQubeWayQualityGate extends DataChange { - - private static final Logger LOG = Loggers.get(RenameOldSonarQubeWayQualityGate.class); - private static final String SONARQUBE_WAY_QUALITY_GATE = "SonarQube way"; - private static final String SONARQUBE_WAY_QUALITY_GATE_OUTDATED = "Sonar way (outdated copy)"; - private final System2 system2; - - public RenameOldSonarQubeWayQualityGate(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - try { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT id FROM quality_gates WHERE name = ?") - .setString(1, SONARQUBE_WAY_QUALITY_GATE); - massUpdate.rowPluralName("quality gates"); - massUpdate.update("UPDATE quality_gates SET name=?, is_built_in=?, updated_at=? WHERE id=?"); - massUpdate.execute((row, update) -> { - update.setString(1, SONARQUBE_WAY_QUALITY_GATE_OUTDATED); - update.setBoolean(2, false); - update.setDate(3, new Date(system2.now())); - update.setLong(4, row.getLong(1)); - return true; - }); - } catch(Exception ex) { - LOG.error("There is already a quality profile with name [{}]", SONARQUBE_WAY_QUALITY_GATE_OUTDATED); - throw ex; - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizations.java deleted file mode 100644 index 375f55ba439..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizations.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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 SetDefaultQualityGateUuidAsNotNullableInOrganizations extends DdlChange { - - public SetDefaultQualityGateUuidAsNotNullableInOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "organizations") - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("default_quality_gate_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/package-info.java deleted file mode 100644 index 1af22bde23f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v70; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranches.java deleted file mode 100644 index ed088a806e3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranches.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -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; - -public class AddKeyTypeInProjectBranches extends DdlChange { - - public static final String TABLE_NAME = "project_branches"; - - public AddKeyTypeInProjectBranches(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("key_type") - .setIsNullable(true) - .setLimit(12) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranches.java deleted file mode 100644 index 64f8be9719e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranches.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BlobColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPullRequestBinaryInProjectBranches extends DdlChange { - - static final String TABLE_NAME = "project_branches"; - static final String COLUMN_NAME = "pull_request_binary"; - - public AddPullRequestBinaryInProjectBranches(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME) - .addColumn(BlobColumnDef.newBlobColumnDefBuilder() - .setColumnName(COLUMN_NAME) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddRuleScope.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddRuleScope.java deleted file mode 100644 index b12583536af..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddRuleScope.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -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; - -public class AddRuleScope extends DdlChange { - - public AddRuleScope(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "rules") - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("scope") - .setIsNullable(true) - .setLimit(20) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTable.java deleted file mode 100644 index f4c0ed88d83..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTable.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -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 AddWebhookKeyToWebhookDeliveriesTable extends DdlChange { - - public AddWebhookKeyToWebhookDeliveriesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - - context.execute("delete from webhook_deliveries"); - - context.execute(new AddColumnsBuilder(getDialect(), "webhook_deliveries") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("webhook_uuid") - .setIsNullable(false) - .setLimit(40) - .build()) - .build()); - - context.execute(new AlterColumnsBuilder(getDialect(), "webhook_deliveries") - .updateColumn(newBigIntegerColumnDefBuilder() - .setColumnName("duration_ms") - .setIsNullable(false) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferences.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferences.java deleted file mode 100644 index b7b9ff47b6e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferences.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.util.HashSet; -import java.util.Set; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class CleanBrokenProjectToQGReferences extends DataChange { - - private static final String PROPERTY_SONAR_QUALITYGATE = "sonar.qualitygate"; - - public CleanBrokenProjectToQGReferences(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - Set qualityGateIds = new HashSet<>(); - context.prepareSelect("select id from quality_gates") - .scroll(s -> qualityGateIds.add(String.valueOf(s.getInt(1)))); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " distinct text_value" + - " from properties" + - " where" + - " prop_key=?" + - " and text_value is not null" + - " and resource_id is not null") - .setString(1, PROPERTY_SONAR_QUALITYGATE); - massUpdate.update("delete from properties" + - " where" + - " prop_key=?" + - " and resource_id is not null" + - " and text_value=?"); - massUpdate.execute((row, update) -> handle(row, update, qualityGateIds)); - } - - private static boolean handle(Select.Row row, SqlStatement update, Set qualityGateIds) throws SQLException { - String qgId = row.getString(1); - if (qualityGateIds.contains(qgId)) { - return false; - } - - update.setString(1, PROPERTY_SONAR_QUALITYGATE); - update.setString(2, qgId); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphans.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphans.java deleted file mode 100644 index fddd2095778..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphans.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class CleanCeChildTablesOrphans extends DataChange { - public CleanCeChildTablesOrphans(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - deleteOrphansInCeChildTable(context, "ce_task_input"); - deleteOrphansInCeChildTable(context, "ce_scanner_context"); - deleteOrphansInCeChildTable(context, "ce_task_characteristics"); - } - - private static void deleteOrphansInCeChildTable(Context context, String childTableName) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select task_uuid from " + childTableName + " child where" + - " not exists (select 1 from ce_activity a where a.uuid = child.task_uuid)" + - " and not exists (select 1 from ce_queue q where q.uuid = child.task_uuid)"); - massUpdate.rowPluralName("orphans rows in " + childTableName); - massUpdate.update("delete from " + childTableName + " where task_uuid=?"); - massUpdate.execute(CleanCeChildTablesOrphans::deleteByTaskUuid); - } - - private static boolean deleteByTaskUuid(Select.Row row, SqlStatement update) throws SQLException { - String taskUuid = row.getString(1); - update.setString(1, taskUuid); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTable.java deleted file mode 100644 index 0d5637b1d9c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -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.BigIntegerColumnDef; -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.sql.CreateTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class CreateDeprecatedRuleKeysTable extends DdlChange { - - private static final String DEPRECATED_RULE_KEYS = "deprecated_rule_keys"; - private static final VarcharColumnDef UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final IntegerColumnDef RULE_ID_COLUMN = IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("rule_id") - .setIsNullable(false) - .build(); - private static final VarcharColumnDef OLD_REPOSITORY_KEY_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("old_repository_key") - .setIsNullable(false) - .setLimit(255) - .build(); - private static final VarcharColumnDef OLD_RULE_KEY_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("old_rule_key") - .setIsNullable(false) - .setLimit(200) - .build(); - private static final BigIntegerColumnDef CREATED_AT_COLUMN = BigIntegerColumnDef.newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - private Database db; - - public CreateDeprecatedRuleKeysTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - if (!tableExists()) { - context.execute(new CreateTableBuilder(getDialect(), DEPRECATED_RULE_KEYS) - .addPkColumn(UUID_COLUMN) - .addColumn(RULE_ID_COLUMN) - .addColumn(OLD_REPOSITORY_KEY_COLUMN) - .addColumn(OLD_RULE_KEY_COLUMN) - .addColumn(CREATED_AT_COLUMN) - .build() - ); - - context.execute(new CreateIndexBuilder() - .setTable(DEPRECATED_RULE_KEYS) - .addColumn(OLD_REPOSITORY_KEY_COLUMN) - .addColumn(OLD_RULE_KEY_COLUMN) - .setUnique(true) - .setName("uniq_deprecated_rule_keys") - .build() - ); - - context.execute(new CreateIndexBuilder() - .setTable(DEPRECATED_RULE_KEYS) - .addColumn(RULE_ID_COLUMN) - .setUnique(true) - .setName("rule_id_deprecated_rule_keys") - .build() - ); - } - } - - private boolean tableExists() throws SQLException { - try (Connection connection = db.getDataSource().getConnection()) { - return DatabaseUtils.tableExists(DEPRECATED_RULE_KEYS, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2.java deleted file mode 100644 index 203661ef96e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateTableProjectLinks2 extends DdlChange { - - private static final String TABLE_NAME = "project_links2"; - - public CreateTableProjectLinks2(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("link_type") - .setLimit(20) - .setIsNullable(false) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("name") - .setLimit(128) - .setIsNullable(true) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("href") - .setLimit(2048) - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTable.java deleted file mode 100644 index 91d887eddd4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTable.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -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.BigIntegerColumnDef; -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.sql.CreateTableBuilder; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateWebhooksTable extends DdlChange { - - private static final String TABLE_NAME = "webhooks"; - - private static final String ORGANIZATION_WEBHOOK_INDEX_NAME = "organization_webhook"; - private static final String PROJECT_WEBHOOK_INDEX_NAME = "project_webhook"; - - private static final VarcharColumnDef UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef NAME_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("name") - .setIsNullable(false) - .setLimit(100) - .build(); - private static final VarcharColumnDef URL_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("url") - .setIsNullable(false) - .setLimit(2000) - .build(); - private static final VarcharColumnDef ORGANIZATION_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef PROJECT_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build(); - private static final BigIntegerColumnDef CREATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - private static final BigIntegerColumnDef UPDATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(true) - .build(); - - public CreateWebhooksTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - - if (!tableExists()) { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID_COLUMN) - .addColumn(NAME_COLUMN) - .addColumn(URL_COLUMN) - .addColumn(ORGANIZATION_UUID_COLUMN) - .addColumn(PROJECT_UUID_COLUMN) - .addColumn(CREATED_AT_COLUMN) - .addColumn(UPDATED_AT_COLUMN) - .build() - ); - - context.execute(new CreateIndexBuilder() - .addColumn(ORGANIZATION_UUID_COLUMN) - .setUnique(false) - .setTable(TABLE_NAME) - .setName(ORGANIZATION_WEBHOOK_INDEX_NAME) - .build() - ); - - context.execute(new CreateIndexBuilder() - .addColumn(PROJECT_UUID_COLUMN) - .setUnique(false) - .setTable(TABLE_NAME) - .setName(PROJECT_WEBHOOK_INDEX_NAME) - .build() - ); - - } - - } - - private boolean tableExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.tableExists(TABLE_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DbVersion71.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DbVersion71.java deleted file mode 100644 index 1abc490c34f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DbVersion71.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion71 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(2000, "Delete settings defined in sonar.properties from PROPERTIES table", DeleteSettingsDefinedInSonarDotProperties.class) - .add(2001, "Add scope to rules", AddRuleScope.class) - .add(2002, "Set rules scope to MAIN", SetRuleScopeToMain.class) - .add(2003, "Make scope not nullable in rules", MakeScopeNotNullableInRules.class) - .add(2004, "Use rule id in QPROFILE_CHANGES", UseRuleIdInQPChangesData.class) - .add(2005, "Create table DEPRECATED_RULE_KEYS", CreateDeprecatedRuleKeysTable.class) - .add(2006, "Clean orphans in Compute Engine child tables", CleanCeChildTablesOrphans.class) - .add(2007, "Update PERMISSION_TEMPLATES.KEYS ", UpdatePermissionTooLongTemplateKeys.class) - .add(2008, "Make scope not nullable in rules", MakeScopeNotNullableInRules.class) - .add(2009, "Create table PROJECT_LINKS2", CreateTableProjectLinks2.class) - .add(2010, "Populate table PROJECT_LINKS2", PopulateTableProjectLinks2.class) - .add(2011, "Drop table PROJECT_LINKS", DropTableProjectLinks.class) - .add(2012, "Rename table PROJECT_LINKS2 to PROJECT_LINKS", RenameTableProjectLinks2ToProjectLinks.class) - .add(2013, "Create WEBHOOKS Table", CreateWebhooksTable.class) - .add(2014, "Migrate webhooks from SETTINGS table to WEBHOOKS table", MigrateWebhooksToWebhooksTable.class) - .add(2015, "Add webhook key to WEBHOOK_DELIVERIES table", AddWebhookKeyToWebhookDeliveriesTable.class) - .add(2016, "Increase branch type size in PROJECT_BRANCHES", IncreaseBranchTypeSizeForPullRequest.class) - .add(2017, "Add key_type column in PROJECT_BRANCHES", AddKeyTypeInProjectBranches.class) - .add(2018, "Fill key_type column in PROJECT_BRANCHES", SetKeyTypeToBranchInProjectBranches.class) - .add(2019, "Make key_type not nullable in PROJECT_BRANCHES", MakeKeyTypeNotNullableInProjectBranches.class) - .add(2020, "Replace index in PROJECT_BRANCHES", ReplaceIndexInProjectBranches.class) - .add(2021, "Add pull_request_data in PROJECT_BRANCHES", AddPullRequestBinaryInProjectBranches.class) - .add(2022, "Clean broken project to QG references", CleanBrokenProjectToQGReferences.class) - .add(2023, "Delete measures of project copies", DeleteMeasuresOfProjectCopies.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopies.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopies.java deleted file mode 100644 index 70dc926fd03..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopies.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -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 DeleteMeasuresOfProjectCopies extends DataChange { - - public DeleteMeasuresOfProjectCopies(Database db) { - super(db); - } - - @Override - protected void execute(DataChange.Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct uuid from projects where copy_component_uuid is not null"); - massUpdate.update("delete from project_measures where component_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/v71/DeleteSettingsDefinedInSonarDotProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotProperties.java deleted file mode 100644 index ca6c1f40a52..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotProperties.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import com.google.common.base.Joiner; -import java.sql.SQLException; -import java.util.List; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -import static java.util.Arrays.asList; - -public class DeleteSettingsDefinedInSonarDotProperties extends DataChange { - - private static final Logger LOG = Loggers.get(DeleteSettingsDefinedInSonarDotProperties.class); - - private static final List SONAR_PROPERTIES = asList( - "sonar.jdbc.url", - "sonar.jdbc.username", - "sonar.jdbc.password", - "sonar.jdbc.driverPath", - "sonar.jdbc.maxActive", - "sonar.jdbc.maxIdle", - "sonar.jdbc.minIdle", - "sonar.jdbc.maxWait", - "sonar.jdbc.minEvictableIdleTimeMillis", - "sonar.jdbc.timeBetweenEvictionRunsMillis", - "sonar.embeddedDatabase.port", - "sonar.path.data", - "sonar.path.home", - "sonar.path.logs", - "sonar.path.temp", - "sonar.path.web", - "sonar.search.host", - "sonar.search.port", - "sonar.search.httpPort", - "sonar.search.javaOpts", - "sonar.search.javaAdditionalOpts", - "sonar.search.replicas", - "sonar.search.minimumMasterNodes", - "sonar.search.initialStateTimeout", - "sonar.web.javaOpts", - "sonar.web.javaAdditionalOpts", - "sonar.web.port", - "sonar.auth.jwtBase64Hs256Secret", - "sonar.ce.javaOpts", - "sonar.ce.javaAdditionalOpts", - "sonar.enableStopCommand", - "http.proxyHost", - "https.proxyHost", - "http.proxyPort", - "https.proxyPort", - "http.proxyUser", - "http.proxyPassword", - "sonar.cluster.enabled", - "sonar.cluster.node.type", - "sonar.cluster.search.hosts", - "sonar.cluster.hosts", - "sonar.cluster.node.port", - "sonar.cluster.node.host", - "sonar.cluster.node.name", - "sonar.cluster.name", - "sonar.cluster.web.startupLeader", - "sonar.sonarcloud.enabled", - "sonar.updatecenter.activate", - "http.nonProxyHosts", - "http.auth.ntlm.domain", - "socksProxyHost", - "socksProxyPort", - "sonar.web.sso.enable", - "sonar.web.sso.loginHeader", - "sonar.web.sso.nameHeader", - "sonar.web.sso.emailHeader", - "sonar.web.sso.groupsHeader", - "sonar.web.sso.refreshIntervalInMinutes", - "sonar.security.realm", - "sonar.authenticator.ignoreStartupFailure", - "sonar.telemetry.enable", - "sonar.telemetry.url", - "sonar.telemetry.frequencyInSeconds"); - - private static final Joiner COMMA_JOINER = Joiner.on(","); - - public DeleteSettingsDefinedInSonarDotProperties(Database db) { - super(db); - } - - @Override - protected void execute(DataChange.Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - String selectSql = "select id, prop_key from properties where prop_key in ("; - selectSql += SONAR_PROPERTIES.stream().map(p -> "?").collect(MoreCollectors.join(COMMA_JOINER)); - selectSql += ")"; - SqlStatement selectStatement = massUpdate.select(selectSql); - for (int i = 1; i <= SONAR_PROPERTIES.size(); i++) { - selectStatement.setString(i, SONAR_PROPERTIES.get(i - 1)); - } - massUpdate.update("delete from properties where id=?"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - LOG.warn("System setting '{}' was defined in database, it has been removed", row.getString(2)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinks.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinks.java deleted file mode 100644 index 90e4faa0075..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinks.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTableProjectLinks extends DdlChange { - - public DropTableProjectLinks(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropTableBuilder(getDialect(), "project_links").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequest.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequest.java deleted file mode 100644 index 042c7929c5b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 IncreaseBranchTypeSizeForPullRequest extends DdlChange { - private static final String TABLE_NAME = "project_branches"; - - public IncreaseBranchTypeSizeForPullRequest(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("branch_type") - .setLimit(12) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranches.java deleted file mode 100644 index a58c709f5d3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranches.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 MakeKeyTypeNotNullableInProjectBranches extends DdlChange { - static final String TABLE_NAME = "project_branches"; - - public MakeKeyTypeNotNullableInProjectBranches(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("key_type") - .setLimit(12) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRules.java deleted file mode 100644 index 3966ece4bd6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRules.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 MakeScopeNotNullableInRules extends DdlChange { - private static final String TABLE_NAME = "rules"; - - public MakeScopeNotNullableInRules(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("scope") - .setLimit(20) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTable.java deleted file mode 100644 index 82d31b594af..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTable.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import com.google.common.collect.Multimap; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Function; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; - -import static java.util.stream.Collectors.toList; - -public class MigrateWebhooksToWebhooksTable extends DataChange { - - private static final long NO_RESOURCE_ID = -8_435_121; - private static final Logger LOGGER = Loggers.get(MigrateWebhooksToWebhooksTable.class); - - private DefaultOrganizationUuidProvider defaultOrganizationUuidProvider; - private UuidFactory uuidFactory; - - public MigrateWebhooksToWebhooksTable(Database db, DefaultOrganizationUuidProvider defaultOrganizationUuidProvider, UuidFactory uuidFactory) { - super(db); - this.defaultOrganizationUuidProvider = defaultOrganizationUuidProvider; - this.uuidFactory = uuidFactory; - } - - @Override - public void execute(Context context) throws SQLException { - Multimap rows = context - .prepareSelect("select" + - " props.id, props.prop_key, props.resource_id, prj.uuid, props.text_value, props.created_at" + - " from properties props" + - " left join projects prj on prj.id = props.resource_id and prj.scope = ? and prj.qualifier = ? and prj.enabled = ?" + - " where" + - " props.prop_key like 'sonar.webhooks%'" + - " and props.text_value is not null") - .setString(1, "PRJ") - .setString(2, "TRK") - .setBoolean(3, true) - .list(row -> new PropertyRow( - row.getLong(1), - row.getString(2), - row.getNullableLong(3), - row.getNullableString(4), - row.getString(5), - row.getLong(6))) - .stream() - .collect(MoreCollectors.index(PropertyRow::getResourceId, Function.identity())); - - for (Map.Entry> entry : rows.asMap().entrySet()) { - long projectId = entry.getKey(); - if (projectId == NO_RESOURCE_ID) { - migrateGlobalWebhooks(context, entry.getValue()); - } else { - migrateProjectsWebhooks(context, entry.getValue()); - } - deleteAllWebhookProperties(context); - } - } - - private static void deleteAllWebhookProperties(Context context) throws SQLException { - context - .prepareUpsert("delete from properties where prop_key like 'sonar.webhooks.global%' or prop_key like 'sonar.webhooks.project%'") - .execute() - .commit(); - } - - private void migrateGlobalWebhooks(Context context, Collection rows) throws SQLException { - Multimap rowsByPropertyKey = rows.stream() - .collect(MoreCollectors.index(PropertyRow::getPropertyKey)); - Optional rootProperty = rowsByPropertyKey.get("sonar.webhooks.global").stream().findFirst(); - if (rootProperty.isPresent()) { - PropertyRow row = rootProperty.get(); - // can't lambda due to checked exception. - for (Webhook webhook : extractGlobalWebhooksFrom(context, rowsByPropertyKey, row.value().split(","))) { - insert(context, webhook); - } - } - } - - private List extractGlobalWebhooksFrom(Context context, Multimap rowsByPropertyKey, String[] values) throws SQLException { - String defaultOrganizationUuid = defaultOrganizationUuidProvider.get(context); - return Arrays.stream(values) - .map(value -> { - Optional name = rowsByPropertyKey.get("sonar.webhooks.global." + value + ".name").stream().findFirst(); - Optional url = rowsByPropertyKey.get("sonar.webhooks.global." + value + ".url").stream().findFirst(); - if (name.isPresent() && url.isPresent()) { - return new Webhook( - name.get(), - url.get(), - defaultOrganizationUuid, - null); - } - LOGGER.warn( - "Global webhook missing name and/or url will be deleted (name='{}', url='{}')", - name.map(PropertyRow::value).orElse(null), - url.map(PropertyRow::value).orElse(null)); - return null; - }) - .filter(Objects::nonNull) - .collect(toList()); - } - - private void migrateProjectsWebhooks(Context context, Collection rows) throws SQLException { - Multimap rowsByPropertyKey = rows.stream() - .collect(MoreCollectors.index(PropertyRow::getPropertyKey)); - Optional rootProperty = rowsByPropertyKey.get("sonar.webhooks.project").stream().findFirst(); - if (rootProperty.isPresent()) { - PropertyRow row = rootProperty.get(); - if (row.getProjectUuid() == null) { - LOGGER.warn("At least one webhook referenced missing or non project resource '{}' and will be deleted", row.getResourceId()); - } else { - for (Webhook webhook : extractProjectWebhooksFrom(row, rowsByPropertyKey, row.value().split(","))) { - insert(context, webhook); - } - } - } - } - - private static List extractProjectWebhooksFrom(PropertyRow row, Multimap properties, String[] values) { - return Arrays.stream(values) - .map(value -> { - Optional name = properties.get("sonar.webhooks.project." + value + ".name").stream().findFirst(); - Optional url = properties.get("sonar.webhooks.project." + value + ".url").stream().findFirst(); - if (name.isPresent() && url.isPresent()) { - return new Webhook(name.get(), url.get(), null, row.projectUuid); - } - LOGGER.warn("Project webhook for project {} (id={}) missing name and/or url will be deleted (name='{}', url='{}')", - row.getProjectUuid(), row.getResourceId(), name.map(PropertyRow::value).orElse(null), url.map(PropertyRow::value).orElse(null)); - return null; - }) - .filter(Objects::nonNull) - .collect(MoreCollectors.toList()); - } - - private void insert(Context context, Webhook webhook) throws SQLException { - if (webhook.isValid()) { - context.prepareUpsert("insert into webhooks (uuid, name, url, organization_uuid, project_uuid, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?)") - .setString(1, uuidFactory.create()) - .setString(2, webhook.name()) - .setString(3, webhook.url()) - .setString(4, webhook.organisationUuid()) - .setString(5, webhook.projectUuid()) - .setLong(6, webhook.createdAt()) - .setLong(7, webhook.createdAt()) - .execute() - .commit(); - } else { - LOGGER.info("Unable to migrate inconsistent webhook (entry deleted from PROPERTIES) : " + webhook); - } - } - - private static class PropertyRow { - private final Long id; - private final String propertyKey; - private final Long resourceId; - private final String projectUuid; - private final String value; - private final Long createdAt; - - private PropertyRow(long id, String propertyKey, @Nullable Long resourceId, @Nullable String projectUuid, String value, Long createdAt) { - this.id = id; - this.propertyKey = propertyKey; - this.resourceId = resourceId; - this.projectUuid = projectUuid; - this.value = value; - this.createdAt = createdAt; - } - - public Long id() { - return id; - } - - public String getPropertyKey() { - return propertyKey; - } - - public long getResourceId() { - return resourceId == null ? NO_RESOURCE_ID : resourceId; - } - - @CheckForNull - public String getProjectUuid() { - return projectUuid; - } - - public String value() { - return value; - } - - public Long createdAt() { - return createdAt; - } - - @Override - public String toString() { - return "{" + - "id=" + id + - ", propertyKey='" + propertyKey + '\'' + - ", resourceId=" + resourceId + - ", projectUuid=" + projectUuid + - ", value='" + value + '\'' + - ", createdAt=" + createdAt + - '}'; - } - } - - private static class Webhook { - - private final PropertyRow name; - private final PropertyRow url; - private String organisationUuid; - private String projectUuid; - - public Webhook(@Nullable PropertyRow name, @Nullable PropertyRow url, @Nullable String organisationUuid, @Nullable String projectUuid) { - this.name = name; - this.url = url; - this.organisationUuid = organisationUuid; - this.projectUuid = projectUuid; - } - - public String name() { - return name.value(); - } - - public String url() { - return url.value(); - } - - public String organisationUuid() { - return organisationUuid; - } - - public String projectUuid() { - return projectUuid; - } - - public Long createdAt() { - return name.createdAt(); - } - - public boolean isValid() { - return name != null && url != null && name() != null && url() != null && (organisationUuid() != null || projectUuid() != null) && createdAt() != null; - } - - @Override - public String toString() { - final StringBuilder s = new StringBuilder().append("Webhook{").append("name=").append(name); - if (name != null) { - s.append(name.toString()); - } - s.append(", url=").append(url); - if (url != null) { - s.append(url.toString()); - } - s.append(", organisationUuid='").append(organisationUuid).append('\'') - .append(", projectUuid='").append(projectUuid).append('\'').append('}'); - return s.toString(); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2.java deleted file mode 100644 index c4674428896..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import com.google.common.collect.ImmutableList; -import java.sql.SQLException; -import java.util.List; -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; - -/** - * Populate PROJECT_LINK2 data from PROJECT_LINK table and take the opportunity to do some cleanup : - * - Ignore link that are not set on project (only take component with qualifier TRK and scope PRJ) - * - Do not set a name on provided links (SONAR-10411) - * - Do not copy link on Developer Connection (SONAR-10299) - */ -public class PopulateTableProjectLinks2 extends DataChange { - - private static final String TYPE_HOME_PAGE = "homepage"; - private static final String TYPE_CI = "ci"; - private static final String TYPE_ISSUE_TRACKER = "issue"; - private static final String TYPE_SOURCES = "scm"; - private static final String TYPE_SOURCES_DEV = "scm_dev"; - private static final List PROVIDED_TYPES = ImmutableList.of(TYPE_HOME_PAGE, TYPE_CI, TYPE_ISSUE_TRACKER, TYPE_SOURCES); - - private static final String SCOPE_PROJECT = "PRJ"; - private static final String QUALIFIER_PROJECT = "TRK"; - - private final UuidFactory uuidFactory; - private final System2 system2; - - public PopulateTableProjectLinks2(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT" + - " p.component_uuid, p.link_type, p.name, p.href" + - " from project_links p" + - // Join on projects in order to sanitize orphans (if any) - " inner join projects prj on prj.uuid=p.component_uuid and prj.scope=? and prj.qualifier=? " + - " left outer join project_links2 p2" + - " on p2.project_uuid=p.component_uuid " + - " and p2.href=p.href" + - " and p2.link_type=p.link_type" + - " and (p2.name=p.name or (p2.name is null and p.link_type in (?, ?, ?, ?)))" + - " where" + - " p2.uuid is null" + - " order by p.id") - .setString(1, SCOPE_PROJECT) - .setString(2, QUALIFIER_PROJECT) - .setString(3, TYPE_HOME_PAGE) - .setString(4, TYPE_CI) - .setString(5, TYPE_ISSUE_TRACKER) - .setString(6, TYPE_SOURCES); - massUpdate.update("insert into project_links2" + - " (uuid, project_uuid, link_type, name, href, created_at, updated_at)" + - " values " + - " (?, ?, ?, ?, ?, ?, ?)"); - massUpdate.rowPluralName("project links"); - massUpdate.execute((row, update) -> { - String componentUuid = row.getString(1); - String linkType = row.getString(2); - String name = row.getString(3); - String href = row.getString(4); - - // project link "developer connection" are removed - if (linkType.equals(TYPE_SOURCES_DEV)) { - return false; - } - - update.setString(1, uuidFactory.create()); - update.setString(2, componentUuid); - update.setString(3, linkType); - // provided type don't need anymore a name, the UI will display it by getting the i18 bundle of the link_type value - if (PROVIDED_TYPES.contains(linkType)) { - update.setString(4, null); - } else { - update.setString(4, name); - } - update.setString(5, href); - update.setLong(6, now); - update.setLong(7, now); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinks.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinks.java deleted file mode 100644 index 4aa10c6e4c2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinks.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.RenameTableBuilder; -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 RenameTableProjectLinks2ToProjectLinks extends DdlChange { - - public RenameTableProjectLinks2ToProjectLinks(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new RenameTableBuilder(getDialect()) - .setName("project_links2") - .setNewName("project_links") - .setAutoGeneratedId(false) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable("project_links") - .setName("project_links_project") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranches.java deleted file mode 100644 index 790abeb3e86..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranches.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class ReplaceIndexInProjectBranches extends DdlChange { - - static final String TABLE_NAME = "project_branches"; - private static final String OLD_INDEX_NAME = "project_branches_kee"; - static final String NEW_INDEX_NAME = "project_branches_kee_key_type"; - - static final VarcharColumnDef PROJECT_UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(50) - .build(); - - static final VarcharColumnDef KEE_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(255) - .build(); - - static final VarcharColumnDef KEY_TYPE_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("key_type") - .setIsNullable(false) - .setLimit(12) - .build(); - - public ReplaceIndexInProjectBranches(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(OLD_INDEX_NAME) - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(PROJECT_UUID_COLUMN) - .addColumn(KEE_COLUMN) - .addColumn(KEY_TYPE_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName(NEW_INDEX_NAME) - .build() - ); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranches.java deleted file mode 100644 index 16d70f128a4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranches.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -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 SetKeyTypeToBranchInProjectBranches extends DataChange { - static final String TABLE_NAME = "project_branches"; - static final String DEFAULT_KEY_TYPE = "BRANCH"; - - private final System2 system2; - - public SetKeyTypeToBranchInProjectBranches(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.rowPluralName("branches"); - massUpdate.select("select uuid from " + TABLE_NAME + " where key_type is null"); - massUpdate.update("update " + TABLE_NAME + " set key_type=?, updated_at=? where uuid = ?"); - massUpdate.execute((row, update) -> { - update.setString(1, DEFAULT_KEY_TYPE); - update.setLong(2, now); - update.setString(3, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMain.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMain.java deleted file mode 100644 index 85376012c87..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMain.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.api.rule.RuleScope; -import org.sonar.api.utils.System2; -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 SetRuleScopeToMain extends DataChange { - private final System2 system2; - - public SetRuleScopeToMain(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from rules where scope is NULL"); - massUpdate.rowPluralName("rules"); - massUpdate.update("update rules set scope=?, updated_at=? where scope is NULL"); - massUpdate.execute((row, update) -> { - update.setString(1, RuleScope.MAIN.name()); - update.setLong(2, now); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeys.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeys.java deleted file mode 100644 index c5562d269e4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeys.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -/** - * SONAR-10409 - * - * Update keys of PERMISSION_TEMPLATES that are longer than 40 characters - */ -public class UpdatePermissionTooLongTemplateKeys extends DataChange { - - private final String lengthFunction; - private final UuidFactory uuidFactory; - - public UpdatePermissionTooLongTemplateKeys(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - if (db.getDialect().getId().equals(MsSql.ID)) { - lengthFunction = "len"; - } else { - lengthFunction = "length"; - } - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select kee from permission_templates where " + lengthFunction + "(kee) > ?").setInt(1, VarcharColumnDef.UUID_SIZE); - massUpdate.update("update permission_templates set kee=? where kee=?"); - massUpdate.rowPluralName("permission templates"); - - massUpdate.execute((row, update) -> { - String oldKey = row.getString(1); - String newKey = uuidFactory.create(); - - update.setString(1, newKey); - update.setString(2, oldKey); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesData.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesData.java deleted file mode 100644 index 5edfa913685..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesData.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.util.Map; -import java.util.stream.Collectors; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.utils.KeyValueFormat; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class UseRuleIdInQPChangesData extends DataChange { - - private static final String RULE_KEY_DATA_FIELD = "ruleKey"; - private static final String RULE_ID_DATA_FIELD = "ruleId"; - - public UseRuleIdInQPChangesData(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - Map ruleKeysById = context.prepareSelect("select id, plugin_name, plugin_rule_key from rules") - .list(row -> new Rule(row.getInt(1), RuleKey.of(row.getString(2), row.getString(3)).toString())) - .stream() - .collect(Collectors.toMap(r -> r.ruleKey, r -> r.ruleId)); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select kee,change_data from qprofile_changes"); - massUpdate.update("update qprofile_changes set change_data=? where kee=?"); - massUpdate.execute(((row, update) -> handle(row, update, ruleKeysById))); - } - - private static boolean handle(Select.Row row, SqlStatement update, Map ruleKeysById) throws SQLException { - String key = row.getString(1); - String data = row.getString(2); - - Map map = KeyValueFormat.parse(data); - String ruleKey = map.get(RULE_KEY_DATA_FIELD); - if (ruleKey == null) { - return false; - } - - Integer ruleId = ruleKeysById.get(ruleKey); - if (ruleId != null) { - map.put(RULE_ID_DATA_FIELD, String.valueOf(ruleId)); - } - map.remove(RULE_KEY_DATA_FIELD); - - update.setString(1, KeyValueFormat.format(map)); - update.setString(2, key); - return true; - } - - private static final class Rule { - private final int ruleId; - private final String ruleKey; - - private Rule(int ruleId, String ruleKey) { - this.ruleId = ruleId; - this.ruleKey = ruleKey; - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/package-info.java deleted file mode 100644 index df0391cec14..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v71/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v71; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsers.java deleted file mode 100644 index 0e95f0bac88..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsers.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 AddExternalIdToUsers extends DdlChange { - - public AddExternalIdToUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "users") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("external_id") - .setLimit(255) - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCount.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCount.java deleted file mode 100644 index 839f5b07caf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCount.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.IntegerColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddFileSourceLineCount extends DdlChange { - public AddFileSourceLineCount(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "file_sources") - .addColumn(IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("line_count") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTable.java deleted file mode 100644 index 6bf3ae9f011..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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; - -public class AddHashMethodToUsersTable extends DdlChange { - - public AddHashMethodToUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "users") - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("hash_method") - .setIsNullable(true) - .setLimit(10) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSources.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSources.java deleted file mode 100644 index 7da7fe63bd2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSources.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.IntegerColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddLineHashesVersionToFileSources extends DdlChange { - - public AddLineHashesVersionToFileSources(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "file_sources") - .addColumn(IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("line_hashes_version") - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsers.java deleted file mode 100644 index 23ba6d58141..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsers.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddOrganizationUuidToUsers extends DdlChange { - - public AddOrganizationUuidToUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "users") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setLimit(UUID_SIZE) - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddRuleExternal.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddRuleExternal.java deleted file mode 100644 index e51f6af0172..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddRuleExternal.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import java.sql.SQLException; - -public class AddRuleExternal extends DdlChange { - - public AddRuleExternal(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "rules") - .addColumn(BooleanColumnDef.newBooleanColumnDefBuilder() - .setColumnName("is_external") - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers.java deleted file mode 100644 index e37e2b01651..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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; - -public class AddUUIDtoUsers extends DdlChange { - - private static final String TABLE_NAME = "users"; - private static final String UUID_COLUMN_NAME = "uuid"; - // We need to use a length of 255 as the migration that fed it will use login, which are using a length of 255 - private static final int UUID_LENGTH = 255; - - public AddUUIDtoUsers(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName(UUID_COLUMN_NAME) - .setIsNullable(true) - .setLimit(UUID_LENGTH) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParameters.java deleted file mode 100644 index d0644008952..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParameters.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -/** - * The missing unique index can be added when server is up, so - * blue/green deployment is supported. - * See {@link PurgeDuplicateRulesParameters} for more details. - */ -@SupportsBlueGreen -public class AddUniqueIndexOnRulesParameters extends DdlChange { - - public AddUniqueIndexOnRulesParameters(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("rules_parameters") - .setName("rules_parameters_unique") - .setUnique(true) - .addColumn(IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("rule_id") - .setIsNullable(false) - .build()) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("name") - .setLimit(128) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsers.java deleted file mode 100644 index 615901e9eb8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsers.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexesOnUsers extends DdlChange { - - public AddUniqueIndexesOnUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("users") - .setName("users_uuid") - .setUnique(true) - .addColumn(notNullableColumn("uuid", 255)) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable("users") - .setName("uniq_external_id") - .setUnique(true) - .addColumn(notNullableColumn("external_identity_provider", 100)) - .addColumn(notNullableColumn("external_id", 255)) - .build()); - } - - private static VarcharColumnDef notNullableColumn(String columnName, int limit) { - return newVarcharColumnDefBuilder() - .setColumnName(columnName) - .setLimit(limit) - .setIsNullable(false) - .build(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTable.java deleted file mode 100644 index 368b0f915a5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTable.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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.BigIntegerColumnDef; -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.sql.CreateTableBuilder; -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.MAX_SIZE; -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 CreateAlmAppInstallsTable extends DdlChange { - - private static final String TABLE_NAME = "alm_app_installs"; - - private static final VarcharColumnDef UUID = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .build(); - private static final VarcharColumnDef ALM_ID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("alm_id") - .setIsNullable(false) - .setLimit(40) - .build(); - private static final VarcharColumnDef OWNER_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("owner_id") - .setIsNullable(false) - .setLimit(MAX_SIZE) - .build(); - private static final VarcharColumnDef INSTALL_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("install_id") - .setIsNullable(false) - .setLimit(MAX_SIZE) - .build(); - private static final BigIntegerColumnDef CREATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - private static final BigIntegerColumnDef UPDATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build(); - - public CreateAlmAppInstallsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - - if (!tableExists()) { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID) - .addColumn(ALM_ID_COLUMN) - .addColumn(OWNER_COLUMN) - .addColumn(INSTALL_COLUMN) - .addColumn(CREATED_AT_COLUMN) - .addColumn(UPDATED_AT_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(ALM_ID_COLUMN) - .addColumn(OWNER_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("alm_app_installs_owner") - .build()); - context.execute(new CreateIndexBuilder() - .addColumn(ALM_ID_COLUMN) - .addColumn(INSTALL_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("alm_app_installs_install") - .build()); - } - } - - private boolean tableExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.tableExists(TABLE_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTable.java deleted file mode 100644 index e50fc1276ca..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTable.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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.BigIntegerColumnDef; -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.sql.CreateTableBuilder; -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.MAX_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateProjectMappingsTable extends DdlChange { - - private static final String TABLE_NAME = "project_mappings"; - - private static final VarcharColumnDef UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final VarcharColumnDef KEY_TYPE_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("key_type") - .setIsNullable(false) - .setLimit(200) - .build(); - private static final VarcharColumnDef KEE_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(MAX_SIZE) - .build(); - private static final VarcharColumnDef PROJECT_UUID = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final BigIntegerColumnDef CREATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - public CreateProjectMappingsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - - if (!tableExists()) { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID_COLUMN) - .addColumn(KEY_TYPE_COLUMN) - .addColumn(KEE_COLUMN) - .addColumn(PROJECT_UUID) - .addColumn(CREATED_AT_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(KEY_TYPE_COLUMN) - .addColumn(KEE_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("key_type_kee") - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(PROJECT_UUID) - .setUnique(false) - .setTable(TABLE_NAME) - .setName("project_uuid") - .build()); - } - } - - private boolean tableExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.tableExists(TABLE_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/DbVersion72.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/DbVersion72.java deleted file mode 100644 index c256d1a495f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/DbVersion72.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion72 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(2100, "Increase size of USERS.CRYPTED_PASSWORD", IncreaseCryptedPasswordSize.class) - .add(2101, "Add HASH_METHOD to table users", AddHashMethodToUsersTable.class) - .add(2102, "Populate HASH_METHOD on table users", PopulateHashMethodOnUsers.class) - .add(2103, "Add isExternal boolean to rules", AddRuleExternal.class) - .add(2104, "Create ALM_APP_INSTALLS table", CreateAlmAppInstallsTable.class) - .add(2105, "Add LINE_HASHES_VERSION to table FILE_SOURCES", AddLineHashesVersionToFileSources.class) - .add(2106, "Create PROJECT_MAPPINGS table", CreateProjectMappingsTable.class) - .add(2107, "Add UUID on table USERS", AddUUIDtoUsers.class) - .add(2108, "Populate USERS.UUID with USERS.LOGIN", PopulateUUIDOnUsers.class) - .add(2109, "Add EXTERNAL_ID on table users", AddExternalIdToUsers.class) - .add(2110, "Rename EXTERNAL_IDENTITY to EXTERNAL_LOGIN on table users", RenameExternalIdentityToExternalLoginOnUsers.class) - .add(2111, "Update null values from external columns and login of users", UpdateNullValuesFromExternalColumnsAndLoginOfUsers.class) - .add(2112, "Fix duplication in EXTERNAL_ID and EXTERNAL_LOGIN on table users", FixDuplicationInExternalLoginOnUsers.class) - .add(2113, "Makes same columns of table users not nullable", MakeSomeColumnsOfUsersNotNullable.class) - .add(2114, "Add unique indexes on table users", AddUniqueIndexesOnUsers.class) - .add(2115, "Add ORGANIZATION_UUID on table users", AddOrganizationUuidToUsers.class) - .add(2116, "Populate ORGANIZATION_UUID in table users", PopulateOrganizationUuidOnUsers.class) - .add(2117, "Drop USER_ID from table organizations", DropUserIdFromOrganizations.class) - .add(2118, "Rename USER_LOGIN TO USER_UUID on table QPROFILE_CHANGES", RenameUserLoginToUserUuidOnTableQProfileChanges.class) - .add(2119, "Rename LOGIN TO USER_UUID on table USER_TOKENS", RenameLoginToUserUuidOnTableUserTokens.class) - .add(2120, "Rename USER_LOGIN TO USER_UUID on table MANUAL_MEASURES", RenameUserLoginToUserUuidOnTableManualMeasures.class) - .add(2121, "Rename NOTE_USER_LOGIN TO NOTE_USER_UUID on table RULES_METADATA", RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata.class) - .add(2122, "Rename SUBMITTER_LOGIN TO SUBMITTER_UUID on table CE_QUEUE", RenameSubmitterLoginToSubmitterUuidOnTableCeQueue.class) - .add(2123, "Rename SUBMITTER_LOGIN TO SUBMITTER_UUID on table CE_ACTIVITY", RenameSubmitterLoginToSubmitterUuidOnTableCeActivity.class) - .add(2124, "Add FILE_SOURCE.LINE_COUNT", AddFileSourceLineCount.class) - .add(2125, "Populate FILE_SOURCE.LINE_COUNT", PopulateFileSourceLineCount.class) - .add(2126, "Make FILE_SOURCE.LINE_COUNT not nullable", MakeFileSourceLineCountNotNullable.class) - .add(2127, "Purge orphans for Compute Engine", PurgeOrphansForCE.class) - .add(2128, "Purge duplicate rules_parameters and their orphans", PurgeDuplicateRulesParameters.class) - .add(2129, "Add unique index on rule_id + name on rules_parameters", AddUniqueIndexOnRulesParameters.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizations.java deleted file mode 100644 index 1c37f0c9310..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizations.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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 DropUserIdFromOrganizations extends DdlChange { - - public DropUserIdFromOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "organizations", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsers.java deleted file mode 100644 index 6a7d645da9e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsers.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -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 FixDuplicationInExternalLoginOnUsers extends DataChange { - - private final System2 system2; - - public FixDuplicationInExternalLoginOnUsers(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("users having duplicated values in EXTERNAL_LOGIN"); - massUpdate.select("SELECT u1.id, u1.login FROM users u1 " + - "WHERE EXISTS (SELECT 1 FROM users u2 WHERE u2.external_login = u1.external_login AND u2.id != u1.id)"); - // EXTERNAL_ID is also updated because the column was added previously and content was copied from EXTERNAL_LOGIN - massUpdate.update("UPDATE users SET external_login=?, external_id=?, updated_at=? WHERE id=?"); - - long now = system2.now(); - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - String login = row.getString(2); - update.setString(1, login); - update.setString(2, login); - update.setLong(3, now); - update.setLong(4, id); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSize.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSize.java deleted file mode 100644 index af654321fc8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSize.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -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 IncreaseCryptedPasswordSize extends DdlChange { - private static final String TABLE_NAME = "users"; - - public IncreaseCryptedPasswordSize(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("crypted_password") - .setLimit(100) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullable.java deleted file mode 100644 index 0535ee135cf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -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.IntegerColumnDef.newIntegerColumnDefBuilder; - -public class MakeFileSourceLineCountNotNullable extends DdlChange { - public MakeFileSourceLineCountNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "file_sources") - .updateColumn(newIntegerColumnDefBuilder() - .setColumnName("line_count") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullable.java deleted file mode 100644 index 436a9c572e0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullable.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeSomeColumnsOfUsersNotNullable extends DdlChange { - - public static final String USERS_TABLE = "users"; - public static final String USERS_LOGIN_INDEX = "users_login"; - - public MakeSomeColumnsOfUsersNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(USERS_TABLE) - .setName(USERS_LOGIN_INDEX) - .build()); - - context.execute(new AlterColumnsBuilder(getDialect(), USERS_TABLE) - .updateColumn(notNullableColumn("uuid", 255)) - .updateColumn(notNullableColumn("login", 255)) - .updateColumn(notNullableColumn("external_id", 255)) - .updateColumn(notNullableColumn("external_login", 255)) - .updateColumn(notNullableColumn("external_identity_provider", 100)) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(USERS_TABLE) - .setName(USERS_LOGIN_INDEX) - .addColumn(notNullableColumn("login", 255)) - .setUnique(true) - .build()); - } - - private static VarcharColumnDef notNullableColumn(String columnName, int limit) { - return newVarcharColumnDefBuilder() - .setColumnName(columnName) - .setLimit(limit) - .setIsNullable(false) - .build(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCount.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCount.java deleted file mode 100644 index bdd6961334b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCount.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -/** - * New column is populated with value {@code -1} rather than with the number of lines computed from the value of column - * {@code line_hashes} (which would be the correct value for this column). - *

- * Column will be populated with the correct value by the new "DB migration step" of the analysis report processing the - * first time a project is analyzed after SonarQube's upgrade. - *

- * This innovative approach to DB migration is used because populating the column from {@code line_hashes} will take - * a very long time on large DBs. - */ -public class PopulateFileSourceLineCount extends DataChange { - private static final int LINE_COUNT_NOT_POPULATED = -1; - - public PopulateFileSourceLineCount(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct project_uuid from file_sources where line_count is null"); - massUpdate.update("update file_sources set line_count = ? where project_uuid = ?") - // Having transactions involving many rows can be very slow and should be avoided. - // A project can have many file_sources, so transaction is committed after each project. - .setBatchSize(1); - massUpdate.rowPluralName("file sources"); - massUpdate.execute(PopulateFileSourceLineCount::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - String projectUuid = row.getString(1); - - update.setInt(1, LINE_COUNT_NOT_POPULATED); - update.setString(2, projectUuid); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsers.java deleted file mode 100644 index 18d35c7e401..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsers.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateHashMethodOnUsers extends DataChange { - - private final System2 system2; - - public PopulateHashMethodOnUsers(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - context.prepareUpsert("UPDATE users SET hash_method=?, updated_at=? WHERE crypted_password IS NOT NULL") - .setString(1, "SHA1") - .setLong(2, system2.now()) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsers.java deleted file mode 100644 index f9f58ead902..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsers.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -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 PopulateOrganizationUuidOnUsers extends DataChange { - - private final System2 system2; - - public PopulateOrganizationUuidOnUsers(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("users"); - massUpdate.select("SELECT u.id, o.uuid FROM users u " + - "INNER JOIN organizations o ON o.user_id=u.id " + - "WHERE u.organization_uuid IS NULL"); - massUpdate.update("UPDATE users SET organization_uuid=?, updated_at=? WHERE id=?"); - - long now = system2.now(); - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - String organizationUuid = row.getString(2); - update.setString(1, organizationUuid); - update.setLong(2, now); - update.setLong(3, id); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsers.java deleted file mode 100644 index b9826f6aafa..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsers.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -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 PopulateUUIDOnUsers extends DataChange { - - private final System2 system2; - private final UuidFactory uuidFactory; - - public PopulateUUIDOnUsers(Database db, System2 system2, UuidFactory uuidFactory) { - super(db); - this.system2 = system2; - this.uuidFactory = uuidFactory; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id, login from users where uuid is null"); - massUpdate.rowPluralName("users"); - massUpdate.update("update users set uuid=?, updated_at=? where id=?"); - massUpdate.execute((row, update) -> { - String login = row.getString(2); - if (login == null) { - login = uuidFactory.create(); - } - // login -> uuid - update.setString(1, login); - update.setLong(2, system2.now()); - update.setLong(3, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParameters.java deleted file mode 100644 index 7ea968173ba..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParameters.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; - -/** - * The migration drops duplicated rows from some rules-related tables. - * The root cause of these duplications is not known. It could even - * be already fixed. Assuming that the duplications are not created frequently, - * nor recently, then executing the migration when server is up - * is safe. Blue/green deployment is supported. - */ -@SupportsBlueGreen -public class PurgeDuplicateRulesParameters extends DataChange { - - private static final String REMOVE_DUPLICATE_RULES_PARAMS_SQL_FOR_GENERIC = - "DELETE FROM rules_parameters p1 WHERE id NOT IN (SELECT * FROM (SELECT MIN(id) FROM rules_parameters GROUP BY rule_id, name) temp)"; - - private static final String REMOVE_DUPLICATE_ACTIVE_RULE_PARAMS_SQL_FOR_GENERIC = - "DELETE FROM active_rule_parameters arp WHERE arp.rules_parameter_id NOT IN (SELECT * FROM (SELECT MIN(id) FROM rules_parameters GROUP BY rule_id, name) temp)"; - - private static final String REMOVE_DUPLICATE_RULES_PARAMS_SQL_FOR_MSSQL = - "DELETE p1 FROM rules_parameters as p1 WHERE id NOT IN (SELECT id FROM (SELECT MIN(id) as id FROM rules_parameters GROUP BY rule_id, name) temp)"; - - private static final String REMOVE_DUPLICATE_ACTIVE_RULE_PARAMS_SQL_FOR_MSSQL = - "DELETE arp FROM active_rule_parameters as arp WHERE arp.rules_parameter_id NOT IN (SELECT id FROM (SELECT MIN(id) as id FROM rules_parameters GROUP BY rule_id, name) temp)"; - - public PurgeDuplicateRulesParameters(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - String removeDuplicateRulesParamsSql; - String removeDuplicateActiveRuleParamsSql; - switch (getDialect().getId()) { - case "mssql": - removeDuplicateRulesParamsSql = REMOVE_DUPLICATE_RULES_PARAMS_SQL_FOR_MSSQL; - removeDuplicateActiveRuleParamsSql = REMOVE_DUPLICATE_ACTIVE_RULE_PARAMS_SQL_FOR_MSSQL; - break; - default: - removeDuplicateRulesParamsSql = REMOVE_DUPLICATE_RULES_PARAMS_SQL_FOR_GENERIC; - removeDuplicateActiveRuleParamsSql = REMOVE_DUPLICATE_ACTIVE_RULE_PARAMS_SQL_FOR_GENERIC; - break; - } - - context.prepareUpsert(removeDuplicateActiveRuleParamsSql) - .execute() - .commit(); - context.prepareUpsert(removeDuplicateRulesParamsSql) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCE.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCE.java deleted file mode 100644 index e399cd04114..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCE.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.util.Arrays.asList; - -/** - * The migration drops the orphans from tables ce_*. It can be executed - * when server is up, so it supports blue/green deployments. - */ -@SupportsBlueGreen -public class PurgeOrphansForCE extends DataChange { - - public PurgeOrphansForCE(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - for (String tableName : asList("ce_task_characteristics", "ce_task_input", "ce_scanner_context")) { - deleteOrphansFrom(context, tableName); - } - } - - private void deleteOrphansFrom(Context context, String tableName) throws SQLException { - String query = buildDeleteFromQuery(tableName, "c", - "not exists (select 1 from ce_activity ca where ca.uuid = c.task_uuid)" + - "and not exists (select 1 from ce_queue cq where cq.uuid = c.task_uuid)"); - - context.prepareUpsert(query) - .execute() - .commit(); - } - - private String buildDeleteFromQuery(String tableName, String alias, String whereClause) { - String dialectId = getDialect().getId(); - if ("mssql".equals(dialectId)) { - return "delete " + alias + " from " + tableName + " as " + alias + " where " + whereClause; - } - return "delete from " + tableName + " " + alias + " where " + whereClause; - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsers.java deleted file mode 100644 index 21085b5dd1a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsers.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RenameExternalIdentityToExternalLoginOnUsers extends DdlChange { - - public RenameExternalIdentityToExternalLoginOnUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new RenameColumnsBuilder(getDialect(), "users") - .renameColumn("external_identity", - newVarcharColumnDefBuilder() - .setColumnName("external_login") - .setLimit(255) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokens.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokens.java deleted file mode 100644 index 54fd5f4d061..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokens.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RenameLoginToUserUuidOnTableUserTokens extends DdlChange { - - private static final String USER_TOKENS_TABLE = "user_tokens"; - - public RenameLoginToUserUuidOnTableUserTokens(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(USER_TOKENS_TABLE) - .setName("user_tokens_login_name") - .build()); - - VarcharColumnDef userUuidColumn = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(255) - .setIsNullable(false) - .build(); - context.execute(new RenameColumnsBuilder(getDialect(), USER_TOKENS_TABLE) - .renameColumn("login", - userUuidColumn) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(USER_TOKENS_TABLE) - .setName("user_tokens_user_uuid_name") - .setUnique(true) - .addColumn(userUuidColumn) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("name") - .setLimit(100) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata.java deleted file mode 100644 index ff1b6592ff6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata extends DdlChange { - - private static final String TABLE = "rules_metadata"; - - public RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new RenameColumnsBuilder(getDialect(), TABLE) - .renameColumn("note_user_login", - newVarcharColumnDefBuilder() - .setColumnName("note_user_uuid") - .setLimit(255) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivity.java deleted file mode 100644 index 42b9406f374..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivity.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RenameSubmitterLoginToSubmitterUuidOnTableCeActivity extends DdlChange { - - private final MigrationEsClient esClient; - - public RenameSubmitterLoginToSubmitterUuidOnTableCeActivity(Database db, MigrationEsClient esClient) { - super(db); - this.esClient = esClient; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new RenameColumnsBuilder(getDialect(), "ce_activity") - .renameColumn("submitter_login", - newVarcharColumnDefBuilder() - .setColumnName("submitter_uuid") - .setLimit(255) - .setIsNullable(true) - .build()) - .build()); - - esClient.deleteIndexes("users"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueue.java deleted file mode 100644 index d868e6c8d23..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueue.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RenameSubmitterLoginToSubmitterUuidOnTableCeQueue extends DdlChange { - - public RenameSubmitterLoginToSubmitterUuidOnTableCeQueue(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new RenameColumnsBuilder(getDialect(), "ce_queue") - .renameColumn("submitter_login", - newVarcharColumnDefBuilder() - .setColumnName("submitter_uuid") - .setLimit(255) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasures.java deleted file mode 100644 index 67f46fe0007..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasures.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RenameUserLoginToUserUuidOnTableManualMeasures extends DdlChange { - - private static final String TABLE = "manual_measures"; - - public RenameUserLoginToUserUuidOnTableManualMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new RenameColumnsBuilder(getDialect(), TABLE) - .renameColumn("user_login", - newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(255) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChanges.java deleted file mode 100644 index 912f850cea7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChanges.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class RenameUserLoginToUserUuidOnTableQProfileChanges extends DdlChange { - - public RenameUserLoginToUserUuidOnTableQProfileChanges(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new RenameColumnsBuilder(getDialect(), "qprofile_changes") - .renameColumn("user_login", - newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(255) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsers.java deleted file mode 100644 index 3bc54f68c5e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsers.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -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; - -/** - * The goal of this migration is to sanitize disabled USERS, regarding new way of authentication users. - * Indeed, authentication will search for user by LOGIN but also by using EXTERNAL_ID and EXTERNAL_PROVIDER. - * - * As a consequence, these columns must be set as NOT NULL in order to add a UNIQUE index on them. - * - * Unfortunately, these columns were previously set as null when disabling a user, that's why we need to populate them. - */ -public class UpdateNullValuesFromExternalColumnsAndLoginOfUsers extends DataChange { - - private static final Logger LOG = Loggers.get(UpdateNullValuesFromExternalColumnsAndLoginOfUsers.class); - - private final System2 system2; - private UuidFactory uuidFactory; - - public UpdateNullValuesFromExternalColumnsAndLoginOfUsers(Database db, System2 system2, UuidFactory uuidFactory) { - super(db); - this.system2 = system2; - this.uuidFactory = uuidFactory; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("users"); - massUpdate.select("SELECT id, login, external_login, external_identity_provider FROM users " + - "WHERE login IS NULL OR external_login IS NULL OR external_id IS NULL OR external_identity_provider IS NULL"); - massUpdate.update("UPDATE users SET login=?, external_login=?, external_id=?, external_identity_provider=?, updated_at=? WHERE id=?"); - - long now = system2.now(); - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - String login = row.getString(2); - if (login == null) { - LOG.warn("No login has been found for user id '{}'. A UUID has been generated to not have null value.", id); - login = uuidFactory.create(); - } - String externalLogin = row.getNullableString(3); - externalLogin = externalLogin == null ? login : externalLogin; - - String externalIdentityProvider = row.getNullableString(4); - - update.setString(1, login); - update.setString(2, externalLogin); - update.setString(3, externalLogin); - update.setString(4, externalIdentityProvider == null ? "sonarqube" : externalIdentityProvider); - update.setLong(5, now); - update.setLong(6, id); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/package-info.java deleted file mode 100644 index db577f646f1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v72; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssues.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssues.java deleted file mode 100644 index b4751a51081..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssues.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -@SupportsBlueGreen -public class AddFromHotspotFlagToIssues extends DdlChange { - - public AddFromHotspotFlagToIssues(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "issues") - .addColumn(newBooleanColumnDefBuilder() - .setColumnName("from_hotspot") - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembers.java deleted file mode 100644 index 1055e19f666..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembers.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.def.IntegerColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -@SupportsBlueGreen -public class AddIndexOnOrganizationMembers extends DdlChange { - public AddIndexOnOrganizationMembers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new CreateIndexBuilder() - .setTable("organization_members") - .setName("ix_org_members_on_user_id") - .addColumn(IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("user_id") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRules.java deleted file mode 100644 index 13f95696f56..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRules.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddSecurityStandardsToRules extends DdlChange { - - private static final String TABLE_NAME = "rules"; - private static final String COLUMN_NAME = "security_standards"; - private static final int COLUMN_LENGTH = 4000; - - public AddSecurityStandardsToRules(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME) - .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName(COLUMN_NAME) - .setIsNullable(true) - .setLimit(COLUMN_LENGTH) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizations.java deleted file mode 100644 index 541b0127dc1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizations.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddSubscriptionToOrganizations extends DdlChange { - - public AddSubscriptionToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "organizations") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("subscription") - .setLimit(40) - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTable.java deleted file mode 100644 index 11163f36e53..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTable.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -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.SupportsBlueGreen; -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class CreateProjectAlmBindingsTable extends DdlChange { - - private static final String TABLE_NAME = "project_alm_bindings"; - - private static final VarcharColumnDef UUID = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .build(); - private static final VarcharColumnDef ALM_ID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("alm_id") - .setIsNullable(false) - .setLimit(40) - .build(); - private static final VarcharColumnDef REPO_ID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("repo_id") - .setIsNullable(false) - .setLimit(256) - .build(); - private static final VarcharColumnDef PROJECT_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(40) - .build(); - private static final VarcharColumnDef GITHUB_SLUG_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("github_slug") - .setIsNullable(true) - .setLimit(256) - .build(); - private static final VarcharColumnDef URL_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("url") - .setIsNullable(false) - .setLimit(2000) - .build(); - private static final BigIntegerColumnDef CREATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - private static final BigIntegerColumnDef UPDATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build(); - - public CreateProjectAlmBindingsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - - if (!tableExists()) { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID) - .addColumn(ALM_ID_COLUMN) - .addColumn(REPO_ID_COLUMN) - .addColumn(PROJECT_UUID_COLUMN) - .addColumn(GITHUB_SLUG_COLUMN) - .addColumn(URL_COLUMN) - .addColumn(CREATED_AT_COLUMN) - .addColumn(UPDATED_AT_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(ALM_ID_COLUMN) - .addColumn(REPO_ID_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_alm_repo") - .build()); - context.execute(new CreateIndexBuilder() - .addColumn(PROJECT_UUID_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_project") - .build()); - } - } - - private boolean tableExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.tableExists(TABLE_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/DbVersion73.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/DbVersion73.java deleted file mode 100644 index 1852a795727..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/DbVersion73.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion73 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(2200, "Populate PROJECT_BRANCHES with existing main application branches", PopulateMainApplicationBranches.class) - .add(2201, "Add 'securityhotspotadmin' permission to all permission templates groups already having 'issueadmin'", PopulateHotspotAdminPermissionOnTemplatesGroups.class) - .add(2202, "Add 'securityhotspotadmin' permission to all permission templates users already having 'issueadmin'", PopulateHotspotAdminPermissionOnTemplatesUsers.class) - .add(2203, "Add 'securityhotspotadmin' permission to all groups already having 'issueadmin'", PopulateHotspotAdminPermissionOnGroups.class) - .add(2204, "Add 'securityhotspotadmin' permission to all users already having 'issueadmin'", PopulateHotspotAdminPermissionOnUsers.class) - .add(2205, "Add 'from hotspot' flag to issues", AddFromHotspotFlagToIssues.class) - .add(2206, "Add SUBSCRIPTION column to ORGANIZATIONS table", AddSubscriptionToOrganizations.class) - .add(2207, "Populate SUBSCRIPTION in ORGANIZATIONS", PopulateSubscriptionOnOrganizations.class) - .add(2208, "Add rules.security_standards", AddSecurityStandardsToRules.class) - .add(2209, "Fix missing quality profiles on organizations", FixMissingQualityProfilesOnOrganizations.class) - .add(2210, "Add 'securityhotspotadmin' permission to templates characteristics already having 'issueadmin'", PopulateHotspotAdminPermissionOnTemplatesCharacteristics.class) - .add(2211, "Set SUBSCRIPTION not nullable in ORGANIZATIONS", SetSubscriptionOnOrganizationsNotNullable.class) - .add(2212, "Add index on ORGANIZATION_MEMBERS", AddIndexOnOrganizationMembers.class) - .add(2213, "Create table to store project ALM bindings", CreateProjectAlmBindingsTable.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizations.java deleted file mode 100644 index ff1f5a98789..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizations.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import java.sql.SQLException; -import java.util.List; -import org.sonar.api.config.Configuration; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -import static java.util.stream.Collectors.joining; - -@SupportsBlueGreen -// SONAR-11021 -public class FixMissingQualityProfilesOnOrganizations extends DataChange { - - private final System2 system2; - private final UuidFactory uuidFactory; - private final Configuration configuration; - private final String as; - - public FixMissingQualityProfilesOnOrganizations(Database db, System2 system2, UuidFactory uuidFactory, Configuration configuration) { - super(db); - this.system2 = system2; - this.uuidFactory = uuidFactory; - this.configuration = configuration; - if (db.getDialect().getId().equals(MsSql.ID)) { - as = " AS "; - } else { - as = ""; - } - } - - @Override - protected void execute(Context context) throws SQLException { - if (!configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) { - return; - } - - long now = system2.now(); - - insertMissingOrgQProfiles(context, now); - insertMissingDefaultQProfiles(context, now); - } - - private void insertMissingOrgQProfiles(Context context, long now) throws SQLException { - MassUpdate massUpdate = context - .prepareMassUpdate() - .rowPluralName("Organization quality profiles"); - massUpdate.select("SELECT o.uuid, rp.kee FROM organizations " + as + " o, rules_profiles " + as + " rp " + - "WHERE rp.is_built_in = ? " + - "AND NOT EXISTS(SELECT (1) FROM org_qprofiles oqp WHERE oqp.organization_uuid = o.uuid AND oqp.rules_profile_uuid = rp.kee)") - .setBoolean(1, true); - massUpdate.update("INSERT INTO org_qprofiles (uuid, organization_uuid, rules_profile_uuid, created_at, updated_at) VALUES(?, ?, ?, ?, ?)"); - massUpdate.execute((row, update) -> { - String organizationUuid = row.getString(1); - String rulesProfileUuid = row.getString(2); - update.setString(1, uuidFactory.create()); - update.setString(2, organizationUuid); - update.setString(3, rulesProfileUuid); - update.setLong(4, now); - update.setLong(5, now); - - return true; - }); - } - - private void insertMissingDefaultQProfiles(Context context, long now) throws SQLException { - String defaultRulesProfileKees = reduceBuiltInQualityProfiles(context) - .stream() - .map(qp -> "'" + qp.kee + "'") - .collect(joining(",")); - - if (defaultRulesProfileKees.isEmpty()) { - return; - } - - MassUpdate massUpdate = context - .prepareMassUpdate() - .rowPluralName("Organization default quality profiles"); - massUpdate.select("SELECT o.uuid, oqp.uuid, rp.language FROM organizations " + as + " o, org_qprofiles " + as + " oqp, rules_profiles " + as + " rp " + - "WHERE oqp.rules_profile_uuid = rp.kee " + - "AND oqp.organization_uuid = o.uuid " + - "AND rp.kee IN ( " + defaultRulesProfileKees + " ) " + - "AND NOT EXISTS(SELECT(1) FROM default_qprofiles dqp WHERE dqp.organization_uuid = o.uuid AND dqp.language = rp.language)"); - massUpdate.update("INSERT INTO default_qprofiles (organization_uuid, language, qprofile_uuid, created_at, updated_at) VALUES(?, ?, ?, ?, ?)"); - massUpdate.execute((row, update) -> { - String organizationUuid = row.getString(1); - String orgQProfileUuid = row.getString(2); - String language = row.getString(3); - update.setString(1, organizationUuid); - update.setString(2, language); - update.setString(3, orgQProfileUuid); - update.setLong(4, now); - update.setLong(5, now); - - return true; - }); - } - - /** - * Return the list of preferred built-in quality profiles. - * In the current state of database, the information of the "by-default" one is absent (handled by plugin). - * Let's choose the "Sonar Way" one, fallbacking to the first one - * - * This methods is returning the list of rules_profiles kee of built-in quality profiles with one by language - */ - private static List reduceBuiltInQualityProfiles(Context context) throws SQLException { - ListMultimap builtInQPByLanguages = ArrayListMultimap.create(); - - List builtInQProfiles = context.prepareSelect("SELECT kee, language, name FROM rules_profiles WHERE is_built_in = ?") - .setBoolean(1, true) - .list(row -> new BuiltInQProfile(row.getString(1), row.getString(2), row.getString(3))); - - builtInQProfiles.forEach(builtInQProfile -> builtInQPByLanguages.put(builtInQProfile.language, builtInQProfile)); - - // Filter all built in quality profiles to have only one by language - // And prefer the one named "Sonar Way" - builtInQPByLanguages.keySet().forEach(l -> { - List qps = builtInQPByLanguages.get(l); - if (qps.size() > 1) { - BuiltInQProfile sonarWay = qps.stream().filter(qp -> qp.name.equals("Sonar way")) - .findFirst() - .orElse(qps.get(0)); - qps.forEach(qp -> { - if (qp.kee.equals(sonarWay.kee)) { - return; - } - builtInQProfiles.remove(qp); - }); - } - }); - - return builtInQProfiles; - } - - private static class BuiltInQProfile { - private final String kee; - private final String language; - private final String name; - - public BuiltInQProfile(String kee, String language, String name) { - this.kee = kee; - this.language = language; - this.name = name; - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroups.java deleted file mode 100644 index 195e2ce12bf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroups.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class PopulateHotspotAdminPermissionOnGroups extends DataChange { - private static final String ISSUE_ADMIN_ROLE = "issueadmin"; - private static final String HOTSPOT_ADMIN_ROLE = "securityhotspotadmin"; - - public PopulateHotspotAdminPermissionOnGroups(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT group_id, resource_id, organization_uuid" + - " FROM group_roles gr1" + - " WHERE role = ?" + - " AND NOT EXISTS (" + - " SELECT id" + - " FROM group_roles gr2" + - " WHERE role = ?" + - " AND gr1.group_id = gr2.group_id" + - " AND gr1.resource_id = gr2.resource_id" + - " AND gr1.organization_uuid = gr2.organization_uuid)") - .setString(1, ISSUE_ADMIN_ROLE) - .setString(2, HOTSPOT_ADMIN_ROLE); - massUpdate.update("INSERT INTO group_roles (group_id, resource_id, organization_uuid, role) values (?,?,?,?)"); - massUpdate.rowPluralName("group roles"); - massUpdate.execute(PopulateHotspotAdminPermissionOnGroups::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - int groupId = row.getInt(1); - int resourceId = row.getInt(2); - String organizationUuid = row.getString(3); - - update.setInt(1, groupId); - update.setInt(2, resourceId); - update.setString(3, organizationUuid); - update.setString(4, HOTSPOT_ADMIN_ROLE); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristics.java deleted file mode 100644 index f8458a4a610..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristics.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.Date; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class PopulateHotspotAdminPermissionOnTemplatesCharacteristics extends DataChange { - private static final String ISSUE_ADMIN_ROLE = "issueadmin"; - private static final String HOTSPOT_ADMIN_ROLE = "securityhotspotadmin"; - private final System2 system2; - - public PopulateHotspotAdminPermissionOnTemplatesCharacteristics(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - Date now = new Date(system2.now()); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT template_id" + - " FROM perm_tpl_characteristics c1" + - " WHERE permission_key = ?" + - " AND with_project_creator = ?" + - " AND NOT EXISTS (" + - " SELECT id" + - " FROM perm_tpl_characteristics c2" + - " WHERE permission_key = ?" + - " AND c1.template_id = c2.template_id)") - .setString(1, ISSUE_ADMIN_ROLE) - .setBoolean(2, true) - .setString(3, HOTSPOT_ADMIN_ROLE); - massUpdate.update("INSERT INTO perm_tpl_characteristics (template_id, permission_key, with_project_creator, created_at, updated_at) values (?,?,?,?,?)"); - massUpdate.rowPluralName("permission templates characteristics"); - massUpdate.execute((row, update) -> handle(row, update, now.getTime())); - } - - private static boolean handle(Select.Row row, SqlStatement update, long now) throws SQLException { - int templateId = row.getInt(1); - - update.setInt(1, templateId); - update.setString(2, HOTSPOT_ADMIN_ROLE); - update.setBoolean(3, true); - update.setLong(4, now); - update.setLong(5, now); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroups.java deleted file mode 100644 index 1b241dc40ca..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroups.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.Date; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class PopulateHotspotAdminPermissionOnTemplatesGroups extends DataChange { - private static final String ISSUE_ADMIN_ROLE = "issueadmin"; - private static final String HOTSPOT_ADMIN_ROLE = "securityhotspotadmin"; - private final System2 system2; - - public PopulateHotspotAdminPermissionOnTemplatesGroups(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - Date now = new Date(system2.now()); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT group_id, template_id" + - " FROM perm_templates_groups gr1" + - " WHERE permission_reference = ?" + - " AND NOT EXISTS (" + - " SELECT id" + - " FROM perm_templates_groups gr2" + - " WHERE permission_reference = ?" + - " AND gr1.group_id = gr2.group_id" + - " AND gr1.template_id = gr2.template_id)") - .setString(1, ISSUE_ADMIN_ROLE) - .setString(2, HOTSPOT_ADMIN_ROLE); - massUpdate.update("INSERT INTO perm_templates_groups (group_id, template_id, permission_reference, created_at, updated_at) values (?,?,?,?,?)"); - massUpdate.rowPluralName("permission templates groups roles"); - massUpdate.execute((row, update) -> handle(row, update, now)); - } - - private static boolean handle(Select.Row row, SqlStatement update, Date now) throws SQLException { - int groupId = row.getInt(1); - int templateId = row.getInt(2); - - update.setInt(1, groupId); - update.setInt(2, templateId); - update.setString(3, HOTSPOT_ADMIN_ROLE); - update.setDate(4, now); - update.setDate(5, now); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsers.java deleted file mode 100644 index be4a281d38d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsers.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.Date; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class PopulateHotspotAdminPermissionOnTemplatesUsers extends DataChange { - private static final String ISSUE_ADMIN_ROLE = "issueadmin"; - private static final String HOTSPOT_ADMIN_ROLE = "securityhotspotadmin"; - private final System2 system2; - - public PopulateHotspotAdminPermissionOnTemplatesUsers(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - Date now = new Date(system2.now()); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT user_id, template_id" + - " FROM perm_templates_users u1" + - " WHERE permission_reference = ?" + - " AND NOT EXISTS (" + - " SELECT id" + - " FROM perm_templates_users u2" + - " WHERE permission_reference = ?" + - " AND u1.user_id = u2.user_id" + - " AND u1.template_id = u2.template_id)") - .setString(1, ISSUE_ADMIN_ROLE) - .setString(2, HOTSPOT_ADMIN_ROLE); - massUpdate.update("INSERT INTO perm_templates_users (user_id, template_id, permission_reference, created_at, updated_at) values (?,?,?,?,?)"); - massUpdate.rowPluralName("permission templates users roles"); - massUpdate.execute((row, update) -> handle(row, update, now)); - } - - private static boolean handle(Select.Row row, SqlStatement update, Date now) throws SQLException { - int userId = row.getInt(1); - int templateId = row.getInt(2); - - update.setInt(1, userId); - update.setInt(2, templateId); - update.setString(3, HOTSPOT_ADMIN_ROLE); - update.setDate(4, now); - update.setDate(5, now); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsers.java deleted file mode 100644 index 592aa0d047a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsers.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class PopulateHotspotAdminPermissionOnUsers extends DataChange { - private static final String ISSUE_ADMIN_ROLE = "issueadmin"; - private static final String HOTSPOT_ADMIN_ROLE = "securityhotspotadmin"; - - public PopulateHotspotAdminPermissionOnUsers(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT user_id, resource_id, organization_uuid" + - " FROM user_roles ur1" + - " WHERE role = ?" + - " AND NOT EXISTS (" + - " SELECT id" + - " FROM user_roles ur2" + - " WHERE role = ?" + - " AND ur1.user_id = ur2.user_id" + - " AND ur1.resource_id = ur2.resource_id" + - " AND ur1.organization_uuid = ur2.organization_uuid)") - .setString(1, ISSUE_ADMIN_ROLE) - .setString(2, HOTSPOT_ADMIN_ROLE); - massUpdate.update("INSERT INTO user_roles (user_id, resource_id, organization_uuid, role) values (?,?,?,?)"); - massUpdate.rowPluralName("user roles"); - massUpdate.execute(PopulateHotspotAdminPermissionOnUsers::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - int userId = row.getInt(1); - int resourceId = row.getInt(2); - String organizationUuid = row.getString(3); - - update.setInt(1, userId); - update.setInt(2, resourceId); - update.setString(3, organizationUuid); - update.setString(4, HOTSPOT_ADMIN_ROLE); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranches.java deleted file mode 100644 index 2ce9144829b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranches.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class PopulateMainApplicationBranches extends DataChange { - - private static final String MAIN_BRANCH_NAME = "master"; - - private final System2 system2; - - public PopulateMainApplicationBranches(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT uuid FROM projects p " - + "WHERE p.scope='PRJ' AND p.qualifier='APP' AND p.main_branch_project_uuid IS NULL " - + "AND NOT EXISTS (SELECT uuid FROM project_branches b WHERE b.uuid = p.uuid)"); - massUpdate.update("INSERT INTO project_branches (uuid, project_uuid, kee, branch_type, key_type, " - + "merge_branch_uuid, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); - massUpdate.rowPluralName("applications"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - update.setString(1, uuid); - update.setString(2, uuid); - update.setString(3, MAIN_BRANCH_NAME); - update.setString(4, "LONG"); - update.setString(5, "BRANCH"); - update.setString(6, null); - update.setLong(7, now); - update.setLong(8, now); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizations.java deleted file mode 100644 index b57ea298580..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizations.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.api.config.Configuration; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class PopulateSubscriptionOnOrganizations extends DataChange { - - private final System2 system2; - private final Configuration configuration; - - public PopulateSubscriptionOnOrganizations(Database db, System2 system2, Configuration configuration) { - super(db); - this.system2 = system2; - this.configuration = configuration; - } - - @Override - protected void execute(Context context) throws SQLException { - if (configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) { - executeOnSonarCloud(context); - } else { - executeOnSonarQube(context); - } - } - - private void executeOnSonarQube(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("organizations"); - massUpdate.select("SELECT o.uuid FROM organizations o WHERE o.subscription IS NULL "); - massUpdate.update("UPDATE organizations SET subscription=?, updated_at=? WHERE uuid=?"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - update.setString(1, "SONARQUBE"); - update.setLong(2, now); - update.setString(3, uuid); - return true; - }); - } - - private void executeOnSonarCloud(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("organizations"); - massUpdate.select("SELECT o.uuid, count(p.uuid) FROM organizations o " + - "LEFT OUTER JOIN projects p on p.organization_uuid=o.uuid AND p.private=? " + - "WHERE subscription IS NULL " + - "GROUP BY o.uuid") - .setBoolean(1, true); - massUpdate.update("UPDATE organizations SET subscription=?, updated_at=? WHERE uuid=?"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - long privateProjectsCount = row.getLong(2); - update.setString(1, privateProjectsCount > 0 ? "PAID" : "FREE"); - update.setLong(2, now); - update.setString(3, uuid); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullable.java deleted file mode 100644 index 12fe4be4b29..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullable.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class SetSubscriptionOnOrganizationsNotNullable extends DdlChange { - - public SetSubscriptionOnOrganizationsNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "organizations") - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("subscription") - .setLimit(40) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/package-info.java deleted file mode 100644 index 4911af7a1f0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v73/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v73; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadata.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadata.java deleted file mode 100644 index bab0ce2395d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadata.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.ClobColumnDef.newClobColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.TinyIntColumnDef.newTinyIntColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class AddAdHocColumnsInInRulesMetadata extends DdlChange { - - public AddAdHocColumnsInInRulesMetadata(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "rules_metadata") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("ad_hoc_name") - .setLimit(200) - .setIsNullable(true) - .build()) - .addColumn(newClobColumnDefBuilder() - .setColumnName("ad_hoc_description") - .setIsNullable(true) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("ad_hoc_severity") - .setIsNullable(true) - .setLimit(10) - .build()) - .addColumn(newTinyIntColumnDefBuilder() - .setColumnName("ad_hoc_type") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator.java deleted file mode 100644 index aa01ecb64fa..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.api.config.Configuration; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; - -@SupportsBlueGreen -public class AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator extends DataChange { - - private final Configuration configuration; - private final DefaultOrganizationUuidProvider defaultOrganizationUuidProvider; - - public AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator(Database db, Configuration configuration, - DefaultOrganizationUuidProvider defaultOrganizationUuidProvider) { - super(db); - this.configuration = configuration; - this.defaultOrganizationUuidProvider = defaultOrganizationUuidProvider; - } - - @Override - protected void execute(Context context) throws SQLException { - if (configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) { - // Nothing to do on SonarCloud - return; - } - - Integer sonarAdmGroupId = context.prepareSelect("SELECT id FROM groups WHERE name=?") - .setString(1, "sonar-administrators") - .get(r -> r.getInt(1)); - - if (sonarAdmGroupId == null) { - // We cannot find the default sonar-administrators groups - return; - } - - insertPermissionIfMissing(context, sonarAdmGroupId, "applicationcreator"); - insertPermissionIfMissing(context, sonarAdmGroupId, "portfoliocreator"); - } - - private void insertPermissionIfMissing(Context context, Integer sonarAdmGroupId, String role) throws SQLException { - if (isPermissionMissing(context, sonarAdmGroupId, role)) { - context.prepareUpsert("INSERT INTO group_roles(organization_uuid, group_id, role) VALUES(?, ?, ?)") - .setString(1, defaultOrganizationUuidProvider.get(context)) - .setInt(2, sonarAdmGroupId) - .setString(3, role) - .execute() - .commit(); - } - } - - private static boolean isPermissionMissing(Context context, Integer sonarAdmGroupId, String role) throws SQLException { - Integer count = context.prepareSelect("SELECT COUNT(id) FROM group_roles WHERE group_id=? AND role=?") - .setInt(1, sonarAdmGroupId) - .setString(2, role) - .get(r -> r.getInt(1)); - - return count == null || count == 0; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizations.java deleted file mode 100644 index 31e30a92cd4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizations.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddDefaultPermTemplateColumnsToOrganizations extends DdlChange { - public AddDefaultPermTemplateColumnsToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new AddColumnsBuilder(getDialect(), "organizations") - .addColumn( - newVarcharColumnDefBuilder() - .setColumnName("default_perm_template_app") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build()) - .addColumn( - newVarcharColumnDefBuilder() - .setColumnName("default_perm_template_port") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRules.java deleted file mode 100644 index cb42483d92b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRules.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -@SupportsBlueGreen -public class AddIsAdHocToRules extends DdlChange { - - public AddIsAdHocToRules(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "rules") - .addColumn(newBooleanColumnDefBuilder() - .setColumnName("is_ad_hoc") - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivity.java deleted file mode 100644 index 5803606af9b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivity.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; - -@SupportsBlueGreen -public class AddTmpColumnsToCeActivity extends AddTmpColumnsToCeTable { - - public AddTmpColumnsToCeActivity(Database db) { - super(db, "ce_activity"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueue.java deleted file mode 100644 index c349212b9ce..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueue.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; - -@SupportsBlueGreen -public class AddTmpColumnsToCeQueue extends AddTmpColumnsToCeTable { - - public AddTmpColumnsToCeQueue(Database db) { - super(db, "ce_queue"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeTable.java deleted file mode 100644 index 51ab5562ae1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeTable.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -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.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -abstract class AddTmpColumnsToCeTable extends DdlChange { - private static final VarcharColumnDef COLUMN_TMP_COMPONENT_UUID = newVarcharColumnDefBuilder() - .setColumnName("tmp_component_uuid") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build(); - private static final VarcharColumnDef COLUMN_TMP_MAIN_COMPONENT_UUID = newVarcharColumnDefBuilder() - .setColumnName("tmp_main_component_uuid") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build(); - private final String tableName; - - public AddTmpColumnsToCeTable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), tableName) - .addColumn(COLUMN_TMP_MAIN_COMPONENT_UUID) - .addColumn(COLUMN_TMP_COMPONENT_UUID) - .build()); - - // create indexes - context.execute(new CreateIndexBuilder() - .setTable(tableName) - .setName(tableName + "_tmp_cpnt_uuid") - .addColumn(COLUMN_TMP_COMPONENT_UUID) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(tableName) - .setName(tableName + "_tmp_main_cpnt_uuid") - .addColumn(COLUMN_TMP_MAIN_COMPONENT_UUID) - .setUnique(false) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivity.java deleted file mode 100644 index fcc299822ca..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivity.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -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.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class AddTmpLastKeyColumnsToCeActivity extends DdlChange { - private static final String TABLE_NAME = "ce_activity"; - private static final int TASK_TYPE_COLUMN_SIZE = 15; - private static final BooleanColumnDef COLUMN_TMP_IS_LAST = newBooleanColumnDefBuilder() - .setColumnName("tmp_is_last") - .setIsNullable(true) - .build(); - private static final VarcharColumnDef COLUMN_TMP_IS_LAST_KEY = newVarcharColumnDefBuilder() - .setColumnName("tmp_is_last_key") - .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE) - .setIsNullable(true) - .build(); - private static final BooleanColumnDef COLUMN_TMP_MAIN_IS_LAST = newBooleanColumnDefBuilder() - .setColumnName("tmp_main_is_last") - .setIsNullable(true) - .build(); - private static final VarcharColumnDef COLUMN_TMP_MAIN_IS_LAST_KEY = newVarcharColumnDefBuilder() - .setColumnName("tmp_main_is_last_key") - .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE) - .setIsNullable(true) - .build(); - private static final VarcharColumnDef COLUMN_STATUS = newVarcharColumnDefBuilder() - .setColumnName("status") - .setLimit(15) - .setIsNullable(false) - .build(); - - public AddTmpLastKeyColumnsToCeActivity(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME) - .addColumn(COLUMN_TMP_IS_LAST) - .addColumn(COLUMN_TMP_IS_LAST_KEY) - .addColumn(COLUMN_TMP_MAIN_IS_LAST) - .addColumn(COLUMN_TMP_MAIN_IS_LAST_KEY) - .build()); - - // create indexes - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_t_islast_key") - .addColumn(COLUMN_TMP_IS_LAST_KEY) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_t_islast") - .addColumn(COLUMN_TMP_IS_LAST) - .addColumn(COLUMN_STATUS) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_t_main_islast_key") - .addColumn(COLUMN_TMP_MAIN_IS_LAST_KEY) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_t_main_islast") - .addColumn(COLUMN_TMP_MAIN_IS_LAST) - .addColumn(COLUMN_STATUS) - .setUnique(false) - .build()); - - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTables.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTables.java deleted file mode 100644 index 1303aa7ab2a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTables.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.api.config.Configuration; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class CleanOrphanRowsInCeTables extends DataChange { - private final Configuration configuration; - - public CleanOrphanRowsInCeTables(Database db, Configuration configuration1) { - super(db); - this.configuration = configuration1; - } - - @Override - protected void execute(Context context) throws SQLException { - if (isSonarCloud(configuration)) { - return; - } - - // clean orphans on ce_activity - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " cea.uuid" + - " from ce_activity cea" + - " where" + - " cea.component_uuid is not null" + - " and cea.main_component_uuid is not null" + - " and cea.component_uuid = cea.main_component_uuid" + - " and exists (select 1 from ce_task_characteristics ctc where ctc.task_uuid = cea.uuid)"); - massUpdate.update("delete from ce_task_input where task_uuid = ?"); - massUpdate.update("delete from ce_scanner_context where task_uuid = ?"); - massUpdate.update("delete from ce_task_characteristics where task_uuid = ?"); - massUpdate.update("delete from ce_activity where uuid = ?"); - massUpdate.rowPluralName("orphans of deleted branch/pr"); - massUpdate.execute((row, update, updateIndex) -> { - String taskUuid = row.getString(1); - update.setString(1, taskUuid); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissions.java deleted file mode 100644 index fb93bdef350..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissions.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import org.sonar.api.security.DefaultGroups; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; - -import java.sql.SQLException; -import java.util.Date; - -@SupportsBlueGreen -public class CreateApplicationsAndPortfoliosCreatorPermissions extends DataChange { - - private static final Logger LOG = Loggers.get(CreateApplicationsAndPortfoliosCreatorPermissions.class); - private static final String DEFAULT_ORGANIZATION_KEY = "default-organization"; - - private final System2 system2; - - public CreateApplicationsAndPortfoliosCreatorPermissions(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - Date now = new Date(system2.now()); - Long adminGroupId = context.prepareSelect("SELECT id FROM groups WHERE name=?") - .setString(1, DefaultGroups.ADMINISTRATORS) - .get(row -> row.getLong(1)); - String templateKey = context.prepareSelect("SELECT default_perm_template_view FROM organizations WHERE kee=?") - .setString(1, DEFAULT_ORGANIZATION_KEY) - .get(row -> row.getString(1)); - - if (adminGroupId == null) { - LOG.info("Unable to find {} group. Skipping adding applications and portfolios creator permissions.", DefaultGroups.ADMINISTRATORS); - return; - } - - if (templateKey == null) { - LOG.info("There is no default template for views. Skipping adding applications and portfolios creator permissions."); - } - - Long templateId = context.prepareSelect("SELECT id FROM permission_templates WHERE kee=?") - .setString(1, templateKey) - .get(row -> row.getLong(1)); - - if (templateId == null) { - LOG.info("Unable to find the default template [{}] for views. Skipping adding applications and portfolios creator permissions.", templateKey); - return; - } - - if (isPermissionAbsent(context, adminGroupId, "applicationcreator")) { - insertPermission(context, adminGroupId, templateId, "applicationcreator", now); - } - - if (isPermissionAbsent(context, adminGroupId, "portfoliocreator")) { - insertPermission(context, adminGroupId, templateId, "portfoliocreator", now); - } - } - - private static boolean isPermissionAbsent(Context context, Long groupId, String permission) throws SQLException { - Long count = context.prepareSelect("SELECT count(*) FROM perm_templates_groups WHERE group_id=? AND permission_reference=?") - .setLong(1, groupId) - .setString(2, permission) - .get(row -> (row.getLong(1))); - - return (count == null) || count == 0; - } - - private static void insertPermission(Context context, Long groupId, Long templateId, String permission, Date now) throws SQLException { - context.prepareUpsert("INSERT INTO perm_templates_groups (group_id, template_id, permission_reference, created_at, updated_at) values (?,?,?,?,?)") - .setLong(1, groupId) - .setLong(2, templateId) - .setString(3, permission) - .setDate(4, now) - .setDate(5, now) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessage.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessage.java deleted file mode 100644 index 4b87653fa0b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessage.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.MAX_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class CreateCeTaskMessage extends DdlChange { - - public static final String TABLE_NAME = "ce_task_message"; - private static final VarcharColumnDef COLUMN_UUID = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef COLUMN_TASK_UUID = newVarcharColumnDefBuilder() - .setColumnName("task_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef COLUMN_MESSAGE = newVarcharColumnDefBuilder() - .setColumnName("message") - .setIsNullable(false) - .setLimit(MAX_SIZE) - .build(); - private static final BigIntegerColumnDef COLUMN_CREATED_AT = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - public CreateCeTaskMessage(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - CreateTableBuilder createTableBuilder = new CreateTableBuilder(getDialect(), TABLE_NAME); - if (!createTableBuilder.tableExists(getDatabase())) { - context.execute(createTableBuilder - .addPkColumn(COLUMN_UUID) - .addColumn(COLUMN_TASK_UUID) - .addColumn(COLUMN_MESSAGE) - .addColumn(COLUMN_CREATED_AT) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_task") - .addColumn(COLUMN_TASK_UUID) - .setUnique(false) - .build()); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74.java deleted file mode 100644 index 6a30e9412a6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion74 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(2300, "Populate null values of IS_EXTERNAL in RULES", PopulateNullValuesOfIsExternalOnRules.class) - .add(2301, "Add IS_ADHOC column to RULES table", AddIsAdHocToRules.class) - .add(2302, "Populate IS_AD_HOC in RULES", PopulateIsAdHocOnRules.class) - .add(2303, "Set IS_EXTERNAL and IS_AD_HOC not nullable in RULES", SetIsExternalAndIsAdHocNotNullableInRules.class) - .add(2304, "Add ad hoc related columns in RULES_METADATA", AddAdHocColumnsInInRulesMetadata.class) - .add(2312, "Add CE_QUEUE.MAIN_COMPONENT_UUID 1/3", AddTmpColumnsToCeQueue.class) - .add(2313, "Add CE_ACTIVITY.MAIN_COMPONENT_UUID 1/3", AddTmpColumnsToCeActivity.class) - .add(2314, "Populate CE_QUEUE.MAIN_COMPONENT_UUID 2/3", PopulateTmpColumnsToCeQueue.class) - .add(2315, "Populate CE_ACTIVITY.MAIN_COMPONENT_UUID 2/3", PopulateTmpColumnsToCeActivity.class) - .add(2316, "Add CE_ACTIVITY.MAIN_LAST_KEY 1/3", AddTmpLastKeyColumnsToCeActivity.class) - .add(2317, "Populate CE_ACTIVITY.MAIN_LAST_KEY 2/3", PopulateTmpLastKeyColumnsToCeActivity.class) - .add(2318, "Finalize CE_QUEUE.MAIN_COMPONENT_UUID 3/3", FinalizeMainComponentUuidColumnsToCeActivity.class) - .add(2319, "Finalize CE_ACTIVITY.MAIN_COMPONENT_UUID 3/3", FinalizeMainComponentUuidColumnsToCeQueue.class) - .add(2320, "Finalize CE_ACTIVITY.MAIN_LAST_KEY 3/3", FinalizeMainLastKeyColumnsToCeActivity.class) - .add(2321, "Increase organization key and name length", IncreaseOrganizationsKeeAndNameLength.class) - .add(2322, "Create table CE_TASK_MESSAGE", CreateCeTaskMessage.class) - .add(2323, "Clean orphans from deleted branches and PRs in CE_* tables", CleanOrphanRowsInCeTables.class) - .add(2324, "Create new creator permissions for applications and portfolios", CreateApplicationsAndPortfoliosCreatorPermissions.class) - .add(2325, "Add default templates for applications and portfolios", AddDefaultPermTemplateColumnsToOrganizations.class) - .add(2326, "Create new creator permissions for applications and portfolios", CreateApplicationsAndPortfoliosCreatorPermissions.class) - .add(2327, "Populate default template permissions on organizations", PopulateDefaultPermTemplateOnOrganizations.class) - .add(2328, "Add portfolio and application creator permissions on sonar-administrators group", AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator.class) - .add(2329, "Drop column DEFAULT_PERM_TEMPLATE_VIEW on organizations", DropDefaultPermTemplateViewFromOrganizations.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizations.java deleted file mode 100644 index cd64b933bbb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizations.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -@SupportsBlueGreen -public class DropDefaultPermTemplateViewFromOrganizations extends DdlChange { - - public DropDefaultPermTemplateViewFromOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "organizations", "default_perm_template_view").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivity.java deleted file mode 100644 index 9575cf91534..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivity.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import org.sonar.db.Database; - -public class FinalizeMainComponentUuidColumnsToCeActivity extends FinalizeMainComponentUuidColumnsToCeTable { - - public FinalizeMainComponentUuidColumnsToCeActivity(Database db) { - super(db, "ce_activity"); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueue.java deleted file mode 100644 index dff65a05a43..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueue.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import org.sonar.db.Database; - -public class FinalizeMainComponentUuidColumnsToCeQueue extends FinalizeMainComponentUuidColumnsToCeTable { - public FinalizeMainComponentUuidColumnsToCeQueue(Database db) { - super(db, "ce_queue"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeTable.java deleted file mode 100644 index af2a9911bd5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeTable.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public abstract class FinalizeMainComponentUuidColumnsToCeTable extends DdlChange { - private static final VarcharColumnDef COLUMN_COMPONENT_UUID = newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build(); - private static final VarcharColumnDef COLUMN_MAIN_COMPONENT_UUID = newVarcharColumnDefBuilder() - .setColumnName("main_component_uuid") - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build(); - private final String tableName; - - FinalizeMainComponentUuidColumnsToCeTable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - // drop index on existing column COMPONENT_UUID - context.execute(new DropIndexBuilder(getDialect()) - .setTable(tableName) - .setName(tableName + "_component_uuid") - .build()); - // drop existing column - context.execute(new DropColumnsBuilder(getDialect(), tableName, "component_uuid").build()); - - // drop indexes on tmp columns - context.execute(new DropIndexBuilder(getDialect()) - .setTable(tableName) - .setName(tableName + "_tmp_cpnt_uuid") - .build()); - context.execute(new DropIndexBuilder(getDialect()) - .setTable(tableName) - .setName(tableName + "_tmp_main_cpnt_uuid") - .build()); - - // rename tmp columns - context.execute(new RenameColumnsBuilder(getDialect(), tableName) - .renameColumn("tmp_component_uuid", COLUMN_COMPONENT_UUID) - .renameColumn("tmp_main_component_uuid", COLUMN_MAIN_COMPONENT_UUID) - .build()); - - // recreate indexes on renamed columns - context.execute(new CreateIndexBuilder() - .setTable(tableName) - .setName(tableName + "_component") - .addColumn(COLUMN_COMPONENT_UUID) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(tableName) - .setName(tableName + "_main_component") - .addColumn(COLUMN_MAIN_COMPONENT_UUID) - .setUnique(false) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivity.java deleted file mode 100644 index e93c562ff6e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivity.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -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.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; -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 FinalizeMainLastKeyColumnsToCeActivity extends DdlChange { - private static final String TABLE_NAME = "ce_activity"; - private static final int TASK_TYPE_COLUMN_SIZE = 15; - private static final BooleanColumnDef COLUMN_IS_LAST = newBooleanColumnDefBuilder() - .setColumnName("is_last") - .setIsNullable(false) - .build(); - private static final VarcharColumnDef COLUMN_IS_LAST_KEY = newVarcharColumnDefBuilder() - .setColumnName("is_last_key") - .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE) - .setIsNullable(false) - .build(); - private static final BooleanColumnDef COLUMN_MAIN_IS_LAST = newBooleanColumnDefBuilder() - .setColumnName("main_is_last") - .setIsNullable(false) - .build(); - private static final VarcharColumnDef COLUMN_MAIN_IS_LAST_KEY = newVarcharColumnDefBuilder() - .setColumnName("main_is_last_key") - .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE) - .setIsNullable(false) - .build(); - private static final VarcharColumnDef COLUMN_STATUS = newVarcharColumnDefBuilder() - .setColumnName("status") - .setLimit(15) - .setIsNullable(false) - .build(); - - public FinalizeMainLastKeyColumnsToCeActivity(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - // drop index on existing columns - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("ce_activity_islastkey") - .build()); - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("ce_activity_islast_status") - .build()); - - // drop existing columns - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, COLUMN_IS_LAST.getName(), COLUMN_IS_LAST_KEY.getName()) - .build()); - - // drop index on tmp columns - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("ce_activity_t_islast_key") - .build()); - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("ce_activity_t_islast") - .build()); - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("ce_activity_t_main_islast_key") - .build()); - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("ce_activity_t_main_islast") - .build()); - - // rename tmp columns - context.execute(new RenameColumnsBuilder(getDialect(), TABLE_NAME) - .renameColumn("tmp_is_last", COLUMN_IS_LAST) - .renameColumn("tmp_is_last_key", COLUMN_IS_LAST_KEY) - .renameColumn("tmp_main_is_last", COLUMN_MAIN_IS_LAST) - .renameColumn("tmp_main_is_last_key", COLUMN_MAIN_IS_LAST_KEY) - .build()); - - // make not nullable - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(COLUMN_IS_LAST) - .updateColumn(COLUMN_IS_LAST_KEY) - .updateColumn(COLUMN_MAIN_IS_LAST) - .updateColumn(COLUMN_MAIN_IS_LAST_KEY) - .build()); - - // create indexes - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_islast_key") - .addColumn(COLUMN_IS_LAST_KEY) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_islast") - .addColumn(COLUMN_IS_LAST) - .addColumn(COLUMN_STATUS) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_main_islast_key") - .addColumn(COLUMN_MAIN_IS_LAST_KEY) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_main_islast") - .addColumn(COLUMN_MAIN_IS_LAST) - .addColumn(COLUMN_STATUS) - .setUnique(false) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLength.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLength.java deleted file mode 100644 index dcd49a2ad36..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLength.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class IncreaseOrganizationsKeeAndNameLength extends DdlChange { - - public static final String ORGANIZATIONS_TABLE = "organizations"; - - public IncreaseOrganizationsKeeAndNameLength(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), ORGANIZATIONS_TABLE) - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("kee") - .setLimit(255) - .setIsNullable(false) - .build()) - .build()); - context.execute(new AlterColumnsBuilder(getDialect(), ORGANIZATIONS_TABLE) - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("name") - .setLimit(255) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizations.java deleted file mode 100644 index a4eb89d015b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizations.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class PopulateDefaultPermTemplateOnOrganizations extends DataChange { - - private final System2 system2; - - public PopulateDefaultPermTemplateOnOrganizations(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("organizations"); - massUpdate.select("SELECT uuid, default_perm_template_view FROM organizations WHERE default_perm_template_view IS NOT NULL"); - massUpdate.update("UPDATE organizations " + - "SET default_perm_template_app=?, default_perm_template_port=?, updated_at=? " + - "WHERE uuid=?"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - String defaultPermTemplateView = row.getString(2); - update.setString(1, defaultPermTemplateView); - update.setString(2, defaultPermTemplateView); - update.setLong(3, now); - update.setString(4, uuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRules.java deleted file mode 100644 index d3a7506de65..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRules.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class PopulateIsAdHocOnRules extends DataChange { - - private final System2 system2; - - public PopulateIsAdHocOnRules(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("rules"); - massUpdate.select("SELECT r.id, r.is_external FROM rules r WHERE r.is_ad_hoc IS NULL"); - massUpdate.update("UPDATE rules SET is_ad_hoc=?, updated_at=? WHERE id=?"); - massUpdate.execute((row, update) -> { - int id = row.getInt(1); - update.setBoolean(1, row.getBoolean(2)); - update.setLong(2, now); - update.setInt(3, id); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRules.java deleted file mode 100644 index aaa39dc17a6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRules.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class PopulateNullValuesOfIsExternalOnRules extends DataChange { - - private final System2 system2; - - public PopulateNullValuesOfIsExternalOnRules(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("rules"); - massUpdate.select("SELECT r.id FROM rules r WHERE r.is_external IS NULL"); - massUpdate.update("UPDATE rules SET is_external=?, updated_at=? WHERE id=?"); - massUpdate.execute((row, update) -> { - int id = row.getInt(1); - update.setBoolean(1, false); - update.setLong(2, now); - update.setInt(3, id); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivity.java deleted file mode 100644 index 308e003bd67..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivity.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class PopulateTmpColumnsToCeActivity extends DataChange { - - public PopulateTmpColumnsToCeActivity(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - // activity of long and short branches - populateCeActivityTmpColumns(context, "Archived tasks of branches", - "select" + - " cea.uuid, p.uuid, cea.component_uuid" + - " from ce_activity cea" + - " inner join projects mp on mp.uuid = cea.component_uuid" + - " inner join ce_task_characteristics ctc1 on ctc1.task_uuid = cea.uuid and ctc1.kee = 'branchType'" + - " inner join ce_task_characteristics ctc2 on ctc2.task_uuid = cea.uuid and ctc2.kee = 'branch'" + - " inner join projects p on p.kee = concat(mp.kee, concat(':BRANCH:', ctc2.text_value))" + - " where" + - " cea.component_uuid is not null" + - " and (cea.tmp_component_uuid is null or cea.tmp_main_component_uuid is null)"); - - // activity of PRs - populateCeActivityTmpColumns(context, "Archived tasks of PRs", - "select" + - " cea.uuid, p.uuid, cea.component_uuid" + - " from ce_activity cea" + - " inner join projects mp on mp.uuid = cea.component_uuid " + - " inner join ce_task_characteristics ctc1 on ctc1.task_uuid = cea.uuid and ctc1.kee = 'pullRequest'" + - " inner join projects p on p.kee = concat(mp.kee, concat(':PULL_REQUEST:', ctc1.text_value))" + - " where" + - " cea.component_uuid is not null" + - " and (cea.tmp_component_uuid is null or cea.tmp_main_component_uuid is null)"); - - // all activities which tmp columns are not populated yet (will include main and deprecated branches) - // both tmp columns will be set to CE_ACTIVITY.COMPONENT_UUID - // do not join on PROJECTS to also catch orphans - populateCeActivityTmpColumns(context, "Archived tasks of main and deprecated branches", - "select" + - " cea.uuid, cea.component_uuid, cea.component_uuid" + - " from ce_activity cea" + - " where" + - " cea.component_uuid is not null" + - " and (cea.tmp_component_uuid is null or cea.tmp_main_component_uuid is null)"); - } - - private static void populateCeActivityTmpColumns(Context context, String rowPluralName, String sql) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select(sql); - massUpdate.update("update ce_activity set tmp_component_uuid=?, tmp_main_component_uuid=? where uuid=?"); - massUpdate.rowPluralName(rowPluralName); - massUpdate.execute(PopulateTmpColumnsToCeActivity::handleUpdate); - } - - private static boolean handleUpdate(Select.Row row, SqlStatement update) throws SQLException { - String uuid = row.getString(1); - String componentUuuid = row.getString(2); - String mainComponentUuuid = row.getString(3); - - update.setString(1, componentUuuid); - update.setString(2, mainComponentUuuid); - update.setString(3, uuid); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueue.java deleted file mode 100644 index 9fa4c9eac49..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueue.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class PopulateTmpColumnsToCeQueue extends DataChange { - public PopulateTmpColumnsToCeQueue(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - // queued task of long and short branches which have already been analyzed at least once - populateCeQueueTmpColumns(context, "queued tasks of branches", - "select" + - " cq.uuid, p.uuid, cq.component_uuid" + - " from ce_queue cq" + - " inner join projects mp on mp.uuid = cq.component_uuid" + - " inner join ce_task_characteristics ctc1 on ctc1.task_uuid = cq.uuid and ctc1.kee = 'branchType'" + - " inner join ce_task_characteristics ctc2 on ctc2.task_uuid = cq.uuid and ctc2.kee = 'branch'" + - " inner join projects p on p.kee = concat(mp.kee, concat(':BRANCH:', ctc2.text_value))" + - " where" + - " cq.component_uuid is not null" + - " and (cq.tmp_component_uuid is null or cq.tmp_main_component_uuid is null)"); - - // queued task of pull request which have already been analyzed at least once - populateCeQueueTmpColumns(context, "queued tasks of PRs", - " select" + - " cq.uuid, p.uuid, cq.component_uuid" + - " from ce_queue cq" + - " inner join projects mp on mp.uuid = cq.component_uuid " + - " inner join ce_task_characteristics ctc1 on ctc1.task_uuid = cq.uuid and ctc1.kee = 'pullRequest'" + - " inner join projects p on p.kee = concat(mp.kee, concat(':PULL_REQUEST:', ctc1.text_value))" + - " where" + - " cq.component_uuid is not null" + - " and (cq.tmp_component_uuid is null or cq.tmp_main_component_uuid is null)"); - - // queued task of long and short branches which have never been analyzed must be deleted - deleteFromCeQueue(context, "queued tasks of never analyzed branches", - "select" + - " cq.uuid" + - " from ce_queue cq" + - " inner join projects mp on mp.uuid = cq.component_uuid" + - " inner join ce_task_characteristics ctc1 on ctc1.task_uuid = cq.uuid and ctc1.kee = 'branchType'" + - " inner join ce_task_characteristics ctc2 on ctc2.task_uuid = cq.uuid and ctc2.kee = 'branch'" + - " where" + - " cq.component_uuid is not null" + - " and (cq.tmp_component_uuid is null or cq.tmp_main_component_uuid is null)" + - " and not exists (select 1 from projects p where p.kee = concat(mp.kee, concat(':BRANCH:', ctc2.text_value)))"); - - // queued of pull request which have never been analyzed must be deleted - deleteFromCeQueue(context, "queued tasks of never analyzed PRs", - "select" + - " cq.uuid" + - " from ce_queue cq" + - " inner join projects mp on mp.uuid = cq.component_uuid " + - " inner join ce_task_characteristics ctc1 on ctc1.task_uuid = cq.uuid and ctc1.kee = 'pullRequest'" + - " where" + - " cq.component_uuid is not null" + - " and (cq.tmp_component_uuid is null or cq.tmp_main_component_uuid is null)" + - " and not exists (select 1 from projects p where p.kee = concat(mp.kee, concat(':PULL_REQUEST:', ctc1.text_value)))"); - - // all queue which tmp columns are not populated yet (will include main and deprecated branches) - // both tmp columns will be set to CE_QUEUE.COMPONENT_UUID - // do not join on PROJECTS to also catch orphans (there are many for branch and PRs due to SONAR-10642) - populateCeQueueTmpColumns(context, "queued tasks of main and deprecated branches", - "select" + - " cq.uuid, cq.component_uuid, cq.component_uuid" + - " from ce_queue cq" + - " where" + - " cq.component_uuid is not null" + - " and (cq.tmp_component_uuid is null or cq.tmp_main_component_uuid is null)"); - } - - private static void populateCeQueueTmpColumns(Context context, String pluralName, String selectSQL) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select(selectSQL); - massUpdate.update("update ce_queue set tmp_component_uuid=?, tmp_main_component_uuid=? where uuid=?"); - massUpdate.rowPluralName(pluralName); - massUpdate.execute(PopulateTmpColumnsToCeQueue::handleUpdate); - } - - private static boolean handleUpdate(Select.Row row, SqlStatement update) throws SQLException { - String uuid = row.getString(1); - String componentUuuid = row.getString(2); - String mainComponentUuuid = row.getString(3); - - update.setString(1, componentUuuid); - update.setString(2, mainComponentUuuid); - update.setString(3, uuid); - - return true; - } - - private static void deleteFromCeQueue(Context context, String pluralName, String sql) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select(sql); - massUpdate.update("delete from ce_queue where uuid = ?"); - massUpdate.rowPluralName(pluralName); - massUpdate.execute(PopulateTmpColumnsToCeQueue::handleDelete); - } - - private static boolean handleDelete(Select.Row row, SqlStatement update) throws SQLException { - String uuid = row.getString(1); - - update.setString(1, uuid); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivity.java deleted file mode 100644 index 9bcbaf1c342..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivity.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class PopulateTmpLastKeyColumnsToCeActivity extends DataChange { - - public PopulateTmpLastKeyColumnsToCeActivity(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select" + - " cea.uuid, cea.task_type, cea.component_uuid, cea.tmp_component_uuid, cea.tmp_main_component_uuid" + - " from ce_activity cea" + - " where" + - " cea.tmp_is_last is null" + - " or cea.tmp_is_last_key is null" + - " or cea.tmp_main_is_last is null" + - " or cea.tmp_main_is_last_key is null"); - massUpdate.update("update ce_activity" + - " set" + - " tmp_is_last=?" + - " ,tmp_is_last_key=?" + - " ,tmp_main_is_last=?" + - " ,tmp_main_is_last_key=?" + - " where uuid=?"); - massUpdate.rowPluralName("rows of ce_activity"); - massUpdate.execute(PopulateTmpLastKeyColumnsToCeActivity::handleUpdate); - } - - private static boolean handleUpdate(Select.Row row, SqlStatement update) throws SQLException { - String uuid = row.getString(1); - String taskType = row.getString(2); - String oldComponentUuid = row.getString(3); - String componentUuuid = row.getString(4); - String mainComponentUuuid = row.getString(5); - - update.setBoolean(1, false); - update.setString(2, oldComponentUuid == null ? taskType : (taskType + componentUuuid)); - update.setBoolean(3, false); - update.setString(4, oldComponentUuid == null ? taskType : (taskType + mainComponentUuuid)); - update.setString(5, uuid); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRules.java deleted file mode 100644 index e8217c1deab..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRules.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -@SupportsBlueGreen -public class SetIsExternalAndIsAdHocNotNullableInRules extends DdlChange { - - public SetIsExternalAndIsAdHocNotNullableInRules(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "rules") - .updateColumn(newBooleanColumnDefBuilder() - .setColumnName("is_external") - .setIsNullable(false) - .build()) - .updateColumn(newBooleanColumnDefBuilder() - .setColumnName("is_ad_hoc") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/package-info.java deleted file mode 100644 index bdbfad024f4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v74; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChanges.java deleted file mode 100644 index ee56f735e99..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChanges.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class AddEventComponentChanges extends DdlChange { - private static final String TABLE_NAME = "event_component_changes"; - private static final VarcharColumnDef COLUMN_UUID = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef COLUMN_EVENT_UUID = newVarcharColumnDefBuilder() - .setColumnName("event_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef COLUMN_EVENT_ANALYSIS_UUID = newVarcharColumnDefBuilder() - .setColumnName("event_analysis_uuid") - .setIsNullable(false) - .setLimit(UUID_VARCHAR_SIZE) - .build(); - private static final VarcharColumnDef COLUMN_EVENT_COMPONENT_UUID = newVarcharColumnDefBuilder() - .setColumnName("event_component_uuid") - .setIsNullable(false) - .setLimit(UUID_VARCHAR_SIZE) - .build(); - private static final VarcharColumnDef COLUMN_CHANGE_CATEGORY = newVarcharColumnDefBuilder() - .setColumnName("change_category") - .setIsNullable(false) - .setLimit(12) - .build(); - private static final VarcharColumnDef COLUMN_COMPONENT_UUID = newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setIsNullable(false) - .setLimit(UUID_VARCHAR_SIZE) - .build(); - private static final VarcharColumnDef COLUMN_COMPONENT_KEY = newVarcharColumnDefBuilder() - .setColumnName("component_key") - .setIsNullable(false) - .setLimit(400) - .build(); - private static final VarcharColumnDef COLUMN_COMPONENT_NAME = newVarcharColumnDefBuilder() - .setColumnName("component_name") - .setIsNullable(false) - .setLimit(2000) - .build(); - private static final VarcharColumnDef COLUMN_COMPONENT_BRANCH_KEY = newVarcharColumnDefBuilder() - .setColumnName("component_branch_key") - .setIsNullable(true) - .setLimit(255) - .build(); - private static final BigIntegerColumnDef COLUMN_CREATED_AT = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - public AddEventComponentChanges(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - CreateTableBuilder createTableBuilder = new CreateTableBuilder(getDialect(), TABLE_NAME); - if (!createTableBuilder.tableExists(getDatabase())) { - context.execute(createTableBuilder - .addPkColumn(COLUMN_UUID) - .addColumn(COLUMN_EVENT_UUID) - .addColumn(COLUMN_EVENT_COMPONENT_UUID) - .addColumn(COLUMN_EVENT_ANALYSIS_UUID) - .addColumn(COLUMN_CHANGE_CATEGORY) - .addColumn(COLUMN_COMPONENT_UUID) - .addColumn(COLUMN_COMPONENT_KEY) - .addColumn(COLUMN_COMPONENT_NAME) - .addColumn(COLUMN_COMPONENT_BRANCH_KEY) - .addColumn(COLUMN_CREATED_AT) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(TABLE_NAME + "_unique") - .addColumn(COLUMN_EVENT_UUID) - .addColumn(COLUMN_CHANGE_CATEGORY) - .addColumn(COLUMN_COMPONENT_UUID) - .setUnique(true) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("event_cpnt_changes_cpnt") - .addColumn(COLUMN_EVENT_COMPONENT_UUID) - .setUnique(false) - .build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("event_cpnt_changes_analysis") - .addColumn(COLUMN_EVENT_ANALYSIS_UUID) - .setUnique(false) - .build()); - } - - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstall.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstall.java deleted file mode 100644 index f0e5c287ac6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstall.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -@SupportsBlueGreen -public class AddIsOwnerUserColumnInAlmAppInstall extends DdlChange { - - public AddIsOwnerUserColumnInAlmAppInstall(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "alm_app_installs") - .addColumn(newBooleanColumnDefBuilder() - .setColumnName("is_owner_user") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstall.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstall.java deleted file mode 100644 index 3ed05df6886..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstall.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class AddUserExternalIdColumnInAlmAppInstall extends DdlChange { - - private static final String ALM_APP_INSTALLS_TABLE = "alm_app_installs"; - private static final String USER_EXTERNAL_ID_COLUMN = "user_external_id"; - - public AddUserExternalIdColumnInAlmAppInstall(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef userExternalIdDef = newVarcharColumnDefBuilder() - .setColumnName(USER_EXTERNAL_ID_COLUMN) - .setLimit(255) - .setIsNullable(true) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), ALM_APP_INSTALLS_TABLE) - .addColumn(userExternalIdDef).build()); - context.execute(new CreateIndexBuilder() - .setTable(ALM_APP_INSTALLS_TABLE) - .addColumn(userExternalIdDef) - .setUnique(false) - .setName("alm_app_installs_external_id") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/CreateOrganizationsAlmBindingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/CreateOrganizationsAlmBindingsTable.java deleted file mode 100644 index 8c7421e2b88..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/CreateOrganizationsAlmBindingsTable.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -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.SupportsBlueGreen; -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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; - -@SupportsBlueGreen -public class CreateOrganizationsAlmBindingsTable extends DdlChange { - - private static final String TABLE_NAME = "organization_alm_bindings"; - - private static final VarcharColumnDef UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final VarcharColumnDef ORGANIZATION_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final VarcharColumnDef ALM_APP_INSTALL_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("alm_app_install_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final VarcharColumnDef ALM_ID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("alm_id") - .setIsNullable(false) - .setLimit(40) - .build(); - private static final VarcharColumnDef URL_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("url") - .setIsNullable(false) - .setLimit(2000) - .build(); - private static final VarcharColumnDef USER_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(false) - .setLimit(255) - .build(); - private static final BigIntegerColumnDef CREATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - public CreateOrganizationsAlmBindingsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!tableExists()) { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID_COLUMN) - .addColumn(ORGANIZATION_UUID_COLUMN) - .addColumn(ALM_APP_INSTALL_UUID_COLUMN) - .addColumn(ALM_ID_COLUMN) - .addColumn(URL_COLUMN) - .addColumn(USER_UUID_COLUMN) - .addColumn(CREATED_AT_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(ORGANIZATION_UUID_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("org_alm_bindings_org") - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(ALM_APP_INSTALL_UUID_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("org_alm_bindings_install") - .build()); - } - } - - private boolean tableExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.tableExists(TABLE_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/DbVersion75.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/DbVersion75.java deleted file mode 100644 index 05176b69a7b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/DbVersion75.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion75 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(2400, "Add column IS_OWNER_USER in ALM_APP_INSTALLS", AddIsOwnerUserColumnInAlmAppInstall.class) - .add(2401, "Create ORGANIZATION_ALM_BINDINGS table", CreateOrganizationsAlmBindingsTable.class) - .add(2402, "Add column USER_EXTERNAL_ID in ALM_APP_INSTALLS", AddUserExternalIdColumnInAlmAppInstall.class) - .add(2403, "Set IS_OWNER_USER not nullable in ALM_APP_INSTALLS", SetIsOwnerUserNotNullableInAlmAppInstalls.class) - .add(2404, "Add table EVENT_COMPONENT_CHANGES", AddEventComponentChanges.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstalls.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstalls.java deleted file mode 100644 index e3958722bb3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstalls.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.BooleanColumnDef.newBooleanColumnDefBuilder; - -@SupportsBlueGreen -public class SetIsOwnerUserNotNullableInAlmAppInstalls extends DdlChange { - - public SetIsOwnerUserNotNullableInAlmAppInstalls(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "alm_app_installs") - .updateColumn(newBooleanColumnDefBuilder() - .setColumnName("is_owner_user") - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/package-info.java deleted file mode 100644 index 65298459ec9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v75/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v75; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTable.java deleted file mode 100644 index cb01b4464d2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTable.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddUniqueIndexInUserPropertiesTable extends DdlChange { - - private static final String TABLE_NAME = "user_properties"; - - public AddUniqueIndexInUserPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(false) - .setLimit(255) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(100) - .build()) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("user_properties_user_uuid_kee") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTable.java deleted file mode 100644 index 61e30223aff..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTable.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddUniqueIndexOnExternalLoginInUsersTable extends DdlChange { - - public AddUniqueIndexOnExternalLoginInUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable("users") - .setName("uniq_external_login") - .setUnique(true) - .addColumn(notNullableColumn("external_identity_provider", 100)) - .addColumn(notNullableColumn("external_login", 255)) - .build()); - } - - private static VarcharColumnDef notNullableColumn(String columnName, int limit) { - return newVarcharColumnDefBuilder() - .setColumnName(columnName) - .setLimit(limit) - .setIsNullable(false) - .build(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/CreateUserPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/CreateUserPropertiesTable.java deleted file mode 100644 index d501b1db4f2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/CreateUserPropertiesTable.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -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.SupportsBlueGreen; -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.CreateTableBuilder; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class CreateUserPropertiesTable extends DdlChange { - - private static final String TABLE_NAME = "user_properties"; - - private static final VarcharColumnDef UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef USER_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(false) - .setLimit(255) - .build(); - private static final VarcharColumnDef KEY_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(100) - .build(); - private static final VarcharColumnDef TEXT_VALUE_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("text_value") - .setIsNullable(false) - .setLimit(4000) - .build(); - private static final BigIntegerColumnDef CREATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - private static final BigIntegerColumnDef UPDATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build(); - - public CreateUserPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (tableExists()) { - return; - } - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID_COLUMN) - .addColumn(USER_UUID_COLUMN) - .addColumn(KEY_COLUMN) - .addColumn(TEXT_VALUE_COLUMN) - .addColumn(CREATED_AT_COLUMN) - .addColumn(UPDATED_AT_COLUMN) - .build()); - } - - private boolean tableExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.tableExists(TABLE_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76.java deleted file mode 100644 index ee64126ef95..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion76 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(2500, "Create table USER_PROPERTIES", CreateUserPropertiesTable.class) - .add(2501, "Add index in table USER_PROPERTIES", AddUniqueIndexInUserPropertiesTable.class) - .add(2502, "Archive module properties in a new project level property", MigrateModuleProperties.class) - .add(2503, "Delete useless 'sonar.dbcleaner.cleanDirectory' property", DeleteUselessProperty.class) - .add(2504, "Delete useless module and folder level measures", DeleteModuleAndFolderMeasures.class) - .add(2505, "Fix the direction values of certain metrics (prepare for migration of conditions)", FixDirectionOfMetrics.class) - .add(2506, "Migrate quality gate conditions using warning, period and no more supported operations", MigrateNoMoreUsedQualityGateConditions.class) - .add(2507, "Delete sonar.onboardingTutorial.showToNewUsers from settings", DeleteUselessOnboardingSetting.class) - .add(2508, "Add unique index on EXTERNAL_LOGIN and EXTERNAL_IDENTITY_PROVIDER columns in table USERS", AddUniqueIndexOnExternalLoginInUsersTable.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasures.java deleted file mode 100644 index 2d2e7af9577..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasures.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.sonar.api.config.Configuration; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -/** - * Remove module and folder level measures - */ -@SupportsBlueGreen -public class DeleteModuleAndFolderMeasures extends DataChange { - - private final Configuration configuration; - - public DeleteModuleAndFolderMeasures(Database db, Configuration configuration) { - super(db); - this.configuration = configuration; - } - - @Override - public void execute(Context context) throws SQLException { - if (isSonarCloud(configuration)) { - return; - } - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("components"); - massUpdate.select("SELECT p.uuid FROM projects p WHERE p.qualifier in ('DIR', 'BRC') AND exists(SELECT 1 FROM project_measures m WHERE m.component_uuid = p.uuid)"); - massUpdate.update("DELETE FROM project_measures WHERE component_uuid=?") - // important to keep the number of rows in a transaction under control. A component may have dozens/hundreds of measures to be deleted. - .setBatchSize(10); - massUpdate.execute((row, update) -> { - String componentUuid = row.getString(1); - update.setString(1, componentUuid); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSetting.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSetting.java deleted file mode 100644 index 303cffb419f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSetting.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -import java.sql.SQLException; - -/** - * Remove the "sonar.onboardingTutorial.showToNewUsers" settings from the PROPERTIES table - */ -@SupportsBlueGreen -public class DeleteUselessOnboardingSetting extends DataChange { - - public DeleteUselessOnboardingSetting(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("useless onboarding settings"); - massUpdate.select("SELECT id FROM properties WHERE prop_key=?") - .setString(1, "sonar.onboardingTutorial.showToNewUsers"); - massUpdate.update("DELETE FROM properties WHERE id=?"); - massUpdate.execute((row, update) -> { - long propertyId = row.getLong(1); - update.setLong(1, propertyId); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessProperty.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessProperty.java deleted file mode 100644 index 441b5a8ece1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessProperty.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; - -/** - * Remove the following settings from the PROPERTIES table : - * - sonar.dbcleaner.cleanDirectory - */ -@SupportsBlueGreen -public class DeleteUselessProperty extends DataChange { - - public DeleteUselessProperty(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.prepareUpsert("DELETE FROM properties WHERE prop_key = 'sonar.dbcleaner.cleanDirectory'") - .execute() - .commit(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetrics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetrics.java deleted file mode 100644 index 8bbc6992fbe..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetrics.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; - -@SupportsBlueGreen -public class FixDirectionOfMetrics extends DataChange { - - public FixDirectionOfMetrics(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - String sql = "UPDATE metrics SET direction = ? WHERE name = ? AND direction != ?"; - - context.prepareUpsert(sql) - .setInt(1, 1) - .setString(2, "tests") - .setInt(3, 1) - .execute() - .commit(); - - context.prepareUpsert(sql) - .setInt(1, -1) - .setString(2, "conditions_to_cover") - .setInt(3, -1) - .execute() - .commit(); - - context.prepareUpsert(sql) - .setInt(1, -1) - .setString(2, "new_conditions_to_cover") - .setInt(3, -1) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateModuleProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateModuleProperties.java deleted file mode 100644 index 79fa960913c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateModuleProperties.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import java.util.concurrent.atomic.AtomicReference; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.utils.System2; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Upsert; - -@SupportsBlueGreen -public class MigrateModuleProperties extends DataChange { - - protected static final String NEW_PROPERTY_NAME = "sonar.subproject.settings.archived"; - - private final System2 system2; - - public MigrateModuleProperties(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system2.now(); - moveModulePropertiesToProjectLevel(context, now); - removeModuleProperties(context); - } - - private static void moveModulePropertiesToProjectLevel(Context context, long time) throws SQLException { - StringBuilder builder = new StringBuilder(); - AtomicReference currentProjectId = new AtomicReference<>(); - AtomicReference currentModuleUuid = new AtomicReference<>(); - - context.prepareSelect("select prop.prop_key, prop.text_value, prop.clob_value, module1.name, module1.uuid, root.id as project_id, root.name as project_name " + - "from properties prop " + - "left join projects module1 on module1.id = prop.resource_id " + - "left join projects root on root.uuid = module1.project_uuid " + - "where module1.qualifier = 'BRC' and prop.user_id is null " + - "order by root.uuid, module1.uuid, prop.prop_key") - .scroll(row -> { - String propertyKey = row.getString(1); - String propertyTextValue = row.getString(2); - String propertyClobValue = row.getString(3); - String moduleName = row.getString(4); - String moduleUuid = row.getString(5); - Integer projectId = row.getInt(6); - String projectName = row.getString(7); - - if (!projectId.equals(currentProjectId.get())) { - if (currentProjectId.get() != null) { - insertProjectProperties(context, currentProjectId.get(), builder.toString(), time); - } - - builder.setLength(0); - currentProjectId.set(projectId); - } - - if (!moduleUuid.equals(currentModuleUuid.get())) { - if (currentModuleUuid.get() != null && builder.length() != 0) { - builder.append("\n"); - } - builder.append("# Settings from '").append(projectName).append("::").append(moduleName).append("'\n"); - currentModuleUuid.set(moduleUuid); - } - - builder.append(propertyKey).append("="); - if (StringUtils.isNotBlank(propertyTextValue)) { - builder.append(propertyTextValue); - } else if (StringUtils.isNotBlank(propertyClobValue)) { - builder.append(propertyClobValue); - } - builder.append("\n"); - }); - - if (builder.length() > 0) { - insertProjectProperties(context, currentProjectId.get(), builder.toString(), time); - } - } - - private static void insertProjectProperties(Context context, int projectId, String content, long time) throws SQLException { - Upsert upsert = context.prepareUpsert("insert into properties (prop_key, resource_id, is_empty, clob_value, created_at) values (?, ?, ?, ?, ?)"); - upsert.setString(1, NEW_PROPERTY_NAME) - .setInt(2, projectId) - .setBoolean(3, false) - .setString(4, content) - .setLong(5, time) - .execute() - .commit(); - } - - private static void removeModuleProperties(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("module level properties"); - massUpdate.select("select prop.id as property_id " + - "from properties prop " + - "left join projects module1 on module1.id = prop.resource_id " + - "where module1.qualifier = 'BRC'"); - massUpdate.update("delete from properties where id=?"); - massUpdate.execute((row, update) -> { - update.setInt(1, row.getInt(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditions.java deleted file mode 100644 index 7bd9a7636f6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditions.java +++ /dev/null @@ -1,428 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.Upsert; - -import static com.google.common.base.Strings.isNullOrEmpty; -import static java.util.stream.Collectors.toSet; -import static org.sonar.core.util.stream.MoreCollectors.toList; -import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; -import static org.sonar.server.platform.db.migration.step.Select.LONG_READER; - -@SupportsBlueGreen -public class MigrateNoMoreUsedQualityGateConditions extends DataChange { - - private static final Logger LOG = Loggers.get(MigrateNoMoreUsedQualityGateConditions.class); - - private static final String OPERATOR_GREATER_THAN = "GT"; - private static final String OPERATOR_LESS_THAN = "LT"; - - private static final int DIRECTION_WORST = -1; - private static final int DIRECTION_BETTER = 1; - private static final int DIRECTION_NONE = 0; - - private static final Set SUPPORTED_OPERATORS = ImmutableSet.of(OPERATOR_GREATER_THAN, OPERATOR_LESS_THAN); - private static final Set SUPPORTED_METRIC_TYPES = ImmutableSet.of("INT", "FLOAT", "PERCENT", "MILLISEC", "LEVEL", "RATING", "WORK_DUR"); - private static final Map LEAK_METRIC_KEY_BY_METRIC_KEY = ImmutableMap.builder() - .put("branch_coverage", "new_branch_coverage") - .put("conditions_to_cover", "new_conditions_to_cover") - .put("coverage", "new_coverage") - .put("line_coverage", "new_line_coverage") - .put("lines_to_cover", "new_lines_to_cover") - .put("uncovered_conditions", "new_uncovered_conditions") - .put("uncovered_lines", "new_uncovered_lines") - .put("duplicated_blocks", "new_duplicated_blocks") - .put("duplicated_lines", "new_duplicated_lines") - .put("duplicated_lines_density", "new_duplicated_lines_density") - .put("blocker_violations", "new_blocker_violations") - .put("critical_violations", "new_critical_violations") - .put("info_violations", "new_info_violations") - .put("violations", "new_violations") - .put("major_violations", "new_major_violations") - .put("minor_violations", "new_minor_violations") - .put("sqale_index", "new_technical_debt") - .put("code_smells", "new_code_smells") - .put("sqale_rating", "new_maintainability_rating") - .put("sqale_debt_ratio", "new_sqale_debt_ratio") - .put("bugs", "new_bugs") - .put("reliability_rating", "new_reliability_rating") - .put("reliability_remediation_effort", "new_reliability_remediation_effort") - .put("vulnerabilities", "new_vulnerabilities") - .put("security_rating", "new_security_rating") - .put("security_remediation_effort", "new_security_remediation_effort") - .put("lines", "new_lines") - .build(); - - private final System2 system2; - - public MigrateNoMoreUsedQualityGateConditions(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - MigrationContext migrationContext = new MigrationContext(context, new Date(system2.now()), loadMetrics(context)); - List qualityGateIds = context.prepareSelect("SELECT id FROM quality_gates qg WHERE qg.is_built_in=?") - .setBoolean(1, false) - .list(LONG_READER); - for (long qualityGateId : qualityGateIds) { - List conditions = loadConditions(context, qualityGateId); - - markNoMoreSupportedConditionsAsToBeDeleted(migrationContext, conditions); - markConditionsHavingOnlyWarningAsToBeDeleted(conditions); - markConditionsUsingLeakPeriodHavingNoRelatedLeakMetricAsToBeDeleted(migrationContext, conditions); - markConditionsUsingLeakPeriodHavingAlreadyRelatedConditionAsToBeDeleted(migrationContext, conditions); - updateConditionsUsingLeakPeriod(migrationContext, conditions); - updateConditionsHavingErrorAndWarningByRemovingWarning(migrationContext, conditions); - dropConditionsIfNeeded(migrationContext, conditions); - - migrationContext.increaseNumberOfProcessedQualityGate(); - } - LOG.info("{} custom quality gates have been loaded", migrationContext.getNbOfQualityGates()); - LOG.info("{} conditions have been removed", migrationContext.getNbOfRemovedConditions()); - LOG.info("{} conditions have been updated", migrationContext.getNbOfUpdatedConditions()); - } - - private static List loadMetrics(Context context) throws SQLException { - return context - .prepareSelect("SELECT m.id, m.name, m.val_type, m.direction FROM metrics m WHERE m.enabled=?") - .setBoolean(1, true) - .list(row -> new Metric(row.getInt(1), row.getString(2), row.getString(3), row.getInt(4))); - } - - private static List loadConditions(Context context, long qualityGateId) throws SQLException { - return context.prepareSelect("SELECT qgc.id, qgc.metric_id, qgc.operator, qgc.value_error, qgc.value_warning, qgc.period FROM quality_gate_conditions qgc " + - "WHERE qgc.qgate_id=? ") - .setLong(1, qualityGateId) - .list( - row -> new QualityGateCondition(row.getInt(1), row.getInt(2), row.getString(3), - row.getString(4), row.getString(5), row.getInt(6))); - } - - private static void markNoMoreSupportedConditionsAsToBeDeleted(MigrationContext migrationContext, List conditions) { - conditions.stream() - .filter(c -> !c.isToBeDeleted()) - .filter(c -> !isConditionStillSupported(c, migrationContext.getMetricById(c.getMetricId()))) - .forEach(QualityGateCondition::setToBeDeleted); - } - - private static void markConditionsHavingOnlyWarningAsToBeDeleted(List conditions) { - conditions.stream() - .filter(c -> !c.isToBeDeleted()) - .filter(c -> !isNullOrEmpty(c.getWarning()) && isNullOrEmpty(c.getError())) - .forEach(QualityGateCondition::setToBeDeleted); - } - - private static void markConditionsUsingLeakPeriodHavingNoRelatedLeakMetricAsToBeDeleted(MigrationContext migrationContext, List conditions) { - conditions - .stream() - .filter(c -> !c.isToBeDeleted()) - .filter(QualityGateCondition::hasLeakPeriod) - .filter(condition -> !isConditionOnLeakMetric(migrationContext, condition)) - .forEach(condition -> { - String metricKey = migrationContext.getMetricById(condition.getMetricId()).getKey(); - String relatedLeakMetric = LEAK_METRIC_KEY_BY_METRIC_KEY.get(metricKey); - // Metric has no related metric on leak period => delete condition - if (relatedLeakMetric == null) { - condition.setToBeDeleted(); - } - }); - } - - private static void markConditionsUsingLeakPeriodHavingAlreadyRelatedConditionAsToBeDeleted(MigrationContext migrationContext, List conditions) { - Map conditionsByMetricKey = conditions.stream() - .filter(c -> !c.isToBeDeleted()) - .collect(uniqueIndex(c -> migrationContext.getMetricById(c.getMetricId()).getKey())); - - conditions - .stream() - .filter(condition -> !condition.isToBeDeleted()) - .filter(QualityGateCondition::hasLeakPeriod) - .filter(condition -> !isConditionOnLeakMetric(migrationContext, condition)) - .forEach(condition -> { - String metricKey = migrationContext.getMetricById(condition.getMetricId()).getKey(); - String relatedLeakMetric = LEAK_METRIC_KEY_BY_METRIC_KEY.get(metricKey); - if (relatedLeakMetric != null) { - QualityGateCondition existingConditionUsingRelatedLeakPeriod = conditionsByMetricKey.get(relatedLeakMetric); - if (existingConditionUsingRelatedLeakPeriod != null) { - // Another condition on related leak period metric exist => delete condition - condition.setToBeDeleted(); - } - } - }); - } - - private static void updateConditionsHavingErrorAndWarningByRemovingWarning(MigrationContext migrationContext, List conditions) - throws SQLException { - Set conditionsToBeUpdated = conditions.stream() - .filter(c -> !c.isToBeDeleted()) - .filter(c -> !isNullOrEmpty(c.getWarning()) && !isNullOrEmpty(c.getError())) - .map(QualityGateCondition::getId) - .collect(toSet()); - if (conditionsToBeUpdated.isEmpty()) { - return; - } - migrationContext.getContext() - .prepareUpsert("UPDATE quality_gate_conditions SET value_warning = NULL, updated_at = ? WHERE id IN (" + conditionsToBeUpdated - .stream() - .map(c -> Integer.toString(c)) - .collect(Collectors.joining(",")) + ")") - .setDate(1, migrationContext.getNow()) - .execute() - .commit(); - migrationContext.addUpdatedConditions(conditionsToBeUpdated.size()); - } - - private static void updateConditionsUsingLeakPeriod(MigrationContext migrationContext, List conditions) - throws SQLException { - - Map conditionsByMetricKey = conditions.stream() - .filter(c -> !c.isToBeDeleted()) - .collect(uniqueIndex(c -> migrationContext.getMetricById(c.getMetricId()).getKey())); - - Upsert updateMetricId = migrationContext.getContext() - .prepareUpsert("UPDATE quality_gate_conditions SET metric_id = ?, updated_at = ? WHERE id = ? ") - .setDate(2, migrationContext.getNow()); - - conditions - .stream() - .filter(c -> !c.isToBeDeleted()) - .filter(QualityGateCondition::hasLeakPeriod) - .filter(condition -> !isConditionOnLeakMetric(migrationContext, condition)) - .forEach(condition -> { - String metricKey = migrationContext.getMetricById(condition.getMetricId()).getKey(); - String relatedLeakMetric = LEAK_METRIC_KEY_BY_METRIC_KEY.get(metricKey); - QualityGateCondition existingConditionUsingRelatedLeakPeriod = conditionsByMetricKey.get(relatedLeakMetric); - // Metric has a related leak period metric => update the condition - if (existingConditionUsingRelatedLeakPeriod == null) { - try { - updateMetricId.setInt(1, migrationContext.getMetricByKey(relatedLeakMetric).getId()); - updateMetricId.setInt(3, condition.getId()); - updateMetricId.execute(); - migrationContext.addUpdatedConditions(1); - } catch (SQLException e) { - throw new IllegalStateException("Fail to update quality gate conditions", e); - } - } - }); - updateMetricId.commit(); - } - - private static void dropConditionsIfNeeded(MigrationContext context, List conditions) throws SQLException { - List conditionsToBeDeleted = conditions.stream() - .filter(QualityGateCondition::isToBeDeleted) - .collect(toList()); - if (conditionsToBeDeleted.isEmpty()) { - return; - } - context.getContext() - .prepareUpsert("DELETE FROM quality_gate_conditions WHERE id IN (" + conditionsToBeDeleted - .stream() - .map(c -> Integer.toString(c.getId())) - .collect(Collectors.joining(",")) + ")") - .execute() - .commit(); - context.addRemovedConditions(conditionsToBeDeleted.size()); - } - - private static boolean isConditionOnLeakMetric(MigrationContext migrationContext, QualityGateCondition condition) { - return LEAK_METRIC_KEY_BY_METRIC_KEY.containsValue(migrationContext.getMetricById(condition.getMetricId()).getKey()); - } - - private static boolean isConditionStillSupported(QualityGateCondition condition, Metric metric) { - return isSupportedMetricType(metric) && isSupportedOperator(condition, metric); - } - - private static boolean isSupportedMetricType(Metric metric) { - return SUPPORTED_METRIC_TYPES.contains(metric.getType()); - } - - private static boolean isSupportedOperator(QualityGateCondition condition, Metric metric) { - String operator = condition.getOperator(); - int direction = metric.getDirection(); - return SUPPORTED_OPERATORS.contains(operator) && - (direction == DIRECTION_NONE || - (direction == DIRECTION_WORST && operator.equalsIgnoreCase(OPERATOR_GREATER_THAN)) || - (direction == DIRECTION_BETTER && operator.equalsIgnoreCase(OPERATOR_LESS_THAN))); - } - - private static class QualityGateCondition { - private final int id; - private final int metricId; - private final String operator; - private final String error; - private final String warning; - private final Integer period; - - private boolean toBeDeleted = false; - - public QualityGateCondition(int id, int metricId, String operator, @Nullable String error, @Nullable String warning, - @Nullable Integer period) { - this.id = id; - this.metricId = metricId; - this.operator = operator; - this.error = error; - this.warning = warning; - this.period = period; - } - - public int getId() { - return id; - } - - public int getMetricId() { - return metricId; - } - - public String getOperator() { - return operator; - } - - @CheckForNull - public String getError() { - return error; - } - - @CheckForNull - public String getWarning() { - return warning; - } - - public boolean hasLeakPeriod() { - return period != null && period == 1; - } - - public void setToBeDeleted() { - toBeDeleted = true; - } - - public boolean isToBeDeleted() { - return toBeDeleted; - } - } - - private static class Metric { - private final int id; - private final String key; - private final String type; - private final int direction; - - public Metric(int id, String key, String type, int direction) { - this.id = id; - this.key = key; - this.type = type; - this.direction = direction; - } - - public int getId() { - return id; - } - - public String getKey() { - return key; - } - - public String getType() { - return type; - } - - public int getDirection() { - return direction; - } - } - - private static class MigrationContext { - - private final Context context; - private final Date now; - private final Map metricsById; - private final Map metricsByKey; - - private int nbOfQualityGates; - private int nbOfRemovedConditions; - private int nbOfUpdatedConditions; - - public MigrationContext(Context context, Date now, List metrics) { - this.context = context; - this.now = now; - this.metricsById = metrics.stream().collect(uniqueIndex(Metric::getId)); - this.metricsByKey = metrics.stream().collect(uniqueIndex(Metric::getKey)); - } - - public Context getContext() { - return context; - } - - public Date getNow() { - return now; - } - - public Metric getMetricByKey(String key) { - return metricsByKey.get(key); - } - - public Metric getMetricById(int id) { - return metricsById.get(id); - } - - public void increaseNumberOfProcessedQualityGate() { - nbOfQualityGates += 1; - } - - public int getNbOfQualityGates() { - return nbOfQualityGates; - } - - public void addRemovedConditions(int removedConditions) { - nbOfRemovedConditions += removedConditions; - } - - public int getNbOfRemovedConditions() { - return nbOfRemovedConditions; - } - - public void addUpdatedConditions(int updatedConditions) { - nbOfUpdatedConditions += updatedConditions; - } - - public int getNbOfUpdatedConditions() { - return nbOfUpdatedConditions; - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/package-info.java deleted file mode 100644 index 994c7342253..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v76; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshot.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshot.java deleted file mode 100644 index 2390465ea14..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshot.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddBuildStringToSnapshot extends DdlChange { - private static final String TABLE_NAME = "snapshots"; - private static final VarcharColumnDef COLUMN = newVarcharColumnDefBuilder() - .setColumnName("build_string") - .setIsNullable(true) - .setLimit(100) - .build(); - - public AddBuildStringToSnapshot(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME) - .addColumn(COLUMN) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokens.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokens.java deleted file mode 100644 index c2b3170ed38..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokens.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.def.BigIntegerColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -@SupportsBlueGreen -public class AddLastConnectionDateToUserTokens extends DdlChange { - - public AddLastConnectionDateToUserTokens(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "user_tokens") - .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder() - .setColumnName("last_connection_date") - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsers.java deleted file mode 100644 index 40b5c9a233a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsers.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.def.BigIntegerColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -@SupportsBlueGreen -public class AddLastConnectionDateToUsers extends DdlChange { - - public AddLastConnectionDateToUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "users") - .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder() - .setColumnName("last_connection_date") - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranches.java deleted file mode 100644 index 3c0ee15e286..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranches.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class AddManualBaselineToProjectBranches extends DdlChange { - - static final String TABLE_NAME = "project_branches"; - - private static final VarcharColumnDef COLUMN_MANUAL_BASELINE_ANALYSIS_UUID = newVarcharColumnDefBuilder() - .setColumnName("manual_baseline_analysis_uuid") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build(); - - public AddManualBaselineToProjectBranches(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME) - .addColumn(COLUMN_MANUAL_BASELINE_ANALYSIS_UUID) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBinding.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBinding.java deleted file mode 100644 index b75f0584f71..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBinding.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.def.BooleanColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -@SupportsBlueGreen -public class AddMembersSyncFlagToOrgAlmBinding extends DdlChange { - - public AddMembersSyncFlagToOrgAlmBinding(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "organization_alm_bindings") - .addColumn(BooleanColumnDef.newBooleanColumnDefBuilder() - .setColumnName("members_sync_enabled") - .setIsNullable(true) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java deleted file mode 100644 index 86da2b49f30..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion77 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(2600, "Drop elasticsearch index 'tests'", DropElasticsearchIndexTests.class) - .add(2601, "Delete lines with DATA_TYPE='TEST' from table FILES_SOURCE", DeleteTestDataTypeFromFileSources.class) - .add(2602, "Add column LAST_CONNECTION_DATE to USERS table", AddLastConnectionDateToUsers.class) - .add(2603, "Add column LAST_USED_DATE to USER_TOKENS table", AddLastConnectionDateToUserTokens.class) - .add(2604, "Add baseline columns in PROJECT_BRANCHES", AddManualBaselineToProjectBranches.class) - .add(2606, "Drop DATA_TYPE column from FILE_SOURCES table", DropDataTypeFromFileSources.class) - .add(2607, "Add MEMBERS_SYNC_ENABLED column to ORGANIZATIONS_ALM_BINDING table", AddMembersSyncFlagToOrgAlmBinding.class) - .add(2608, "Delete favorites on not supported components", DeleteFavouritesOnNotSupportedComponentQualifiers.class) - .add(2609, "Delete exceeding favorites when there are more than 100 for a user", DeleteFavoritesExceedingOneHundred.class) - .add(2610, "Truncate ES_QUEUE table content", TruncateEsQueue.class) - .add(2611, "Add SNAPSHOTS.BUILD_STRING", AddBuildStringToSnapshot.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundred.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundred.java deleted file mode 100644 index 688dcfab9e6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundred.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.Upsert; - -import static java.util.Arrays.asList; -import static org.sonar.core.util.stream.MoreCollectors.toList; - -@SupportsBlueGreen -public class DeleteFavoritesExceedingOneHundred extends DataChange { - - private static final Logger LOG = Loggers.get(DeleteFavoritesExceedingOneHundred.class); - - private static final String FAVOURITE_PROPERTY = "favourite"; - - private static final List SORTED_QUALIFIERS = asList("TRK", "VW", "APP", "SVW", "FIL", "UTS"); - - public DeleteFavoritesExceedingOneHundred(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - List userIdsHavingMoreThanOneHundredFavourites = context.prepareSelect("SELECT user_id FROM " + - "(SELECT DISTINCT user_id, COUNT(id) AS nb FROM properties WHERE prop_key = ? AND user_id IS NOT NULL GROUP BY user_id) sub " + - "WHERE sub.nb > 100") - .setString(1, FAVOURITE_PROPERTY) - .list(row -> row.getInt(1)); - LOG.info("Deleting favourites exceeding one hundred elements for {} users", userIdsHavingMoreThanOneHundredFavourites.size()); - for (Integer userId : userIdsHavingMoreThanOneHundredFavourites) { - List propertyIdsToKeep = context.prepareSelect("SELECT prop.id, p.qualifier, p.enabled FROM properties prop " + - "INNER JOIN projects p ON p.id=prop.resource_id " + - "WHERE prop.prop_key=? AND prop.user_id = ?") - .setString(1, FAVOURITE_PROPERTY) - .setInt(2, userId) - .list(Property::new) - .stream() - .sorted() - .map(Property::getId) - .limit(100) - .collect(toList()); - - String idsToString = IntStream.range(0, propertyIdsToKeep.size()).mapToObj(i -> "?").collect(Collectors.joining(",")); - Upsert upsert = context.prepareUpsert("DELETE FROM properties WHERE prop_key=? AND user_id=? AND id NOT in (" + idsToString + ")") - .setString(1, FAVOURITE_PROPERTY) - .setInt(2, userId); - int index = 3; - for (Integer id : propertyIdsToKeep) { - upsert.setInt(index, id); - index++; - } - upsert.execute().commit(); - } - } - - private static class Property implements Comparable { - private final int id; - private final String qualifier; - private final boolean enabled; - - Property(Select.Row row) throws SQLException { - this.id = row.getInt(1); - this.qualifier = row.getString(2); - this.enabled = row.getBoolean(3); - } - - int getId() { - return id; - } - - String getQualifier() { - return qualifier; - } - - boolean isEnabled() { - return enabled; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Property property = (Property) o; - return id == property.id; - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public int compareTo(Property o) { - return Comparator.comparing(Property::isEnabled) - .reversed() - .thenComparing(property -> SORTED_QUALIFIERS.indexOf(property.getQualifier())) - .compare(this, o); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiers.java deleted file mode 100644 index eae96710a36..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiers.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class DeleteFavouritesOnNotSupportedComponentQualifiers extends DataChange { - - public DeleteFavouritesOnNotSupportedComponentQualifiers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("favourites"); - massUpdate.select("SELECT prop.id FROM properties prop " + - "INNER JOIN projects p ON p.id=prop.resource_id AND p.qualifier NOT IN ('TRK', 'FIL', 'VW', 'SVW', 'APP', 'UTS') " + - "WHERE prop_key=? AND user_id IS NOT NULL") - .setString(1, "favourite"); - massUpdate.update("DELETE FROM properties WHERE id=?"); - massUpdate.execute((row, update) -> { - int id = row.getInt(1); - update.setInt(1, id); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSources.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSources.java deleted file mode 100644 index c059fe71cce..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSources.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class DeleteTestDataTypeFromFileSources extends DataChange { - - public DeleteTestDataTypeFromFileSources(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("file sources"); - massUpdate.select("SELECT DISTINCT project_uuid FROM file_sources WHERE data_type='TEST'"); - massUpdate.update("DELETE FROM file_sources WHERE project_uuid=? AND data_type='TEST'"); - massUpdate.execute((row, update) -> { - String projectUuid = row.getString(1); - update.setString(1, projectUuid); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSources.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSources.java deleted file mode 100644 index 6ace29f5179..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSources.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -@SupportsBlueGreen -public class DropDataTypeFromFileSources extends DdlChange { - - private static final String TABLE_NAME = "file_sources"; - - public DropDataTypeFromFileSources(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("file_sources_uuid_type") - .build()); - - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "data_type") - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("file_sources_file_uuid") - .setUnique(true) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("file_uuid") - .setIsNullable(false) - .setLimit(50) - .build()) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropElasticsearchIndexTests.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropElasticsearchIndexTests.java deleted file mode 100644 index 3b30eabe317..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropElasticsearchIndexTests.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.step.DdlChange; - -@SupportsBlueGreen -public class DropElasticsearchIndexTests extends DdlChange { - - private final MigrationEsClient migrationEsClient; - - public DropElasticsearchIndexTests(Database db, MigrationEsClient migrationEsClient) { - super(db); - this.migrationEsClient = migrationEsClient; - } - - @Override - public void execute(Context context) throws SQLException { - migrationEsClient.deleteIndexes("tests"); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueue.java deleted file mode 100644 index b0c1650047f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueue.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -/** - * This DB migration comes with the change of ES indices structures and must not be flagged as compatible with BlueGreen - * deployment because ES indices must be recreated and this is not compatible with BlueGreen. - */ -public class TruncateEsQueue extends DataChange { - public TruncateEsQueue(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("truncate table es_queue").execute().commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/package-info.java deleted file mode 100644 index 84451d73f64..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v77; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuid.java deleted file mode 100644 index e983ec7c4e9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddIndexToOrgQProfileParentUuid extends DdlChange { - - public AddIndexToOrgQProfileParentUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("parent_uuid") - .setLimit(255) - .setIsNullable(true) - .setIgnoreOracleUnit(true) - .build()) - .setUnique(false) - .setTable("org_qprofiles") - .setName("org_qprofiles_parent_uuid") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddSecurityFieldsToElasticsearchIndices.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddSecurityFieldsToElasticsearchIndices.java deleted file mode 100644 index 11ae80f5322..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddSecurityFieldsToElasticsearchIndices.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import java.util.Map; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.step.DdlChange; - -@SupportsBlueGreen -public class AddSecurityFieldsToElasticsearchIndices extends DdlChange { - - private static final String ISSUE_INDEX = "issues"; - private static final String RULE_INDEX = "rules"; - private static final String KEYWORD_TYPE = "keyword"; - - private final MigrationEsClient migrationEsClient; - - public AddSecurityFieldsToElasticsearchIndices(Database db, MigrationEsClient migrationEsClient) { - super(db); - this.migrationEsClient = migrationEsClient; - } - - @Override - public void execute(Context context) throws SQLException { - Map mappingOptions = ImmutableMap.of("norms", "false"); - - migrationEsClient.addMappingToExistingIndex(ISSUE_INDEX, "auth", "sonarsourceSecurity", KEYWORD_TYPE, mappingOptions); - migrationEsClient.addMappingToExistingIndex(RULE_INDEX, "rule", "cwe", KEYWORD_TYPE, mappingOptions); - migrationEsClient.addMappingToExistingIndex(RULE_INDEX, "rule", "owaspTop10", KEYWORD_TYPE, mappingOptions); - migrationEsClient.addMappingToExistingIndex(RULE_INDEX, "rule", "sansTop25", KEYWORD_TYPE, mappingOptions); - migrationEsClient.addMappingToExistingIndex(RULE_INDEX, "rule", "sonarsourceSecurity", KEYWORD_TYPE, mappingOptions); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevision.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevision.java deleted file mode 100644 index bf04798289d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevision.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddSnapshotRevision extends DdlChange { - - public AddSnapshotRevision(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "snapshots") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("revision") - .setIsNullable(true) - .setLimit(100) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecret.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecret.java deleted file mode 100644 index 72b18c9c0a9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecret.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -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; - -@SupportsBlueGreen -public class AddWebhooksSecret extends DdlChange { - - public AddWebhooksSecret(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "webhooks") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("secret") - .setIsNullable(true) - .setLimit(200) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/CreateInternalComponentPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/CreateInternalComponentPropertiesTable.java deleted file mode 100644 index bd2c70a069a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/CreateInternalComponentPropertiesTable.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -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.SupportsBlueGreen; -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; -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; - -@SupportsBlueGreen -public class CreateInternalComponentPropertiesTable extends DdlChange { - - private static final String TABLE_NAME = "internal_component_props"; - - private static final VarcharColumnDef UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final VarcharColumnDef COMPONENT_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setIsNullable(false) - .setLimit(50) - .build(); - - private static final VarcharColumnDef KEE_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(512) - .build(); - - private static final VarcharColumnDef VALUE_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("value") - .setIsNullable(true) - .setLimit(4000) - .build(); - - private static final BigIntegerColumnDef UPDATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build(); - - private static final BigIntegerColumnDef CREATED_AT_COLUMN = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - public CreateInternalComponentPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!tableExists()) { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID_COLUMN) - .addColumn(COMPONENT_UUID_COLUMN) - .addColumn(KEE_COLUMN) - .addColumn(VALUE_COLUMN) - .addColumn(UPDATED_AT_COLUMN) - .addColumn(CREATED_AT_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .addColumn(COMPONENT_UUID_COLUMN) - .addColumn(KEE_COLUMN) - .setUnique(true) - .setTable(TABLE_NAME) - .setName("unique_component_uuid_kee") - .build()); - } - } - - private boolean tableExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.tableExists(TABLE_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/DbVersion78.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/DbVersion78.java deleted file mode 100644 index 1910c2ea02b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/DbVersion78.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion78 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(2700, "Drop overall subscriptions on notifications about new and resolved issues", DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications.class) - .add(2701, "Add index to org_qprofile.parent_uuid", AddIndexToOrgQProfileParentUuid.class) - .add(2702, "Add column webhooks.secret", AddWebhooksSecret.class) - .add(2703, "Add security fields to Elasticsearch indices", AddSecurityFieldsToElasticsearchIndices.class) - .add(2704, "Add InternalComponentProperties table", CreateInternalComponentPropertiesTable.class) - .add(2705, "Add column snapshots.revision", AddSnapshotRevision.class) - .add(2706, "Migrate revision from analysis_properties to snapshots.revision", MigrateRevision.class) - .add(2707, "Update statuses of Security Hotspots", UpdateSecurityHotspotsStatuses.class) - .add(2708, "Remove orphans from PROJECT_BRANCHES", RemoveOrphansFromProjectBranches.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications.java deleted file mode 100644 index 4863cf66b6e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications extends DataChange { - - public DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("subscriptions"); - massUpdate.select("select id from properties " + - "where resource_id is null " + - "and (prop_key like 'notification.NewFalsePositiveIssue.%' or prop_key like 'notification.NewIssues.%')"); - massUpdate.update("delete from properties where id=?"); - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - update.setLong(1, id); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/MigrateRevision.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/MigrateRevision.java deleted file mode 100644 index 5959a6e4cca..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/MigrateRevision.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class MigrateRevision extends DataChange { - public MigrateRevision(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select ap.snapshot_uuid, ap.text_value" + - " from analysis_properties ap" + - " where kee = 'sonar.analysis.scm_revision_id'"); - massUpdate.update("update snapshots set revision=? where uuid=?"); - massUpdate.rowPluralName("migrate revision from analysis_properties to snapshots"); - massUpdate.execute((row, update) -> { - String snapshotUuid = row.getString(1); - String revision = row.getString(2); - update.setString(1, revision); - update.setString(2, snapshotUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranches.java deleted file mode 100644 index 97b97937ef5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranches.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class RemoveOrphansFromProjectBranches extends DataChange { - public RemoveOrphansFromProjectBranches(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select pb.uuid from project_branches pb where not exists (select 1 from projects p where p.uuid = pb.uuid)"); - massUpdate.update("delete from project_branches where uuid=?"); - massUpdate.rowPluralName("orphans in table PROJECT_BRANCHES"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - - update.setString(1, uuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatuses.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatuses.java deleted file mode 100644 index ca988261401..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatuses.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import com.google.common.collect.Maps; -import java.io.Serializable; -import java.sql.SQLException; -import java.util.Map; -import java.util.Objects; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.sonar.api.config.Configuration; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class UpdateSecurityHotspotsStatuses extends DataChange { - - private static final String RESOLUTION_FIXED = "FIXED"; - private static final String RESOLUTION_WONT_FIX = "WONTFIX"; - - private static final String STATUS_OPEN = "OPEN"; - private static final String STATUS_REOPENED = "REOPENED"; - private static final String STATUS_RESOLVED = "RESOLVED"; - - private static final String STATUS_TO_REVIEW = "TO_REVIEW"; - private static final String STATUS_IN_REVIEW = "IN_REVIEW"; - private static final String STATUS_REVIEWED = "REVIEWED"; - - private static final int RULE_TYPE_SECURITY_HOTSPOT = 4; - - private final Configuration configuration; - private final System2 system2; - private final MigrationEsClient esClient; - private final UuidFactory uuidFactory; - - public UpdateSecurityHotspotsStatuses(Database db, Configuration configuration, System2 system2, MigrationEsClient esClient, UuidFactory uuidFactory) { - super(db); - this.configuration = configuration; - this.system2 = system2; - this.esClient = esClient; - this.uuidFactory = uuidFactory; - } - - @Override - public void execute(Context context) throws SQLException { - if (configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) { - return; - } - long now = system2.now(); - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("security hotspots"); - massUpdate.select("select i.kee, i.status, i.resolution, i.issue_type from issues i " + - "inner join rules r on r.id = i.rule_id and r.rule_type = ? " + - "where (i.resolution is null or i.resolution in (?, ?)) and i.issue_type=? " + - // Add status check for the re-entrance, in order to not reload already migrated issues - "and i.status not in (?, ?, ?)") - .setInt(1, RULE_TYPE_SECURITY_HOTSPOT) - .setString(2, RESOLUTION_FIXED) - .setString(3, RESOLUTION_WONT_FIX) - .setInt(4, RULE_TYPE_SECURITY_HOTSPOT) - .setString(5, STATUS_TO_REVIEW) - .setString(6, STATUS_IN_REVIEW) - .setString(7, STATUS_REVIEWED); - massUpdate.update("update issues set status=?, resolution=?, updated_at=? where kee=? "); - massUpdate.update("insert into issue_changes (kee, issue_key, change_type, change_data, created_at, updated_at, issue_change_creation_date) values (?, ?, 'diff', ?, ?, ?, ?)"); - massUpdate.execute((row, update, updateIndex) -> { - String issueKey = row.getString(1); - String status = row.getString(2); - String resolution = row.getNullableString(3); - - IssueUpdate issueUpdate = new IssueUpdate(status, resolution); - FieldDiffs fieldDiffs = issueUpdate.process(); - if (!issueUpdate.isUpdated()) { - return false; - } - if (updateIndex == 0) { - update.setString(1, issueUpdate.getNewStatus()); - update.setString(2, issueUpdate.getNewResolution()); - update.setLong(3, now); - update.setString(4, issueKey); - return true; - } else { - // No changelog on OPEN issue as there was no previous state - if (!status.equals(STATUS_OPEN)) { - update.setString(1, uuidFactory.create()); - update.setString(2, issueKey); - update.setString(3, fieldDiffs.toEncodedString()); - update.setLong(4, now); - update.setLong(5, now); - update.setLong(6, now); - return true; - } - return false; - } - }); - esClient.deleteIndexes("issues"); - } - - private static class IssueUpdate { - - private static final String RESOLUTION_FIELD = "resolution"; - private static final String STATUS_FIELD = "status"; - - private final String status; - private final String resolution; - - private String newStatus; - private String newResolution; - private boolean updated; - - IssueUpdate(String status, @CheckForNull String resolution) { - this.status = status; - this.resolution = resolution; - } - - FieldDiffs process() { - if ((status.equals(STATUS_OPEN) || (status.equals(STATUS_REOPENED))) && resolution == null) { - newStatus = STATUS_TO_REVIEW; - newResolution = null; - updated = true; - } else if (status.equals(STATUS_RESOLVED) && resolution != null) { - if (resolution.equals(RESOLUTION_FIXED)) { - newStatus = STATUS_IN_REVIEW; - newResolution = null; - updated = true; - } else if (resolution.equals(RESOLUTION_WONT_FIX)) { - newStatus = STATUS_REVIEWED; - newResolution = RESOLUTION_FIXED; - updated = true; - } - } - FieldDiffs fieldDiffs = new FieldDiffs(); - fieldDiffs.setDiff(STATUS_FIELD, status, newStatus); - fieldDiffs.setDiff(RESOLUTION_FIELD, resolution, newResolution); - return fieldDiffs; - } - - String getNewStatus() { - return newStatus; - } - - String getNewResolution() { - return newResolution; - } - - boolean isUpdated() { - return updated; - } - } - - /** - * Inspired and simplified from {@link org.sonar.core.issue.FieldDiffs} - */ - static class FieldDiffs implements Serializable { - - private final Map diffs = Maps.newLinkedHashMap(); - - void setDiff(String field, @Nullable String oldValue, @Nullable String newValue) { - diffs.put(field, new Diff(oldValue, newValue)); - } - - String toEncodedString() { - StringBuilder sb = new StringBuilder(); - boolean notFirst = false; - for (Map.Entry entry : diffs.entrySet()) { - if (notFirst) { - sb.append(','); - } else { - notFirst = true; - } - sb.append(entry.getKey()); - sb.append('='); - sb.append(entry.getValue().toEncodedString()); - } - return sb.toString(); - } - - static class Diff implements Serializable { - private String oldValue; - private String newValue; - - Diff(@Nullable String oldValue, @Nullable String newValue) { - this.oldValue = oldValue; - this.newValue = newValue; - } - - private String toEncodedString() { - StringBuilder sb = new StringBuilder(); - if (oldValue != null) { - sb.append(oldValue); - sb.append('|'); - } - if (newValue != null) { - sb.append(newValue); - } - return sb.toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FieldDiffs.Diff diff = (FieldDiffs.Diff) o; - return Objects.equals(oldValue, diff.oldValue) && - Objects.equals(newValue, diff.newValue); - } - - @Override - public int hashCode() { - return Objects.hash(oldValue, newValue); - } - } - - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/package-info.java deleted file mode 100644 index b5b3035b9be..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v78; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchema.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchema.java new file mode 100644 index 00000000000..b6e36d57228 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchema.java @@ -0,0 +1,1375 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v79; + +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.BooleanColumnDef; +import org.sonar.server.platform.db.migration.def.ColumnDef; +import org.sonar.server.platform.db.migration.def.IntegerColumnDef; +import org.sonar.server.platform.db.migration.def.TinyIntColumnDef; +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.sql.CreateTableBuilder; +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.BlobColumnDef.newBlobColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.ClobColumnDef.newClobColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.DecimalColumnDef.newDecimalColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.IntegerColumnDef.newIntegerColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.TimestampColumnDef.newTimestampColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.TinyIntColumnDef.newTinyIntColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.MAX_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; +import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.ColumnFlag.AUTO_INCREMENT; + +public class CreateInitialSchema extends DdlChange { + + public CreateInitialSchema(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + createActiveRuleParameters(context); + createActiveRules(context); + createAlmAppInstalls(context); + createAnalysisProperties(context); + createCeActivity(context); + createCeQueue(context); + createCeScannerContext(context); + createCeTaskCharacteristics(context); + createCeTaskInput(context); + createCeTaskMessage(context); + createDefaultQProfiles(context); + createDeprecatedRuleKeys(context); + createDuplicationsIndex(context); + createEsQueue(context); + createEventComponentChanges(context); + createEvents(context); + createFileSources(context); + createGroupRoles(context); + createGroups(context); + createGroupsUsers(context); + createInternalComponentProps(context); + createInternalProperties(context); + createIssueChanges(context); + createIssues(context); + createLiveMeasures(context); + createManualMeasures(context); + createMetrics(context); + createNotifications(context); + createOrgQProfiles(context); + createOrgQualityGates(context); + createOrganizationAlmBindings(context); + createOrganizationMembers(context); + createOrganizations(context); + createPermTemplatesGroups(context); + createPermTemplatesUsers(context); + createPermTemplatesCharacteristics(context); + createPermissionTemplates(context); + createPlugins(context); + createProjectAlmBindings(context); + createProjectBranches(context); + createProjectLinks(context); + createProjectMappings(context); + createProjectMeasures(context); + createProjectQprofiles(context); + createProjects(context); + createProperties(context); + createQProfileChanges(context); + createQProfileEditGroups(context); + createQProfileEditUsers(context); + createQualityGateConditions(context); + createQualityGates(context); + createRulesRepository(context); + createRules(context); + createRulesMetadata(context); + createRulesParameters(context); + createRulesProfiles(context); + createSnapshots(context); + createUserProperties(context); + createUserRoles(context); + createUserTokens(context); + createUsers(context); + createWebhookDeliveries(context); + createWebhooks(context); + } + + private void createActiveRuleParameters(Context context) { + String tableName = "active_rule_parameters"; + IntegerColumnDef activeRuleIdColumnDef = newIntegerColumnDefBuilder().setColumnName("active_rule_id").setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(activeRuleIdColumnDef) + .addColumn(newIntegerColumnDefBuilder().setColumnName("rules_parameter_id").setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("value").setLimit(MAX_SIZE).build()) + .addColumn(newLenientVarcharBuilder("rules_parameter_key").setLimit(128).build()) + .build()); + addIndex(context, tableName, "ix_arp_on_active_rule_id", false, activeRuleIdColumnDef); + } + + private void createActiveRules(Context context) { + IntegerColumnDef profileIdCol = newIntegerColumnDefBuilder().setColumnName("profile_id").setIsNullable(false).build(); + IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(false).build(); + context.execute( + newTableBuilder("active_rules") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(profileIdCol) + .addColumn(ruleIdCol) + .addColumn(newIntegerColumnDefBuilder().setColumnName("failure_level").setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("inheritance").setLimit(10).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) + .build()); + addIndex(context, "active_rules", "uniq_profile_rule_ids", true, profileIdCol, ruleIdCol); + } + + private void createAlmAppInstalls(Context context) { + String tableName = "alm_app_installs"; + VarcharColumnDef almIdCol = newVarcharColumnBuilder("alm_id").setIsNullable(false).setLimit(UUID_SIZE).build(); + VarcharColumnDef ownerCol = newVarcharColumnBuilder("owner_id").setIsNullable(false).setLimit(MAX_SIZE).build(); + VarcharColumnDef installCol = newVarcharColumnBuilder("install_id").setIsNullable(false).setLimit(MAX_SIZE).build(); + VarcharColumnDef userExternalIdCol = newVarcharColumnBuilder("user_external_id").setLimit(255).setIsNullable(true).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(almIdCol) + .addColumn(ownerCol) + .addColumn(installCol) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_owner_user").setIsNullable(false).build()) + .addColumn(userExternalIdCol) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "alm_app_installs_owner", true, almIdCol, ownerCol); + addIndex(context, tableName, "alm_app_installs_install", true, almIdCol, installCol); + addIndex(context, tableName, "alm_app_installs_external_id", false, userExternalIdCol); + } + + private void createAnalysisProperties(Context context) { + String tableName = "analysis_properties"; + VarcharColumnDef snapshotUuidColumn = newVarcharColumnBuilder("snapshot_uuid") + .setIsNullable(false) + .setLimit(UUID_SIZE) + .build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(snapshotUuidColumn) + .addColumn(newVarcharColumnBuilder("kee").setIsNullable(false).setLimit(512).build()) + .addColumn(newVarcharColumnBuilder("text_value").setIsNullable(true).setLimit(MAX_SIZE).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "ix_snapshot_uuid", false, snapshotUuidColumn); + } + + private void createCeActivity(Context context) { + String tableName = "ce_activity"; + VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build(); + VarcharColumnDef mainComponentUuidCol = newVarcharColumnBuilder("main_component_uuid").setLimit(UUID_SIZE).setIsNullable(true).build(); + VarcharColumnDef componentUuidCol = newVarcharColumnBuilder("component_uuid").setLimit(UUID_SIZE).setIsNullable(true).build(); + VarcharColumnDef statusCol = newLenientVarcharBuilder("status").setLimit(15).setIsNullable(false).build(); + BooleanColumnDef isLastCol = newBooleanColumnDefBuilder().setColumnName("is_last").setIsNullable(false).build(); + VarcharColumnDef isLastKeyCol = newLenientVarcharBuilder("is_last_key").setLimit(55).setIsNullable(false).build(); + BooleanColumnDef mainIsLastCol = newBooleanColumnDefBuilder().setColumnName("main_is_last").setIsNullable(false).build(); + VarcharColumnDef mainIsLastKeyCol = newLenientVarcharBuilder("main_is_last_key").setLimit(55).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(uuidCol) + .addColumn(newLenientVarcharBuilder("task_type").setLimit(15).setIsNullable(false).build()) + .addColumn(mainComponentUuidCol) + .addColumn(componentUuidCol) + .addColumn(statusCol) + .addColumn(mainIsLastCol) + .addColumn(mainIsLastKeyCol) + .addColumn(isLastCol) + .addColumn(isLastKeyCol) + .addColumn(newLenientVarcharBuilder("submitter_uuid").setLimit(255).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("submitted_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("started_at").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("executed_at").setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("execution_count").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("execution_time_ms").setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("error_message").setLimit(1_000).setIsNullable(true).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("error_stacktrace").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("error_type").setLimit(20).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("worker_uuid").setLimit(UUID_SIZE).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "ce_activity_component", false, componentUuidCol); + addIndex(context, tableName, "ce_activity_islast", false, isLastCol, statusCol); + addIndex(context, tableName, "ce_activity_islast_key", false, isLastKeyCol); + addIndex(context, tableName, "ce_activity_main_component", false, mainComponentUuidCol); + addIndex(context, tableName, "ce_activity_main_islast", false, mainIsLastCol, statusCol); + addIndex(context, tableName, "ce_activity_main_islast_key", false, mainIsLastKeyCol); + addIndex(context, tableName, "ce_activity_uuid", true, uuidCol); + } + + private void createCeQueue(Context context) { + String tableName = "ce_queue"; + VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build(); + VarcharColumnDef mainComponentUuidCol = newLenientVarcharBuilder("main_component_uuid").setLimit(UUID_SIZE).setIsNullable(true).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(UUID_SIZE).setIsNullable(true).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(uuidCol) + .addColumn(newLenientVarcharBuilder("task_type").setLimit(15).setIsNullable(false).build()) + .addColumn(mainComponentUuidCol) + .addColumn(componentUuidCol) + .addColumn(newLenientVarcharBuilder("status").setLimit(15).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("submitter_uuid").setLimit(255).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("started_at").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("worker_uuid").setLimit(UUID_SIZE).setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("execution_count").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "ce_queue_main_component", false, mainComponentUuidCol); + addIndex(context, tableName, "ce_queue_component", false, componentUuidCol); + addIndex(context, tableName, "ce_queue_uuid", true, uuidCol); + } + + private void createCeScannerContext(Context context) { + context.execute( + newTableBuilder("ce_scanner_context") + .addPkColumn(newLenientVarcharBuilder("task_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(newBlobColumnDefBuilder().setColumnName("context_data").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + } + + private void createCeTaskCharacteristics(Context context) { + String tableName = "ce_task_characteristics"; + VarcharColumnDef ceTaskUuidColumn = newLenientVarcharBuilder("task_uuid") + .setLimit(UUID_SIZE) + .setIsNullable(false) + .build(); + + context.execute( + newTableBuilder(tableName) + .addPkColumn(newLenientVarcharBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(ceTaskUuidColumn) + .addColumn(newLenientVarcharBuilder("kee").setLimit(512).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("text_value").setLimit(512).setIsNullable(true).build()) + .build()); + addIndex(context, tableName, "ce_characteristics_" + ceTaskUuidColumn.getName(), false, ceTaskUuidColumn); + } + + private void createCeTaskInput(Context context) { + context.execute( + newTableBuilder("ce_task_input") + .addPkColumn(newLenientVarcharBuilder("task_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(newBlobColumnDefBuilder().setColumnName("input_data").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + } + + private void createCeTaskMessage(Context context) { + String tableName = "ce_task_message"; + VarcharColumnDef taskUuidCol = newVarcharColumnBuilder("task_uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(taskUuidCol) + .addColumn(newVarcharColumnBuilder("message").setIsNullable(false).setLimit(MAX_SIZE).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, tableName + "_task", false, taskUuidCol); + } + + private void createDefaultQProfiles(Context context) { + String tableName = "default_qprofiles"; + VarcharColumnDef profileUuidColumn = newLenientVarcharBuilder("qprofile_uuid") + .setLimit(255) + .setIsNullable(false) + .build(); + + context.execute( + newTableBuilder(tableName) + .addPkColumn(newLenientVarcharBuilder("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addPkColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(false).build()) + .addColumn(profileUuidColumn) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "uniq_default_qprofiles_uuid", true, profileUuidColumn); + } + + private void createDeprecatedRuleKeys(Context context) { + String tableName = "deprecated_rule_keys"; + IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(false).build(); + VarcharColumnDef oldRepositoryKeyCol = newVarcharColumnBuilder("old_repository_key").setIsNullable(false).setLimit(255).build(); + VarcharColumnDef oldRuleKeyCol = newVarcharColumnBuilder("old_rule_key").setIsNullable(false).setLimit(200).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(ruleIdCol) + .addColumn(oldRepositoryKeyCol) + .addColumn(oldRuleKeyCol) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "uniq_deprecated_rule_keys", true, oldRepositoryKeyCol, oldRuleKeyCol); + addIndex(context, tableName, "rule_id_deprecated_rule_keys", true, ruleIdCol); + } + + private void createDuplicationsIndex(Context context) { + String tableName = "duplications_index"; + VarcharColumnDef hashCol = newLenientVarcharBuilder("hash").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef analysisUuidCol = newLenientVarcharBuilder("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(analysisUuidCol) + .addColumn(componentUuidCol) + .addColumn(hashCol) + .addColumn(newIntegerColumnDefBuilder().setColumnName("index_in_file").setIsNullable(false).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("start_line").setIsNullable(false).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("end_line").setIsNullable(false).build()) + .build()); + + addIndex(context, tableName, "duplications_index_hash", false, hashCol); + addIndex(context, tableName, "duplication_analysis_component", false, analysisUuidCol, componentUuidCol); + } + + private void createEsQueue(Context context) { + String tableName = "es_queue"; + BigIntegerColumnDef createdAtCol = newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(newVarcharColumnBuilder("doc_type").setIsNullable(false).setLimit(40).build()) + .addColumn(newVarcharColumnBuilder("doc_id").setIsNullable(false).setLimit(MAX_SIZE).build()) + .addColumn(newVarcharColumnBuilder("doc_id_type").setIsNullable(true).setLimit(20).build()) + .addColumn(newVarcharColumnBuilder("doc_routing").setIsNullable(true).setLimit(MAX_SIZE).build()) + .addColumn(createdAtCol) + .build()); + addIndex(context, tableName, "es_queue_created_at", false, createdAtCol); + } + + private void createEventComponentChanges(Context context) { + String tableName = "event_component_changes"; + VarcharColumnDef eventUuidCol = newVarcharColumnBuilder("event_uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + VarcharColumnDef eventComponentUuidCol = newVarcharColumnBuilder("event_component_uuid").setIsNullable(false).setLimit(UUID_VARCHAR_SIZE).build(); + VarcharColumnDef eventAnalysisUuidCol = newVarcharColumnBuilder("event_analysis_uuid").setIsNullable(false).setLimit(UUID_VARCHAR_SIZE).build(); + VarcharColumnDef changeCategoryCol = newVarcharColumnBuilder("change_category").setIsNullable(false).setLimit(12).build(); + VarcharColumnDef componentUuidCol = newVarcharColumnBuilder("component_uuid").setIsNullable(false).setLimit(UUID_VARCHAR_SIZE).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(eventUuidCol) + .addColumn(eventComponentUuidCol) + .addColumn(eventAnalysisUuidCol) + .addColumn(changeCategoryCol) + .addColumn(componentUuidCol) + .addColumn(newVarcharColumnBuilder("component_key").setIsNullable(false).setLimit(400).build()) + .addColumn(newVarcharColumnBuilder("component_name").setIsNullable(false).setLimit(2000).build()) + .addColumn(newVarcharColumnBuilder("component_branch_key").setIsNullable(true).setLimit(255).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, tableName + "_unique", true, eventUuidCol, changeCategoryCol, componentUuidCol); + addIndex(context, tableName, "event_cpnt_changes_cpnt", false, eventComponentUuidCol); + addIndex(context, tableName, "event_cpnt_changes_analysis", false, eventAnalysisUuidCol); + } + + private void createEvents(Context context) { + String tableName = "events"; + VarcharColumnDef uuidCol = newVarcharColumnBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build(); + VarcharColumnDef analysisUuidCol = newLenientVarcharBuilder("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + VarcharColumnDef componentUuid = newLenientVarcharBuilder("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(uuidCol) + .addColumn(analysisUuidCol) + .addColumn(newLenientVarcharBuilder("name").setLimit(400).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("category").setLimit(50).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(MAX_SIZE).build()) + .addColumn(newLenientVarcharBuilder("event_data").setLimit(MAX_SIZE).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("event_date").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(componentUuid) + .build()); + addIndex(context, tableName, "events_uuid", true, uuidCol); + addIndex(context, tableName, "events_analysis", false, analysisUuidCol); + addIndex(context, tableName, "events_component_uuid", false, componentUuid); + } + + private void createFileSources(Context context) { + String tableName = "file_sources"; + VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build(); + VarcharColumnDef fileUuidCol = newLenientVarcharBuilder("file_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(projectUuidCol) + .addColumn(fileUuidCol) + .addColumn(newClobColumnDefBuilder().setColumnName("line_hashes").setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("line_hashes_version").setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("data_hash").setLimit(50).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("src_hash").setLimit(50).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("revision").setLimit(100).setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("line_count").setIsNullable(false).build()) + .addColumn(newBlobColumnDefBuilder().setColumnName("binary_data").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(updatedAtCol) + .build()); + addIndex(context, tableName, "file_sources_file_uuid", true, fileUuidCol); + addIndex(context, tableName, "file_sources_project_uuid", false, projectUuidCol); + addIndex(context, tableName, "file_sources_updated_at", false, updatedAtCol); + } + + private void createGroupRoles(Context context) { + String tableName = "group_roles"; + IntegerColumnDef groupIdCol = newIntegerColumnDefBuilder().setColumnName("group_id").setIsNullable(true).build(); + IntegerColumnDef resourceIdCol = newIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build(); + VarcharColumnDef roleCol = newLenientVarcharBuilder("role").setLimit(64).setIsNullable(false).build(); + VarcharColumnDef organizationUuidCol = newLenientVarcharBuilder("organization_uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(organizationUuidCol) + .addColumn(groupIdCol) + .addColumn(resourceIdCol) + .addColumn(roleCol) + .build()); + addIndex(context, tableName, "uniq_group_roles", true, organizationUuidCol, groupIdCol, resourceIdCol, roleCol); + addIndex(context, tableName, "group_roles_resource", false, resourceIdCol); + } + + private void createGroups(Context context) { + context.execute( + newTableBuilder("groups") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newLenientVarcharBuilder("organization_uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(500).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(200).setIsNullable(true).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) + .build()); + } + + private void createGroupsUsers(Context context) { + String tableName = "groups_users"; + BigIntegerColumnDef userIdCol = newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build(); + BigIntegerColumnDef groupIdCol = newBigIntegerColumnDefBuilder().setColumnName("group_id").setIsNullable(true).build(); + context.execute( + newTableBuilder(tableName) + .addColumn(userIdCol) + .addColumn(groupIdCol) + .build()); + addIndex(context, tableName, "index_groups_users_on_user_id", false, userIdCol); + addIndex(context, tableName, "index_groups_users_on_group_id", false, groupIdCol); + addIndex(context, tableName, "groups_users_unique", true, groupIdCol, userIdCol); + } + + private void createInternalComponentProps(Context context) { + String tableName = "internal_component_props"; + VarcharColumnDef componentUuidCol = newVarcharColumnBuilder("component_uuid").setIsNullable(false).setLimit(UUID_VARCHAR_SIZE).build(); + VarcharColumnDef keeCol = newVarcharColumnBuilder("kee").setIsNullable(false).setLimit(512).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(componentUuidCol) + .addColumn(keeCol) + .addColumn(newVarcharColumnBuilder("value").setIsNullable(true).setLimit(MAX_SIZE).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "unique_component_uuid_kee", true, componentUuidCol, keeCol); + } + + private void createInternalProperties(Context context) { + context.execute( + newTableBuilder("internal_properties") + .addPkColumn(newLenientVarcharBuilder("kee").setLimit(20).setIsNullable(false).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("text_value").setLimit(MAX_SIZE).setIgnoreOracleUnit(true).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + } + + private void createIssueChanges(Context context) { + String tableName = "issue_changes"; + VarcharColumnDef issueKeyCol = newLenientVarcharBuilder("issue_key").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(50).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(keeCol) + .addColumn(issueKeyCol) + .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("change_type").setLimit(20).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("change_data").build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_change_creation_date").build()) + .build()); + addIndex(context, tableName, "issue_changes_issue_key", false, issueKeyCol); + addIndex(context, tableName, "issue_changes_kee", false, keeCol); + } + + private void createIssues(Context context) { + VarcharColumnDef assigneeCol = newLenientVarcharBuilder("assignee").setLimit(255).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(50).build(); + BigIntegerColumnDef issueCreationDateCol = newBigIntegerColumnDefBuilder().setColumnName("issue_creation_date").build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(50).build(); + VarcharColumnDef resolutionCol = newLenientVarcharBuilder("resolution").setLimit(20).build(); + IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").build(); + BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").build(); + context.execute( + newTableBuilder("issues") + .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(keeCol) + .addColumn(ruleIdCol) + .addColumn(newLenientVarcharBuilder("severity").setLimit(10).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("manual_severity").setIsNullable(false).build()) + // unit has been fixed in SonarQube 5.6 (see migration 1151, SONAR-7493) + .addColumn(newVarcharColumnBuilder("message").setLimit(MAX_SIZE).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("line").build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("gap").setPrecision(30).setScale(20).build()) + .addColumn(newLenientVarcharBuilder("status").setLimit(20).build()) + .addColumn(resolutionCol) + .addColumn(newLenientVarcharBuilder("checksum").setLimit(1000).build()) + .addColumn(newLenientVarcharBuilder("reporter").setLimit(255).build()) + .addColumn(assigneeCol) + .addColumn(newLenientVarcharBuilder("author_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("action_plan_key").setLimit(50).build()) + .addColumn(newLenientVarcharBuilder("issue_attributes").setLimit(MAX_SIZE).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("effort").build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) + .addColumn(updatedAtCol) + .addColumn(issueCreationDateCol) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_update_date").build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_close_date").build()) + .addColumn(newLenientVarcharBuilder("tags").setLimit(MAX_SIZE).build()) + .addColumn(componentUuidCol) + .addColumn(projectUuidCol) + .addColumn(newBlobColumnDefBuilder().setColumnName("locations").build()) + .addColumn(new TinyIntColumnDef.Builder().setColumnName("issue_type").build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("from_hotspot").setIsNullable(true).build()) + .build()); + addIndex(context, "issues", "issues_assignee", false, assigneeCol); + addIndex(context, "issues", "issues_component_uuid", false, componentUuidCol); + addIndex(context, "issues", "issues_creation_date", false, issueCreationDateCol); + addIndex(context, "issues", "issues_kee", true, keeCol); + addIndex(context, "issues", "issues_project_uuid", false, projectUuidCol); + addIndex(context, "issues", "issues_resolution", false, resolutionCol); + addIndex(context, "issues", "issues_rule_id", false, ruleIdCol); + addIndex(context, "issues", "issues_updated_at", false, updatedAtCol); + } + + private void createLiveMeasures(Context context) { + String tableName = "live_measures"; + VarcharColumnDef projectUuidCol = newVarcharColumnBuilder("project_uuid").setIsNullable(false).setLimit(UUID_VARCHAR_SIZE).build(); + VarcharColumnDef componentUuidCol = newVarcharColumnBuilder("component_uuid").setIsNullable(false).setLimit(UUID_VARCHAR_SIZE).build(); + IntegerColumnDef metricIdCol = newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(false).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(projectUuidCol) + .addColumn(componentUuidCol) + .addColumn(metricIdCol) + .addColumn(newDecimalColumnDefBuilder().setColumnName("value").setPrecision(38).setScale(20).build()) + .addColumn(newVarcharColumnBuilder("text_value").setIsNullable(true).setLimit(MAX_SIZE).build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("variation").setPrecision(38).setScale(20).build()) + .addColumn(newBlobColumnDefBuilder().setColumnName("measure_data").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("update_marker").setIsNullable(true).setLimit(UUID_SIZE).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "live_measures_project", false, projectUuidCol); + addIndex(context, tableName, "live_measures_component", true, componentUuidCol, metricIdCol); + } + + private void createManualMeasures(Context context) { + String tableName = "manual_measures"; + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(false).build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("value").setPrecision(38).setScale(20).build()) + .addColumn(newLenientVarcharBuilder("text_value").setLimit(MAX_SIZE).build()) + .addColumn(newLenientVarcharBuilder("user_uuid").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(MAX_SIZE).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) + .addColumn(componentUuidCol) + .build()); + addIndex(context, tableName, "manual_measures_component_uuid", false, componentUuidCol); + } + + private void createMetrics(Context context) { + String tableName = "metrics"; + VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(64).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(nameCol) + .addColumn(newLenientVarcharBuilder("description").setLimit(255).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("direction").setIsNullable(false).setDefaultValue(0).build()) + .addColumn(newLenientVarcharBuilder("domain").setLimit(64).build()) + .addColumn(newLenientVarcharBuilder("short_name").setLimit(64).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("qualitative").setDefaultValue(false).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("val_type").setLimit(8).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("user_managed").setDefaultValue(false).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("enabled").setDefaultValue(true).build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("worst_value").setPrecision(38).setScale(20).build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("best_value").setPrecision(38).setScale(20).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("optimized_best_value").build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("hidden").build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("delete_historical_data").build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("decimal_scale").build()) + .build()); + addIndex(context, tableName, "metrics_unique_name", true, nameCol); + } + + private void createNotifications(Context context) { + context.execute( + newTableBuilder("notifications") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newBlobColumnDefBuilder().setColumnName("data").build()) + .build()); + } + + private void createOrgQProfiles(Context context) { + String tableName = "org_qprofiles"; + int profileUuidSize = 255; + VarcharColumnDef organizationCol = newLenientVarcharBuilder("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).build(); + VarcharColumnDef rulesProfileUuidCol = newLenientVarcharBuilder("rules_profile_uuid").setLimit(profileUuidSize).setIsNullable(false).build(); + VarcharColumnDef parentUuidCol = newLenientVarcharBuilder("parent_uuid").setLimit(profileUuidSize).setIsNullable(true).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setLimit(profileUuidSize).setIsNullable(false).build()) + .addColumn(organizationCol) + .addColumn(rulesProfileUuidCol) + .addColumn(parentUuidCol) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("last_used").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_updated_at").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "qprofiles_org_uuid", false, organizationCol); + addIndex(context, tableName, "qprofiles_rp_uuid", false, rulesProfileUuidCol); + addIndex(context, tableName, "org_qprofiles_parent_uuid", false, parentUuidCol); + } + + private void createOrgQualityGates(Context context) { + String tableName = "org_quality_gates"; + VarcharColumnDef organizationUuidCol = newVarcharColumnBuilder("organization_uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + VarcharColumnDef qualityGateUuidCol = newVarcharColumnBuilder("quality_gate_uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(organizationUuidCol) + .addColumn(qualityGateUuidCol) + .build()); + addIndex(context, tableName, "uniq_org_quality_gates", true, organizationUuidCol, qualityGateUuidCol); + } + + private void createOrganizationAlmBindings(Context context) { + String tableName = "organization_alm_bindings"; + VarcharColumnDef organizationUuidCol = newVarcharColumnBuilder("organization_uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + VarcharColumnDef almAppInstallUuidCol = newVarcharColumnBuilder("alm_app_install_uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(organizationUuidCol) + .addColumn(almAppInstallUuidCol) + .addColumn(newVarcharColumnBuilder("alm_id").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(newVarcharColumnBuilder("url").setIsNullable(false).setLimit(2000).build()) + .addColumn(newVarcharColumnBuilder("user_uuid").setIsNullable(false).setLimit(255).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("members_sync_enabled").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "org_alm_bindings_org", true, organizationUuidCol); + addIndex(context, tableName, "org_alm_bindings_install", true, almAppInstallUuidCol); + } + + private void createOrganizationMembers(Context context) { + String tableName = "organization_members"; + IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addPkColumn(userIdCol) + .build()); + addIndex(context, tableName, "ix_org_members_on_user_id", false, userIdCol); + } + + private void createOrganizations(Context context) { + String tableName = "organizations"; + VarcharColumnDef keeColumn = newLenientVarcharBuilder("kee").setLimit(255).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newLenientVarcharBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(keeColumn) + .addColumn(newLenientVarcharBuilder("name").setLimit(255).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(256).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("url").setLimit(256).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("avatar_url").setLimit(256).setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("guarded").setIsNullable(false).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("default_group_id").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("default_quality_gate_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(newVarcharColumnBuilder("default_perm_template_project").setLimit(UUID_SIZE).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("default_perm_template_app").setLimit(UUID_SIZE).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("default_perm_template_port").setLimit(UUID_SIZE).setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("new_project_private").setIsNullable(false).build()) + .addColumn(newVarcharColumnBuilder("subscription").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "organization_key", true, keeColumn); + } + + private void createPermTemplatesGroups(Context context) { + context.execute( + newTableBuilder("perm_templates_groups") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newIntegerColumnDefBuilder().setColumnName("group_id").build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("permission_reference").setLimit(64).setIsNullable(false).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) + .build()); + } + + private void createPermTemplatesUsers(Context context) { + context.execute( + newTableBuilder("perm_templates_users") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(false).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("permission_reference").setLimit(64).setIsNullable(false).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) + .build()); + } + + private void createPermTemplatesCharacteristics(Context context) { + String tableName = "perm_tpl_characteristics"; + IntegerColumnDef templateIdColumn = newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build(); + VarcharColumnDef permissionKeyColumn = newLenientVarcharBuilder("permission_key").setLimit(64).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(templateIdColumn) + .addColumn(permissionKeyColumn) + .addColumn(newBooleanColumnDefBuilder().setColumnName("with_project_creator").setIsNullable(false).setDefaultValue(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + + addIndex(context, tableName, "uniq_perm_tpl_charac", true, templateIdColumn, permissionKeyColumn); + } + + private void createPermissionTemplates(Context context) { + context.execute( + newTableBuilder("permission_templates") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newLenientVarcharBuilder("organization_uuid").setIsNullable(false).setLimit(40).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("kee").setLimit(100).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(MAX_SIZE).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) + .addColumn(newLenientVarcharBuilder("key_pattern").setLimit(500).build()) + .build()); + } + + private void createPlugins(Context context) { + int pluginKeyMaxSize = 200; + String tableName = "plugins"; + VarcharColumnDef keyColumn = newVarcharColumnBuilder("kee").setLimit(pluginKeyMaxSize).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newLenientVarcharBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(keyColumn) + .addColumn(newVarcharColumnBuilder("base_plugin_key").setLimit(pluginKeyMaxSize).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("file_hash").setLimit(200).setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "plugins_key", true, keyColumn); + } + + private void createProjectAlmBindings(Context context) { + String tableName = "project_alm_bindings"; + VarcharColumnDef almIdCol = newVarcharColumnDefBuilder().setColumnName("alm_id").setIsNullable(false).setLimit(40).build(); + VarcharColumnDef repoIdCol = newVarcharColumnDefBuilder().setColumnName("repo_id").setIsNullable(false).setLimit(256).build(); + VarcharColumnDef projectUuidCol = newVarcharColumnDefBuilder().setColumnName("project_uuid").setIsNullable(false).setLimit(40).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(almIdCol) + .addColumn(repoIdCol) + .addColumn(projectUuidCol) + .addColumn(newVarcharColumnBuilder("github_slug").setIsNullable(true).setLimit(256).build()) + .addColumn(newVarcharColumnBuilder("url").setIsNullable(false).setLimit(2000).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, tableName + "_alm_repo", true, almIdCol, repoIdCol); + addIndex(context, tableName, tableName + "_project", true, projectUuidCol); + } + + private void createProjectBranches(Context context) { + String tableName = "project_branches"; + VarcharColumnDef projectUuidCol = newVarcharColumnBuilder("project_uuid").setIsNullable(false).setLimit(UUID_VARCHAR_SIZE).build(); + VarcharColumnDef keeCol = newVarcharColumnBuilder("kee").setIsNullable(false).setLimit(255).build(); + VarcharColumnDef keyTypeCol = newVarcharColumnBuilder("key_type").setIsNullable(false).setLimit(12).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_VARCHAR_SIZE).build()) + .addColumn(projectUuidCol) + .addColumn(keeCol) + .addColumn(newVarcharColumnBuilder("branch_type").setIsNullable(true).setLimit(12).build()) + .addColumn(newVarcharColumnBuilder("merge_branch_uuid").setIsNullable(true).setLimit(UUID_VARCHAR_SIZE).build()) + .addColumn(keyTypeCol) + .addColumn(newBlobColumnDefBuilder().setColumnName("pull_request_binary").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("manual_baseline_analysis_uuid").setIsNullable(true).setLimit(UUID_SIZE).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "project_branches_kee_key_type", true, projectUuidCol, keeCol, keyTypeCol); + } + + private void createProjectLinks(Context context) { + String tableName = "project_links"; + VarcharColumnDef projectUuidCol = newVarcharColumnBuilder("project_uuid").setLimit(UUID_SIZE).setIsNullable(false).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(projectUuidCol) + .addColumn(newVarcharColumnBuilder("link_type").setLimit(20).setIsNullable(false).build()) + .addColumn(newVarcharColumnBuilder("name").setLimit(128).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("href").setLimit(2048).setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "project_links_project", false, projectUuidCol); + } + + private void createProjectMappings(Context context) { + String tableName = "project_mappings"; + VarcharColumnDef keyTypeCol = newVarcharColumnBuilder("key_type").setIsNullable(false).setLimit(200).build(); + VarcharColumnDef keyCol = newVarcharColumnBuilder("kee").setIsNullable(false).setLimit(MAX_SIZE).build(); + VarcharColumnDef projectUuidCol = newVarcharColumnBuilder("project_uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(keyTypeCol) + .addColumn(keyCol) + .addColumn(projectUuidCol) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "key_type_kee", true, keyTypeCol, keyCol); + addIndex(context, tableName, "project_uuid", false, projectUuidCol); + } + + private void createProjectMeasures(Context context) { + String tableName = "project_measures"; + IntegerColumnDef personIdCol = newIntegerColumnDefBuilder().setColumnName("person_id").build(); + IntegerColumnDef metricIdCol = newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(false).build(); + VarcharColumnDef analysisUuidCol = newLenientVarcharBuilder("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newDecimalColumnDefBuilder().setColumnName("value").setPrecision(38).setScale(20).build()) + .addColumn(metricIdCol) + .addColumn(analysisUuidCol) + .addColumn(componentUuidCol) + .addColumn(newLenientVarcharBuilder("text_value").setLimit(MAX_SIZE).build()) + .addColumn(newLenientVarcharBuilder("alert_status").setLimit(5).build()) + .addColumn(newLenientVarcharBuilder("alert_text").setLimit(MAX_SIZE).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(MAX_SIZE).build()) + .addColumn(personIdCol) + .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_1").setPrecision(38).setScale(20).build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_2").setPrecision(38).setScale(20).build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_3").setPrecision(38).setScale(20).build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_4").setPrecision(38).setScale(20).build()) + .addColumn(newDecimalColumnDefBuilder().setColumnName("variation_value_5").setPrecision(38).setScale(20).build()) + .addColumn(newBlobColumnDefBuilder().setColumnName("measure_data").build()) + .build()); + addIndex(context, tableName, "measures_analysis_metric", false, analysisUuidCol, metricIdCol); + addIndex(context, tableName, "measures_component_uuid", false, componentUuidCol); + } + + private void createProjectQprofiles(Context context) { + String tableName = "project_qprofiles"; + VarcharColumnDef projectUuid = newLenientVarcharBuilder("project_uuid").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef profileKey = newLenientVarcharBuilder("profile_key").setLimit(50).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(projectUuid) + .addColumn(profileKey) + .build()); + addIndex(context, tableName, "uniq_project_qprofiles", true, projectUuid, profileKey); + } + + private void createProjects(Context context) { + String tableName = "projects"; + VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef organizationUuidCol = newVarcharColumnBuilder("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(400).setIsNullable(true).build(); + VarcharColumnDef qualifierCol = newLenientVarcharBuilder("qualifier").setLimit(10).setIsNullable(true).build(); + VarcharColumnDef rootUuidCol = newVarcharColumnBuilder("root_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef moduleUuidCol = newLenientVarcharBuilder("module_uuid").setLimit(50).setIsNullable(true).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(uuidCol) + .addColumn(organizationUuidCol) + .addColumn(keeCol) + .addColumn(newLenientVarcharBuilder("deprecated_kee").setLimit(400).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(2_000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("long_name").setLimit(2_000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(2_000).setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("enabled").setDefaultValue(true).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("scope").setLimit(3).setIsNullable(true).build()) + .addColumn(qualifierCol) + .addColumn(newBooleanColumnDefBuilder().setColumnName("private").setIsNullable(false).build()) + .addColumn(rootUuidCol) + .addColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("copy_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("developer_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("path").setLimit(2_000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("uuid_path").setLimit(1_500).setIsNullable(false).build()) + .addColumn(projectUuidCol) + .addColumn(moduleUuidCol) + .addColumn(newLenientVarcharBuilder("module_uuid_path").setLimit(1_500).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("authorization_updated_at").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("tags").setLimit(500).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("main_branch_project_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("b_changed").setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_name").setLimit(500).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_long_name").setLimit(500).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_description").setLimit(2_000).setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("b_enabled").setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_qualifier").setLimit(10).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_language").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_copy_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_path").setLimit(2_000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_uuid_path").setLimit(1_500).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_module_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("b_module_uuid_path").setLimit(1_500).setIsNullable(true).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) + .build()); + addIndex(context, tableName, "projects_organization", false, organizationUuidCol); + addIndex(context, tableName, "projects_kee", true, keeCol); + addIndex(context, tableName, "projects_module_uuid", false, moduleUuidCol); + addIndex(context, tableName, "projects_project_uuid", false, projectUuidCol); + addIndex(context, tableName, "projects_qualifier", false, qualifierCol); + addIndex(context, tableName, "projects_root_uuid", false, rootUuidCol); + // see SONAR-12341, index projects_uuid should actually be unique + addIndex(context, tableName, "projects_uuid", false, uuidCol); + } + + private void createProperties(Context context) { + String tableName = "properties"; + VarcharColumnDef propKey = newLenientVarcharBuilder("prop_key").setLimit(512).setIsNullable(false).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(propKey) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("text_value").setLimit(MAX_SIZE).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + // table with be renamed to properties in following migration, use final constraint name right away + .withPkConstraintName("pk_properties") + .build()); + addIndex(context, tableName, "properties_key", false, propKey); + } + + private void createQProfileChanges(Context context) { + String tableName = "qprofile_changes"; + VarcharColumnDef rulesProfileUuidCol = newLenientVarcharBuilder("rules_profile_uuid").setLimit(255).setIsNullable(false).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newLenientVarcharBuilder("kee").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(rulesProfileUuidCol) + .addColumn(newLenientVarcharBuilder("change_type").setLimit(20).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("user_uuid").setLimit(255).setIsNullable(true).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("change_data").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "qp_changes_rules_profile_uuid", false, rulesProfileUuidCol); + } + + private void createQProfileEditGroups(Context context) { + String tableName = "qprofile_edit_groups"; + IntegerColumnDef groupCol = newIntegerColumnDefBuilder().setColumnName("group_id").setIsNullable(false).build(); + VarcharColumnDef qProfileUuidCol = newVarcharColumnBuilder("qprofile_uuid").setIsNullable(false).setLimit(255).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(groupCol) + .addColumn(qProfileUuidCol) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, tableName + "_qprofile", false, qProfileUuidCol); + addIndex(context, tableName, tableName + "_unique", true, groupCol, qProfileUuidCol); + } + + private void createQProfileEditUsers(Context context) { + String tableName = "qprofile_edit_users"; + IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(false).build(); + VarcharColumnDef qProfileUuidCol = newVarcharColumnBuilder("qprofile_uuid").setIsNullable(false).setLimit(255).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build()) + .addColumn(userIdCol) + .addColumn(qProfileUuidCol) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, tableName + "_qprofile", false, qProfileUuidCol); + addIndex(context, tableName, tableName + "_unique", true, userIdCol, qProfileUuidCol); + } + + private void createQualityGateConditions(Context context) { + context.execute( + newTableBuilder("quality_gate_conditions") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newIntegerColumnDefBuilder().setColumnName("qgate_id").setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("period").setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("operator").setLimit(3).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("value_error").setLimit(64).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("value_warning").setLimit(64).setIsNullable(true).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) + .build()); + } + + private void createQualityGates(Context context) { + String tableName = "quality_gates"; + VarcharColumnDef uuidCol = newVarcharColumnBuilder("uuid").setIsNullable(false).setLimit(UUID_SIZE).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(uuidCol) + .addColumn(newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_built_in").setIsNullable(false).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) + .build()); + addIndex(context, tableName, "uniq_quality_gates_uuid", true, uuidCol); + } + + private void createRulesRepository(Context context) { + String tableName = "rule_repositories"; + context.execute(newTableBuilder(tableName) + .addPkColumn(newLenientVarcharBuilder("kee").setLimit(200).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(4_000).setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + } + + private void createRules(Context context) { + VarcharColumnDef pluginRuleKeyCol = newLenientVarcharBuilder("plugin_rule_key").setLimit(200).setIsNullable(false).build(); + VarcharColumnDef pluginNameCol = newLenientVarcharBuilder("plugin_name").setLimit(255).setIsNullable(false).build(); + context.execute( + newTableBuilder("rules") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newLenientVarcharBuilder("name").setLimit(200).setIsNullable(true).build()) + .addColumn(pluginRuleKeyCol) + .addColumn(newVarcharColumnBuilder("plugin_key").setLimit(200).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("plugin_config_key").setLimit(200).setIsNullable(true).build()) + .addColumn(pluginNameCol) + .addColumn(newVarcharColumnBuilder("scope").setLimit(20).setIsNullable(false).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("description").setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("priority").setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("status").setLimit(40).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("def_remediation_function").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("def_remediation_gap_mult").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("def_remediation_base_effort").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("gap_description").setLimit(MAX_SIZE).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("system_tags").setLimit(MAX_SIZE).setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_template").setIsNullable(false).setDefaultValue(false).build()) + .addColumn(newLenientVarcharBuilder("description_format").setLimit(20).setIsNullable(true).build()) + .addColumn(new TinyIntColumnDef.Builder().setColumnName("rule_type").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("security_standards").setIsNullable(true).setLimit(4_000).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_ad_hoc").setIsNullable(false).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_external").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) + .build()); + addIndex(context, "rules", "rules_repo_key", true, pluginRuleKeyCol, pluginNameCol); + } + + private void createRulesMetadata(Context context) { + String tableName = "rules_metadata"; + context.execute(newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(false).build()) + .addPkColumn(newVarcharColumnBuilder("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("note_data").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("note_user_uuid").setLimit(255).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("note_created_at").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("note_updated_at").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("remediation_function").setLimit(20).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("remediation_gap_mult").setLimit(20).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("remediation_base_effort").setLimit(20).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("tags").setLimit(4_000).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("ad_hoc_name").setLimit(200).setIsNullable(true).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("ad_hoc_description").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("ad_hoc_severity").setLimit(10).setIsNullable(true).build()) + .addColumn(newTinyIntColumnDefBuilder().setColumnName("ad_hoc_type").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .withPkConstraintName("pk_" + tableName) + .build()); + } + + private void createRulesParameters(Context context) { + String tableName = "rules_parameters"; + IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(false).build(); + VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(128).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(ruleIdCol) + .addColumn(nameCol) + .addColumn(newLenientVarcharBuilder("description").setLimit(MAX_SIZE).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("param_type").setLimit(512).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("default_value").setLimit(MAX_SIZE).setIsNullable(true).build()) + .build()); + addIndex(context, tableName, "rules_parameters_rule_id", false, ruleIdCol); + addIndex(context, tableName, "rules_parameters_unique", true, ruleIdCol, nameCol); + } + + private void createRulesProfiles(Context context) { + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(255).setIsNullable(false).build(); + context.execute( + newTableBuilder("rules_profiles") + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) + .addColumn(keeCol) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_built_in").setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("rules_updated_at").setLimit(100).setIsNullable(true).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) + .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) + .build()); + addIndex(context, "rules_profiles", "uniq_qprof_key", true, keeCol); + } + + private void createSnapshots(Context context) { + String tableName = "snapshots"; + VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(uuidCol) + .addColumn(componentUuidCol) + .addColumn(newLenientVarcharBuilder("status").setLimit(4).setIsNullable(false).setDefaultValue("U").build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("islast").setIsNullable(false).setDefaultValue(false).build()) + .addColumn(newLenientVarcharBuilder("version").setLimit(500).setIsNullable(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("purge_status").setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("build_string").setLimit(100).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("revision").setLimit(100).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("build_date").setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period1_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period1_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period2_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period2_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period3_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period3_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period4_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period4_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period5_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period5_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period1_date").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period2_date").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period3_date").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period4_date").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period5_date").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) + .build()); + addIndex(context, tableName, "analyses_uuid", true, uuidCol); + addIndex(context, tableName, "snapshot_component", false, componentUuidCol); + } + + private void createUserProperties(Context context) { + String tableName = "user_properties"; + VarcharColumnDef userUuidCol = newVarcharColumnBuilder("user_uuid").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef keyCol = newVarcharColumnBuilder("kee").setLimit(100).setIsNullable(false).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(userUuidCol) + .addColumn(keyCol) + .addColumn(newVarcharColumnBuilder("text_value").setLimit(4_000).setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "user_properties_user_uuid_kee", true, userUuidCol, keyCol); + } + + private void createUserRoles(Context context) { + String tableName = "user_roles"; + IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build(); + IntegerColumnDef resourceIdCol = newIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(newLenientVarcharBuilder("organization_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(userIdCol) + .addColumn(resourceIdCol) + .addColumn(newLenientVarcharBuilder("role").setLimit(64).setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "user_roles_resource", false, resourceIdCol); + addIndex(context, tableName, "user_roles_user", false, userIdCol); + } + + private void createUserTokens(Context context) { + String tableName = "user_tokens"; + VarcharColumnDef userUuidCol = newVarcharColumnBuilder("user_uuid").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef nameCol = newVarcharColumnBuilder("name").setLimit(100).setIsNullable(false).build(); + VarcharColumnDef tokenHashCol = newVarcharColumnBuilder("token_hash").setLimit(255).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(userUuidCol) + .addColumn(nameCol) + .addColumn(tokenHashCol) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("last_connection_date").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "user_tokens_user_uuid_name", true, userUuidCol, nameCol); + addIndex(context, tableName, "user_tokens_token_hash", true, tokenHashCol); + } + + private void createUsers(Context context) { + String tableName = "users"; + VarcharColumnDef uuidCol = newVarcharColumnBuilder("uuid").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef loginCol = newLenientVarcharBuilder("login").setLimit(255).setIsNullable(false).build(); + BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build(); + VarcharColumnDef externalLoginCol = newLenientVarcharBuilder("external_login").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef externalIdentityProviderCol = newLenientVarcharBuilder("external_identity_provider").setLimit(100).setIsNullable(false).build(); + VarcharColumnDef externalIdCol = newVarcharColumnBuilder("external_id").setLimit(255).setIsNullable(false).build(); + context.execute( + newTableBuilder(tableName) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(uuidCol) + .addColumn(loginCol) + .addColumn(newVarcharColumnBuilder("organization_uuid").setLimit(UUID_SIZE).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(200).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("email").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("crypted_password").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("salt").setLimit(40).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("hash_method").setLimit(10).setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("active").setDefaultValue(true).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("scm_accounts").setLimit(MAX_SIZE).build()) + .addColumn(externalLoginCol) + .addColumn(externalIdentityProviderCol) + .addColumn(externalIdCol) + .addColumn(newBooleanColumnDefBuilder().setColumnName("is_root").setIsNullable(false).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("user_local").setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("onboarded").setIsNullable(false).build()) + .addColumn(newVarcharColumnBuilder("homepage_type").setLimit(40).setIsNullable(true).build()) + .addColumn(newVarcharColumnBuilder("homepage_parameter").setLimit(40).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("last_connection_date").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) + .addColumn(updatedAtCol) + .build()); + addIndex(context, tableName, "users_login", true, loginCol); + addIndex(context, tableName, "users_updated_at", false, updatedAtCol); + addIndex(context, tableName, "users_uuid", true, uuidCol); + addIndex(context, tableName, "uniq_external_id", true, externalIdentityProviderCol, externalIdCol); + addIndex(context, tableName, "uniq_external_login", true, externalIdentityProviderCol, externalLoginCol); + } + + private void createWebhookDeliveries(Context context) { + String tableName = "webhook_deliveries"; + VarcharColumnDef componentUuidColumn = newLenientVarcharBuilder("component_uuid").setLimit(UUID_SIZE).setIsNullable(false).build(); + VarcharColumnDef ceTaskUuidColumn = newLenientVarcharBuilder("ce_task_uuid").setLimit(UUID_SIZE).setIsNullable(true).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newLenientVarcharBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(newVarcharColumnBuilder("webhook_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(componentUuidColumn) + .addColumn(ceTaskUuidColumn) + .addColumn(newVarcharColumnBuilder("analysis_uuid").setLimit(UUID_SIZE).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("url").setLimit(2_000).setIsNullable(false).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("success").setIsNullable(false).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("http_status").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("duration_ms").setIsNullable(false).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("payload").setIsNullable(false).build()) + .addColumn(newClobColumnDefBuilder().setColumnName("error_stacktrace").setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .build()); + addIndex(context, tableName, "component_uuid", false, componentUuidColumn); + addIndex(context, tableName, "ce_task_uuid", false, ceTaskUuidColumn); + } + + private void createWebhooks(Context context) { + String tableName = "webhooks"; + VarcharColumnDef organizationUuidCol = newVarcharColumnBuilder("organization_uuid").setLimit(UUID_SIZE).setIsNullable(true).build(); + VarcharColumnDef projectUuidCol = newVarcharColumnBuilder("project_uuid").setLimit(UUID_SIZE).setIsNullable(true).build(); + context.execute(newTableBuilder(tableName) + .addPkColumn(newVarcharColumnBuilder("uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) + .addColumn(organizationUuidCol) + .addColumn(projectUuidCol) + .addColumn(newVarcharColumnBuilder("name").setLimit(100).setIsNullable(false).build()) + .addColumn(newVarcharColumnBuilder("url").setLimit(2_000).setIsNullable(false).build()) + .addColumn(newVarcharColumnBuilder("secret").setLimit(200).setIsNullable(true).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) + .build()); + addIndex(context, tableName, "organization_webhook", false, organizationUuidCol); + addIndex(context, tableName, "project_webhook", false, projectUuidCol); + } + + private static void addIndex(Context context, String table, String index, boolean unique, ColumnDef... columns) { + CreateIndexBuilder builder = new CreateIndexBuilder() + .setTable(table) + .setName(index) + .setUnique(unique); + for (ColumnDef column : columns) { + builder.addColumn(column); + } + context.execute(builder.build()); + } + + private static VarcharColumnDef.Builder newLenientVarcharBuilder(String column) { + return new VarcharColumnDef.Builder().setColumnName(column).setIgnoreOracleUnit(true); + } + + private static VarcharColumnDef.Builder newVarcharColumnBuilder(String column) { + return newVarcharColumnDefBuilder().setColumnName(column); + } + + private CreateTableBuilder newTableBuilder(String tableName) { + return new CreateTableBuilder(getDialect(), tableName); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/DbVersion79.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/DbVersion79.java index 39f8bf26db1..741aa24b9d5 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/DbVersion79.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/DbVersion79.java @@ -26,11 +26,7 @@ public class DbVersion79 implements DbVersion { @Override public void addSteps(MigrationStepRegistry registry) { registry - .add(2800, "Truncate environment variables and system properties from existing scanner reports", - TruncateEnvAndSystemVarsFromScannerContext.class) - .add(2801, "populate install version and install date internal properties", PopulateInstallDateAndVersion.class) - .add(2802, "Migrate property 'sonar.pullrequest.provider' value from VSTS to Azure DevOps", MigrateVstsProviderToAzureDevOps.class) - .add(2803, "Remove quality gate conditions on Security Review Rating", RemoveQGConditionsOnSecurityReviewRating.class) - .add(2804, "Reindex issues and rules to take into account latest categories definition", ReindexIssuesAndRules.class); + .add(1, "Create initial schema", CreateInitialSchema.class) + .add(2, "Populate initial schema", PopulateInitialSchema.class); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOps.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOps.java deleted file mode 100644 index 23a6bd06a28..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOps.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class MigrateVstsProviderToAzureDevOps extends DataChange { - - private static final String VSTS = "VSTS"; - private static final String VSTS_TFS = "VSTS / TFS"; - - public MigrateVstsProviderToAzureDevOps(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id, text_value from properties " + - " where prop_key = 'sonar.pullrequest.provider' and text_value in ('" + VSTS + "', '" + VSTS_TFS + "')"); - massUpdate.update("update properties " + - " set text_value= ?, " + - " clob_value = null " + - " where id = ?"); - massUpdate.rowPluralName("PR provider properties"); - massUpdate.execute((row, update) -> { - update.setString(1, convert(row.getString(2))); - update.setLong(2, row.getLong(1)); - return true; - }); - } - - private static String convert(String oldValue) { - switch (oldValue) { - case VSTS: - return "Azure DevOps Services"; - case VSTS_TFS: - return "Azure DevOps"; - default: - throw new IllegalStateException("Unexpected value: " + oldValue); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchema.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchema.java new file mode 100644 index 00000000000..4d18e3bfa84 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchema.java @@ -0,0 +1,276 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v79; + +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import org.sonar.api.SonarRuntime; +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.Upsert; + +public class PopulateInitialSchema extends DataChange { + + private static final String ADMINS_GROUP = "sonar-administrators"; + private static final String USERS_GROUP = "sonar-users"; + private static final String ADMIN_USER = "admin"; + private static final List ADMIN_ROLES = Arrays.asList("admin", "profileadmin", "gateadmin", "provisioning", "applicationcreator", "portfoliocreator"); + + private final System2 system2; + private final UuidFactory uuidFactory; + private final SonarRuntime sonarRuntime; + + public PopulateInitialSchema(Database db, System2 system2, UuidFactory uuidFactory, SonarRuntime sonarRuntime) { + super(db); + this.system2 = system2; + this.uuidFactory = uuidFactory; + this.sonarRuntime = sonarRuntime; + } + + @Override + public void execute(Context context) throws SQLException { + String organizationUuid = uuidFactory.create(); + + int adminUserId = insertAdminUser(context); + Groups groups = insertGroups(context, organizationUuid); + String defaultQGUuid = insertQualityGate(context); + insertOrganization(context, organizationUuid, groups, defaultQGUuid); + insertOrgQualityGate(context, organizationUuid, defaultQGUuid); + insertInternalProperty(context, organizationUuid); + insertGroupRoles(context, organizationUuid, groups); + insertGroupUsers(context, adminUserId, groups); + insertOrganizationMember(context, adminUserId, organizationUuid); + } + + private int insertAdminUser(Context context) throws SQLException { + truncateTable(context, "users"); + + long now = system2.now(); + context.prepareUpsert("insert into users " + + "(uuid, login, name, email, external_id, external_login, external_identity_provider, user_local, crypted_password, salt, hash_method, is_root, onboarded, created_at, updated_at)" + + + " values " + + "(?, ?, 'Administrator', null, 'admin', 'admin', 'sonarqube', ?, '$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi', null, 'BCRYPT', ?, ?, ?, ?)") + .setString(1, uuidFactory.create()) + .setString(2, ADMIN_USER) + .setBoolean(3, true) + .setBoolean(4, false) + .setBoolean(5, true) + .setLong(6, now) + .setLong(7, now) + .execute() + .commit(); + + return context.prepareSelect("select id from users where login=?") + .setString(1, ADMIN_USER) + .get(t -> t.getInt(1)); + } + + private void insertOrganization(Context context, String organizationUuid, Groups groups, String defaultQGUuid) throws SQLException { + truncateTable(context, "organizations"); + + long now = system2.now(); + context.prepareUpsert("insert into organizations " + + "(uuid, kee, name, guarded, new_project_private, default_group_id, default_quality_gate_uuid, subscription, created_at, updated_at)" + + " values " + + "(?, 'default-organization', 'Default Organization', ?, ?, ?, ?, 'SONARQUBE', ?, ?)") + .setString(1, organizationUuid) + .setBoolean(2, true) + .setBoolean(3, false) + .setInt(4, groups.getUserGroupId()) + .setString(5, defaultQGUuid) + .setLong(6, now) + .setLong(7, now) + .execute() + .commit(); + } + + private void insertOrgQualityGate(Context context, String organizationUuid, String defaultQGUuid) throws SQLException { + truncateTable(context, "org_quality_gates"); + + context.prepareUpsert("insert into org_quality_gates " + + "(uuid, organization_uuid, quality_gate_uuid)" + + " values " + + "(?, ?, ?)") + .setString(1, uuidFactory.create()) + .setString(2, organizationUuid) + .setString(3, defaultQGUuid) + .execute() + .commit(); + } + + private void insertInternalProperty(Context context, String organizationUuid) throws SQLException { + truncateTable(context, "internal_properties"); + + long now = system2.now(); + Upsert upsert = context.prepareUpsert("insert into internal_properties " + + "(kee, is_empty, text_value, created_at)" + + " values" + + " (?, ?, ?, ?)"); + upsert + .setString(1, "organization.default") + .setBoolean(2, false) + .setString(3, organizationUuid) + .setLong(4, now) + .addBatch(); + upsert + .setString(1, "installation.date") + .setBoolean(2, false) + .setString(3, String.valueOf(system2.now())) + .setLong(4, now) + .addBatch(); + upsert + .setString(1, "installation.version") + .setBoolean(2, false) + .setString(3, sonarRuntime.getApiVersion().toString()) + .setLong(4, now) + .addBatch(); + upsert + .execute() + .commit(); + } + + private Groups insertGroups(Context context, String organizationUuid) throws SQLException { + truncateTable(context, "groups"); + + Date now = new Date(system2.now()); + Upsert upsert = context.prepareUpsert("insert into groups (organization_uuid, name, description, created_at, updated_at) values (?, ?, ?, ?, ?)"); + upsert + .setString(1, organizationUuid) + .setString(2, ADMINS_GROUP) + .setString(3, "System administrators") + .setDate(4, now) + .setDate(5, now) + .addBatch(); + upsert + .setString(1, organizationUuid) + .setString(2, USERS_GROUP) + .setString(3, "Any new users created will automatically join this group") + .setDate(4, now) + .setDate(5, now) + .addBatch(); + upsert + .execute() + .commit(); + + return new Groups(getGroupId(context, ADMINS_GROUP), getGroupId(context, USERS_GROUP)); + } + + private static int getGroupId(Context context, String groupName) throws SQLException { + return context.prepareSelect("select id from groups where name=?") + .setString(1, groupName) + .get(t -> t.getInt(1)); + } + + private String insertQualityGate(Context context) throws SQLException { + truncateTable(context, "quality_gates"); + + String uuid = uuidFactory.create(); + Date now = new Date(system2.now()); + context.prepareUpsert("insert into quality_gates " + + "(uuid, name, is_built_in, created_at, updated_at)" + + " values " + + "(?, 'Sonar way', ?, ?, ?)") + .setString(1, uuid) + .setBoolean(2, true) + .setDate(3, now) + .setDate(4, now) + .execute() + .commit(); + return uuid; + } + + private static final class Groups { + private final int adminGroupId; + private final int userGroupId; + + private Groups(int adminGroupId, int userGroupId) { + this.adminGroupId = adminGroupId; + this.userGroupId = userGroupId; + } + + public int getAdminGroupId() { + return adminGroupId; + } + + public int getUserGroupId() { + return userGroupId; + } + } + + private static void insertGroupRoles(Context context, String organizationUuid, Groups groups) throws SQLException { + truncateTable(context, "group_roles"); + + Upsert upsert = context.prepareUpsert("insert into group_roles (organization_uuid, group_id, role) values (?, ?, ?)"); + for (String adminRole : ADMIN_ROLES) { + upsert + .setString(1, organizationUuid) + .setInt(2, groups.getAdminGroupId()) + .setString(3, adminRole) + .addBatch(); + } + for (String anyoneRole : Arrays.asList("scan", "provisioning")) { + upsert + .setString(1, organizationUuid) + .setInt(2, null) + .setString(3, anyoneRole) + .addBatch(); + } + upsert + .execute() + .commit(); + } + + private static void insertGroupUsers(Context context, int adminUserId, Groups groups) throws SQLException { + truncateTable(context, "groups_users"); + + Upsert upsert = context.prepareUpsert("insert into groups_users (user_id, group_id) values (?,?)"); + upsert + .setInt(1, adminUserId) + .setInt(2, groups.getUserGroupId()) + .addBatch(); + upsert + .setInt(1, adminUserId) + .setInt(2, groups.getAdminGroupId()) + .addBatch(); + upsert + .execute() + .commit(); + } + + private static void insertOrganizationMember(Context context, int adminUserId, String organizationUuid) throws SQLException { + truncateTable(context, "organization_members"); + + context.prepareUpsert("insert into organization_members(organization_uuid, user_id) values (?, ?)") + .setString(1, organizationUuid) + .setInt(2, adminUserId) + .execute() + .commit(); + } + + private static void truncateTable(Context context, String table) throws SQLException { + context.prepareUpsert("truncate table " + table).execute().commit(); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersion.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersion.java deleted file mode 100644 index 14b1b9624d3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersion.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import java.sql.SQLException; -import org.sonar.api.SonarRuntime; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; - -@SupportsBlueGreen -public class PopulateInstallDateAndVersion extends DataChange { - - private static final Logger LOG = Loggers.get(PopulateInstallDateAndVersion.class); - private static final String INSTALLATION_DATE = "installation.date"; - private static final String INSTALLATION_VERSION = "installation.version"; - private final SonarRuntime sonarRuntime; - private final System2 system2; - - public PopulateInstallDateAndVersion(Database db, SonarRuntime sonarRuntime, System2 system2) { - super(db); - this.sonarRuntime = sonarRuntime; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - removeProperties(context); - Long createdAt = context.prepareSelect("select min(created_at) from users where created_at is not null") - .get(row -> row.getLong(1)); - if (createdAt != null && createdAt != 0) { - populateInstallationDate(context, createdAt); - populateInstallationVersion(context, createdAt); - } - } - - private void populateInstallationDate(Context context, Long createdAt) throws SQLException { - insertInternalProperty(context, INSTALLATION_DATE, String.valueOf(createdAt)); - } - - private void populateInstallationVersion(Context context, Long createdAt) throws SQLException { - if (Math.abs(system2.now() - createdAt) / 60 / 60 / 1000 <= 24) { - String apiVersion = sonarRuntime.getApiVersion().toString(); - insertInternalProperty(context, INSTALLATION_VERSION, apiVersion); - } else { - // if the difference between now and smallest account creation date is more than a day, we consider that this is a - // start with an existing SQ, and not a fresh start. in this case, we do not populate the internalProperty, - // as there is no way to know the original SQ installation version. - LOG.warn("skipping " + INSTALLATION_VERSION + " because we cannot determine what is the installation version."); - } - } - - private void insertInternalProperty(Context context, String key, String value) throws SQLException { - context.prepareUpsert("insert into internal_properties (kee, is_empty, text_value, clob_value, created_at) VALUES (?, ?, ?, ?, ?)") - .setString(1, key) - .setBoolean(2, false) - .setString(3, value) - .setString(4, null) - .setLong(5, system2.now()) - .execute().commit().close(); - } - - private static void removeProperties(Context context) throws SQLException { - context.prepareUpsert("delete from internal_properties where kee = ? or kee = ?") - .setString(1, INSTALLATION_DATE) - .setString(2, INSTALLATION_VERSION) - .execute().commit().close(); - - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/ReindexIssuesAndRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/ReindexIssuesAndRules.java deleted file mode 100644 index a9eefedfa63..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/ReindexIssuesAndRules.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import java.sql.SQLException; -import org.sonar.api.config.Configuration; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.step.DataChange; - -@SupportsBlueGreen -public class ReindexIssuesAndRules extends DataChange { - - private final Configuration configuration; - private final MigrationEsClient esClient; - - public ReindexIssuesAndRules(Database db, Configuration configuration, MigrationEsClient esClient) { - super(db); - this.configuration = configuration; - this.esClient = esClient; - } - - @Override - public void execute(Context context) throws SQLException { - if (configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) { - return; - } - esClient.deleteIndexes("issues", "rules"); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRating.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRating.java deleted file mode 100644 index 53ca0613b9c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRating.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.SupportsBlueGreen; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -@SupportsBlueGreen -public class RemoveQGConditionsOnSecurityReviewRating extends DataChange { - - public RemoveQGConditionsOnSecurityReviewRating(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("quality gate conditions on security review rating"); - massUpdate.select("SELECT qgc.id FROM quality_gate_conditions qgc " + - "INNER JOIN metrics m on m.id=qgc.metric_id " + - "WHERE m.name='security_review_rating'"); - massUpdate.update("DELETE FROM quality_gate_conditions WHERE id=?"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContext.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContext.java deleted file mode 100644 index 1815b52e6d8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContext.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - - import java.nio.charset.StandardCharsets; - import java.sql.SQLException; - import org.sonar.db.Database; - import org.sonar.server.platform.db.migration.SupportsBlueGreen; - import org.sonar.server.platform.db.migration.step.DataChange; - import org.sonar.server.platform.db.migration.step.MassUpdate; - import org.sonar.server.platform.db.migration.step.Select; - import org.sonar.server.platform.db.migration.step.SqlStatement; - -@SupportsBlueGreen -public class TruncateEnvAndSystemVarsFromScannerContext extends DataChange { - - public TruncateEnvAndSystemVarsFromScannerContext(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select task_uuid, context_data from ce_scanner_context sc"); - massUpdate.update("update ce_scanner_context set context_data = ? where task_uuid = ?"); - massUpdate.rowPluralName("truncate scanner context content"); - massUpdate.execute(TruncateEnvAndSystemVarsFromScannerContext::truncateScannerContext); - } - - private static boolean truncateScannerContext(Select.Row row, SqlStatement update) throws SQLException { - String taskUuid = row.getString(1); - byte[] bytes = row.getBytes(2); - String reportContent = new String(bytes, StandardCharsets.UTF_8); - int startIndex = reportContent.indexOf("SonarQube plugins:"); - if (startIndex != -1) { - reportContent = reportContent.substring(startIndex); - } - update.setBytes(1, reportContent.getBytes(StandardCharsets.UTF_8)); - update.setString(2, taskUuid); - return true; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java index 4dbc9a9f8f8..4244868b614 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java @@ -37,7 +37,7 @@ public class MigrationConfigurationModuleTest { assertThat(container.getPicoContainer().getComponentAdapters()) .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER // DbVersion classes - + 21 + + 2 // Others + 4); } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProviderImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProviderImplTest.java similarity index 97% rename from server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProviderImplTest.java rename to server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProviderImplTest.java index 7c395732887..5e529145414 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProviderImplTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProviderImplTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v63; +package org.sonar.server.platform.db.migration.version; import java.sql.Connection; import org.junit.Rule; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/TestDefaultOrganizationUuidProvider.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/TestDefaultOrganizationUuidProvider.java similarity index 94% rename from server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/TestDefaultOrganizationUuidProvider.java rename to server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/TestDefaultOrganizationUuidProvider.java index 8bc6f6afb77..5d736c0b33b 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/TestDefaultOrganizationUuidProvider.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/TestDefaultOrganizationUuidProvider.java @@ -17,9 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v63; +package org.sonar.server.platform.db.migration.version; -import java.sql.SQLException; import org.sonar.server.platform.db.migration.step.DataChange; import static java.util.Objects.requireNonNull; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/DbVersion56Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/DbVersion56Test.java deleted file mode 100644 index 2e42e537db8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/DbVersion56Test.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v56; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion56Test { - private DbVersion56 underTest = new DbVersion56(); - - @Test - public void verify_no_support_component() { - assertThat(underTest.getSupportComponents()).isEmpty(); - } - - @Test - public void migrationNumber_starts_at_1153() { - verifyMinimumMigrationNumber(underTest, 1); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 2); - } - - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java deleted file mode 100644 index 64bbd0b0a44..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v56; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateInitialSchemaTest { - - private static final long NOW = 1_500L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private System2 system2 = mock(System2.class); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateInitialSchemaTest.class, "v56.sql"); - - private PopulateInitialSchema underTest = new PopulateInitialSchema(db.database(), system2); - - @Test - public void migration_inserts_users_and_groups() throws SQLException { - when(system2.now()).thenReturn(NOW); - - underTest.execute(); - - verifyGroup("sonar-administrators", "System administrators"); - verifyGroup("sonar-users", "Any new users created will automatically join this group"); - verifyRolesOfAdminsGroup(); - verifyRolesOfUsersGroup(); - verifyRolesOfAnyone(); - verifyAdminUser(); - verifyMembershipOfAdminUser(); - } - - private void verifyRolesOfAdminsGroup() { - List roles = selectRoles("sonar-administrators"); - assertThat(roles).containsOnly("admin", "profileadmin", "gateadmin", "shareDashboard", "provisioning"); - } - - private void verifyRolesOfUsersGroup() { - assertThat(selectRoles("sonar-users")).isEmpty(); - } - - private void verifyRolesOfAnyone() { - List> rows = db.select("select gr.role as \"role\" " + - "from group_roles gr where gr.group_id is null"); - List roles = rows.stream() - .map(row -> (String) row.get("role")) - .collect(MoreCollectors.toArrayList()); - assertThat(roles).containsOnly("provisioning", "scan"); - } - - private List selectRoles(String groupName) { - List> rows = db.select("select gr.role as \"role\" " + - "from group_roles gr " + - "inner join groups g on gr.group_id = g.id " + - "where g.name='" + groupName + "'"); - return rows.stream() - .map(row -> (String) row.get("role")) - .collect(MoreCollectors.toArrayList()); - } - - private void verifyGroup(String expectedName, String expectedDescription) { - Map cols = db.selectFirst("select name as \"name\", description as \"description\", " + - "created_at as \"created_at\", updated_at as \"updated_at\" " + - "from groups where name='" + expectedName + "'"); - assertThat(cols.get("name")).isEqualTo(expectedName); - assertThat(cols.get("description")).isEqualTo(expectedDescription); - assertThat(cols.get("created_at")).isNotNull(); - } - - private void verifyMembershipOfAdminUser() { - List> rows = db.select("select g.name as \"groupName\" from groups g " + - "inner join groups_users gu on gu.group_id = g.id " + - "inner join users u on gu.user_id = u.id " + - "where u.login='admin'"); - List groupNames = rows.stream() - .map(row -> (String) row.get("groupName")) - .collect(MoreCollectors.toArrayList()); - assertThat(groupNames).containsOnly("sonar-administrators", "sonar-users"); - } - - private void verifyAdminUser() { - Map cols = db.selectFirst("select login as \"login\", name as \"name\", email as \"email\", " + - "external_identity as \"external_identity\", external_identity_provider as \"external_identity_provider\", " + - "user_local as \"user_local\", crypted_password as \"crypted_password\", salt as \"salt\", created_at as \"created_at\", " + - "updated_at as \"updated_at\", remember_token as \"remember_token\", remember_token_expires_at as \"remember_token_expires_at\" " + - "from users where login='admin'"); - assertThat(cols.get("login")).isEqualTo("admin"); - assertThat(cols.get("name")).isEqualTo("Administrator"); - assertThat(cols.get("email")).isNull(); - assertThat(cols.get("user_local")).isEqualTo(true); - assertThat(cols.get("crypted_password")).isEqualTo("a373a0e667abb2604c1fd571eb4ad47fe8cc0878"); - assertThat(cols.get("salt")).isEqualTo("48bc4b0d93179b5103fd3885ea9119498e9d161b"); - assertThat(cols.get("created_at")).isEqualTo(NOW); - assertThat(cols.get("updated_at")).isEqualTo(NOW); - assertThat(cols.get("remember_token")).isNull(); - assertThat(cols.get("remember_token_expires_at")).isNull(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/DbVersion561Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/DbVersion561Test.java deleted file mode 100644 index 37b8ba37eb1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/DbVersion561Test.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v561; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion561Test { - private DbVersion561 underTest = new DbVersion561(); - - @Test - public void verify_no_support_component() { - assertThat(underTest.getSupportComponents()).isEmpty(); - } - - @Test - public void migrationNumber_starts_at_1153() { - verifyMinimumMigrationNumber(underTest, 1153); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 1); - } - - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java deleted file mode 100644 index 096aef78818..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v561; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class UpdateUsersExternalIdentityWhenEmptyTest { - - private static final long PAST = 1_000_000_000_000L; - private static final long NOW = 1_500_000_000_000L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(UpdateUsersExternalIdentityWhenEmptyTest.class, "schema.sql"); - - private System2 system = mock(System2.class); - - private UpdateUsersExternalIdentityWhenEmpty underTest = new UpdateUsersExternalIdentityWhenEmpty(db.database(), system); - - @Before - public void setUp() throws Exception { - when(system.now()).thenReturn(NOW); - } - - @Test - public void migrate_users() throws Exception { - insertUser("user-without-eternal-identity", null, null, PAST); - insertUser("user-with-only-eternal-identity-provider", "github", null, PAST); - insertUser("user-with-only-eternal-identity", null, "login1", PAST); - insertUser("user-with-both-eternal-identity", "github", "login2", PAST); - - underTest.execute(); - - checkUserIsUpdated("user-without-eternal-identity"); - checkUserIsUpdated("user-with-only-eternal-identity-provider"); - checkUserIsUpdated("user-with-only-eternal-identity"); - - checkUserIsNotUpdated("user-with-both-eternal-identity"); - } - - @Test - public void doest_not_fail_when_no_user() throws Exception { - underTest.execute(); - } - - private void insertUser(String login, @Nullable String externalIdentity, @Nullable String externalIdentityProvider, long updatedAt) { - Map params = new HashMap<>(); - params.put("LOGIN", login); - params.put("CREATED_AT", Long.toString(PAST)); - params.put("UPDATED_AT", Long.toString(updatedAt)); - if (externalIdentity != null) { - params.put("EXTERNAL_IDENTITY", externalIdentity); - } - if (externalIdentityProvider != null) { - params.put("EXTERNAL_IDENTITY_PROVIDER", externalIdentityProvider); - } - - db.executeInsert("users", params); - } - - private void checkUserIsUpdated(String login) { - Map row = db.selectFirst("select EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, UPDATED_AT from users where LOGIN='" + login + "'"); - assertThat((String) row.get("EXTERNAL_IDENTITY_PROVIDER")).isEqualTo("sonarqube"); - assertThat((String) row.get("EXTERNAL_IDENTITY")).isEqualTo(login); - assertThat(row.get("UPDATED_AT")).isEqualTo(NOW); - } - - private void checkUserIsNotUpdated(String login) { - Map row = db.selectFirst("select EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, UPDATED_AT from users where LOGIN='" + login + "'"); - assertThat((String) row.get("EXTERNAL_IDENTITY_PROVIDER")).isNotEmpty(); - assertThat((String) row.get("EXTERNAL_IDENTITY")).isNotEmpty(); - assertThat(row.get("UPDATED_AT")).isEqualTo(PAST); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java deleted file mode 100644 index 2daa4de9703..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddAnalysisUuidColumnToCeActivityTest { - - private static final long A_DATE = 123_456L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddAnalysisUuidColumnToCeActivityTest.class, "old_ce_activity.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddAnalysisUuidColumnToCeActivity underTest = new AddAnalysisUuidColumnToCeActivity(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_column_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - "ce_activity", - "uuid", valueOf(i), - "task_type", "REPORT", - "status", "SUCCESS", - "is_last", valueOf(true), - "is_last_key", valueOf(i + 100), - "created_at", valueOf(A_DATE), - "updated_at", valueOf(A_DATE), - "submitted_at", valueOf(A_DATE)); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition("ce_activity", "analysis_uuid", Types.VARCHAR, 50, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java deleted file mode 100644 index 92ee79e16f8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddAnalysisUuidColumnToEventsTest { - - private static final String TABLE_EVENTS = "events"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddAnalysisUuidColumnToEventsTest.class, "events_before_6-0.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddAnalysisUuidColumnToEvents underTest = new AddAnalysisUuidColumnToEvents(db.database()); - - @Test - public void migration_adds_columns_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_columns_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - TABLE_EVENTS, - "NAME", valueOf(i), - "EVENT_DATE", valueOf(1 + 100), - "CREATED_AT", valueOf(1 + 300)); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition(TABLE_EVENTS, "analysis_uuid", Types.VARCHAR, 50, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java deleted file mode 100644 index 509387b8b88..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddAnalysisUuidColumnToMeasuresTest { - - private static final String TABLE = "project_measures"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddAnalysisUuidColumnToMeasuresTest.class, "old_measures.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddAnalysisUuidColumnToMeasures underTest = new AddAnalysisUuidColumnToMeasures(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumn(); - } - - @Test - public void migration_adds_column_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - TABLE, - "metric_id", valueOf(i), - "value", valueOf(i + 10), - "snapshot_id", valueOf(i + 100), - "component_uuid", valueOf(i + 1_000)); - } - - underTest.execute(); - - verifyAddedColumn(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumn() { - db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 50, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java deleted file mode 100644 index 160980d6f39..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddBColumnsToProjectsTest { - - private static final String TABLE = "projects"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddBColumnsToProjectsTest.class, "old_projects.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddBColumnsToProjects underTest = new AddBColumnsToProjects(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_columns_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - TABLE, - "uuid", valueOf(i), - "kee", valueOf(i + 10), - "root_uuid", valueOf(i + 20), - "uuid_path", valueOf(i + 30)); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition(TABLE, "b_changed", Types.BOOLEAN, null, true); - db.assertColumnDefinition(TABLE, "b_copy_component_uuid", Types.VARCHAR, 50, true); - db.assertColumnDefinition(TABLE, "b_description", Types.VARCHAR, 2000, true); - db.assertColumnDefinition(TABLE, "b_enabled", Types.BOOLEAN, null, true); - db.assertColumnDefinition(TABLE, "b_language", Types.VARCHAR, 20, true); - db.assertColumnDefinition(TABLE, "b_long_name", Types.VARCHAR, 500, true); - db.assertColumnDefinition(TABLE, "b_module_uuid", Types.VARCHAR, 50, true); - db.assertColumnDefinition(TABLE, "b_module_uuid_path", Types.VARCHAR, 1500, true); - db.assertColumnDefinition(TABLE, "b_name", Types.VARCHAR, 500, true); - db.assertColumnDefinition(TABLE, "b_path", Types.VARCHAR, 2000, true); - db.assertColumnDefinition(TABLE, "b_qualifier", Types.VARCHAR, 10, true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java deleted file mode 100644 index 23183833028..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest { - - private static final String TABLE = "duplications_index"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.class, - "duplications_index_5.6.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex underTest = new AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_column_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - TABLE, - "ID", valueOf(i), - "PROJECT_SNAPSHOT_ID", valueOf(10 + i), - "SNAPSHOT_ID", valueOf(20 + i), - "HASH", "some_hash_" + i, - "INDEX_IN_FILE", "2", - "START_LINE", "3", - "END_LINE", "4"); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 50, true); - db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 50, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java deleted file mode 100644 index 0a61e470493..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddComponentUuidColumnToMeasuresTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddComponentUuidColumnToMeasuresTest.class, "project_measures_5.6.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddComponentUuidColumnToMeasures underTest = new AddComponentUuidColumnToMeasures(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_column_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - "project_measures", - "METRIC_ID", valueOf(i), - "VALUE", valueOf(i), - "SNAPSHOT_ID", valueOf(i)); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition("project_measures", "component_uuid", Types.VARCHAR, 50, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java deleted file mode 100644 index c0c5f910805..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddComponentUuidColumnsToSnapshotsTest { - - private static final String SNAPSHOTS_TABLE = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddComponentUuidColumnsToSnapshotsTest.class, "old_snapshots.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddComponentUuidColumnsToSnapshots underTest = new AddComponentUuidColumnsToSnapshots(db.database()); - - @Test - public void migration_adds_columns_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_columns_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - SNAPSHOTS_TABLE, - "PROJECT_ID", valueOf(i), - "ISLAST", "TRUE"); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition(SNAPSHOTS_TABLE, "component_uuid", Types.VARCHAR, 50, true); - db.assertColumnDefinition(SNAPSHOTS_TABLE, "root_component_uuid", Types.VARCHAR, 50, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasuresTest.java deleted file mode 100644 index 59b8ebef129..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasuresTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.H2; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class AddIndexOnComponentUuidOfMeasuresTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Test - public void add_index_to_measures() throws Exception { - when(db.getDialect()).thenReturn(new H2()); - AddIndexOnComponentUuidOfMeasures underTest = new AddIndexOnComponentUuidOfMeasures(db); - - underTest.execute(context); - - verify(context).execute(asList("CREATE INDEX measures_component_uuid ON project_measures (component_uuid)")); - verifyNoMoreInteractions(context); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java deleted file mode 100644 index 625ba481497..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddLastUsedColumnToRulesProfilesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddLastUsedColumnToRulesProfilesTest.class, "rules_profiles.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddLastUsedColumnToRulesProfiles underTest = new AddLastUsedColumnToRulesProfiles(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_column_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - "rules_profiles", - "name", "NAME_" + i, - "language", "java", - "kee", "" + i, - "rules_updated_at", "2016-06-21"); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition("rules_profiles", "last_used", Types.BIGINT, null, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java deleted file mode 100644 index 65a470ac67a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddProfileKeyToActivitiesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddProfileKeyToActivitiesTest.class, "activities.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddProfileKeyToActivities underTest = new AddProfileKeyToActivities(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_column_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - "activities", - "log_key", "LOG_KEY_" + i, - "user_login", "login"); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition("activities", "profile_key", Types.VARCHAR, 255, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshotsTest.java deleted file mode 100644 index f1376c4ec97..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshotsTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.H2; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class AddUniqueIndexOnUuidOfSnapshotsTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Test - public void create_unique_index() throws Exception { - when(db.getDialect()).thenReturn(new H2()); - AddUniqueIndexOnUuidOfSnapshots underTest = new AddUniqueIndexOnUuidOfSnapshots(db); - - underTest.execute(context); - - verify(context).execute(asList("CREATE UNIQUE INDEX analyses_uuid ON snapshots (uuid)")); - verifyNoMoreInteractions(context); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java deleted file mode 100644 index 41a55d27895..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddUserUpdatedAtToRulesProfilesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUpdatedAtToRulesProfilesTest.class, "rules_profiles.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - AddUserUpdatedAtToRulesProfiles underTest = new AddUserUpdatedAtToRulesProfiles(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumn(); - } - - @Test - public void migration_adds_column_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - "rules_profiles", - "name", "NAME_" + i, - "language", "java", - "kee", "" + i, - "rules_updated_at", "2016-06-21", - "last_used", "123456789"); - } - - underTest.execute(); - - verifyAddedColumn(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumn() { - db.assertColumnDefinition("rules_profiles", "user_updated_at", Types.BIGINT, null, true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java deleted file mode 100644 index e450bd3b703..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddUuidColumnToSnapshotsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToSnapshotsTest.class, "old_snapshots.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUuidColumnToSnapshots underTest = new AddUuidColumnToSnapshots(db.database()); - - @Test - public void migration_adds_columns_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_column_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - "snapshots", - "component_uuid", valueOf(i), - "root_component_uuid", valueOf(i + 10), - "QUALIFIER", (i % 2 == 0 ? "FIL" : "TRK")); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition("snapshots", "uuid", Types.VARCHAR, 50, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java deleted file mode 100644 index 85901554e74..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddUuidColumnsToProjectsTest { - - private static final String PROJECTS_TABLE = "projects"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnsToProjectsTest.class, "old_projects.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUuidColumnsToProjects underTest = new AddUuidColumnsToProjects(db.database()); - - @Test - public void migration_adds_columns_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_columns_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - PROJECTS_TABLE, - "KEE", "key_" + i, - "ENABLED", "true"); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition(PROJECTS_TABLE, "root_uuid", Types.VARCHAR, 50, true); - db.assertColumnDefinition(PROJECTS_TABLE, "copy_component_uuid", Types.VARCHAR, 50, true); - db.assertColumnDefinition(PROJECTS_TABLE, "developer_uuid", Types.VARCHAR, 50, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java deleted file mode 100644 index 9b92a72a9e3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanEventsWithoutAnalysisUuidTest { - - private static final String TABLE_EVENTS = "events"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanEventsWithoutAnalysisUuidTest.class, - "in_progress_events.sql"); - - private CleanEventsWithoutAnalysisUuid underTest = new CleanEventsWithoutAnalysisUuid(db.database()); - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_EVENTS)).isEqualTo(0); - } - - @Test - public void migration_deletes_any_row_with_a_null_uuid() throws SQLException { - insertEvent(1, true, true); - insertEvent(2, false, true); - insertEvent(3, false, false); - insertEvent(4, true, true); - - underTest.execute(); - - assertThat(idsOfRowsInResourceIndex()).containsOnly(1L, 3L, 4L); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertEvent(1, true, true); - insertEvent(2, false, true); - - underTest.execute(); - - assertThat(idsOfRowsInResourceIndex()).containsOnly(1L); - - underTest.execute(); - - assertThat(idsOfRowsInResourceIndex()).containsOnly(1L); - } - - private List idsOfRowsInResourceIndex() { - return db.select("select ID from events").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - } - - private void insertEvent(long id, boolean hasAnalysisUuid, boolean hasSnapshotId) { - db.executeInsert( - TABLE_EVENTS, - "ID", valueOf(id), - "NAME", "name_" + id, - "ANALYSIS_UUID", hasAnalysisUuid ? "uuid_" + id : null, - "SNAPSHOT_ID", hasSnapshotId ? valueOf(id + 100) : null, - "EVENT_DATE", valueOf(1 + 100), - "CREATED_AT", valueOf(1 + 300)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java deleted file mode 100644 index c8f16f10177..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanEventsWithoutSnapshotIdTest { - - private static final String TABLE_EVENTS = "events"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanEventsWithoutSnapshotIdTest.class, - "in_progress_events.sql"); - - private CleanEventsWithoutSnapshotId underTest = new CleanEventsWithoutSnapshotId(db.database()); - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_EVENTS)).isEqualTo(0); - } - - @Test - public void migration_deletes_any_row_with_a_null_uuid() throws SQLException { - insertEvent(1, true); - insertEvent(2, false); - insertEvent(3, false); - insertEvent(4, true); - - underTest.execute(); - - assertThat(idsOfRowsInResourceIndex()).containsOnly(1L, 4L); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertEvent(1, true); - insertEvent(2, false); - - underTest.execute(); - - assertThat(idsOfRowsInResourceIndex()).containsOnly(1L); - - underTest.execute(); - - assertThat(idsOfRowsInResourceIndex()).containsOnly(1L); - } - - private List idsOfRowsInResourceIndex() { - return db.select("select ID from events").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - } - - private void insertEvent(long id, boolean hasSnapshotId) { - db.executeInsert( - TABLE_EVENTS, - "ID", valueOf(id), - "NAME", "name_" + id, - "SNAPSHOT_ID", hasSnapshotId ? valueOf(id + 100) : null, - "EVENT_DATE", valueOf(1 + 100), - "CREATED_AT", valueOf(1 + 300)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java deleted file mode 100644 index 5b131d4b99b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanMeasuresWithNullAnalysisUuidTest { - - private static final String TABLE_MEASURES = "project_measures"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanMeasuresWithNullAnalysisUuidTest.class, - "in_progress_measures.sql"); - - private CleanMeasuresWithNullAnalysisUuid underTest = new CleanMeasuresWithNullAnalysisUuid(db.database()); - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(0); - } - - @Test - public void migration_deletes_rows_with_null_analysis_uuid() throws SQLException { - insertMeasure(1, "U1"); - insertMeasure(2, "U1"); - insertMeasure(3, null); - - underTest.execute(); - - assertThat(idsOfRows()).containsOnly(1L, 2L); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMeasure(1, "U1"); - insertMeasure(2, null); - - underTest.execute(); - assertThat(idsOfRows()).containsOnly(1L); - - underTest.execute(); - assertThat(idsOfRows()).containsOnly(1L); - } - - private void insertMeasure(long id, @Nullable String analysisUuid) { - db.executeInsert( - TABLE_MEASURES, - "ID", valueOf(id), - "SNAPSHOT_ID", valueOf(id + 10), - "METRIC_ID", valueOf(id + 100), - "VALUE", valueOf(id + 200), - "COMPONENT_UUID", valueOf(id + 300), - "ANALYSIS_UUID", analysisUuid); - } - - private List idsOfRows() { - return db.select("select ID from project_measures").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java deleted file mode 100644 index 8e9a701d411..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanOrphanRowsInSnapshotsTest { - - private static final String SNAPSHOTS_TABLE = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInSnapshotsTest.class, - "in_progress_snapshots_and_children_tables.sql"); - - private CleanOrphanRowsInSnapshots underTest = new CleanOrphanRowsInSnapshots(db.database()); - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(SNAPSHOTS_TABLE)).isEqualTo(0); - } - - @Test - public void migration_deletes_any_row_with_a_null_uuid() throws SQLException { - insertSnapshots(1, true, true); - insertSnapshots(2, false, false); - insertSnapshots(3, true, false); - insertSnapshots(4, false, true); - insertSnapshots(5, true, true); - - underTest.execute(); - - assertThat(idsOfRowsInSnapshots()).containsOnly(1l, 5l); - } - - @Test - public void migration_deletes_rows_in_children_tables_referencing_snapshots_with_at_least_null_uuid() throws SQLException { - insertSnapshots(1, true, true); - insertSnapshots(2, false, true); - insertSnapshots(3, true, false); - insertDuplicationIndex(1, 1); - insertDuplicationIndex(30, 1); - insertDuplicationIndex(1, 40); - insertDuplicationIndex(50, 2); - insertDuplicationIndex(2, 2); - insertDuplicationIndex(2, 60); - insertDuplicationIndex(3, 3); - insertDuplicationIndex(70, 3); - insertDuplicationIndex(3, 90); - insertProjectMeasure(1); - insertProjectMeasure(2); - insertProjectMeasure(3); - insertCeActivity(1); - insertCeActivity(2); - insertCeActivity(3); - insertEvents(1); - insertEvents(2); - insertEvents(3); - - underTest.execute(); - - verifyLineCountsPerSnapshot(1, 1, 3, 1, 1, 1); - verifyLineCountsPerSnapshot(2, 0, 0, 0, 0, 0); - verifyLineCountsPerSnapshot(3, 0, 0, 0, 0, 0); - } - - private void verifyLineCountsPerSnapshot(int snapshotId, int snapshotCount, int duplicationIndexCount, int projectMeasureCount, int ceActivityCount, int eventCount) { - assertThat(count("SNAPSHOTS where id=" + snapshotId)).isEqualTo(snapshotCount); - assertThat(count("DUPLICATIONS_INDEX where snapshot_id=" + snapshotId + " or project_snapshot_id=" + snapshotId)).isEqualTo(duplicationIndexCount); - assertThat(count("PROJECT_MEASURES where snapshot_id=" + snapshotId)).isEqualTo(projectMeasureCount); - assertThat(count("CE_ACTIVITY where snapshot_id=" + snapshotId)).isEqualTo(ceActivityCount); - assertThat(count("EVENTS where snapshot_id=" + snapshotId)).isEqualTo(eventCount); - } - - private long count(String tableAndWhereClause) { - return (Long) db.selectFirst("select count(*) from " + tableAndWhereClause).entrySet().iterator().next().getValue(); - } - - private void insertDuplicationIndex(int snapshotId, int parentSnapshotId) { - db.executeInsert( - "DUPLICATIONS_INDEX", - "SNAPSHOT_ID", valueOf(snapshotId), - "PROJECT_SNAPSHOT_ID", valueOf(parentSnapshotId), - "HASH", "hash_" + snapshotId + "-" + parentSnapshotId, - "INDEX_IN_FILE", valueOf(snapshotId + parentSnapshotId), - "START_LINE", "1", - "END_LINE", "1"); - } - - private void insertProjectMeasure(int snapshotId) { - db.executeInsert( - "PROJECT_MEASURES", - "SNAPSHOT_ID", valueOf(snapshotId), - "METRIC_ID", "111"); - } - - private void insertCeActivity(int snapshotId) { - db.executeInsert( - "CE_ACTIVITY", - "UUID", valueOf(snapshotId + 10), - "TASK_TYPE", "REPORT", - "STATUS", "OK", - "COMPONENT_UUID", valueOf(snapshotId + 20), - "SNAPSHOT_ID", valueOf(snapshotId), - "IS_LAST", "true", - "IS_LAST_KEY", "key", - "SUBMITTED_AT", "984651", - "CREATED_AT", "984651", - "UPDATED_AT", "984651"); - } - - private void insertEvents(int snapshotId) { - db.executeInsert( - "EVENTS", - "SNAPSHOT_ID", valueOf(snapshotId), - "EVENT_DATE", "984651", - "CREATED_AT", "984651"); - } - - private void insertSnapshots(long id, boolean hasComponentUiid, boolean hasRootComponentUuid) { - db.executeInsert( - SNAPSHOTS_TABLE, - "ID", valueOf(id), - "ISLAST", "TRUE", - "PROJECT_ID", valueOf(id + 300), - "COMPONENT_UUID", hasComponentUiid ? "uuid_" + id : null, - "ROOT_COMPONENT_UUID", hasRootComponentUuid ? "root_uuid_" + id : null); - } - - private List idsOfRowsInSnapshots() { - return db.select("select ID from snapshots").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java deleted file mode 100644 index 955db8513ed..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import com.google.common.collect.ImmutableList; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanUsurperRootComponentsTest { - - private static final List TABLES = ImmutableList.of( - "duplications_index", "project_measures", "ce_activity", "events", "snapshots", - "project_links", "project_measures", "issues", "file_sources", "group_roles", - "user_roles", "properties", "widgets", "projects"); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanUsurperRootComponentsTest.class, - "complete_schema.sql"); - - private CleanUsurperRootComponents underTest = new CleanUsurperRootComponents(db.database()); - - @Test - public void migration_has_no_effect_on_empty_db() throws SQLException { - underTest.execute(); - - TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isEqualTo(0)); - } - - @Test - public void execute_fixes_scope_and_qualifier_of_snapshot_inconsistent_with_component() throws SQLException { - String[] componentUuids = { - insertComponent("sc1", "qu1"), - insertComponent("sc2", "qu2"), - insertComponent("sc3", "qu3"), - insertComponent("sc4", "qu4") - }; - Long[] snapshotIds = { - insertSnapshot(componentUuids[0], "sc1", "qu1"), - insertSnapshot(componentUuids[1], "sc2", "quW"), - insertSnapshot(componentUuids[2], "scX", "qu3"), - insertSnapshot(componentUuids[3], "scY", "quZ"), - }; - - underTest.execute(); - - assertSnapshot(snapshotIds[0], "sc1", "qu1"); - assertSnapshot(snapshotIds[1], "sc2", "qu2"); - assertSnapshot(snapshotIds[2], "sc3", "qu3"); - assertSnapshot(snapshotIds[3], "sc4", "qu4"); - } - - @Test - public void executes_deletes_usurper_root_components() throws SQLException { - String[] componentUuids = { - insertRootComponent(Scopes.PROJECT, Qualifiers.PROJECT), - insertRootComponent(Scopes.PROJECT, Qualifiers.MODULE), - insertRootComponent(Scopes.DIRECTORY, Qualifiers.DIRECTORY), - insertRootComponent(Scopes.FILE, Qualifiers.FILE), - insertRootComponent(Scopes.PROJECT, Qualifiers.VIEW), - insertRootComponent(Scopes.PROJECT, Qualifiers.SUBVIEW), - insertRootComponent(Scopes.FILE, Qualifiers.PROJECT), - insertRootComponent(Scopes.PROJECT, "DEV"), - insertRootComponent(Scopes.PROJECT, "DEV_PRJ"), - }; - - underTest.execute(); - - assertUuidsInTableProjects("projects", componentUuids[0], componentUuids[4], componentUuids[7]); - } - - @Test - public void executes_deletes_data_in_all_children_tables_of_component_for_usurper_root_components() throws SQLException { - long usurperId = 12L; - String usurperUuid = "usurper_uuid"; - insertComponent(Scopes.PROJECT, Qualifiers.MODULE, usurperId, usurperUuid, usurperUuid); - Long snapshotId = insertSnapshot(usurperUuid, usurperUuid); - insertDuplicationsIndex(snapshotId); - insertProjectMeasures(usurperUuid, dontCareLong()); - insertCeActivity(usurperUuid, dontCareLong()); - insertEvent(usurperUuid, dontCareLong()); - insertSnapshot(usurperUuid, dontCare()); - insertSnapshot(dontCare(), usurperUuid); - insertProjectLinks(usurperUuid); - insertIssue(usurperUuid, null); - insertIssue(null, usurperUuid); - insertIssue(usurperUuid, usurperUuid); - insertFileSource(null, usurperUuid); - insertFileSource(usurperUuid, null); - insertFileSource(usurperUuid, usurperUuid); - insertGroupRole(usurperId); - insertUserRole(usurperId); - insertProperties(usurperId); - insertWidget(usurperId); - - TABLES.stream() - .forEach(s -> assertThat(db.countRowsOfTable(s)).describedAs("table " + s).isGreaterThanOrEqualTo(1)); - - underTest.execute(); - - TABLES.stream() - .forEach(s -> assertThat(db.countRowsOfTable(s)).describedAs("table " + s).isEqualTo(0)); - } - - @Test - public void execute_deletes_snapshots_which_root_is_not_root() throws SQLException { - String[] componentUuids = { - insertRootComponent(Scopes.PROJECT, Qualifiers.PROJECT), - insertComponent(Scopes.PROJECT, Qualifiers.MODULE), - insertComponent(Scopes.DIRECTORY, Qualifiers.DIRECTORY), - insertComponent(Scopes.FILE, Qualifiers.FILE), - insertComponent(Scopes.PROJECT, Qualifiers.VIEW), - insertComponent(Scopes.PROJECT, Qualifiers.SUBVIEW), - insertComponent(Scopes.FILE, Qualifiers.PROJECT), - insertComponent(Scopes.PROJECT, "DEV"), - insertComponent(Scopes.PROJECT, "DEV_PRJ"), - }; - Long[] snapshotIds = { - insertSnapshot(dontCare(), componentUuids[0]), - insertSnapshot(dontCare(), componentUuids[1]), - insertSnapshot(dontCare(), componentUuids[2]), - insertSnapshot(dontCare(), componentUuids[3]), - insertSnapshot(dontCare(), componentUuids[4]), - insertSnapshot(dontCare(), componentUuids[5]), - insertSnapshot(dontCare(), componentUuids[6]), - insertSnapshot(dontCare(), componentUuids[7]), - insertSnapshot(dontCare(), componentUuids[8]) - }; - - underTest.execute(); - - assertIdsInTableProjects("snapshots", snapshotIds[0], snapshotIds[4], snapshotIds[7]); - } - - @Test - public void execute_deletes_children_tables_of_snapshots_when_root_of_snapshot_is_not_root() throws SQLException { - String componentUuid = insertComponent(Scopes.FILE, Scopes.FILE); - Long snapshotId = insertSnapshot(dontCare(), componentUuid); - insertProjectMeasures(dontCare(), snapshotId); - insertCeActivity(componentUuid, snapshotId); - insertEvent(componentUuid, snapshotId); - - underTest.execute(); - - TABLES.stream() - .filter(s1 -> !s1.equals("projects")) - .forEach(s -> assertThat(db.countRowsOfTable(s)).describedAs("table " + s).isEqualTo(0)); - } - - private void insertDuplicationsIndex(Long snapshotId) { - db.executeInsert( - "duplications_index", - "PROJECT_SNAPSHOT_ID", valueOf(dontCareLong()), - "SNAPSHOT_ID", valueOf(snapshotId), - "HASH", dontCare(), - "INDEX_IN_FILE", valueOf(0), - "START_LINE", valueOf(0), - "END_LINE", valueOf(0)); - - } - - private void insertProjectMeasures(String componentUuid, Long snapshotId) { - db.executeInsert( - "project_measures", - "METRIC_ID", valueOf(123L), - "COMPONENT_UUID", componentUuid, - "SNAPSHOT_ID", valueOf(snapshotId)); - - } - - private void insertCeActivity(String componentUuid, Long snapshotId) { - db.executeInsert( - "ce_activity", - "UUID", dontCare(), - "TASK_TYPE", dontCare(), - "COMPONENT_UUID", componentUuid, - "SNAPSHOT_ID", valueOf(snapshotId), - "STATUS", dontCare(), - "IS_LAST", "true", - "IS_LAST_KEY", dontCare(), - "SUBMITTED_AT", valueOf(121L), - "CREATED_AT", valueOf(122L), - "UPDATED_AT", valueOf(123L)); - - } - - private void insertEvent(String componentUuid, Long snapshotId) { - db.executeInsert( - "events", - "SNAPSHOT_ID", valueOf(snapshotId), - "COMPONENT_UUID", componentUuid, - "CREATED_AT", valueOf(122L), - "EVENT_DATE", valueOf(123L)); - - } - - private Long insertSnapshot(String componentUuid, String rootComponentUuid) { - Long id = idGenerator++; - db.executeInsert( - "snapshots", - "ID", valueOf(id), - "COMPONENT_UUID", componentUuid, - "ROOT_COMPONENT_UUID", rootComponentUuid); - - return id; - } - - private void insertProjectLinks(String componentUuid) { - db.executeInsert( - "project_links", - "COMPONENT_UUID", componentUuid, - "HREF", dontCare()); - - } - - private void insertIssue(@Nullable String componentUuid, @Nullable String projectUuid) { - db.executeInsert( - "issues", - "COMPONENT_UUID", componentUuid == null ? dontCare() : componentUuid, - "PROJECT_UUID", projectUuid == null ? dontCare() : projectUuid, - "KEE", "kee_" + componentUuid + projectUuid, - "MANUAL_SEVERITY", valueOf(true)); - - } - - private void insertFileSource(@Nullable String fileUuid, @Nullable String projectUuid) { - db.executeInsert( - "file_sources", - "FILE_UUID", fileUuid == null ? dontCare() : fileUuid, - "PROJECT_UUID", projectUuid == null ? dontCare() : projectUuid, - "CREATED_AT", valueOf(122L), - "UPDATED_AT", valueOf(123L)); - - } - - private void insertGroupRole(long componentId) { - db.executeInsert( - "group_roles", - "RESOURCE_ID", valueOf(componentId), - "ROLE", dontCare()); - - } - - private void insertUserRole(long componentId) { - db.executeInsert( - "user_roles", - "RESOURCE_ID", valueOf(componentId), - "ROLE", dontCare()); - - } - - private void insertProperties(long componentId) { - db.executeInsert( - "properties", - "RESOURCE_ID", valueOf(componentId)); - - } - - private void insertWidget(long componentId) { - db.executeInsert( - "widgets", - "DASHBOARD_ID", valueOf(95), - "WIDGET_KEY", dontCare(), - "RESOURCE_ID", valueOf(componentId)); - - } - - private long idGenerator = 0; - - private String insertComponent(String scope, String qualifier) { - long id = idGenerator++; - String uuid = "uuid_" + id; - return insertComponent(scope, qualifier, id, uuid, dontCare()); - } - - private String insertRootComponent(String scope, String qualifier) { - long id = idGenerator++; - String uuid = "uuid_" + id; - return insertComponent(scope, qualifier, id, uuid, uuid); - } - - private String insertComponent(String scope, String qualifier, long id, String uuid, String projectUuid) { - db.executeInsert( - "projects", - "ID", valueOf(id), - "UUID", uuid, - "PROJECT_UUID", projectUuid, - "SCOPE", scope, - "QUALIFIER", qualifier); - - return uuid; - } - - private Long insertSnapshot(String componentUuid, String scope, String qualifier) { - long id = idGenerator++; - - db.executeInsert( - "snapshots", - "id", valueOf(id), - "component_uuid", componentUuid, - "root_component_uuid", dontCare(), - "scope", scope, - "qualifier", qualifier); - - return id; - } - - private void assertSnapshot(Long snapshotId, String scope, String qualifier) { - List> rows = db.select("select SCOPE, QUALIFIER from snapshots where ID=" + snapshotId); - assertThat(rows).hasSize(1); - Map row = rows.get(0); - assertThat(row.get("SCOPE")).isEqualTo(scope); - assertThat(row.get("QUALIFIER")).isEqualTo(qualifier); - } - - private void assertIdsInTableProjects(String tableName, Long... expected) { - assertThat(db.select("select id from " + tableName) - .stream() - .map(stringObjectMap -> (Long) stringObjectMap.entrySet().iterator().next().getValue())) - .containsOnly(expected); - } - - private void assertUuidsInTableProjects(String tableName, String... expected) { - assertThat(db.select("select uuid from " + tableName) - .stream() - .map(stringObjectMap -> (String) stringObjectMap.entrySet().iterator().next().getValue())) - .containsOnly(expected); - } - - private long dontCareGenerator = 0; - - private String dontCare() { - return "DC_" + dontCareGenerator++; - } - - private Long dontCareLong() { - return dontCareGenerator++; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java deleted file mode 100644 index 085d099d6b5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreatePermTemplatesCharacteristicsTest { - - private static final String TABLE_NAME = "perm_tpl_characteristics"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreatePermTemplatesCharacteristicsTest.class, "empty.sql"); - - private CreatePermTemplatesCharacteristics underTest = new CreatePermTemplatesCharacteristics(dbTester.database()); - - @Test - public void creates_table_and_index() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isEqualTo(0); - dbTester.assertColumnDefinition(TABLE_NAME, "id", Types.INTEGER, null, false); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_" + TABLE_NAME, "id"); - dbTester.assertColumnDefinition(TABLE_NAME, "template_id", Types.INTEGER, null); - dbTester.assertColumnDefinition(TABLE_NAME, "permission_key", Types.VARCHAR, 64, false); - dbTester.assertColumnDefinition(TABLE_NAME, "with_project_creator", Types.BOOLEAN, null, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", Types.BIGINT, null, false); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", Types.BIGINT, null, false); - - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_perm_tpl_charac", "template_id", "permission_key"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211Test.java deleted file mode 100644 index 4c265ce651f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211Test.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.H2; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class CreateTemporaryIndicesFor1211Test { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - when(db.getDialect()).thenReturn(new H2()); - } - - @Test - public void create_two_indices() throws Exception { - CreateTemporaryIndicesFor1211 underTest = new CreateTemporaryIndicesFor1211(db); - - underTest.execute(context); - - verify(context).execute(asList("CREATE INDEX ce_activity_snapshot_id ON ce_activity (snapshot_id)")); - verify(context).execute(asList("CREATE INDEX dup_index_psid ON duplications_index (project_snapshot_id)")); - verifyNoMoreInteractions(context); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java deleted file mode 100644 index 369c8dde9ee..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion60Test { - private DbVersion60 underTest = new DbVersion60(); - - @Test - public void verify_supports_components() { - assertThat(underTest.getSupportComponents()).containsExactly( - FixProjectUuidOfDeveloperProjects.class, - CleanUsurperRootComponents.class); - } - - @Test - public void migrationNumber_starts_at_1200() { - verifyMinimumMigrationNumber(underTest, 1200); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 71); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java deleted file mode 100644 index ec1091e8a5b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteOrphanMeasuresWithoutComponentTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteOrphanMeasuresWithoutComponentTest.class, - "in_progress_project_measures.sql"); - - private DeleteOrphanMeasuresWithoutComponent underTest = new DeleteOrphanMeasuresWithoutComponent(db.database()); - - @Test - public void migration_has_no_effects_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("project_measures")).isEqualTo(0); - } - - @Test - public void migration_deletes_any_row_with_a_null_component_uuid() throws SQLException { - insertMeasure(1, true); - insertMeasure(2, false); - insertMeasure(3, false); - insertMeasure(4, true); - - underTest.execute(); - - assertThat(idsOfRowsInMeasures()).containsOnly(1L, 4L); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMeasure(1, true); - insertMeasure(2, false); - - underTest.execute(); - - assertThat(idsOfRowsInMeasures()).containsOnly(1L); - - underTest.execute(); - - assertThat(idsOfRowsInMeasures()).containsOnly(1L); - } - - private List idsOfRowsInMeasures() { - return db.select("select ID from project_measures").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - } - - private void insertMeasure(long id, boolean hasComponentUuid) { - db.executeInsert( - "project_measures", - "ID", valueOf(id), - "METRIC_ID", valueOf(id + 10), - "SNAPSHOT_ID", valueOf(id + 100), - "VALUE", valueOf(id + 1000)); - - if (hasComponentUuid) { - db.executeUpdateSql("update project_measures set COMPONENT_UUID=? where id=?", "uuid_" + id, valueOf(id)); - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjectsTest.java deleted file mode 100644 index 5cef8e19259..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjectsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropIdColumnsFromProjectsTest { - - private Database database = mock(Database.class); - - private DropIdColumnsFromProjects underTest = new DropIdColumnsFromProjects(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute( - singletonList("ALTER TABLE projects DROP COLUMN root_id, DROP COLUMN copy_resource_id, DROP COLUMN person_id")); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshotsTest.java deleted file mode 100644 index b8c1976f459..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshotsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropIdColumnsFromSnapshotsTest { - - private Database database = mock(Database.class); - - private DropIdColumnsFromSnapshots underTest = new DropIdColumnsFromSnapshots(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute( - singletonList("ALTER TABLE snapshots DROP COLUMN project_id, DROP COLUMN root_project_id")); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndexTest.java deleted file mode 100644 index ef44fc749dc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndexTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class DropIndexDuplicationsIndexSidFromDuplicationsIndexTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - // Some databases have unique names of indexes, so table name is not declared - // when dropping an index ("drop index "). Because of that SQLServer is - // used in the test so that the table name can also be verified - when(db.getDialect()).thenReturn(new MsSql()); - } - - @Test - public void drop_index() throws Exception { - DropIndexDuplicationsIndexSidFromDuplicationsIndex underTest = new DropIndexDuplicationsIndexSidFromDuplicationsIndex(db); - - underTest.execute(context); - - verify(context).execute(asList("DROP INDEX duplications_index_sid ON duplications_index")); - verifyNoMoreInteractions(context); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjectsTest.java deleted file mode 100644 index e39fa82beea..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjectsTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class DropIndexProjectsRootIdFromProjectsTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - // Some databases have unique names of indexes, so table name is not declared - // when dropping an index ("drop index "). Because of that SQLServer is - // used in the test so that the table name can also be verified - when(db.getDialect()).thenReturn(new MsSql()); - } - - @Test - public void drop_index() throws Exception { - DropIndexProjectsRootIdFromProjects underTest = new DropIndexProjectsRootIdFromProjects(db); - - underTest.execute(context); - - verify(context).execute(asList("DROP INDEX projects_root_id ON projects")); - verifyNoMoreInteractions(context); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjectsTest.java deleted file mode 100644 index 97b7a40dc27..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjectsTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class DropIndexProjectsUuidFromProjectsTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - // Some databases have unique names of indexes, so table name is not declared - // when dropping an index ("drop index "). Because of that SQLServer is - // used in the test so that the table name can also be verified - when(db.getDialect()).thenReturn(new MsSql()); - } - - @Test - public void drop_index() throws Exception { - DropIndexProjectsUuidFromProjects underTest = new DropIndexProjectsUuidFromProjects(db); - - underTest.execute(context); - - verify(context).execute(asList("DROP INDEX projects_uuid ON projects")); - verifyNoMoreInteractions(context); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasuresTest.java deleted file mode 100644 index 3077b24181e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasuresTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropProjectIdColumnFromMeasuresTest { - private Database database = mock(Database.class); - - private DropProjectIdColumnFromMeasures underTest = new DropProjectIdColumnFromMeasures(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute(singletonList("ALTER TABLE project_measures DROP COLUMN project_id")); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsersTest.java deleted file mode 100644 index 385506b9363..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsersTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropRememberMeColumnsFromUsersTest { - - private Database database = mock(Database.class); - - private DropRememberMeColumnsFromUsers underTest = new DropRememberMeColumnsFromUsers(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute(singletonList("ALTER TABLE users DROP COLUMN remember_token, DROP COLUMN remember_token_expires_at")); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndexTest.java deleted file mode 100644 index feb275607b0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndexTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class DropResourceIndexRidFromResourceIndexTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - // Some databases have unique names of indexes, so table name is not declared - // when dropping an index ("drop index "). Because of that SQLServer is - // used in the test so that the table name can also be verified - when(db.getDialect()).thenReturn(new MsSql()); - } - - @Test - public void drop_index_from_resource_index() throws Exception { - DropResourceIndexRidFromResourceIndex underTest = new DropResourceIndexRidFromResourceIndex(db); - - underTest.execute(context); - - verify(context).execute(asList("DROP INDEX resource_index_rid ON resource_index")); - verifyNoMoreInteractions(context); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivityTest.java deleted file mode 100644 index 82c6dadbd7c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivityTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropSnapshotIdColumnFromCeActivityTest { - - private Database database = mock(Database.class); - private DropSnapshotIdColumnFromCeActivity underTest = new DropSnapshotIdColumnFromCeActivity(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute(singletonList("ALTER TABLE ce_activity DROP COLUMN snapshot_id")); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEventsTest.java deleted file mode 100644 index e0e8cf2318f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEventsTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropSnapshotIdColumnFromEventsTest { - - private Database database = mock(Database.class); - private DropSnapshotIdColumnFromEvents underTest = new DropSnapshotIdColumnFromEvents(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute(singletonList("ALTER TABLE events DROP COLUMN snapshot_id")); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasuresTest.java deleted file mode 100644 index 98bfaa4e0fd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasuresTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropSnapshotIdColumnFromMeasuresTest { - - private Database database = mock(Database.class); - private DropSnapshotIdColumnFromMeasures underTest = new DropSnapshotIdColumnFromMeasures(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute(singletonList("ALTER TABLE project_measures DROP COLUMN snapshot_id")); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshotsTest.java deleted file mode 100644 index daa9195bd3b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshotsTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -// FIXME migration is badly named -public class DropSnapshotProjectIdFromSnapshotsTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - // Some databases have unique names of indexes, so table name is not declared - // when dropping an index ("drop index "). Because of that SQLServer is - // used in the test so that the table name can also be verified - when(db.getDialect()).thenReturn(new MsSql()); - } - - @Test - public void drop_two_indices_from_snapshots() throws Exception { - DropSnapshotProjectIdFromSnapshots underTest = new DropSnapshotProjectIdFromSnapshots(db); - - underTest.execute(context); - - verify(context).execute(asList("DROP INDEX snapshot_project_id ON snapshots")); - verify(context).execute(asList("DROP INDEX snapshots_root_project_id ON snapshots")); - verifyNoMoreInteractions(context); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210Test.java deleted file mode 100644 index 57e238327a3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210Test.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class DropTemporaryIndicesOf1210Test { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - // Some databases have unique names of indexes, so table name is not declared - // when dropping an index ("drop index "). Because of that SQLServer is - // used in the test so that the table name can also be verified - when(db.getDialect()).thenReturn(new MsSql()); - } - - @Test - public void drop_two_indices() throws Exception { - DropTemporaryIndicesOf1210 underTest = new DropTemporaryIndicesOf1210(db); - - underTest.execute(context); - - verify(context).execute(asList("DROP INDEX ce_activity_snapshot_id ON ce_activity")); - verify(context).execute(asList("DROP INDEX dup_index_psid ON duplications_index")); - verifyNoMoreInteractions(context); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshotsTest.java deleted file mode 100644 index 0f4b01f2472..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshotsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropTreeColumnsFromSnapshotsTest { - - private Database database = mock(Database.class); - private DropTreeColumnsFromSnapshots underTest = new DropTreeColumnsFromSnapshots(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute( - singletonList( - "ALTER TABLE snapshots DROP COLUMN parent_snapshot_id, DROP COLUMN scope, DROP COLUMN qualifier, DROP COLUMN root_snapshot_id, DROP COLUMN path, DROP COLUMN depth, DROP COLUMN root_component_uuid")); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java deleted file mode 100644 index fe0d1e87668..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class DropTreesOfSnapshotsTest { - - private static final String SNAPSHOTS_TABLE = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTreesOfSnapshotsTest.class, - "in_progress_snapshots.sql"); - - private DropTreesOfSnapshots underTest = new DropTreesOfSnapshots(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(SNAPSHOTS_TABLE)).isEqualTo(0); - } - - @Test - public void migration_deletes_snapshots_of_non_root_components() throws SQLException { - insertSnapshot(1L, 0); - insertSnapshot(2L, 2); - insertSnapshot(3L, 1); - insertSnapshot(4L, 0); - insertSnapshot(5L, 3); - - underTest.execute(); - - verifySnapshots(1L, 4L); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSnapshot(1L, 0); - insertSnapshot(2L, 2); - - underTest.execute(); - verifySnapshots(1L); - - underTest.execute(); - verifySnapshots(1L); - } - - private void insertSnapshot(long id, int depth) { - db.executeInsert( - SNAPSHOTS_TABLE, - "ID", valueOf(id), - "DEPTH", valueOf(depth), - "COMPONENT_UUID", valueOf(id + 10), - "UUID", valueOf(id + 100)); - } - - private void verifySnapshots(long... expectedIds) { - List> rows = db.select("select id from snapshots"); - long[] ids = rows.stream() - .mapToLong(row -> (long) row.get("ID")) - .toArray(); - assertThat(ids).containsOnly(expectedIds); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumnsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumnsTest.java deleted file mode 100644 index 6b615a641fe..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumnsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.sonar.db.Database; -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 DropUnusedMeasuresColumnsTest { - - DropUnusedMeasuresColumns underTest; - Database database; - - @Before - public void setUp() { - database = mock(Database.class); - underTest = new DropUnusedMeasuresColumns(database); - } - - @Test - public void generate_sql_on_postgresql() { - when(database.getDialect()).thenReturn(new PostgreSql()); - assertThat(underTest.generateSql()) - .containsOnly( - "ALTER TABLE project_measures DROP COLUMN rules_category_id, DROP COLUMN tendency, DROP COLUMN measure_date, DROP COLUMN url, DROP COLUMN rule_priority, DROP COLUMN characteristic_id, DROP COLUMN rule_id"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java deleted file mode 100644 index 951f1a9728b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class FixProjectUuidOfDeveloperProjectsTest { - - private static final String TABLE_PROJECTS = "projects"; - private static final String PROJECT_UUID = "U1"; - private static final String FILE_UUID = "U2"; - private static final String DEVELOPER_UUID = "U3"; - private static final String DEV1_IN_PROJECT_UUID = "U4"; - private static final String DEV2_IN_PROJECT_UUID = "U5"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(FixProjectUuidOfDeveloperProjectsTest.class, - "projects_5.6.sql"); - - private FixProjectUuidOfDeveloperProjects underTest = new FixProjectUuidOfDeveloperProjects(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROJECTS)).isEqualTo(0); - } - - @Test - public void migration_fixes_project_uuid_of_rows_with_qualifier_DEV_PRJ() throws SQLException { - insertComponents(); - - underTest.execute(); - - verifyComponents(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertComponents(); - - underTest.execute(); - verifyComponents(); - - underTest.execute(); - verifyComponents(); - } - - private void verifyComponents() { - verifyProjectUuid(PROJECT_UUID, PROJECT_UUID); - verifyProjectUuid(FILE_UUID, PROJECT_UUID); - verifyProjectUuid(DEVELOPER_UUID, DEVELOPER_UUID); - verifyProjectUuid(DEV1_IN_PROJECT_UUID, DEVELOPER_UUID); - verifyProjectUuid(DEV2_IN_PROJECT_UUID, DEVELOPER_UUID); - } - - private void insertComponents() { - // regular project - insert(PROJECT_UUID, "TRK", null, PROJECT_UUID); - insert(FILE_UUID, "FIL", null, PROJECT_UUID); - // developer - Long personId = insert(DEVELOPER_UUID, "DEV", null, DEVELOPER_UUID); - insert(DEV1_IN_PROJECT_UUID, "DEV_PRJ", personId, /* not correct */PROJECT_UUID); - insert(DEV2_IN_PROJECT_UUID, "DEV_PRJ", personId, /* not correct */PROJECT_UUID); - } - - private void verifyProjectUuid(String uuid, @Nullable String expectedProjectUuid) { - Map rows = db.selectFirst("select project_uuid as \"projectUuid\" from projects where uuid='" + uuid + "'"); - assertThat(rows.get("projectUuid")).isEqualTo(expectedProjectUuid); - } - - private Long insert(String uuid, String qualifier, @Nullable Long personId, String projectUuid) { - db.executeInsert( - TABLE_PROJECTS, - "UUID", uuid, - "PERSON_ID", personId == null ? null : valueOf(personId), - "PROJECT_UUID", projectUuid, - "QUALIFIER", qualifier); - - return db.select("select ID from projects where UUID='" + uuid + "'").stream() - .findFirst() - .map(f -> (Long) f.get("ID")) - .orElseThrow(() -> new IllegalStateException("NO ID??")); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java deleted file mode 100644 index 67a8cc84e49..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeAnalysisUuidNotNullOnMeasuresTest { - - private static final String TABLE_MEASURES = "project_measures"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeAnalysisUuidNotNullOnMeasuresTest.class, - "in_progress_measures.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeAnalysisUuidNotNullOnMeasures underTest = new MakeAnalysisUuidNotNullOnMeasures(db.database()); - - @Test - public void migration_makes_analysis_uuid_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_makes_analysis_uuid_not_nullable_on_populated_table() throws SQLException { - insertMeasure(1, "U1"); - insertMeasure(2, "U2"); - - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_fails_if_some_uuid_columns_are_null() throws SQLException { - insertMeasure(2, null); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void insertMeasure(long id, @Nullable String analysisUuid) { - db.executeInsert( - TABLE_MEASURES, - "ID", valueOf(id), - "SNAPSHOT_ID", valueOf(id + 10), - "METRIC_ID", valueOf(id + 100), - "VALUE", valueOf(id + 200), - "COMPONENT_UUID", valueOf(id + 300), - "ANALYSIS_UUID", analysisUuid); - } - - private void verifyColumnDefinitions() { - db.assertColumnDefinition(TABLE_MEASURES, "analysis_uuid", Types.VARCHAR, 50, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java deleted file mode 100644 index 9feed565b70..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.class, - "in_progress_duplications_index.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex underTest = new MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex(db.database()); - - @Test - public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinitions(); - verifyIndex(); - } - - @Test - public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { - insertDuplicationIndex(1L, true, true); - insertDuplicationIndex(2L, true, true); - - underTest.execute(); - - verifyColumnDefinitions(); - verifyIndex(); - assertThat(idsOfRowsInDuplicationsIndex()).containsOnly(1L, 2L); - } - - @Test - public void migration_fails_if_some_component_uuid_columns_are_null() throws SQLException { - insertDuplicationIndex(1L, false, true); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - @Test - public void migration_fails_if_some_analysis_uuid_columns_are_null() throws SQLException { - insertDuplicationIndex(1L, true, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinitions() { - db.assertColumnDefinition("duplications_index", "component_uuid", Types.VARCHAR, 50, false); - db.assertColumnDefinition("duplications_index", "analysis_uuid", Types.VARCHAR, 50, false); - } - - private void verifyIndex() { - db.assertIndex("duplications_index", "duplication_analysis_component", "analysis_uuid", "component_uuid"); - } - - private List idsOfRowsInDuplicationsIndex() { - return db.select("select ID from duplications_index").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - } - - private void insertDuplicationIndex(long id, boolean hasComponentUuid, boolean hasAnalysisUuid) { - db.executeInsert( - "duplications_index", - "ID", valueOf(id), - "PROJECT_SNAPSHOT_ID", valueOf(10 + id), - "SNAPSHOT_ID", valueOf(20 + id), - "ANALYSIS_UUID", hasAnalysisUuid ? valueOf(30 + id) : null, - "COMPONENT_UUID", hasComponentUuid ? valueOf(40 + id) : null, - "HASH", "some_hash_" + id, - "INDEX_IN_FILE", "2", - "START_LINE", "3", - "END_LINE", "4"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java deleted file mode 100644 index a87c19d0841..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeComponentUuidColumnsNotNullOnSnapshotsTest { - - private static final String SNAPSHOTS_TABLE = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeComponentUuidColumnsNotNullOnSnapshotsTest.class, - "in_progress_snapshots.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeComponentUuidColumnsNotNullOnSnapshots underTest = new MakeComponentUuidColumnsNotNullOnSnapshots(db.database()); - - @Test - public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinitions(); - verifyIndices(); - } - - @Test - public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { - insertSnapshots(1, true, true); - insertSnapshots(2, true, true); - - underTest.execute(); - - verifyColumnDefinitions(); - verifyIndices(); - } - - @Test - public void migration_fails_if_some_uuid_columns_are_null() throws SQLException { - insertSnapshots(1, false, true); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinitions() { - db.assertColumnDefinition(SNAPSHOTS_TABLE, "component_uuid", Types.VARCHAR, 50, false); - db.assertColumnDefinition(SNAPSHOTS_TABLE, "root_component_uuid", Types.VARCHAR, 50, false); - } - - private void verifyIndices() { - db.assertIndex(SNAPSHOTS_TABLE, "snapshot_component", "component_uuid"); - db.assertIndex(SNAPSHOTS_TABLE, "snapshot_root_component", "root_component_uuid"); - } - - private void insertSnapshots(long id, boolean hasComponentUiid, boolean hasRootComponentUuid) { - db.executeInsert( - SNAPSHOTS_TABLE, - "ID", valueOf(id), - "ISLAST", "TRUE", - "PROJECT_ID", valueOf(id + 300), - "COMPONENT_UUID", hasComponentUiid ? "uuid_" + id : null, - "ROOT_COMPONENT_UUID", hasRootComponentUuid ? "root_uuid_" + id : null); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java deleted file mode 100644 index c530ebaa63e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class MakeComponentUuidNotNullOnMeasuresTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeComponentUuidNotNullOnMeasuresTest.class, - "in_progress_project_measures.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeComponentUuidNotNullOnMeasures underTest = new MakeComponentUuidNotNullOnMeasures(db.database()); - - @Test - public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { - insertMeasure(1L, true); - insertMeasure(2L, true); - - underTest.execute(); - - verifyColumnDefinitions(); - assertThat(idsOfRowsInMeasures()).containsOnly(1L, 2L); - } - - @Test - public void migration_fails_if_some_uuid_columns_are_null() throws SQLException { - insertMeasure(1L, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinitions() { - db.assertColumnDefinition("project_measures", "component_uuid", Types.VARCHAR, 50, false); - } - - private List idsOfRowsInMeasures() { - return db.select("select ID from project_measures").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - } - - private void insertMeasure(long id, boolean hasComponentUuid) { - db.executeInsert( - "project_measures", - "ID", valueOf(id), - "METRIC_ID", valueOf(id + 10), - "SNAPSHOT_ID", valueOf(id + 100), - "VALUE", valueOf(id + 1000)); - - if (hasComponentUuid) { - db.executeUpdateSql("update project_measures set COMPONENT_UUID=? where id=?", "uuid_" + id, valueOf(id)); - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java deleted file mode 100644 index efe3317630a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class MakeProfileKeyNotNullOnActivitiesTest { - - private static final String TABLE_ACTIVITIES = "activities"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProfileKeyNotNullOnActivitiesTest.class, "activities.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeProfileKeyNotNullOnActivities underTest = new MakeProfileKeyNotNullOnActivities(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertActivity(true); - insertActivity(true); - - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_profile_key() throws SQLException { - insertActivity(false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinitions() { - db.assertColumnDefinition(TABLE_ACTIVITIES, "profile_key", Types.VARCHAR, 255, false); - } - - private void insertActivity(boolean hasProfileKey) { - db.executeInsert( - TABLE_ACTIVITIES, - "user_login", "login", - "profile_key", hasProfileKey ? "my_profile_key" : null); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java deleted file mode 100644 index eb39cb3689f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeUuidColumnNotNullOnSnapshotsTest { - - private static final String TABLE_SNAPSHOTS = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeUuidColumnNotNullOnSnapshotsTest.class, - "in_progress_snapshots.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeUuidColumnNotNullOnSnapshots underTest = new MakeUuidColumnNotNullOnSnapshots(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertSnapshot(1, true); - insertSnapshot(2, true); - - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertSnapshot(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinitions() { - db.assertColumnDefinition(TABLE_SNAPSHOTS, "uuid", Types.VARCHAR, 50, false); - } - - private String insertSnapshot(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_SNAPSHOTS, - "ID", valueOf(id), - "COMPONENT_UUID", valueOf(id + 10), - "ROOT_COMPONENT_UUID", valueOf(id + 100), - "UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java deleted file mode 100644 index e6590103dd5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeUuidColumnsNotNullOnProjectsTest { - - private static final String PROJECTS_TABLE = "projects"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeUuidColumnsNotNullOnProjectsTest.class, - "in_progress_projects.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeUuidColumnsNotNullOnProjects underTest = new MakeUuidColumnsNotNullOnProjects(db.database()); - - @Test - public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinitions(); - verifyIndex(); - } - - @Test - public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { - insertComponent(1, true, true); - insertComponent(2, true, true); - - underTest.execute(); - - verifyColumnDefinitions(); - verifyIndex(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertComponent(1, false, true); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_rootuuid() throws SQLException { - insertComponent(1, true, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinitions() { - db.assertColumnDefinition(PROJECTS_TABLE, "uuid", Types.VARCHAR, 50, false); - db.assertColumnDefinition(PROJECTS_TABLE, "root_uuid", Types.VARCHAR, 50, false); - } - - private void verifyIndex() { - db.assertIndex(PROJECTS_TABLE, "projects_root_uuid", "root_uuid"); - } - - private String insertComponent(long id, boolean hasUuid, boolean hasRootUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - "projects", - "ID", valueOf(id), - "UUID", hasUuid ? "uuid_" + id : null, - "ROOT_UUID", hasRootUuid ? "root_uuuid_" + id : null); - return uuid; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java deleted file mode 100644 index 86e6972cef3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Test; -import org.sonar.db.Database; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class Migration1223Test { - private Database database = mock(Database.class); - - private enum Call { - CALL_1, - CALL_2 - } - - private List calls = new ArrayList<>(); - - private FixProjectUuidOfDeveloperProjects projectUuidOfDeveloperProjects = new FixProjectUuidOfDeveloperProjects(database) { - @Override - public void execute(Context context) { - calls.add(Call.CALL_1); - } - }; - private CleanUsurperRootComponents cleanUsurperRootComponents = new CleanUsurperRootComponents(database) { - @Override - public void execute(Context context) { - calls.add(Call.CALL_2); - } - }; - - private Migration1223 underTest = new Migration1223(projectUuidOfDeveloperProjects, cleanUsurperRootComponents); - - @Before - public void setUp() throws Exception { - DataSource dataSource = mock(DataSource.class); - when(database.getDataSource()).thenReturn(dataSource); - Connection connection = mock(Connection.class); - when(dataSource.getConnection()).thenReturn(connection); - when(connection.getMetaData()).thenReturn(mock(DatabaseMetaData.class)); - } - - @Test - public void execute_calls_2_delegates_in_order() throws SQLException { - underTest.execute(); - - assertThat(calls).containsExactly(Call.CALL_1, Call.CALL_2); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java deleted file mode 100644 index f421c543825..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.Map; -import javax.annotation.Nullable; -import org.apache.commons.lang.RandomStringUtils; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateAnalysisUuidColumnOnCeActivityTest { - - private static final long A_DATE = 123_456L; - private static final String TABLE_CE_ACTIVITY = "ce_activity"; - private static final String TABLE_SNAPSHOTS = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateAnalysisUuidColumnOnCeActivityTest.class, - "in_progress_ce_activity.sql"); - - private PopulateAnalysisUuidColumnOnCeActivity underTest = new PopulateAnalysisUuidColumnOnCeActivity(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITY)).isEqualTo(0); - } - - @Test - public void migration_generates_uuids() throws SQLException { - insertSnapshot(1, "U1"); - insertSnapshot(2, "U2"); - insertCeActivity(1, null); - insertCeActivity(2, 1L); - insertCeActivity(3, 2L); - - underTest.execute(); - - verifyAnalysisUuid(1, null); - verifyAnalysisUuid(2, "U1"); - verifyAnalysisUuid(3, "U2"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSnapshot(1, "U1"); - insertCeActivity(1, null); - insertCeActivity(2, 1L); - - underTest.execute(); - verifyAnalysisUuid(1, null); - verifyAnalysisUuid(2, "U1"); - - underTest.execute(); - verifyAnalysisUuid(1, null); - verifyAnalysisUuid(2, "U1"); - } - - private void verifyAnalysisUuid(int activityId, @Nullable String expectedAnalysisUuid) { - Map rows = db.selectFirst("select analysis_uuid as \"analysisUuid\" from ce_activity where id=" + activityId); - assertThat(rows.get("analysisUuid")).isEqualTo(expectedAnalysisUuid); - } - - private String insertSnapshot(long id, String uuid) { - db.executeInsert( - TABLE_SNAPSHOTS, - "ID", valueOf(id), - "UUID", uuid, - "COMPONENT_UUID", valueOf(id + 10), - "ROOT_COMPONENT_UUID", valueOf(id + 100), - "SCOPE", "PRJ", - "QUALIFIER", "FIL"); - return uuid; - } - - private void insertCeActivity(long id, @Nullable Long snapshotId) { - db.executeInsert( - TABLE_CE_ACTIVITY, - "uuid", valueOf(id), - "snapshot_id", snapshotId == null ? null : valueOf(snapshotId), - "task_type", "REPORT", - "status", "SUCCESS", - "is_last", valueOf(true), - "is_last_key", RandomStringUtils.randomAlphabetic(10), - "created_at", valueOf(A_DATE), - "updated_at", valueOf(A_DATE), - "submitted_at", valueOf(A_DATE)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java deleted file mode 100644 index 4d7a62d199b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateAnalysisUuidOnEventsTest { - - private static final String TABLE_EVENTS = "events"; - private static final String TABLE_SNAPSHOTS = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateAnalysisUuidOnEventsTest.class, - "in_progress_events_with_snapshots.sql"); - - private PopulateAnalysisUuidOnEvents underTest = new PopulateAnalysisUuidOnEvents(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_EVENTS)).isEqualTo(0); - } - - @Test - public void migration_populates_uuids_of_root_components_only() throws SQLException { - insertSnapshot(1, "U1", Scopes.PROJECT, Qualifiers.PROJECT); - insertSnapshot(2, "U2", Scopes.PROJECT, Qualifiers.MODULE); - insertSnapshot(3, "U3", Scopes.DIRECTORY, Qualifiers.DIRECTORY); - insertSnapshot(4, "U4", Scopes.FILE, Qualifiers.FILE); - insertSnapshot(5, "U5", Scopes.FILE, Qualifiers.UNIT_TEST_FILE); - insertSnapshot(6, "U6", Scopes.PROJECT, Qualifiers.VIEW); - insertSnapshot(7, "U7", Scopes.PROJECT, Qualifiers.SUBVIEW); - insertSnapshot(8, "U8", Scopes.FILE, Qualifiers.PROJECT); - insertSnapshot(9, "U9", Scopes.PROJECT, "DEV"); - insertSnapshot(10, "U10", Scopes.PROJECT, "DEV_PRJ"); - insertSnapshot(11, "U11", "FOO", "BAR"); - insertEvent(21, null); - insertEvent(22, 1L); - insertEvent(23, 2L); - insertEvent(24, 3L); - insertEvent(25, 4L); - insertEvent(26, 5L); - insertEvent(27, 6L); - insertEvent(28, 7L); - insertEvent(29, 8L); - insertEvent(210, 9L); - insertEvent(211, 10L); - insertEvent(212, 11L); - - underTest.execute(); - - verifyAnalysisUuid(21, null); - verifyAnalysisUuid(22, "U1"); - verifyAnalysisUuid(23, null); - verifyAnalysisUuid(24, null); - verifyAnalysisUuid(25, null); - verifyAnalysisUuid(26, null); - verifyAnalysisUuid(27, "U6"); - verifyAnalysisUuid(28, null); - verifyAnalysisUuid(29, null); - verifyAnalysisUuid(210, "U9"); - verifyAnalysisUuid(212, null); - verifyAnalysisUuid(211, null); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSnapshot(1, "U1", Scopes.PROJECT, Qualifiers.PROJECT); - insertEvent(1, null); - insertEvent(2, 1L); - - underTest.execute(); - verifyAnalysisUuid(1, null); - verifyAnalysisUuid(2, "U1"); - - underTest.execute(); - verifyAnalysisUuid(1, null); - verifyAnalysisUuid(2, "U1"); - } - - private void verifyAnalysisUuid(int eventId, @Nullable String expectedAnalysisUuid) { - Map rows = db.selectFirst("select analysis_uuid as \"analysisUuid\" from events where id=" + eventId); - assertThat(rows.get("analysisUuid")).isEqualTo(expectedAnalysisUuid); - } - - private String insertSnapshot(long id, String uuid, String scope, String qualifier) { - db.executeInsert( - TABLE_SNAPSHOTS, - "ID", valueOf(id), - "UUID", uuid, - "COMPONENT_UUID", valueOf(id + 10), - "ROOT_COMPONENT_UUID", valueOf(id + 100), - "SCOPE", scope, - "QUALIFIER", qualifier); - return uuid; - } - - private void insertEvent(long id, @Nullable Long snapshotId) { - db.executeInsert( - TABLE_EVENTS, - "ID", valueOf(id), - "NAME", "name_" + id, - "SNAPSHOT_ID", snapshotId == null ? null : valueOf(snapshotId), - "EVENT_DATE", valueOf(1 + 100), - "CREATED_AT", valueOf(1 + 300)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java deleted file mode 100644 index 6e01cf7623e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateAnalysisUuidOnMeasuresTest { - - private static final String TABLE_MEASURES = "project_measures"; - private static final String TABLE_SNAPSHOTS = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateAnalysisUuidOnMeasuresTest.class, - "old_measures.sql"); - - private PopulateAnalysisUuidOnMeasures underTest = new PopulateAnalysisUuidOnMeasures(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(0); - } - - @Test - public void migration_populates_analysis_uuids() throws SQLException { - insertSnapshot(1, "U1", Qualifiers.PROJECT, null); - insertSnapshot(2, "U2", Qualifiers.DIRECTORY, 1L); - insertSnapshot(3, "U3", Qualifiers.FILE, 1L); - insertMeasure(21, 1); - insertMeasure(22, 2); - insertMeasure(23, 3); - - underTest.execute(); - - verifyAnalysisUuid(21, "U1"); - verifyAnalysisUuid(22, "U1"); - verifyAnalysisUuid(23, "U1"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSnapshot(1, "U1", Qualifiers.PROJECT, 1L); - insertMeasure(21, 1); - - underTest.execute(); - verifyAnalysisUuid(21, "U1"); - - underTest.execute(); - verifyAnalysisUuid(21, "U1"); - } - - private void verifyAnalysisUuid(int measureId, @Nullable String expectedAnalysisUuid) { - Map rows = db.selectFirst("select analysis_uuid as \"analysisUuid\" from project_measures where id=" + measureId); - assertThat(rows.get("analysisUuid")).isEqualTo(expectedAnalysisUuid); - } - - private void insertSnapshot(long id, String uuid, String qualifier, @Nullable Long rootSnapshotId) { - int depth; - switch (qualifier) { - case "TRK": - depth = 0; - break; - case "BRC": - depth = 1; - break; - case "DIR": - depth = 2; - break; - case "FIL": - depth = 3; - break; - default: - throw new IllegalArgumentException(); - } - db.executeInsert( - TABLE_SNAPSHOTS, - "ID", valueOf(id), - "UUID", uuid, - "COMPONENT_UUID", valueOf(id + 10), - "ROOT_COMPONENT_UUID", valueOf(id + 10), - "ROOT_SNAPSHOT_ID", rootSnapshotId != null ? valueOf(rootSnapshotId) : null, - "QUALIFIER", qualifier, - "DEPTH", valueOf(depth)); - } - - private void insertMeasure(long id, long snapshotId) { - db.executeInsert( - TABLE_MEASURES, - "ID", valueOf(id), - "SNAPSHOT_ID", valueOf(snapshotId), - "METRIC_ID", valueOf(id + 100), - "VALUE", valueOf(id + 200), - "COMPONENT_UUID", valueOf(id + 300)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java deleted file mode 100644 index e8694ae79c8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.class, - "in_progress_measures_with_snapshots.sql"); - - private PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex underTest = new PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("duplications_index")).isEqualTo(0); - assertThat(db.countRowsOfTable("snapshots")).isEqualTo(0); - } - - @Test - public void migration_updates_component_uuid_with_values_from_table_snapshots_when_they_exist() throws SQLException { - insertSnapshot(40, "cpt1"); - String rootUuid1 = insertSnapshot(50, "cpt2"); - insertSnapshot(60, "cpt3"); - String rootUuid2 = insertSnapshot(70, "cpt4"); - - insertDuplicationIndex(1, 40, 50); - insertDuplicationIndex(2, 40, 50); - insertDuplicationIndex(3, 40, 70); - insertDuplicationIndex(4, 60, 110); // 110 doesn't exist - insertDuplicationIndex(5, 90, 120); // 90 and 120 does not exist - insertDuplicationIndex(6, 100, 70); // 100 does not exist - - underTest.execute(); - - verifyDuplicationsIndex(1, 40, "cpt1", rootUuid1); - verifyDuplicationsIndex(2, 40, "cpt1", rootUuid1); - verifyDuplicationsIndex(3, 40, "cpt1", rootUuid2); - verifyDuplicationsIndex(4, 60, "cpt3", null); - verifyDuplicationsIndex(5, 90, null, null); - verifyDuplicationsIndex(6, 100, null, rootUuid2); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSnapshot(40, "cpt1"); - String rootUuid = insertSnapshot(50, "cp2"); - insertDuplicationIndex(1, 40, 50); - - underTest.execute(); - verifyDuplicationsIndex(1, 40, "cpt1", rootUuid); - - underTest.execute(); - verifyDuplicationsIndex(1, 40, "cpt1", rootUuid); - - } - - private void verifyDuplicationsIndex(long id, long snapshotId, @Nullable String componentUuid, @Nullable String analysisUuid) { - List> rows = db.select("select SNAPSHOT_ID, COMPONENT_UUID,ANALYSIS_UUID from duplications_index where ID=" + id); - assertThat(rows).hasSize(1); - Map row = rows.get(0); - assertThat(row.get("SNAPSHOT_ID")).isEqualTo(snapshotId); - assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid); - assertThat(row.get("ANALYSIS_UUID")).isEqualTo(analysisUuid); - } - - private String insertSnapshot(long id, String componentUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - "snapshots", - "uuid", uuid, - "id", valueOf(id), - "component_uuid", componentUuid, - "root_component_uuid", valueOf(id + 100)); - return uuid; - } - - private void insertDuplicationIndex(long id, long snapshotId, long projectSnapshotId) { - db.executeInsert( - "duplications_index", - "ID", valueOf(id), - "PROJECT_SNAPSHOT_ID", valueOf(projectSnapshotId), - "SNAPSHOT_ID", valueOf(snapshotId), - "HASH", "some_hash_" + id, - "INDEX_IN_FILE", "2", - "START_LINE", "3", - "END_LINE", "4"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java deleted file mode 100644 index 2b364cff3bc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateComponentUuidColumnsOfSnapshotsTest { - - private static final String SNAPSHOTS_TABLE = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateComponentUuidColumnsOfSnapshotsTest.class, - "in_progress_snapshots_with_projects.sql"); - - private PopulateComponentUuidColumnsOfSnapshots underTest = new PopulateComponentUuidColumnsOfSnapshots(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(SNAPSHOTS_TABLE)).isEqualTo(0); - assertThat(db.countRowsOfTable("projects")).isEqualTo(0); - } - - @Test - public void migration_updates_uuid_columns_with_values_from_table_projects_when_they_exist() throws SQLException { - String uuid1 = insertComponent(40); - String uuid2 = insertComponent(50); - String uuid3 = insertComponent(60); - String uuid4 = insertComponent(70); - String uuid5 = insertComponent(80); - - insertSnapshots(1, 40, 50L); - insertSnapshots(2, 60, 70L); - insertSnapshots(3, 90, 70L); // 90 does not exist - insertSnapshots(4, 40, 100L); // 100 does not exist - insertSnapshots(5, 110, 100L); // 110 and 100 do not exist - insertSnapshots(6, 80, null); // no root - insertSnapshots(7, 120, null); // no root and 120 does not exist - - underTest.execute(); - - verifySnapshots(1, 40, uuid1, 50L, uuid2); - verifySnapshots(2, 60, uuid3, 70L, uuid4); - verifySnapshots(3, 90, null, 70L, uuid4); - verifySnapshots(4, 40, uuid1, 100L, null); - verifySnapshots(5, 110, null, 100L, null); - verifySnapshots(6, 80, uuid5, null, null); - verifySnapshots(7, 120, null, null, null); - } - - @Test - public void migration_is_reentrant() throws SQLException { - String uuid1 = insertComponent(40); - String uuid2 = insertComponent(50); - insertSnapshots(1, 40, 50L); - - underTest.execute(); - verifySnapshots(1, 40, uuid1, 50L, uuid2); - - underTest.execute(); - verifySnapshots(1, 40, uuid1, 50L, uuid2); - } - - private void insertSnapshots(long id, long projectId, @Nullable Long rootId) { - db.executeInsert( - SNAPSHOTS_TABLE, - "ID", valueOf(id), - "ISLAST", "TRUE", - "PROJECT_ID", valueOf(projectId), - "ROOT_PROJECT_ID", rootId == null ? null : valueOf(rootId)); - } - - private String insertComponent(long id) { - String uuid = "uuid_" + id; - db.executeInsert( - "projects", - "ID", valueOf(id), - "UUID", uuid); - return uuid; - } - - private void verifySnapshots(long id, long resourceId, @Nullable String componentUuid, @Nullable Long rootProjectId, @Nullable String rootComponentUuid) { - List> rows = db.select("select PROJECT_ID, COMPONENT_UUID, ROOT_PROJECT_ID, ROOT_COMPONENT_UUID from snapshots where ID=" + id); - assertThat(rows).hasSize(1); - Map row = rows.get(0); - assertThat(row.get("PROJECT_ID")).isEqualTo(resourceId); - assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid); - assertThat(row.get("ROOT_PROJECT_ID")).isEqualTo(rootProjectId); - assertThat(row.get("ROOT_COMPONENT_UUID")).isEqualTo(rootComponentUuid); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java deleted file mode 100644 index 1575d702809..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateComponentUuidOfMeasuresTest { - - private static final int SNAPSHOT_ID_1 = 40; - private static final int SNAPSHOT_ID_2 = 50; - private static final int SNAPSHOT_ID_3 = 60; - private static final int SNAPSHOT_ID_4 = 70; - private static final int SNAPSHOT_ID_5 = 80; - - private static final int COMPONENT_ID_1 = 400; - private static final int COMPONENT_ID_2 = 500; - private static final int COMPONENT_ID_3 = 600; - - private static final String COMPONENT_UUID_1 = "U400"; - private static final String COMPONENT_UUID_2 = "U500"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateComponentUuidOfMeasuresTest.class, - "in_progress_measures_with_projects.sql"); - - private PopulateComponentUuidOfMeasures underTest = new PopulateComponentUuidOfMeasures(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("project_measures")).isEqualTo(0); - assertThat(db.countRowsOfTable("snapshots")).isEqualTo(0); - } - - @Test - public void migration_updates_component_uuid_with_values_from_table_snapshots_when_they_exist() throws SQLException { - insertSnapshot(SNAPSHOT_ID_1, COMPONENT_UUID_1); - insertSnapshot(SNAPSHOT_ID_2, COMPONENT_UUID_1); - insertSnapshot(SNAPSHOT_ID_3, COMPONENT_UUID_2); - insertSnapshot(SNAPSHOT_ID_4, COMPONENT_UUID_2); - - insertMeasure(1, SNAPSHOT_ID_1, COMPONENT_ID_1); - insertMeasure(2, SNAPSHOT_ID_2, COMPONENT_ID_1); - insertMeasure(3, SNAPSHOT_ID_3, COMPONENT_ID_2); - insertMeasure(4, SNAPSHOT_ID_5, COMPONENT_ID_3); // snapshot does not exist - - underTest.execute(); - - verifyMeasure(1, SNAPSHOT_ID_1, COMPONENT_UUID_1); - verifyMeasure(2, SNAPSHOT_ID_2, COMPONENT_UUID_1); - verifyMeasure(3, SNAPSHOT_ID_3, COMPONENT_UUID_2); - verifyMeasure(4, SNAPSHOT_ID_5, null); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSnapshot(SNAPSHOT_ID_1, COMPONENT_UUID_1); - insertMeasure(1, SNAPSHOT_ID_1, COMPONENT_ID_1); - - underTest.execute(); - verifyMeasure(1, SNAPSHOT_ID_1, COMPONENT_UUID_1); - - underTest.execute(); - verifyMeasure(1, SNAPSHOT_ID_1, COMPONENT_UUID_1); - - } - - private void verifyMeasure(long id, long snapshotId, @Nullable String componentUuid) { - List> rows = db.select("select SNAPSHOT_ID, COMPONENT_UUID from project_measures where ID=" + id); - assertThat(rows).hasSize(1); - Map row = rows.get(0); - assertThat(row.get("SNAPSHOT_ID")).isEqualTo(snapshotId); - assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid); - } - - private void insertSnapshot(long id, String componentUuid) { - db.executeInsert( - "snapshots", - "id", valueOf(id), - "component_uuid", componentUuid, - "root_component_uuid", "ROOT_" + componentUuid); - } - - private void insertMeasure(long id, long snapshotId, long componentId) { - db.executeInsert( - "project_measures", - "ID", valueOf(id), - "METRIC_ID", valueOf(id + 10), - "SNAPSHOT_ID", valueOf(snapshotId), - "VALUE", valueOf(id + 1000), - "PROJECT_ID", valueOf(componentId)); - - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java deleted file mode 100644 index 62dd58bd4ae..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.Arrays; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateLastUsedColumnOfRulesProfilesTest { - private static final String QUALITY_PROFILES_TABLE = "rules_profiles"; - private static final String METRICS_TABLE = "metrics"; - private static final String MEASURES_TABLE = "project_measures"; - private static final String SNAPSHOTS_TABLE = "snapshots"; - private static final String METRIC_ID = "1"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateLastUsedColumnOfRulesProfilesTest.class, "rules_profiles.sql"); - - PopulateLastUsedColumnOfRulesProfiles underTest = new PopulateLastUsedColumnOfRulesProfiles(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(QUALITY_PROFILES_TABLE)).isEqualTo(0); - assertThat(db.countRowsOfTable(METRICS_TABLE)).isEqualTo(0); - assertThat(db.countRowsOfTable(MEASURES_TABLE)).isEqualTo(0); - assertThat(db.countRowsOfTable(SNAPSHOTS_TABLE)).isEqualTo(0); - } - - @Test - public void migration_update_quality_profiles_last_used() throws SQLException { - insertQualityProfilesMetric(); - insertQualityProfile(1, "first-quality-profile"); - insertQualityProfile(2, "second-quality-profile"); - insertQualityProfile(3, "third-quality-profile"); - insertQualityProfile(4, "fourth-quality-profile"); - insertMeasure(1, "first-quality-profile", "second-quality-profile"); - insertMeasure(2, "second-quality-profile", "third-quality-profile"); - - underTest.execute(); - - assertLastUsedForQP("first-quality-profile", 1); - assertLastUsedForQP("second-quality-profile", 2); - assertLastUsedForQP("third-quality-profile", 2); - assertNoLastUsedForQP("fourth-quality-profile"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertQualityProfilesMetric(); - insertQualityProfile(1, "first-quality-profile"); - insertMeasure(1, "first-quality-profile"); - - underTest.execute(); - assertLastUsedForQP("first-quality-profile", 1); - - underTest.execute(); - assertLastUsedForQP("first-quality-profile", 1); - } - - private void assertLastUsedForQP(String qualityProfileKey, long expectedLastUsed) { - assertThat(selectLastUser(qualityProfileKey)).isEqualTo(expectedLastUsed); - } - - private void assertNoLastUsedForQP(String qualityProfileKey) { - assertThat(selectLastUser(qualityProfileKey)).isNull(); - } - - @CheckForNull - private Long selectLastUser(String qualityProfileKey) { - return (Long) db.selectFirst(String.format("select last_used as \"lastUsed\" from rules_profiles where kee ='%s'", qualityProfileKey)).get("lastUsed"); - } - - private void insertQualityProfile(long id, String key) { - db.executeInsert(QUALITY_PROFILES_TABLE, - "id", valueOf(id), - "name", key, - "kee", key); - } - - private void insertMeasure(long id, String... keys) { - db.executeInsert( - SNAPSHOTS_TABLE, - "id", valueOf(id), - "uuid", valueOf(id), - "component_uuid", valueOf(id), - "root_component_uuid", valueOf(id), - "islast", "TRUE", - "created_at", valueOf(id)); - - db.executeInsert( - MEASURES_TABLE, - "id", valueOf(id), - "snapshot_id", valueOf(id), - "metric_id", METRIC_ID, - "component_uuid", valueOf(id), - "text_value", toJson(keys)); - } - - private void insertQualityProfilesMetric() { - db.executeInsert(METRICS_TABLE, - "id", METRIC_ID, - "name", "quality_profiles"); - } - - private static String toJson(String... keys) { - return Arrays.stream(keys).map(key -> "\"key\" : \"" + key + "\"").collect(Collectors.joining(", ", "{", "}")); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java deleted file mode 100644 index fa05770ebf8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateProfileKeyOfActivitiesTest { - private static final String ACTIVITIES_TABLE = "activities"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProfileKeyOfActivitiesTest.class, "activities.sql"); - - PopulateProfileKeyOfActivities underTest = new PopulateProfileKeyOfActivities(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(ACTIVITIES_TABLE)).isEqualTo(0); - } - - @Test - public void migration_update_activities_profile_key() throws SQLException { - insertActivity("first-profile-key"); - insertActivity("first-profile-key"); - insertActivity("first-profile-key"); - insertActivity("second-profile-key"); - insertActivity("third-profile-key"); - - underTest.execute(); - - assertCountActivitiesWithProfile("first-profile-key", 3); - assertCountActivitiesWithProfile("second-profile-key", 1); - assertCountActivitiesWithProfile("third-profile-key", 1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertActivity("profile-key"); - underTest.execute(); - assertCountActivitiesWithProfile("profile-key", 1); - - underTest.execute(); - assertCountActivitiesWithProfile("profile-key", 1); - } - - @Test - public void delete_the_rows_of_ACTIVITIES_that_do_not_have_profileKey() throws SQLException { - db.executeInsert(ACTIVITIES_TABLE, "data_field", "key=fakeKey"); - - underTest.execute(); - - assertThat(db.countRowsOfTable(ACTIVITIES_TABLE)).isEqualTo(0); - } - - @Test - public void delete_the_rows_of_ACTIVITIES_that_have_empty_profileKey() throws SQLException { - insertActivity(""); - - underTest.execute(); - - assertThat(db.countRowsOfTable(ACTIVITIES_TABLE)).isEqualTo(0); - } - - @Test - public void delete_the_rows_of_ACTIVITIES_that_have_blank_profileKey() throws SQLException { - insertActivity(" "); - - underTest.execute(); - - assertThat(db.countRowsOfTable(ACTIVITIES_TABLE)).isEqualTo(0); - } - - private void assertCountActivitiesWithProfile(String profileKey, int expectedNumberOfActivities) { - assertThat(countActivitiesWithProfile(profileKey)).isEqualTo(expectedNumberOfActivities); - } - - private int countActivitiesWithProfile(String qualityProfileKey) { - // profile key is removed from data_field - return db.countSql(String.format("select count(1) from activities where profile_key='%s' and data_field='key=fakeKey'", qualityProfileKey)); - } - - private void insertActivity(String profileKey) { - db.executeInsert(ACTIVITIES_TABLE, - "data_field", "key=fakeKey;profileKey=" + profileKey); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java deleted file mode 100644 index 17d8c22df73..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import com.google.common.base.Throwables; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUserUpdatedAtOfRulesProfilesTest { - private static final String TABLE_QUALITY_PROFILES = "rules_profiles"; - private static final String TABLE_ACTIVITIES = "activities"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUserUpdatedAtOfRulesProfilesTest.class, "schema.sql"); - - PopulateUserUpdatedAtOfRulesProfiles underTest = new PopulateUserUpdatedAtOfRulesProfiles(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_QUALITY_PROFILES)).isEqualTo(0); - assertThat(db.countRowsOfTable(TABLE_ACTIVITIES)).isEqualTo(0); - } - - @Test - public void migration_update_quality_profiles_user_updated_at() throws SQLException { - - insertQualityProfile(1, "first-quality-profile"); - insertActivity("first-quality-profile", "my-login", 1_000_000_00L); - insertActivity("first-quality-profile", null, 2_000_000_000L); - insertActivity("first-quality-profile", "my-login", 1_100_000_000L); - insertQualityProfile(2, "second-quality-profile"); - insertActivity("second-quality-profile", null, 1_000_000_00L); - insertQualityProfile(3, "third-quality-profile"); - insertQualityProfile(4, "fourth-quality-profile"); - insertActivity("fourth-quality-profile", "my-login", 1_000_000_00L); - - underTest.execute(); - - assertUserUpdatedAt("first-quality-profile", 1_100_000_000L); - assertNoUserUpdatedAtDate("second-quality-profile"); - assertNoUserUpdatedAtDate("third-quality-profile"); - assertUserUpdatedAt("fourth-quality-profile", 1_000_000_00L); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertQualityProfile(1, "first-quality-profile"); - insertActivity("first-quality-profile", "my-login", 1_000_000_000L); - - underTest.execute(); - assertUserUpdatedAt("first-quality-profile", 1_000_000_000L); - - underTest.execute(); - assertUserUpdatedAt("first-quality-profile", 1_000_000_000L); - } - - private void assertUserUpdatedAt(String qualityProfileKey, long expectedLastUsed) { - assertThat(selectUserUpdatedAt(qualityProfileKey)).isEqualTo(expectedLastUsed); - } - - private void assertNoUserUpdatedAtDate(String qualityProfileKey) { - assertThat(selectUserUpdatedAt(qualityProfileKey)).isNull(); - } - - @CheckForNull - private Long selectUserUpdatedAt(String qualityProfileKey) { - return (Long) db.selectFirst(String.format("select user_updated_at as \"userUpdatedAt\" from rules_profiles where kee ='%s'", qualityProfileKey)).get("userUpdatedAt"); - } - - private void insertActivity(String profileKey, @Nullable String login, @Nullable Long createdAt) { - final String sqlInsertActivity = "insert into activities (profile_key, user_login, created_at) values (?, ?, ?) "; - - try (Connection connection = db.openConnection(); - PreparedStatement ps = connection.prepareStatement(sqlInsertActivity)) { - ps.setString(1, profileKey); - ps.setString(2, login); - ps.setTimestamp(3, createdAt == null ? null : new Timestamp(createdAt)); - ps.executeUpdate(); - connection.commit(); - } catch (SQLException e) { - throw Throwables.propagate(e); - } - } - - private void insertQualityProfile(long id, String key) { - db.executeInsert(TABLE_QUALITY_PROFILES, - "id", valueOf(id), - "name", key, - "kee", key); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java deleted file mode 100644 index 723274aa1b9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import org.apache.commons.lang.StringUtils; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactoryImpl; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUuidColumnOnSnapshotsTest { - - private static final String TABLE_SNAPSHOTS = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidColumnOnSnapshotsTest.class, - "in_progress_snapshots.sql"); - - private PopulateUuidColumnOnSnapshots underTest = new PopulateUuidColumnOnSnapshots(db.database(), UuidFactoryImpl.INSTANCE); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_SNAPSHOTS)).isEqualTo(0); - } - - @Test - public void migration_generates_uuids() throws SQLException { - insertSnapshot(1); - insertSnapshot(2); - insertSnapshot(3); - - underTest.execute(); - - verifyUuids(3); - } - - private void verifyUuids(int expectedCount) { - List> rows = db.select("select uuid from snapshots where uuid is not null"); - Set uuids = rows.stream().map(cols -> cols.get("UUID")).filter(uuid -> StringUtils.isNotBlank((String) uuid)).collect(Collectors.toSet()); - assertThat(uuids).hasSize(expectedCount); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSnapshot(1); - - underTest.execute(); - verifyUuids(1); - - underTest.execute(); - verifyUuids(1); - } - - private String insertSnapshot(long id) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_SNAPSHOTS, - "ID", valueOf(id), - "COMPONENT_UUID", valueOf(id + 10), - "ROOT_COMPONENT_UUID", valueOf(id + 100), - "SCOPE", "PRJ", - "QUALIFIER", "FIL"); - return uuid; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java deleted file mode 100644 index 6665bada17c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUuidColumnsOfProjectsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidColumnsOfProjectsTest.class, - "in_progress_projects.sql"); - - private PopulateUuidColumnsOfProjects underTest = new PopulateUuidColumnsOfProjects(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("projects")).isEqualTo(0); - } - - @Test - public void migration_updates_uuid_columns_with_values_from_table_projects_when_they_exist() throws SQLException { - String uuid1 = insertComponent(1, null, null, null); // project - insertComponent(2, 1L, null, null); // a module or something not a project - String uuid3 = insertComponent(3, null, null, null); // developer - insertComponent(4, 3L, 1L, 3L); // a project copy of project 1 for developer 3 - String uuid5 = insertComponent(5, null, null, null); // another project - String uuid6 = insertComponent(6, null, null, null); // a view - insertComponent(7, 6L, 5L, null); // a project view of project 5 - insertComponent(8, 200L, 1L, 200L); // a project copy of project 1 for developer 200 (does't exist) - insertComponent(9, 6L, 300L, null); // a project view of project 300 (doesn't exist) - insertComponent(10, 400L, null, null); // a module of a non existing project - - underTest.execute(); - - verifyProject(1, null, uuid1, null, null, null, null); - verifyProject(2, 1L, uuid1, null, null, null, null); - verifyProject(3, null, uuid3, null, null, null, null); - verifyProject(4, 3L, uuid3, 1L, uuid1, 3L, uuid3); - verifyProject(5, null, uuid5, null, null, null, null); - verifyProject(6, null, uuid6, null, null, null, null); - verifyProject(7, 6L, uuid6, 5L, uuid5, null, null); - verifyProject(9, 6L, uuid6, 300L, null, null, null); - verifyProject(10, 400L, null, null, null, null, null); - } - - @Test - public void migration_is_reentrant() throws SQLException { - String uuid1 = insertComponent(1, null, null, null); // project - - underTest.execute(); - verifyProject(1, null, uuid1, null, null, null, null); - - underTest.execute(); - verifyProject(1, null, uuid1, null, null, null, null); - } - - private String insertComponent(long id, @Nullable Long rootId, @Nullable Long copyResourceId, @Nullable Long personId) { - String uuid = "uuid_" + id; - db.executeInsert( - "projects", - "ID", valueOf(id), - "UUID", uuid, - "ROOT_ID", toString(rootId), - "COPY_RESOURCE_ID", toString(copyResourceId), - "PERSON_ID", toString(personId)); - return uuid; - } - - private static String toString(@Nullable Long aLong) { - return aLong == null ? null : valueOf(aLong); - } - - private void verifyProject(long id, @Nullable Long rootId, @Nullable String rootUuid, @Nullable Long copyResourceId, @Nullable String copyComponentUuuid, @Nullable Long personId, - @Nullable String developerUuid) { - List> rows = db.select("select ROOT_ID, ROOT_UUID, COPY_RESOURCE_ID, COPY_COMPONENT_UUID, PERSON_ID, DEVELOPER_UUID from projects where ID=" + id); - assertThat(rows).hasSize(1); - Map row = rows.get(0); - assertThat(row.get("ROOT_ID")).isEqualTo(rootId); - assertThat(row.get("ROOT_UUID")).isEqualTo(rootUuid); - assertThat(row.get("COPY_RESOURCE_ID")).isEqualTo(copyResourceId); - assertThat(row.get("COPY_COMPONENT_UUID")).isEqualTo(copyComponentUuuid); - assertThat(row.get("PERSON_ID")).isEqualTo(personId); - assertThat(row.get("DEVELOPER_UUID")).isEqualTo(developerUuid); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java deleted file mode 100644 index 438c4ab77b5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.sql.SQLException; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUuidPathColumnOnProjectsTest { - - private static final String TABLE_PROJECTS = "projects"; - private static final String TABLE_SNAPSHOTS = "snapshots"; - private static final String A_PROJECT_UUID = "U_PRJ"; - private static final String A_MODULE_UUID = "U_MOD"; - private static final String A_DIR_UUID = "U_DIR"; - private static final String A_FILE_UUID = "U_FIL"; - private static final String QUALIFIER_PROJECT = "TRK"; - private static final String QUALIFIER_MODULE = "BRC"; - private static final String QUALIFIER_DIR = "DIR"; - private static final String QUALIFIER_FILE = "FIL"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidPathColumnOnProjectsTest.class, - "in_progress_projects_and_snapshots.sql"); - - private PopulateUuidPathColumnOnProjects underTest = new PopulateUuidPathColumnOnProjects(db.database()); - - @Test - public void has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROJECTS)).isEqualTo(0); - } - - @Test - public void migrates_provisioned_projects() throws SQLException { - insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID); - - underTest.execute(); - - verifyPath(A_PROJECT_UUID, "."); - } - - @Test - public void migrates_projects_without_modules() throws SQLException { - insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); - insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.", true)); - insert(QUALIFIER_FILE, A_FILE_UUID, A_PROJECT_UUID, new Snapshot(3L, "1.2.", true)); - - underTest.execute(); - - verifyPath(A_PROJECT_UUID, "."); - verifyPath(A_DIR_UUID, format(".%s.", A_PROJECT_UUID)); - verifyPath(A_FILE_UUID, format(".%s.%s.", A_PROJECT_UUID, A_DIR_UUID)); - } - - @Test - public void migrates_projects_with_modules() throws SQLException { - insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); - insert(QUALIFIER_MODULE, A_MODULE_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.", true)); - insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(3L, "1.2.", true)); - insert(QUALIFIER_FILE, A_FILE_UUID, A_PROJECT_UUID, new Snapshot(4L, "1.2.3.", true)); - - underTest.execute(); - - verifyPath(A_PROJECT_UUID, "."); - verifyPath(A_MODULE_UUID, format(".%s.", A_PROJECT_UUID)); - verifyPath(A_DIR_UUID, format(".%s.%s.", A_PROJECT_UUID, A_MODULE_UUID)); - verifyPath(A_FILE_UUID, format(".%s.%s.%s.", A_PROJECT_UUID, A_MODULE_UUID, A_DIR_UUID)); - } - - @Test - public void migrates_components_without_snapshot_path() throws SQLException { - // these components do not have snapshots - insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID); - insert(QUALIFIER_FILE, A_FILE_UUID, A_PROJECT_UUID); - - underTest.execute(); - - verifyPath(A_DIR_UUID, format(".%s.", A_PROJECT_UUID)); - verifyPath(A_FILE_UUID, format(".%s.", A_PROJECT_UUID)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); - insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.", true)); - insert(QUALIFIER_FILE, A_FILE_UUID, A_PROJECT_UUID, new Snapshot(3L, "1.2.", true)); - - underTest.execute(); - verifyNoNullPath(); - - underTest.execute(); - verifyNoNullPath(); - } - - @Test - public void ignore_snapshots_with_invalid_snapshots_in_path() throws SQLException { - insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); - // the ID 999999 is unknown in the path - insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.999999.", true)); - - underTest.execute(); - - verifyPath(A_PROJECT_UUID, "."); - // path of orphans is the path to project only - verifyPath(A_DIR_UUID, format(".%s.", A_PROJECT_UUID)); - } - - private void insert(String qualifier, String uuid, String rootUuid, Snapshot... snapshots) { - db.executeInsert( - TABLE_PROJECTS, - "uuid", uuid, - "project_uuid", rootUuid, - "root_uuid", rootUuid, - "qualifier", qualifier); - - for (Snapshot snapshot : snapshots) { - db.executeInsert( - TABLE_SNAPSHOTS, - "id", String.valueOf(snapshot.id), - "uuid", "u" + snapshot.id, - "path", snapshot.idPath, - "islast", String.valueOf(snapshot.isLast), - "component_uuid", uuid, - "root_component_uuid", rootUuid, - "qualifier", qualifier); - } - } - - private void verifyPath(String componentUuid, String expectedUuidPath) { - Map row = db.selectFirst("select uuid_path from projects where uuid='" + componentUuid + "'"); - assertThat(row.get("UUID_PATH")).isEqualTo(expectedUuidPath); - } - - private void verifyNoNullPath() { - assertThat(db.select("select * from projects where uuid_path is null or uuid_path = ''")).isEmpty(); - } - - private static final class Snapshot { - private final long id; - private final String idPath; - private final boolean isLast; - - Snapshot(long id, String idPath, boolean isLast) { - this.id = id; - this.idPath = idPath; - this.isLast = isLast; - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjectsTest.java deleted file mode 100644 index e0a0ca7e7d9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjectsTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.H2; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class RecreateIndexProjectsUuidFromProjectsTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - when(db.getDialect()).thenReturn(new H2()); - } - - @Test - public void create_index() throws Exception { - RecreateIndexProjectsUuidFromProjects underTest = new RecreateIndexProjectsUuidFromProjects(db); - - underTest.execute(context); - - verify(context).execute(asList("CREATE INDEX projects_uuid ON projects (uuid)")); - verifyNoMoreInteractions(context); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java deleted file mode 100644 index 800785fd829..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v60; - -import java.util.List; -import java.util.Map; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class RemoveUsersPasswordWhenNotLocalTest { - - static long PAST_DATE = 1_000_000_000L; - static long NOW = 2_000_000_000L; - - System2 system2 = mock(System2.class); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RemoveUsersPasswordWhenNotLocalTest.class, "schema.sql"); - - private RemoveUsersPasswordWhenNotLocal migration = new RemoveUsersPasswordWhenNotLocal(db.database(), system2); - - @Before - public void setUp() throws Exception { - when(system2.now()).thenReturn(NOW); - } - - @Test - public void update_not_local_user() throws Exception { - insertUserWithPassword("john", false); - - migration.execute(); - - List> rows = db.select("SELECT CRYPTED_PASSWORD,SALT,UPDATED_AT FROM users"); - assertThat(rows).hasSize(1); - assertThat(rows.get(0).get("CRYPTED_PASSWORD")).isNull(); - assertThat(rows.get(0).get("SALT")).isNull(); - assertThat(rows.get(0).get("UPDATED_AT")).isEqualTo(NOW); - } - - @Test - public void ignore_local_user() throws Exception { - insertUserWithPassword("john", true); - - migration.execute(); - - List> rows = db.select("SELECT CRYPTED_PASSWORD,SALT,UPDATED_AT FROM users"); - assertThat(rows).hasSize(1); - assertThat(rows.get(0).get("CRYPTED_PASSWORD")).isNotNull(); - assertThat(rows.get(0).get("SALT")).isNotNull(); - assertThat(rows.get(0).get("UPDATED_AT")).isEqualTo(PAST_DATE); - } - - @Test - public void ignore_already_migrated_user() throws Exception { - insertUserWithoutPasword("john", false); - - migration.execute(); - - List> rows = db.select("SELECT CRYPTED_PASSWORD,SALT,UPDATED_AT FROM users"); - assertThat(rows).hasSize(1); - assertThat(rows.get(0).get("CRYPTED_PASSWORD")).isNull(); - assertThat(rows.get(0).get("SALT")).isNull(); - assertThat(rows.get(0).get("UPDATED_AT")).isEqualTo(PAST_DATE); - } - - private void insertUserWithPassword(String login, boolean isLocal) { - db.executeInsert( - "users", - "LOGIN", login, - "NAME", login, - "USER_LOCAL", Boolean.toString(isLocal), - "CRYPTED_PASSWORD", "crypted_" + login, - "SALT", "salt" + login, - "CREATED_AT", Long.toString(PAST_DATE), - "UPDATED_AT", Long.toString(PAST_DATE)); - } - - private void insertUserWithoutPasword(String login, boolean isLocal) { - db.executeInsert( - "users", - "LOGIN", login, - "NAME", login, - "USER_LOCAL", Boolean.toString(isLocal), - "CREATED_AT", Long.toString(PAST_DATE), - "UPDATED_AT", Long.toString(PAST_DATE)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java deleted file mode 100644 index 0539bf02114..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class AddErrorColumnsToCeActivityTest { - - private static final String TABLE = "CE_ACTIVITY"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddErrorColumnsToCeActivityTest.class, "old_ce_activity.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddErrorColumnsToCeActivity underTest = new AddErrorColumnsToCeActivity(db.database()); - - @Test - public void migration_adds_column_to_empty_table() throws SQLException { - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_adds_columns_to_populated_table() throws SQLException { - for (int i = 0; i < 9; i++) { - db.executeInsert( - TABLE, - "uuid", valueOf(i), - "task_type", "PROJECT", - "component_uuid", valueOf(i + 20), - "analysis_uuid", valueOf(i + 30), - "status", "ok", - "is_last", "true", - "is_last_key", "aa", - "submitted_at", valueOf(84654), - "created_at", valueOf(9512), - "updated_at", valueOf(45120)); - } - - underTest.execute(); - - verifyAddedColumns(); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } - - private void verifyAddedColumns() { - db.assertColumnDefinition(TABLE, "error_message", Types.VARCHAR, 1000, true); - db.assertColumnDefinition(TABLE, "error_stacktrace", Types.CLOB, null, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java deleted file mode 100644 index c65fabe9f18..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.Date; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class CopyActivitiesToQprofileChangesTest { - - private static final long A_DATE = 1_500_000_000_000L; - private static final String TABLE_ACTIVITIES = "activities"; - private static final String TABLE_QPROFILE_CHANGES = "qprofile_changes"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CopyActivitiesToQprofileChangesTest.class, "schema.sql"); - - private CopyActivitiesToQprofileChanges underTest = new CopyActivitiesToQprofileChanges(db.database()); - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_QPROFILE_CHANGES)).isEqualTo(0); - } - - @Test - public void copy_qprofile_changes() throws SQLException { - String key = "U1"; - String profileKey = "P1"; - String login = "marcel"; - String type = "ACTIVATED"; - String data = "D1"; - insertActivity(key, profileKey, login, "QPROFILE", type, data, A_DATE); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_QPROFILE_CHANGES)).isEqualTo(1); - Map change = selectChangeByKey(key); - assertThat(change.get("qprofileKey")).isEqualTo(profileKey); - assertThat(change.get("createdAt")).isEqualTo(A_DATE); - assertThat(change.get("login")).isEqualTo(login); - assertThat(change.get("changeType")).isEqualTo(type); - assertThat(change.get("changeData")).isEqualTo(data); - } - - /** - * Do not copy twice the same row - */ - @Test - public void copy_is_reentrant() throws SQLException { - insertActivity("U1", "P1", "marcel", "QPROFILE", "ACTIVATED", "D1", A_DATE); - - // first run - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_QPROFILE_CHANGES)).isEqualTo(1); - - // second run - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_QPROFILE_CHANGES)).isEqualTo(1); - } - - @Test - public void copy_nullable_fields() throws SQLException { - String key = "U1"; - String type = "ACTIVATED"; - // no login nor data - insertActivity(key, "P1", null, "QPROFILE", type, null, A_DATE); - - underTest.execute(); - - Map change = selectChangeByKey(key); - assertThat(change.get("qprofileKey")).isEqualTo("P1"); - assertThat(change.get("createdAt")).isEqualTo(A_DATE); - assertThat(change.get("changeType")).isEqualTo(type); - assertThat(change.get("login")).isNull(); - assertThat(change.get("data")).isNull(); - } - - @Test - public void ignore_activities_that_do_not_relate_to_qprofiles() throws SQLException { - insertActivity("U1", "P1", "marcel", "OTHER_ACTIVITY_TYPE", "T1", "D1", A_DATE); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_QPROFILE_CHANGES)).isEqualTo(0); - } - - @Test - public void ignore_invalid_activities() throws SQLException { - // no change type - insertActivity("U1", "P1", "marcel", "QPROFILE", null, "D1", A_DATE); - // no date - insertActivity("U2", "P1", "marcel", "QPROFILE", "ACTIVATED", "D1", null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_QPROFILE_CHANGES)).isEqualTo(0); - } - - private void insertActivity(String key, @Nullable String profileKey, @Nullable String login, @Nullable String activityType, @Nullable String type, @Nullable String data, - @Nullable Long createdAt) { - db.executeInsert(TABLE_ACTIVITIES, "log_key", key, "profile_key", profileKey, "user_login", login, "log_type", activityType, "log_action", type, "data_field", data, - "created_at", createdAt != null ? new Date(createdAt) : null); - } - - private Map selectChangeByKey(String key) { - return db.selectFirst( - "select qprofile_key as \"qprofileKey\", created_at as \"createdAt\", user_login as \"login\", change_type as \"changeType\", change_data as \"changeData\" from qprofile_changes where kee='" - + key + "'"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java deleted file mode 100644 index 3de3b7c8db0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableCeTaskInputTest { - private static final String TABLE_CE_TASK_INPUT = "ce_task_input"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableCeTaskInputTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableCeTaskInput underTest = new CreateTableCeTaskInput(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_CE_TASK_INPUT)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "task_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "input_data", Types.BLOB, null, true); - dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "created_at", Types.BIGINT, null, false); - dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "updated_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_CE_TASK_INPUT, "pk_" + TABLE_CE_TASK_INPUT, "task_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java deleted file mode 100644 index 640f6bffac3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableInternalPropertiesTest { - private static final String TABLE_INTERNAL_PROPERTIES = "internal_properties"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableInternalPropertiesTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableInternalProperties underTest = new CreateTableInternalProperties(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_INTERNAL_PROPERTIES)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_INTERNAL_PROPERTIES, "kee", Types.VARCHAR, 20, false); - dbTester.assertColumnDefinition(TABLE_INTERNAL_PROPERTIES, "is_empty", Types.BOOLEAN, null, false); - dbTester.assertColumnDefinition(TABLE_INTERNAL_PROPERTIES, "text_value", Types.VARCHAR, 4000, true); - dbTester.assertColumnDefinition(TABLE_INTERNAL_PROPERTIES, "clob_value", Types.CLOB, null, true); - dbTester.assertColumnDefinition(TABLE_INTERNAL_PROPERTIES, "created_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_INTERNAL_PROPERTIES, "pk_" + TABLE_INTERNAL_PROPERTIES, "kee"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java deleted file mode 100644 index 19fceb21729..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableProperties2Test { - private static final String TABLE_PROPERTIES_2 = "properties2"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableProperties2Test.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableProperties2 underTest = new CreateTableProperties2(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_PROPERTIES_2)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_PROPERTIES_2, "id", Types.INTEGER, null, false); - dbTester.assertColumnDefinition(TABLE_PROPERTIES_2, "prop_key", Types.VARCHAR, 512, false); - dbTester.assertColumnDefinition(TABLE_PROPERTIES_2, "resource_id", Types.BIGINT, null, true); - dbTester.assertColumnDefinition(TABLE_PROPERTIES_2, "user_id", Types.BIGINT, null, true); - dbTester.assertColumnDefinition(TABLE_PROPERTIES_2, "is_empty", Types.BOOLEAN, null, false); - dbTester.assertColumnDefinition(TABLE_PROPERTIES_2, "text_value", Types.VARCHAR, 4000, true); - dbTester.assertColumnDefinition(TABLE_PROPERTIES_2, "clob_value", Types.CLOB, null, true); - dbTester.assertColumnDefinition(TABLE_PROPERTIES_2, "created_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_PROPERTIES_2, "pk_properties", "id"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java deleted file mode 100644 index 942115a5459..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableQprofileChangesTest { - private static final String TABLE_QPROFILE_CHANGES = "qprofile_changes"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableQprofileChangesTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableQprofileChanges underTest = new CreateTableQprofileChanges(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QPROFILE_CHANGES)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_QPROFILE_CHANGES, "kee", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_QPROFILE_CHANGES, "qprofile_key", Types.VARCHAR, 255, false); - dbTester.assertColumnDefinition(TABLE_QPROFILE_CHANGES, "change_type", Types.VARCHAR, 20, false); - dbTester.assertColumnDefinition(TABLE_QPROFILE_CHANGES, "user_login", Types.VARCHAR, 255, true); - dbTester.assertColumnDefinition(TABLE_QPROFILE_CHANGES, "change_data", Types.CLOB, null, true); - dbTester.assertColumnDefinition(TABLE_QPROFILE_CHANGES, "created_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_QPROFILE_CHANGES, "pk_" + TABLE_QPROFILE_CHANGES, "kee"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java deleted file mode 100644 index 8aa626cc7a6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableRuleRepositoriesTest { - private static final String TABLE_RULE_REPOSITORIES = "rule_repositories"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableRuleRepositoriesTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableRuleRepositories underTest = new CreateTableRuleRepositories(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_RULE_REPOSITORIES)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_RULE_REPOSITORIES, "kee", Types.VARCHAR, 200, false); - dbTester.assertColumnDefinition(TABLE_RULE_REPOSITORIES, "language", Types.VARCHAR, 20, false); - dbTester.assertColumnDefinition(TABLE_RULE_REPOSITORIES, "name", Types.VARCHAR, 4000, false); - dbTester.assertColumnDefinition(TABLE_RULE_REPOSITORIES, "created_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_RULE_REPOSITORIES, "pk_" + TABLE_RULE_REPOSITORIES, "kee"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java deleted file mode 100644 index 0b41c0f098e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableScannerContextTest { - private static final String TABLE_CE_SCANNER_CONTEXT = "ce_scanner_context"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableCeTaskInputTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableScannerContext underTest = new CreateTableScannerContext(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_CE_SCANNER_CONTEXT)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "task_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "context_data", Types.BLOB, null, false); - dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "created_at", Types.BIGINT, null, false); - dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "updated_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_CE_SCANNER_CONTEXT, "pk_" + TABLE_CE_SCANNER_CONTEXT, "task_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DbVersion61Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DbVersion61Test.java deleted file mode 100644 index 219e91f52b3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DbVersion61Test.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion61Test { - private DbVersion61 underTest = new DbVersion61(); - - @Test - public void verify_support_components() { - assertThat(underTest.getSupportComponents()) - .containsExactly(ShrinkModuleUuidPathOfProjects.class, AddBUuidPathToProjects.class); - } - - @Test - public void migrationNumber_starts_at_1300() { - verifyMinimumMigrationNumber(underTest, 1300); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 17); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java deleted file mode 100644 index ba90c212ffa..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteProjectDashboardsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteProjectDashboardsTest.class, "schema.sql"); - - private DeleteProjectDashboards underTest = new DeleteProjectDashboards(db.database()); - - @Test - public void no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("dashboards")).isEqualTo(0); - } - - @Test - public void delete_project_dashboard_data() throws SQLException { - insertGlobalDashboards(1L, 10L, 11L); - insertProjectDashboards(2L, 20L, 21L); - insertActiveDashboards(1L, 10L, 11L, 12L); - insertActiveDashboards(2L, 20L, 21L, 22L); - insertWidgets(1L, 100L, 101L, 102L); - insertWidgets(2L, 200L, 201L, 202L); - insertWidgetProperties(100L, 1001L, 1002L, 1003L); - insertWidgetProperties(202L, 2021L, 2022L, 2023L); - - underTest.execute(); - - assertIdsOfDashboardsAre(1L, 10L, 11L); - assertIdsOfActiveDashboardsAre(10L, 11L, 12L); - assertIdsOfWidgetsAre(100L, 101L, 102L); - assertIdsOfWidgetPropertiesAre(1001L, 1002L, 1003L); - } - - @Test - public void is_reentrant() throws SQLException { - insertGlobalDashboards(10L, 11L, 12L); - insertProjectDashboards(20L, 21L, 22L); - underTest.execute(); - assertIdsOfDashboardsAre(10L, 11L, 12L); - - underTest.execute(); - assertIdsOfDashboardsAre(10L, 11L, 12L); - } - - private void insertProjectDashboards(long... ids) { - Arrays.stream(ids).forEach(id -> insertDashboard(id, false)); - } - - private void insertGlobalDashboards(long... ids) { - Arrays.stream(ids).forEach(id -> insertDashboard(id, true)); - } - - private void insertDashboard(long id, boolean isGlobal) { - db.executeInsert( - "dashboards", - "ID", valueOf(id), - "IS_GLOBAL", valueOf(isGlobal)); - } - - private void insertActiveDashboards(long dashboardId, long... ids) { - Arrays.stream(ids).forEach( - id -> db.executeInsert( - "active_dashboards", - "ID", valueOf(id), - "DASHBOARD_ID", valueOf(dashboardId))); - } - - private void insertWidgets(long dashboardId, long... ids) { - Arrays.stream(ids).forEach( - id -> db.executeInsert( - "widgets", - "ID", valueOf(id), - "WIDGET_KEY", valueOf(id), - "DASHBOARD_ID", valueOf(dashboardId))); - } - - private void insertWidgetProperties(long widgetId, long... ids) { - Arrays.stream(ids).forEach( - id -> db.executeInsert( - "widget_properties", - "ID", valueOf(id), - "WIDGET_ID", valueOf(widgetId))); - } - - private void assertIdsOfDashboardsAre(Long... ids) { - List idsInDb = db.select("select ID from dashboards").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - - assertThat(idsInDb).containsOnly(ids); - } - - private void assertIdsOfActiveDashboardsAre(Long... ids) { - List idsInDb = db.select("select ID from active_dashboards").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - - assertThat(idsInDb).containsOnly(ids); - } - - private void assertIdsOfWidgetsAre(Long... ids) { - List idsInDb = db.select("select ID from widgets").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - - assertThat(idsInDb).containsOnly(ids); - } - - private void assertIdsOfWidgetPropertiesAre(Long... ids) { - List idsInDb = db.select("select ID from widget_properties").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); - - assertThat(idsInDb).containsOnly(ids); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java deleted file mode 100644 index a05a44df145..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteReportsFromCeQueueTest { - - private static final long NOW = 1_500_000_000_000L; - private static final String TABLE_NAME = "ce_queue"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteReportsFromCeQueueTest.class, "schema.sql"); - - private DeleteReportsFromCeQueue underTest = new DeleteReportsFromCeQueue(db.database()); - - @Test - public void no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(0); - } - - @Test - public void delete_tasks_with_type_REPORT_only() throws SQLException { - db.executeInsert("ce_queue", "uuid", "U1", "task_type", "REPORT", "status", "PENDING", "created_at", NOW, "updated_at", NOW); - db.executeInsert("ce_queue", "uuid", "U2", "task_type", "REFRESH_VIEWS", "status", "PENDING", "created_at", NOW, "updated_at", NOW); - - underTest.execute(); - - List> uuids = db.select("select uuid as \"uuid\" from ce_queue"); - assertThat(uuids).hasSize(1); - assertThat(uuids.get(0).get("uuid")).isEqualTo("U2"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DropIsGlobalFromDashboardsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DropIsGlobalFromDashboardsTest.java deleted file mode 100644 index 7cfe3eb5c95..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DropIsGlobalFromDashboardsTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class DropIsGlobalFromDashboardsTest { - - Database database = mock(Database.class); - - DropIsGlobalFromDashboards underTest = new DropIsGlobalFromDashboards(database); - - @Test - public void verify_generated_sql_on_postgresql() throws SQLException { - when(database.getDialect()).thenReturn(new PostgreSql()); - - DdlChange.Context context = mock(DdlChange.Context.class); - underTest.execute(context); - - verify(context).execute( - singletonList("ALTER TABLE dashboards DROP COLUMN is_global")); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/Migration1304Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/Migration1304Test.java deleted file mode 100644 index 77deb7f1273..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/Migration1304Test.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Test; -import org.sonar.db.Database; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class Migration1304Test { - - private Database database = mock(Database.class); - - private enum Call { - CALL_1, - CALL_2 - } - - private List calls = new ArrayList<>(); - - private ShrinkModuleUuidPathOfProjects shrinkModuleUuidPathOfProjects = new ShrinkModuleUuidPathOfProjects(database) { - @Override - public void execute(Context context) { - calls.add(Call.CALL_1); - } - }; - private AddBUuidPathToProjects addBUuidPathToProjects = new AddBUuidPathToProjects(database) { - @Override - public void execute(Context context) { - calls.add(Call.CALL_2); - } - }; - - private Migration1304 underTest = new Migration1304(shrinkModuleUuidPathOfProjects, addBUuidPathToProjects); - - @Before - public void setUp() throws Exception { - DataSource dataSource = mock(DataSource.class); - when(database.getDataSource()).thenReturn(dataSource); - Connection connection = mock(Connection.class); - when(dataSource.getConnection()).thenReturn(connection); - when(connection.getMetaData()).thenReturn(mock(DatabaseMetaData.class)); - } - - @Test - public void execute_calls_2_delegates_in_order() throws SQLException { - underTest.execute(); - - assertThat(calls).containsExactly(Call.CALL_1, Call.CALL_2); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java deleted file mode 100644 index 5911e574f73..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java +++ /dev/null @@ -1,403 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.Map; -import java.util.Objects; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.assertj.core.api.AbstractAssert; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.Boolean.FALSE; -import static java.lang.Boolean.TRUE; -import static java.lang.String.valueOf; -import static java.util.Objects.requireNonNull; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateTableProperties2Test { - private static final String EMPTY_PROPERTY = ""; - private static final String VALUE_SMALL = "some small value"; - private static final String VALUE_SIZE_4000 = String.format("%1$4000.4000s", "*"); - private static final String VALUE_SIZE_4001 = VALUE_SIZE_4000 + "P"; - private static final long DATE_1 = 1_555_000L; - private static final long DATE_2 = 2_666_000L; - private static final long DATE_3 = 3_777_000L; - private static final long DATE_4 = 4_888_000L; - - private System2 system2 = mock(System2.class); - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateTableProperties2Test.class, - "properties_and_properties_2_tables.sql"); - - private PopulateTableProperties2 underTest = new PopulateTableProperties2(dbTester.database(), system2); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(0); - assertThat(dbTester.countRowsOfTable("properties2")).isEqualTo(0); - } - - @Test - public void migration_does_copy_again_properties_which_are_already_copied() throws SQLException { - insertProperty(1, VALUE_SMALL, null, null); - insertProperty(10, VALUE_SMALL, null, null); - insertProperty(2, VALUE_SMALL, null, 21); - insertProperty(20, VALUE_SMALL, null, 21); - insertProperty(3, VALUE_SMALL, 31, null); - insertProperty(30, VALUE_SMALL, 31, null); - - insertProperty2(1, VALUE_SMALL, null, null); - insertProperty2(2, VALUE_SMALL, null, 21); - insertProperty2(3, VALUE_SMALL, 31, null); - - assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(6); - assertThat(dbTester.countRowsOfTable("properties2")).isEqualTo(3); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(6); - assertThat(dbTester.countRowsOfTable("properties2")).isEqualTo(6); - } - - @Test - public void migration_moves_global_properties() throws SQLException { - when(system2.now()).thenReturn(DATE_1, DATE_2, DATE_3, DATE_4); - - insertProperty(1, VALUE_SMALL, null, null); - insertProperty(2, EMPTY_PROPERTY, null, null); - insertProperty(3, VALUE_SIZE_4000, null, null); - insertProperty(4, VALUE_SIZE_4001, null, null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(4); - assertThat(dbTester.countRowsOfTable("properties2")).isEqualTo(4); - - assertThatProperty2(1) - .hasNoResourceId() - .hasNoUserId() - .hasTextValue(VALUE_SMALL) - .hasCreatedAt(DATE_1); - assertThatProperty2(2) - .hasNoResourceId() - .hasNoUserId() - .isEmpty() - .hasCreatedAt(DATE_2); - assertThatProperty2(3) - .hasNoResourceId() - .hasNoUserId() - .hasTextValue(VALUE_SIZE_4000) - .hasCreatedAt(DATE_3); - assertThatProperty2(4) - .hasNoResourceId() - .hasNoUserId() - .hasClobValue(VALUE_SIZE_4001) - .hasCreatedAt(DATE_4); - } - - @Test - public void migration_moves_user_properties() throws SQLException { - when(system2.now()).thenReturn(DATE_1, DATE_2, DATE_3, DATE_4); - - insertProperty(1, VALUE_SMALL, null, 11); - insertProperty(2, EMPTY_PROPERTY, null, 12); - insertProperty(3, VALUE_SIZE_4000, null, 13); - insertProperty(4, VALUE_SIZE_4001, null, 14); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(4); - assertThat(dbTester.countRowsOfTable("properties2")).isEqualTo(4); - - assertThatProperty2(1) - .hasNoResourceId() - .hasUserId(11) - .hasTextValue(VALUE_SMALL) - .hasCreatedAt(DATE_1); - assertThatProperty2(2) - .hasNoResourceId() - .hasUserId(12) - .isEmpty() - .hasCreatedAt(DATE_2); - assertThatProperty2(3) - .hasNoResourceId() - .hasUserId(13) - .hasTextValue(VALUE_SIZE_4000) - .hasCreatedAt(DATE_3); - assertThatProperty2(4) - .hasNoResourceId() - .hasUserId(14) - .hasClobValue(VALUE_SIZE_4001) - .hasCreatedAt(DATE_4); - } - - @Test - public void migration_moves_component_properties() throws SQLException { - when(system2.now()).thenReturn(DATE_1, DATE_2, DATE_3, DATE_4); - - insertProperty(1, VALUE_SMALL, 11, null); - insertProperty(2, EMPTY_PROPERTY, 12, null); - insertProperty(3, VALUE_SIZE_4000, 13, null); - insertProperty(4, VALUE_SIZE_4001, 14, null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(4); - assertThat(dbTester.countRowsOfTable("properties2")).isEqualTo(4); - - assertThatProperty2(1) - .hasResourceId(11) - .hasNoUserId() - .hasTextValue(VALUE_SMALL) - .hasCreatedAt(DATE_1); - assertThatProperty2(2) - .hasResourceId(12) - .hasNoUserId() - .isEmpty() - .hasCreatedAt(DATE_2); - assertThatProperty2(3) - .hasResourceId(13) - .hasNoUserId() - .hasTextValue(VALUE_SIZE_4000) - .hasCreatedAt(DATE_3); - assertThatProperty2(4) - .hasResourceId(14) - .hasNoUserId() - .hasClobValue(VALUE_SIZE_4001) - .hasCreatedAt(DATE_4); - } - - private void insertProperty(int idAndKey, String value, @Nullable Integer resourceId, @Nullable Integer userId) { - dbTester.executeInsert("PROPERTIES", - "id", valueOf(idAndKey), - "prop_key", valueOf(idAndKey), - "text_value", value, - "resource_id", resourceId == null ? null : valueOf(resourceId), - "user_id", userId == null ? null : valueOf(userId)); - } - - private void insertProperty2(int idAndKey, @Nullable String value, @Nullable Integer resourceId, @Nullable Integer userId) { - dbTester.executeInsert("PROPERTIES2", - "id", valueOf(idAndKey), - "prop_key", valueOf(idAndKey), - "resource_id", resourceId == null ? null : valueOf(resourceId), - "user_id", userId == null ? null : valueOf(userId), - "is_empty", valueOf(value == null || value.isEmpty()), - "text_value", value != null && value.length() <= 4000 ? value : null, - "clob_value", value != null && value.length() > 4000 ? value : null, - "created_at", valueOf(1_55555_555)); - } - - private Property2Assert assertThatProperty2(int key) { - return new Property2Assert(dbTester, valueOf(key)); - } - - private static class Property2Assert extends AbstractAssert { - - private Property2Assert(CoreDbTester dbTester, String internalPropertyKey) { - super(asInternalProperty(dbTester, internalPropertyKey), Property2Assert.class); - } - - private static Property2 asInternalProperty(CoreDbTester dbTester, String key) { - Map row = dbTester.selectFirst( - "select" + - " user_id as \"userId\", resource_id as \"resourceId\", is_empty as \"isEmpty\", text_value as \"textValue\", clob_value as \"clobValue\", created_at as \"createdAt\"" + - " from properties2" + - " where prop_key='" + key + "'"); - Long userId = (Long) row.get("userId"); - return new Property2( - userId == null ? null : userId.intValue(), - (Long) row.get("resourceId"), - isEmpty(row), - (String) row.get("textValue"), - (String) row.get("clobValue"), - (Long) row.get("createdAt")); - } - - private static Boolean isEmpty(Map row) { - Object flag = row.get("isEmpty"); - if (flag instanceof Boolean) { - return (Boolean) flag; - } - if (flag instanceof Long) { - Long longBoolean = (Long) flag; - return longBoolean.equals(1L); - } - throw new IllegalArgumentException("Unsupported object type returned for column \"isEmpty\": " + flag.getClass()); - } - - public Property2Assert hasNoUserId() { - isNotNull(); - - if (actual.getUserId() != null) { - failWithMessage("Expected Property2 to have column USER_ID to be null but was <%s>", actual.getUserId()); - } - - return this; - } - - public Property2Assert hasUserId(int expected) { - isNotNull(); - - if (!Objects.equals(actual.getUserId(), expected)) { - failWithMessage("Expected Property2 to have column USER_ID to be <%s> but was <%s>", true, actual.getUserId()); - } - - return this; - } - - public Property2Assert hasNoResourceId() { - isNotNull(); - - if (actual.getResourceId() != null) { - failWithMessage("Expected Property2 to have column RESOURCE_ID to be null but was <%s>", actual.getResourceId()); - } - - return this; - } - - public Property2Assert hasResourceId(long expected) { - isNotNull(); - - if (!Objects.equals(actual.getResourceId(), expected)) { - failWithMessage("Expected Property2 to have column RESOURCE_ID to be <%s> but was <%s>", true, actual.getResourceId()); - } - - return this; - } - - public Property2Assert isEmpty() { - isNotNull(); - - if (!Objects.equals(actual.getEmpty(), TRUE)) { - failWithMessage("Expected Property2 to have column IS_EMPTY to be <%s> but was <%s>", true, actual.getEmpty()); - } - if (actual.getTextValue() != null) { - failWithMessage("Expected Property2 to have column TEXT_VALUE to be null but was <%s>", actual.getTextValue()); - } - if (actual.getClobValue() != null) { - failWithMessage("Expected Property2 to have column CLOB_VALUE to be null but was <%s>", actual.getClobValue()); - } - - return this; - } - - public Property2Assert hasTextValue(String expected) { - isNotNull(); - - if (!Objects.equals(actual.getTextValue(), requireNonNull(expected))) { - failWithMessage("Expected Property2 to have column TEXT_VALUE to be <%s> but was <%s>", expected, actual.getTextValue()); - } - if (actual.getClobValue() != null) { - failWithMessage("Expected Property2 to have column CLOB_VALUE to be null but was <%s>", actual.getClobValue()); - } - if (!Objects.equals(actual.getEmpty(), FALSE)) { - failWithMessage("Expected Property2 to have column IS_EMPTY to be <%s> but was <%s>", false, actual.getEmpty()); - } - - return this; - } - - public Property2Assert hasClobValue(String expected) { - isNotNull(); - - if (!Objects.equals(actual.getClobValue(), requireNonNull(expected))) { - failWithMessage("Expected Property2 to have column CLOB_VALUE to be <%s> but was <%s>", expected, actual.getClobValue()); - } - if (actual.getTextValue() != null) { - failWithMessage("Expected Property2 to have column TEXT_VALUE to be null but was <%s>", actual.getTextValue()); - } - if (!Objects.equals(actual.getEmpty(), FALSE)) { - failWithMessage("Expected Property2 to have column IS_EMPTY to be <%s> but was <%s>", false, actual.getEmpty()); - } - - return this; - } - - public Property2Assert hasCreatedAt(long expected) { - isNotNull(); - - if (!Objects.equals(actual.getCreatedAt(), expected)) { - failWithMessage("Expected Property2 to have column CREATED_AT to be <%s> but was <%s>", expected, actual.getCreatedAt()); - } - - return this; - } - - } - - private static final class Property2 { - private final Integer userId; - private final Long resourceId; - private final Boolean empty; - private final String textValue; - private final String clobValue; - private final Long createdAt; - - private Property2(@Nullable Integer userId, @Nullable Long resourceId, - @Nullable Boolean empty, @Nullable String textValue, @Nullable String clobValue, - @Nullable Long createdAt) { - this.userId = userId; - this.resourceId = resourceId; - this.empty = empty; - this.textValue = textValue; - this.clobValue = clobValue; - this.createdAt = createdAt; - } - - public Integer getUserId() { - return userId; - } - - public Long getResourceId() { - return resourceId; - } - - @CheckForNull - public Boolean getEmpty() { - return empty; - } - - @CheckForNull - public String getTextValue() { - return textValue; - } - - @CheckForNull - public String getClobValue() { - return clobValue; - } - - @CheckForNull - public Long getCreatedAt() { - return createdAt; - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java deleted file mode 100644 index 99295b585a2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v61; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -public class RemoveViewsDefinitionFromPropertiesTest { - - private static final long NOW = 1_500_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RemoveViewsDefinitionFromPropertiesTest.class, "properties_and_internal_properties.sql"); - - private System2 system2 = spy(System2.INSTANCE); - private RemoveViewsDefinitionFromProperties underTest = new RemoveViewsDefinitionFromProperties(db.database(), system2); - - @Test - public void ignore_missing_views_definition() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("internal_properties")).isEqualTo(0); - } - - @Test - public void move_views_definition_from_properties_to_text_value_of_internal_properties_table_when_less_than_4000() throws SQLException { - executeAndVerify("views content", false); - } - - @Test - public void move_views_definition_from_properties_to_text_value_of_internal_properties_table_when_is_4000() throws SQLException { - executeAndVerify(String.format("%1$4000.4000s", "*"), false); - } - - @Test - public void move_views_definition_from_properties_to_clob_value_of_internal_properties_table_when_is_more_than_4000() throws SQLException { - executeAndVerify(String.format("%1$4000.4000s", "*") + "abc", true); - } - - private void executeAndVerify(String xml, boolean isClob) throws SQLException { - when(system2.now()).thenReturn(NOW); - db.executeInsert("properties", "prop_key", "views.def", "text_value", xml); - db.executeInsert("properties", "prop_key", "other.property", "text_value", "other content"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("internal_properties")).isEqualTo(1); - Map internalProp = db.selectFirst("select" + - " kee as \"key\", is_empty as \"isEmpty\", text_value as \"textValue\", clob_value as \"clobValue\", created_at as \"createdAt\"" + - " from internal_properties"); - assertThat(internalProp.get("key")).isEqualTo("views.def"); - assertThat(internalProp.get("isEmpty")).isEqualTo(false); - if (isClob) { - assertThat(internalProp.get("clobValue")).isEqualTo(xml); - assertThat(internalProp.get("textValue")).isNull(); - } else { - assertThat(internalProp.get("textValue")).isEqualTo(xml); - assertThat(internalProp.get("clobValue")).isNull(); - } - assertThat(internalProp.get("createdAt")).isEqualTo(NOW); - - // property "views.def" has been deleted - List> properties = db.select("select prop_key as \"prop_key\" from properties"); - assertThat(properties).hasSize(1); - assertThat(properties.get(0).get("prop_key")).isEqualTo("other.property"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java deleted file mode 100644 index 72d8f42dcc7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class AddIsRootColumnOnTableUsersTest { - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIsRootColumnOnTableUsersTest.class, "table_users.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIsRootColumnOnTableUsers underTest = new AddIsRootColumnOnTableUsers(dbTester.database()); - - @Test - public void add_nullable_boolean_column_is_root() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("users", "is_root", Types.BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java deleted file mode 100644 index 4a9ba9413ed..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - - -public class AddOrganizationUuidToGroupRolesTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToGroupRolesTest.class, "previous-group_roles.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToGroupRoles underTest = new AddOrganizationUuidToGroupRoles(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("group_roles", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java deleted file mode 100644 index c5977fc2f8b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class AddOrganizationUuidToGroupsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToGroupsTest.class, "previous-groups.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToGroups underTest = new AddOrganizationUuidToGroups(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("groups", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java deleted file mode 100644 index b0597635bb5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class AddOrganizationUuidToPermissionTemplatesTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToPermissionTemplatesTest.class, "previous-permission_templates.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToPermissionTemplates underTest = new AddOrganizationUuidToPermissionTemplates(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("permission_templates", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java deleted file mode 100644 index 20cf7b56f3f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - - -public class AddOrganizationUuidToUserRolesTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToUserRolesTest.class, "previous-user_roles.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToUserRoles underTest = new AddOrganizationUuidToUserRoles(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("user_roles", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java deleted file mode 100644 index f8d10c4f6e1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Date; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class CreateDefaultOrganizationTest { - private static final String DEFAULT_ORGANIZATION_KEY = "default-organization"; - private static final String DEFAULT_ORGANIZATION_NAME = "Default Organization"; - private static final String INTERNAL_PROPERTY_ORGANIZATION_DEFAULT = "organization.default"; - - private System2 system2 = mock(System2.class); - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateDefaultOrganizationTest.class, "organizations_and_internal_properties.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UuidFactory uuidFactory = mock(UuidFactory.class); - private CreateDefaultOrganization underTest = new CreateDefaultOrganization(dbTester.database(), system2, uuidFactory); - - @Test - public void execute_insert_data_in_organizations_and_internal_properties_when_it_does_not_exist() throws Exception { - long now = 1_222_999L; - String uuid = "a uuid"; - when(system2.now()).thenReturn(now); - when(uuidFactory.create()).thenReturn(uuid); - - underTest.execute(); - - try (Connection connection = dbTester.openConnection(); - PreparedStatement preparedStatement = createSelectStatementByKey(connection, DEFAULT_ORGANIZATION_KEY); - ResultSet resultSet = preparedStatement.executeQuery()) { - if (resultSet.next()) { - assertThat(resultSet.getString(1)).isEqualTo(uuid); - assertThat(resultSet.getString(2)).isEqualTo(DEFAULT_ORGANIZATION_KEY); - assertThat(resultSet.getString(3)).isEqualTo(DEFAULT_ORGANIZATION_NAME); - assertThat(resultSet.getString(4)).isNull(); - assertThat(resultSet.getString(5)).isNull(); - assertThat(resultSet.getString(6)).isNull(); - assertThat(resultSet.getLong(7)).isEqualTo(now); - assertThat(resultSet.getLong(8)).isEqualTo(now); - - assertThat(resultSet.next()).isFalse(); - } else { - fail("Can't retrieve organization " + uuid); - } - } - - verifyInternalProperty(uuid); - } - - @Test - public void execute_inserts_internal_property_if_default_organization_already_exists() throws Exception { - long past = 2_999_033L; - String uuid = "uuidAAAA"; - insertExistingOrganization(uuid, past); - verifyExistingOrganization(uuid, past); - - underTest.execute(); - - // existing organization is unchanged - verifyExistingOrganization(uuid, past); - - // internal property created - verifyInternalProperty(uuid); - } - - private void verifyInternalProperty(String expectedUuid) { - - Map row = dbTester.selectFirst("select" + - " kee as \"KEE\"," + - " is_empty as \"IS_EMPTY\"," + - " text_value as \"TEXT_VALUE\"" + - " from internal_properties" + - " where kee = '" + INTERNAL_PROPERTY_ORGANIZATION_DEFAULT + "'"); - assertThat(row.get("TEXT_VALUE")).isEqualTo(expectedUuid); - } - - @Test - public void execute_has_no_effect_if_organization_and_internal_property_already_exist() throws Exception { - long past = 2_999_033L; - String uuid = "uuidAAAA"; - insertExistingOrganization(uuid, past); - insertExistingInternalProperty(uuid); - verifyExistingOrganization(uuid, past); - verifyInternalProperty(uuid); - - underTest.execute(); - - verifyExistingOrganization(uuid, past); - verifyInternalProperty(uuid); - } - - @Test - public void execute_is_reentrant() throws SQLException { - when(system2.now()).thenReturn(1_222_999L); - when(uuidFactory.create()).thenReturn("a uuid"); - - underTest.execute(); - - underTest.execute(); - } - - private void insertExistingInternalProperty(String uuid) { - dbTester.executeInsert("INTERNAL_PROPERTIES", - "KEE", INTERNAL_PROPERTY_ORGANIZATION_DEFAULT, - "TEXT_VALUE", uuid, - "CREATED_AT", new Date().getTime(), - "IS_EMPTY", false); - } - - private void insertExistingOrganization(String uuid, long past) throws Exception { - try (Connection connection = dbTester.openConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("insert into organizations (uuid,kee,name,created_at,updated_at) values (?,?,?,?,?)")) { - preparedStatement.setString(1, uuid); - preparedStatement.setString(2, DEFAULT_ORGANIZATION_KEY); - preparedStatement.setString(3, "whatever"); - preparedStatement.setLong(4, past); - preparedStatement.setLong(5, past); - preparedStatement.execute(); - if (!connection.getAutoCommit()) { - connection.commit(); - } - } - } - - private void verifyExistingOrganization(String uuid, long past) throws Exception { - try (Connection connection = dbTester.openConnection(); - PreparedStatement preparedStatement = createSelectStatementByUuid(connection, uuid); - ResultSet resultSet = preparedStatement.executeQuery()) { - if (resultSet.next()) { - assertThat(resultSet.getString(1)).isEqualTo(uuid); - assertThat(resultSet.getString(2)).isEqualTo(DEFAULT_ORGANIZATION_KEY); - assertThat(resultSet.getString(3)).isEqualTo("whatever"); - assertThat(resultSet.getString(4)).isNull(); - assertThat(resultSet.getString(5)).isNull(); - assertThat(resultSet.getString(6)).isNull(); - assertThat(resultSet.getLong(7)).isEqualTo(past); - assertThat(resultSet.getLong(8)).isEqualTo(past); - - assertThat(resultSet.next()).isFalse(); - } else { - fail("Can't retrieve organization " + uuid); - } - } - } - - private PreparedStatement createSelectStatementByUuid(Connection connection, String uuid) throws SQLException { - PreparedStatement preparedStatement = connection.prepareStatement("select uuid,kee,name,description,url,avatar_url,created_at,updated_at from organizations where uuid=?"); - preparedStatement.setString(1, uuid); - return preparedStatement; - } - - private PreparedStatement createSelectStatementByKey(Connection connection, String kee) throws SQLException { - PreparedStatement preparedStatement = connection.prepareStatement("select uuid,kee,name,description,url,avatar_url,created_at,updated_at from organizations where kee=?"); - preparedStatement.setString(1, kee); - return preparedStatement; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java deleted file mode 100644 index 80a43516d6f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableOrganizationsTest { - private static final String TABLE_ORGANIZATIONS = "organizations"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableOrganizationsTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableOrganizations underTest = new CreateTableOrganizations(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_ORGANIZATIONS)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "kee", Types.VARCHAR, 32, false); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "name", Types.VARCHAR, 64, false); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "description", Types.VARCHAR, 256, true); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "url", Types.VARCHAR, 256, true); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "avatar_url", Types.VARCHAR, 256, true); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "created_at", Types.BIGINT, null, false); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "updated_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_ORGANIZATIONS, "pk_" + TABLE_ORGANIZATIONS, "uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java deleted file mode 100644 index 433d69a5f3c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class CreateTableWebhookDeliveriesTest { - - private static final String TABLE = "webhook_deliveries"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableWebhookDeliveriesTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableWebhookDeliveries underTest = new CreateTableWebhookDeliveries(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE, "ce_task_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE, "name", Types.VARCHAR, 100, false); - dbTester.assertColumnDefinition(TABLE, "url", Types.VARCHAR, 2000, false); - dbTester.assertColumnDefinition(TABLE, "success", Types.BOOLEAN, null, false); - dbTester.assertColumnDefinition(TABLE, "http_status", Types.INTEGER, null, true); - dbTester.assertColumnDefinition(TABLE, "duration_ms", Types.INTEGER, null, true); - dbTester.assertColumnDefinition(TABLE, "payload", Types.CLOB, null, false); - dbTester.assertColumnDefinition(TABLE, "error_stacktrace", Types.CLOB, null, true); - dbTester.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - dbTester.assertIndex(TABLE, "component_uuid", "component_uuid"); - dbTester.assertIndex(TABLE, "ce_task_uuid", "ce_task_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DbVersion62Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DbVersion62Test.java deleted file mode 100644 index 8b15e294a21..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DbVersion62Test.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion62Test { - private DbVersion62 underTest = new DbVersion62(); - - @Test - public void verify_no_support_component() { - assertThat(underTest.getSupportComponents()).isEmpty(); - } - - @Test - public void migrationNumber_starts_at_1400() { - verifyMinimumMigrationNumber(underTest, 1400); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 24); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java deleted file mode 100644 index 88f448a4622..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DeletePermissionShareDashboardTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeletePermissionShareDashboardTest.class, "roles.sql"); - - private DeletePermissionShareDashboard underTest = new DeletePermissionShareDashboard(db.database()); - - @Test - public void delete_permissions() throws SQLException { - // combinations of group permissions to be kept - db.executeInsert("group_roles", "id", "1", "group_id", null, "resource_id", null, "role", "admin"); - db.executeInsert("group_roles", "id", "2", "group_id", null, "resource_id", "1", "role", "issueadmin"); - db.executeInsert("group_roles", "id", "3", "group_id", "1", "resource_id", null, "role", "admin"); - db.executeInsert("group_roles", "id", "4", "group_id", "1", "resource_id", "1", "role", "issueadmin"); - - // combinations of group permissions to be removed (even if it does make sense to have "shareDashboard" - // on projects) - db.executeInsert("group_roles", "id", "5", "group_id", null, "resource_id", null, "role", "shareDashboard"); - db.executeInsert("group_roles", "id", "6", "group_id", null, "resource_id", "1", "role", "shareDashboard"); - db.executeInsert("group_roles", "id", "7", "group_id", "1", "resource_id", null, "role", "shareDashboard"); - db.executeInsert("group_roles", "id", "8", "group_id", "1", "resource_id", "1", "role", "shareDashboard"); - - // combinations of user permissions to be kept - db.executeInsert("user_roles", "id", "1", "user_id", "100", "resource_id", null, "role", "admin"); - db.executeInsert("user_roles", "id", "2", "user_id", "100", "resource_id", "1", "role", "issueadmin"); - - // combinations of user permissions to be removed (even if it does make sense to have "shareDashboard" - // on projects) - db.executeInsert("user_roles", "id", "3", "user_id", "100", "resource_id", null, "role", "shareDashboard"); - db.executeInsert("user_roles", "id", "4", "user_id", "100", "resource_id", "1", "role", "shareDashboard"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("group_roles")).isEqualTo(4); - assertThat(db.countSql("select count(id) from group_roles where role='shareDashboard'")).isEqualTo(0); - - assertThat(db.countRowsOfTable("user_roles")).isEqualTo(2); - assertThat(db.countSql("select count(id) from user_roles where role='shareDashboard'")).isEqualTo(0); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java deleted file mode 100644 index 9e55efbe07e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class DropIssueFiltersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIssueFiltersTableTest.class, "schema.sql"); - - private DropIssueFiltersTables underTest = new DropIssueFiltersTables(db.database()); - - @Test - public void delete_tables() throws SQLException { - underTest.execute(); - - db.assertTableDoesNotExist("issue_filters"); - db.assertTableDoesNotExist("issue_filter_favourites"); - } - - @Test - public void migration_is_re_entrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("issue_filters"); - db.assertTableDoesNotExist("issue_filter_favourites"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java deleted file mode 100644 index c506e9c4971..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class DropMeasureFiltersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMeasureFiltersTableTest.class, "schema.sql"); - - private DropMeasureFiltersTables underTest = new DropMeasureFiltersTables(db.database()); - - @Test - public void delete_tables() throws SQLException { - underTest.execute(); - - db.assertTableDoesNotExist("measure_filters"); - db.assertTableDoesNotExist("measure_filter_favourites"); - } - - @Test - public void migration_is_re_entrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("measure_filters"); - db.assertTableDoesNotExist("measure_filter_favourites"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java deleted file mode 100644 index 3c71960f84e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class DropRelatedDashboardTablesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRelatedDashboardTablesTest.class, "schema.sql"); - - private DropRelatedDashboardTables underTest = new DropRelatedDashboardTables(db.database()); - - @Test - public void delete_tables() throws SQLException { - underTest.execute(); - - db.assertTableDoesNotExist("widget_properties"); - db.assertTableDoesNotExist("widgets"); - db.assertTableDoesNotExist("active_dashboards"); - db.assertTableDoesNotExist("dashboards"); - } - - @Test - public void migration_is_re_entrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("widget_properties"); - db.assertTableDoesNotExist("widgets"); - db.assertTableDoesNotExist("active_dashboards"); - db.assertTableDoesNotExist("dashboards"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java deleted file mode 100644 index bbfa152e3ef..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeOrganizationUuidNotNullOnGroupRolesTest { - - private static final String TABLE_GROUP_ROLES = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationUuidNotNullOnGroupRolesTest.class, - "in_progress_group_roles.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidNotNullOnGroupRoles underTest = new MakeOrganizationUuidNotNullOnGroupRoles(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertGroupRole(1, true); - insertGroupRole(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertGroupRole(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_GROUP_ROLES, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertGroupRole(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_GROUP_ROLES, - "ID", valueOf(id), - "GROUP_ID", id + 10, - "ROLE", valueOf(id + 100), - "ORGANIZATION_UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java deleted file mode 100644 index ab588fadd6f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeOrganizationUuidNotNullOnGroupsTest { - - private static final String TABLE_GROUPS = "groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationUuidNotNullOnGroupsTest.class, - "in_progress_groups.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidNotNullOnGroups underTest = new MakeOrganizationUuidNotNullOnGroups(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertGroup(1, true); - insertGroup(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertGroup(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_GROUPS, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertGroup(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_GROUPS, - "ID", valueOf(id), - "NAME", valueOf(id + 10), - "ORGANIZATION_UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java deleted file mode 100644 index d8fe81e9e58..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - - -public class MakeOrganizationUuidNotNullOnPermissionTemplatesTest { - - private static final String TABLE_PERMISSION_TEMPLATES = "permission_templates"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationUuidNotNullOnPermissionTemplatesTest.class, - "in_progress_permission_templates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidNotNullOnPermissionTemplates underTest = new MakeOrganizationUuidNotNullOnPermissionTemplates(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertTemplate(1, true); - insertTemplate(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertTemplate(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_PERMISSION_TEMPLATES, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertTemplate(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_PERMISSION_TEMPLATES, - "ID", valueOf(id), - "NAME", valueOf(id + 10), - "KEE", valueOf(id + 100), - "ORGANIZATION_UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java deleted file mode 100644 index d430f6d84bd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeOrganizationUuidNotNullOnUserRolesTest { - - private static final String TABLE_USER_ROLES = "user_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationUuidNotNullOnUserRolesTest.class, - "in_progress_user_roles.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidNotNullOnUserRoles underTest = new MakeOrganizationUuidNotNullOnUserRoles(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertUserRole(1, true); - insertUserRole(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertUserRole(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_USER_ROLES, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertUserRole(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_USER_ROLES, - "ID", valueOf(id), - "USER_ID", id + 10, - "ROLE", valueOf(id + 100), - "ORGANIZATION_UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java deleted file mode 100644 index 418e0aca837..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class MakeRootColumnNotNullOnTableUsersTest { - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MakeRootColumnNotNullOnTableUsersTest.class, "users_with_nullable_root.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeRootColumnNotNullOnTableUsers underTest = new MakeRootColumnNotNullOnTableUsers(dbTester.database()); - - @Test - public void execute_make_column_is_root_not_nullable() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("users", "is_root", Types.BOOLEAN, null, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java deleted file mode 100644 index aeaf0230df6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateIsRootColumnOnTableUsersTest { - private static final String USERS_TABLE = "users"; - private static final String ROLE_ADMIN = "admin"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateIsRootColumnOnTableUsersTest.class, "users_and_permissions_tables.sql"); - - private PopulateIsRootColumnOnTableUsers underTest = new PopulateIsRootColumnOnTableUsers(dbTester.database()); - - @Test - public void execute_on_empty_users_table_has_no_effect() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(USERS_TABLE)).isEqualTo(0); - } - - @Test - public void execute_sets_active_user_with_no_permission_has_not_root() throws SQLException { - insertUser("foo", true); - - underTest.execute(); - - verifySingleUser("foo", false); - } - - @Test - public void execute_sets_inactive_user_with_no_permission_has_not_root() throws SQLException { - insertUser("foo", false); - - underTest.execute(); - - verifySingleUser("foo", false); - } - - @Test - public void execute_sets_active_user_with_admin_role_has_root() throws SQLException { - int userId = insertUser("foo", true); - insertRole(userId, ROLE_ADMIN); - - underTest.execute(); - - verifySingleUser("foo", true); - } - - @Test - public void execute_sets_inactive_user_with_admin_role_has_not_root() throws SQLException { - int userId = insertUser("bar", false); - insertRole(userId, ROLE_ADMIN); - - underTest.execute(); - - verifySingleUser("bar", false); - } - - @Test - public void execute_sets_active_user_in_group_with_admin_role_has_root() throws SQLException { - int userId = insertUser("doo", true); - int groupId = insertGroup("admin group"); - insertGroupRole(groupId, ROLE_ADMIN); - addUserToGroup(userId, groupId); - - underTest.execute(); - - verifySingleUser("doo", true); - } - - @Test - public void execute_sets_inactive_user_in_group_with_admin_role_has_not_root() throws SQLException { - int userId = insertUser("bar", false); - int groupId = insertGroup("admin group"); - insertGroupRole(groupId, ROLE_ADMIN); - addUserToGroup(userId, groupId); - - underTest.execute(); - - verifySingleUser("bar", false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - int adminGroupId = insertGroup("admin group"); - insertGroupRole(adminGroupId, ROLE_ADMIN); - int groupId = insertGroup("other group"); - int[] userIds = { - insertUser("inactive_direct_admin", false), - insertUser("active_direct_admin", true), - insertUser("inactive_group_admin", false), - insertUser("active_group_admin", true), - insertUser("group_and_direct_admin", true), - insertUser("group_perm_user", true), - insertUser("no_perm_user", true), - insertUser("all_groups_user", true) - }; - // inactive_direct_admin - insertRole(userIds[0], ROLE_ADMIN); - // active_direct_admin - insertRole(userIds[1], ROLE_ADMIN); - // inactive_group_admin - addUserToGroup(userIds[2], adminGroupId); - // active_group_admin - addUserToGroup(userIds[3], adminGroupId); - // group_and_direct_admin - addUserToGroup(userIds[4], adminGroupId); - insertRole(userIds[4], ROLE_ADMIN); - // group_perm_user - addUserToGroup(userIds[5], groupId); - // all_groups_user - addUserToGroup(userIds[7], adminGroupId); - addUserToGroup(userIds[7], groupId); - - underTest.execute(); - verifyUsers(); - - underTest.execute(); - verifyUsers(); - } - - private void verifyUsers() { - verifyUser("inactive_direct_admin", false); - verifyUser("active_direct_admin", true); - verifyUser("inactive_group_admin", false); - verifyUser("active_group_admin", true); - verifyUser("group_and_direct_admin", true); - verifyUser("group_perm_user", false); - verifyUser("all_groups_user", true); - verifyUser("no_perm_user", false); - } - - private void insertRole(int userId, String role) { - dbTester.executeInsert("user_roles", "user_id", userId, "role", role); - } - - private int insertUser(String login, boolean active) { - dbTester.executeInsert(USERS_TABLE, "login", login, "active", active); - Long userId = (Long) dbTester.selectFirst("select id as \"id\" from users where login = '" + login + "'").get("id"); - return userId.intValue(); - } - - private int insertGroup(String groupName) { - dbTester.executeInsert("groups", "name", groupName); - Long groupId = (Long) dbTester.selectFirst("select id as \"id\" from groups where name = '" + groupName + "'").get("id"); - return groupId.intValue(); - } - - private void insertGroupRole(int groupId, String role) { - dbTester.executeInsert("group_roles", "group_id", groupId, "role", role); - } - - private void addUserToGroup(int userId, int groupId) { - dbTester.executeInsert("groups_users", "user_id", userId, "group_id", groupId); - } - - private void verifySingleUser(String login, boolean root) { - List> rows = dbTester.select("select login as \"login\", is_root as \"isRoot\" from users"); - assertThat(rows).hasSize(1); - Map row = rows.iterator().next(); - assertThat(row.get("login")).isEqualTo(login); - assertThat(row.get("isRoot")).isEqualTo(root); - } - - private void verifyUser(String login, boolean root) { - Map row = dbTester.selectFirst("select login as \"login\", is_root as \"isRoot\" from users where login = '" + login + "'"); - assertThat(row.get("isRoot")).isEqualTo(root); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java deleted file mode 100644 index 0bf537597ff..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidOfGroupRolesTest { - - private static final String TABLE_GROUP_ROLES = "group_roles"; - private static final String AN_ORG_UUID = "org1"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidOfGroupRolesTest.class, "group_roles.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateOrganizationUuidOfGroupRoles underTest = new PopulateOrganizationUuidOfGroupRoles(dbTester.database()); - - @Test - public void execute_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - @Test - public void migration_populates_missing_organization_uuids() throws SQLException { - dbTester.executeInsert("group_roles", "group_id", "1", "role", "admin", "organization_uuid", null); - dbTester.executeInsert("group_roles", "group_id", "2", "role", "viewever", "organization_uuid", null); - dbTester.executeInsert("group_roles", "group_id", "3", "role", "viewever", "organization_uuid", AN_ORG_UUID); - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(3); - assertThat(dbTester.countSql("select count(1) from group_roles where organization_uuid='" + AN_ORG_UUID + "'")).isEqualTo(3); - } - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(0); - } - - private void insertDefaultOrganizationInternalProperty(String defaultOrganizationUuid) { - dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", defaultOrganizationUuid); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java deleted file mode 100644 index aeaf1e615b8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidOfGroupsTest { - - private static final String TABLE_GROUPS = "groups"; - private static final String AN_ORG_UUID = "org1"; - - private System2 system2 = new TestSystem2().setNow(1_500_000_000L); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidOfGroupsTest.class, "user_groups.sql"); - - private PopulateOrganizationUuidOfGroups underTest = new PopulateOrganizationUuidOfGroups(dbTester.database(), system2); - - @Test - public void execute_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void migration_populates_missing_organization_uuids() throws SQLException { - dbTester.executeInsert(TABLE_GROUPS, "name", "group1", "organization_uuid", null); - dbTester.executeInsert(TABLE_GROUPS, "name", "group2", "organization_uuid", null); - dbTester.executeInsert(TABLE_GROUPS, "name", "group3", "organization_uuid", AN_ORG_UUID); - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("groups")).isEqualTo(3); - assertThat(dbTester.countSql("select count(1) from groups where organization_uuid='" + AN_ORG_UUID + "'")).isEqualTo(3); - } - - @Test - public void execute_is_reentrant() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - dbTester.executeInsert(TABLE_GROUPS, "name", "group1"); - - underTest.execute(); - - underTest.execute(); - } - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("groups")).isEqualTo(0); - } - - private void insertDefaultOrganizationInternalProperty(String defaultOrganizationUuid) { - dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", defaultOrganizationUuid); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java deleted file mode 100644 index 9db77f74cd1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidOfPermissionTemplatesTest { - - private static final String TABLE_PERMISSION_TEMPLATES = "permission_templates"; - private static final String AN_ORG_UUID = "org1"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidOfPermissionTemplatesTest.class, "permission_templates.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateOrganizationUuidOfPermissionTemplates underTest = new PopulateOrganizationUuidOfPermissionTemplates(dbTester.database(), System2.INSTANCE); - - @Test - public void execute_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void migration_populates_missing_organization_uuids() throws SQLException { - dbTester.executeInsert(TABLE_PERMISSION_TEMPLATES, "kee", "t1", "name", "T1", "organization_uuid", null); - dbTester.executeInsert(TABLE_PERMISSION_TEMPLATES, "kee", "t2", "name", "T2", "organization_uuid", null); - dbTester.executeInsert(TABLE_PERMISSION_TEMPLATES, "kee", "t3", "name", "T3", "organization_uuid", AN_ORG_UUID); - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_PERMISSION_TEMPLATES)).isEqualTo(3); - assertThat(dbTester.countSql("select count(1) from permission_templates where organization_uuid='" + AN_ORG_UUID + "'")).isEqualTo(3); - } - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_PERMISSION_TEMPLATES)).isEqualTo(0); - } - - private void insertDefaultOrganizationInternalProperty(String defaultOrganizationUuid) { - dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", defaultOrganizationUuid); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java deleted file mode 100644 index 28b7585601b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidOfUserRolesTest { - - private static final String TABLE_USER_ROLES = "user_roles"; - private static final String AN_ORG_UUID = "org1"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidOfUserRolesTest.class, "user_roles.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateOrganizationUuidOfUserRoles underTest = new PopulateOrganizationUuidOfUserRoles(dbTester.database()); - - @Test - public void execute_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - @Test - public void migration_populates_missing_organization_uuids() throws SQLException { - dbTester.executeInsert("user_roles", "user_id", "1", "role", "admin", "organization_uuid", null); - dbTester.executeInsert("user_roles", "user_id", "2", "role", "viewever", "organization_uuid", null); - dbTester.executeInsert("user_roles", "user_id", "3", "role", "viewever", "organization_uuid", AN_ORG_UUID); - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(3); - assertThat(dbTester.countSql("select count(1) from user_roles where organization_uuid='" + AN_ORG_UUID + "'")).isEqualTo(3); - } - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(0); - } - - private void insertDefaultOrganizationInternalProperty(String defaultOrganizationUuid) { - dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", defaultOrganizationUuid); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java deleted file mode 100644 index 6c16418a017..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v62; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(DataProviderRunner.class) -public class UpdateQualityGateConditionsOnCoverageTest { - - private static final String TABLE_QUALITY_GATES = "quality_gates"; - private static final String TABLE_QUALITY_GATE_CONDITIONS = "quality_gate_conditions"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(UpdateQualityGateConditionsOnCoverageTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UpdateQualityGateConditionsOnCoverage underTest = new UpdateQualityGateConditionsOnCoverage(dbTester.database()); - - @Test - public void move_overall_coverage_condition_to_coverage() throws SQLException { - Map metricIdsByMetricKeys = insertSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("overall_coverage"), null, "GT", "10", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void move_overall_coverage_condition_to_coverage_when_overall_coverage_exists_condition_on_overall_coverage_exists() throws SQLException { - Map metricIdsByMetricKeys = insertSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("overall_coverage"), null, "GT", "10", null); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("coverage"), null, "LT", null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void remove_it_coverage_condition_when_overall_coverage_condition_exists_and_no_coverage_condition() throws Exception { - Map metricIdsByMetricKeys = insertSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("overall_coverage"), null, "GT", "10", null); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("it_coverage"), null, "LT", null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void keep_coverage_condition_when_no_overall_and_it_coverage() throws SQLException { - Map metricIdsByMetricKeys = insertSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("coverage"), null, "GT", "10", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void remove_it_coverage_condition_when_coverage_condition_exists_and_no_overall_coverage_condition() throws SQLException { - Map metricIdsByMetricKeys = insertSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("coverage"), null, "GT", "10", null); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("it_coverage"), null, "LT", null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void move_it_coverage_condition_to_coverage_when_only_it_coverage_condition() throws SQLException { - Map metricIdsByMetricKeys = insertSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("it_coverage"), null, "GT", "10", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void move_new_coverage_conditions() throws SQLException { - Map metricIdsByMetricKeys = insertMetrics("new_coverage", "new_overall_coverage", "new_it_coverage"); - long qualityGate1 = insertQualityGate("qualityGate1"); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get("new_coverage"), 1L, "GT", "10", null); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get("new_overall_coverage"), 1L, "GT", "7", "15"); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get("new_it_coverage"), 2L, "LT", "8", null); - long qualityGate2 = insertQualityGate("qualityGate2"); - insertQualityGateCondition(qualityGate2, metricIdsByMetricKeys.get("new_overall_coverage"), 2L, "GT", "15", null); - insertQualityGateCondition(qualityGate2, metricIdsByMetricKeys.get("new_it_coverage"), 2L, "GT", null, "5"); - long qualityGate3 = insertQualityGate("qualityGate3"); - insertQualityGateCondition(qualityGate3, metricIdsByMetricKeys.get("new_it_coverage"), 3L, "GT", null, "5"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(3); - verifyConditions(qualityGate1, new QualityGateCondition("new_coverage", 1L, "GT", "7", "15")); - verifyConditions(qualityGate2, new QualityGateCondition("new_coverage", 2L, "GT", "15", null)); - verifyConditions(qualityGate3, new QualityGateCondition("new_coverage", 3L, "GT", null, "5")); - } - - @DataProvider - public static Object[][] metricKeys() { - List metrics = ImmutableList.of( - "coverage", "lines_to_cover", "uncovered_lines", "line_coverage", "conditions_to_cover", "uncovered_conditions", "branch_coverage"); - Object[][] res = new Object[metrics.size()][3]; - int i = 0; - for (String metricKey : metrics) { - res[i][0] = metricKey; - res[i][1] = "overall_" + metricKey; - res[i][2] = "it_" + metricKey; - i++; - } - return res; - } - - @Test - @UseDataProvider("metricKeys") - public void move_conditions_from_many_quality_gates_on_all_metrics(String coverageKey, String overallCoverageKey, String itCoverageKey) throws SQLException { - Map metricIdsByMetricKeys = insertMetrics(coverageKey, overallCoverageKey, itCoverageKey, "other"); - long qualityGate1 = insertQualityGate("qualityGate1"); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get(coverageKey), null, "GT", "10", null); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get(overallCoverageKey), null, "GT", "7", "15"); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get(itCoverageKey), null, "LT", "8", null); - long qualityGate2 = insertQualityGate("qualityGate2"); - insertQualityGateCondition(qualityGate2, metricIdsByMetricKeys.get(overallCoverageKey), null, "GT", "15", null); - insertQualityGateCondition(qualityGate2, metricIdsByMetricKeys.get(itCoverageKey), null, "GT", null, "5"); - long qualityGate3 = insertQualityGate("qualityGate3"); - insertQualityGateCondition(qualityGate3, metricIdsByMetricKeys.get(itCoverageKey), null, "GT", null, "5"); - insertQualityGateCondition(qualityGate3, metricIdsByMetricKeys.get("other"), null, "GT", "11", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(4); - verifyConditions(qualityGate1, new QualityGateCondition(coverageKey, null, "GT", "7", "15")); - verifyConditions(qualityGate2, new QualityGateCondition(coverageKey, null, "GT", "15", null)); - verifyConditions(qualityGate3, new QualityGateCondition(coverageKey, null, "GT", null, "5"), new QualityGateCondition("other", null, "GT", "11", null)); - } - - @Test - public void does_not_update_conditions_on_none_related_coverage_metrics() throws Exception { - insertMetrics(); - long metric1 = insertMetric("metric1"); - long metric2 = insertMetric("metric2"); - long qualityGate1 = insertQualityGate("qualityGate1"); - insertQualityGateCondition(qualityGate1, metric1, null, "GT", "10", null); - long qualityGate2 = insertQualityGate("qualityGate2"); - insertQualityGateCondition(qualityGate2, metric2, null, "LT", null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(2); - verifyConditions(qualityGate1, new QualityGateCondition("metric1", null, "GT", "10", null)); - verifyConditions(qualityGate2, new QualityGateCondition("metric2", null, "LT", null, "20")); - } - - @Test - public void move_conditions_linked_to_same_metric() throws Exception { - insertMetric("coverage"); - long metricId = insertMetric("overall_coverage"); - long qualityGate = insertQualityGate("qualityGate"); - insertQualityGateCondition(qualityGate, metricId, null, "GT", "7", "15"); - insertQualityGateCondition(qualityGate, metricId, 1L, "GT", "10", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(2); - verifyConditions(qualityGate, - new QualityGateCondition("coverage", null, "GT", "7", "15"), - new QualityGateCondition("coverage", 1L, "GT", "10", null)); - } - - @Test - public void does_nothing_when_no_quality_gates() throws Exception { - insertMetrics("coverage", "new_coverage", "overall_coverage"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isZero(); - } - - @Test - public void does_nothing_when_no_metrics() throws Exception { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isZero(); - } - - private Map insertSampleMetrics() { - return insertMetrics("coverage", "overall_coverage", "it_coverage"); - } - - private Map insertMetrics(String... metrics) { - Map metricIdsByMetricKeys = new HashMap<>(); - for (String metricKey : metrics) { - metricIdsByMetricKeys.put(metricKey, insertMetric(metricKey)); - } - return metricIdsByMetricKeys; - } - - private long insertMetric(String key) { - dbTester.executeInsert("metrics", "NAME", key); - return (Long) dbTester.selectFirst(format("select id as \"id\" from metrics where name='%s'", key)).get("id"); - } - - private long insertQualityGate(String qualityGate) { - dbTester.executeInsert(TABLE_QUALITY_GATES, "NAME", qualityGate); - return (Long) dbTester.selectFirst(format("select id as \"id\" from %s where name='%s'", TABLE_QUALITY_GATES, qualityGate)).get("id"); - } - - private long insertQualityGateCondition(long qualityGateId, long metricId, @Nullable Long period, String operator, @Nullable String error, @Nullable String warning) { - Map values = new HashMap<>(ImmutableMap.of("QGATE_ID", qualityGateId, "METRIC_ID", metricId, "OPERATOR", operator)); - if (period != null) { - values.put("PERIOD", period); - } - if (error != null) { - values.put("VALUE_ERROR", error); - } - if (warning != null) { - values.put("VALUE_WARNING", warning); - } - dbTester.executeInsert(TABLE_QUALITY_GATE_CONDITIONS, values); - String sql = format("select id as \"id\" from %s where qgate_id='%s' and metric_id='%s'", TABLE_QUALITY_GATE_CONDITIONS, qualityGateId, metricId); - sql += period == null ? "" : format(" and period='%s'", period); - return (Long) dbTester - .selectFirst(sql) - .get("id"); - } - - private void verifyConditions(long qualityGateId, QualityGateCondition... expectedConditions) { - List> results = dbTester.select( - format("select m.name as \"metricKey\", qgc.period as \"period\", qgc.operator as \"operator\", qgc.value_error as \"error\", qgc.value_warning as \"warning\" from %s qgc " + - "inner join metrics m on m.id=qgc.metric_id " + - "where qgc.qgate_id = '%s'", TABLE_QUALITY_GATE_CONDITIONS, qualityGateId)); - List conditions = results.stream().map(QualityGateCondition::new).collect(Collectors.toList()); - assertThat(conditions).containsOnly(expectedConditions); - } - - private static class QualityGateCondition { - String metricKey; - Long period; - String operator; - String valueError; - String valueWarning; - - public QualityGateCondition(String metricKey, @Nullable Long period, String operator, @Nullable String valueError, @Nullable String valueWarning) { - this.metricKey = metricKey; - this.period = period; - this.operator = operator; - this.valueError = valueError; - this.valueWarning = valueWarning; - } - - QualityGateCondition(Map map) { - this.metricKey = (String) map.get("metricKey"); - this.period = (Long) map.get("period"); - this.operator = (String) map.get("operator"); - this.valueError = (String) map.get("error"); - this.valueWarning = (String) map.get("warning"); - } - - public String getMetricKey() { - return metricKey; - } - - @CheckForNull - public Long getPeriod() { - return period; - } - - public String getOperator() { - return operator; - } - - @CheckForNull - public String getValueError() { - return valueError; - } - - @CheckForNull - public String getValueWarning() { - return valueWarning; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QualityGateCondition that = (QualityGateCondition) o; - return new EqualsBuilder() - .append(metricKey, that.getMetricKey()) - .append(period, that.getPeriod()) - .append(operator, that.getOperator()) - .append(valueError, that.getValueError()) - .append(valueWarning, that.getValueWarning()) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(15, 31) - .append(metricKey) - .append(period) - .append(operator) - .append(valueError) - .append(valueWarning) - .toHashCode(); - } - - @Override - public String toString() { - return "QualityGateCondition{" + - "metricKey='" + metricKey + '\'' + - ", period=" + period + - ", operator=" + operator + - ", valueError='" + valueError + '\'' + - ", valueWarning='" + valueWarning + '\'' + - '}'; - } - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java deleted file mode 100644 index bb45ad75b1c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class AddColumnGuardedToOrganizationsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddColumnGuardedToOrganizationsTest.class, "previous-organizations.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddColumnGuardedToOrganizations underTest = new AddColumnGuardedToOrganizations(dbTester.database()); - - @Test - public void add_nullable_boolean_column_guarded_to_table_organizations() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("organizations", "guarded", Types.BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java deleted file mode 100644 index 5795c9b941a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class AddDefaultPermTemplateColumnsToOrganizationsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddDefaultPermTemplateColumnsToOrganizationsTest.class, "previous-organizations.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddDefaultPermTemplateColumnsToOrganizations underTest = new AddDefaultPermTemplateColumnsToOrganizations(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("organizations", "default_perm_template_project", Types.VARCHAR, 40, true); - dbTester.assertColumnDefinition("organizations", "default_perm_template_view", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java deleted file mode 100644 index 1156c321e1f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class AddIndexOnOrganizationUuidOfProjectsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnOrganizationUuidOfProjectsTest.class, "projects.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIndexOnOrganizationUuidOfProjects underTest = new AddIndexOnOrganizationUuidOfProjects(dbTester.database()); - - @Test - public void execute_adds_index_on_ORGANIZATION_UUID() throws SQLException { - underTest.execute(); - - dbTester.assertIndex("projects", "projects_organization", "organization_uuid"); - } - - @Test - public void execute_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java deleted file mode 100644 index 3883ded56dd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class AddOrganizationUuidToProjectsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToProjectsTest.class, "previous-projects.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToProjects underTest = new AddOrganizationUuidToProjects(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("projects", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java deleted file mode 100644 index 9ad69ad00f3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class AddUserIdToOrganizationsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddUserIdToOrganizationsTest.class, "previous-organizations.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUserIdToOrganizations underTest = new AddUserIdToOrganizations(dbTester.database()); - - @Test - public void add_nullable_integer_column_user_id_to_table_organizations() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("organizations", "user_id", Types.INTEGER, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} - diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java deleted file mode 100644 index b28b85cd705..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - - -public class AddUuidToEventsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddUuidToEventsTest.class, "previous-events.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUuidToEvents underTest = new AddUuidToEvents(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("events", "uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DbVersion63Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DbVersion63Test.java deleted file mode 100644 index 70786d01c80..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DbVersion63Test.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion63Test { - private DbVersion63 underTest = new DbVersion63(); - - @Test - public void verify_support_components() { - assertThat(underTest.getSupportComponents()) - .containsOnly(DefaultOrganizationUuidProviderImpl.class); - } - - @Test - public void migrationNumber_starts_at_1500() { - verifyMinimumMigrationNumber(underTest, 1500); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 19); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java deleted file mode 100644 index f5cb1a7dde7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import com.google.common.collect.ImmutableMap; -import java.nio.charset.StandardCharsets; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteMeasuresHavingNoValueTest { - - private static final String TABLE_MEASURES = "project_measures"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteMeasuresHavingNoValueTest.class, "project_measures.sql"); - - private DeleteMeasuresHavingNoValue underTest = new DeleteMeasuresHavingNoValue(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isZero(); - } - - @Test - public void migration_does_not_remove_measures_with_value() throws SQLException { - insertMeasure(5d, null, null, null); - insertMeasure(null, "text", null, null); - insertMeasure(null, null, "data", null); - insertMeasure(null, null, null, 50d); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(4); - } - - @Test - public void migration_removes_measures_with_no_values() throws SQLException { - insertMeasure(null, null, null, null); - insertMeasure(null, null, null, null); - insertMeasure(null, null, null, null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isZero(); - } - - @Test - public void migration_does_not_remove_measures_having_variation_on_leak_period() throws SQLException { - insertMeasureOnlyOnVariations(10d, null, null, null, null); - insertMeasureOnlyOnVariations(11d, 2d, null, null, null); - insertMeasureOnlyOnVariations(12d, null, 3d, 4d, 5d); - insertMeasureOnlyOnVariations(12d, 2d, 3d, 4d, 5d); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(4); - } - - @Test - public void migration_removes_measures_having_only_variation_on_periods2_to_5() throws SQLException { - insertMeasureOnlyOnVariations(null, 2d, null, null, null); - insertMeasureOnlyOnVariations(null, null, 3d, null, null); - insertMeasureOnlyOnVariations(null, null, null, 4d, null); - insertMeasureOnlyOnVariations(null, null, null, null, 5d); - insertMeasureOnlyOnVariations(null, 2d, 3d, 4d, 5d); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isZero(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMeasure(5d, null, null, null); - insertMeasure(null, "text", null, null); - insertMeasure(null, null, null, null); - insertMeasure(null, null, null, null); - - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(2); - - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(2); - } - - private void insertMeasure(@Nullable Double value, @Nullable String textValue, @Nullable String data, @Nullable Double variation) { - Map values = new HashMap<>(ImmutableMap.builder() - .put("METRIC_ID", valueOf(10)) - .put("COMPONENT_UUID", randomAlphanumeric(10)) - .put("ANALYSIS_UUID", randomAlphanumeric(10)) - .put("VARIATION_VALUE_2", 2d) - .put("VARIATION_VALUE_3", 3d) - .put("VARIATION_VALUE_4", 4d) - .put("VARIATION_VALUE_5", 5d) - .build()); - if (value != null) { - values.put("VALUE", valueOf(value)); - } - if (textValue != null) { - values.put("TEXT_VALUE", textValue); - } - if (variation != null) { - values.put("VARIATION_VALUE_1", variation); - } - if (data != null) { - values.put("MEASURE_DATA", data.getBytes(StandardCharsets.UTF_8)); - } - db.executeInsert(TABLE_MEASURES, values); - } - - private void insertMeasureOnlyOnVariations(@Nullable Double variation1, @Nullable Double variation2, @Nullable Double variation3, @Nullable Double variation4, - @Nullable Double variation5) { - Map values = new HashMap<>(ImmutableMap.of( - "METRIC_ID", valueOf(20), - "COMPONENT_UUID", randomAlphanumeric(10), - "ANALYSIS_UUID", randomAlphanumeric(10))); - if (variation1 != null) { - values.put("VARIATION_VALUE_1", valueOf(variation1)); - } - if (variation2 != null) { - values.put("VARIATION_VALUE_2", valueOf(variation2)); - } - if (variation3 != null) { - values.put("VARIATION_VALUE_3", valueOf(variation3)); - } - if (variation4 != null) { - values.put("VARIATION_VALUE_4", valueOf(variation4)); - } - if (variation5 != null) { - values.put("VARIATION_VALUE_4", valueOf(variation5)); - } - db.executeInsert(TABLE_MEASURES, values); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java deleted file mode 100644 index 9a937a997e8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteUselessPropertiesTest { - - private static final String TABLE_PROPERTIES = "properties"; - private static final int COMPONENT_ID_1 = 125; - private static final int COMPONENT_ID_2 = 604; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteUselessPropertiesTest.class, "properties.sql"); - - private DeleteUselessProperties underTest = new DeleteUselessProperties(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_removes_hours_in_day_setting() throws SQLException { - insertProperty("sonar.technicalDebt.hoursInDay", null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_removes_create_user_setting() throws SQLException { - insertProperty("sonar.authenticator.createUser", null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_removes_period2_to_period5_settings() throws SQLException { - insertProperty("sonar.timemachine.period2", null); - insertProperty("sonar.timemachine.period3", null); - insertProperty("sonar.timemachine.period4", null); - insertProperty("sonar.timemachine.period5", null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_removes_period2_to_period5_settings_related_to_component() throws SQLException { - insertProperty("sonar.timemachine.period2", COMPONENT_ID_1); - insertProperty("sonar.timemachine.period2", COMPONENT_ID_1); - insertProperty("sonar.timemachine.period2", COMPONENT_ID_2); - insertProperty("sonar.timemachine.period3", COMPONENT_ID_1); - insertProperty("sonar.timemachine.period4", COMPONENT_ID_2); - insertProperty("sonar.timemachine.period5", COMPONENT_ID_2); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_removes_period2_to_period5_settings_related_to_qualifiers() throws SQLException { - insertProperty("sonar.timemachine.period2.TRK", COMPONENT_ID_1); - insertProperty("sonar.timemachine.period2.TRK", null); - insertProperty("sonar.timemachine.period2.VW", COMPONENT_ID_1); - insertProperty("sonar.timemachine.period2.DEV", COMPONENT_ID_1); - insertProperty("sonar.timemachine.period2", COMPONENT_ID_1); - insertProperty("sonar.timemachine.period3", COMPONENT_ID_2); - insertProperty("sonar.timemachine.period3.TRK", COMPONENT_ID_2); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_ignores_not_relevant_settings() throws SQLException { - insertProperty("sonar.core.serverBaseURL", null); - insertProperty("sonar.dbcleaner.cleanDirectory", null); - insertProperty("sonar.dbcleaner.cleanDirectory", COMPONENT_ID_1); - // Only these settings should be removed - insertProperty("sonar.timemachine.period4", null); - insertProperty("sonar.timemachine.period5", null); - - underTest.execute(); - - verifyPropertyKeys("sonar.core.serverBaseURL", "sonar.dbcleaner.cleanDirectory"); - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProperty("sonar.core.serverBaseURL", null); - insertProperty("sonar.dbcleaner.cleanDirectory", null); - insertProperty("sonar.dbcleaner.cleanDirectory", COMPONENT_ID_1); - // Only these settings should be removed - insertProperty("sonar.timemachine.period4", null); - insertProperty("sonar.timemachine.period5", null); - - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(3); - - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(3); - } - - private void insertProperty(String key, @Nullable Integer componentId) { - Map values = new HashMap<>(ImmutableMap.of( - "PROP_KEY", key, - "IS_EMPTY", false, - "CREATED_AT", 456789)); - if (componentId != null) { - values.put("RESOURCE_ID", valueOf(componentId)); - } - db.executeInsert(TABLE_PROPERTIES, values); - } - - private void verifyPropertyKeys(String... propertyKeys) { - List> rows = db.select("select prop_key from " + TABLE_PROPERTIES); - Set result = rows.stream().map(cols -> (String)cols.get("PROP_KEY")).collect(Collectors.toSet()); - assertThat(result).containsOnly(propertyKeys); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java deleted file mode 100644 index 9528aa04b11..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropTableResourceIndexTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTableResourceIndexTest.class, "schema.sql"); - - private DropTableResourceIndex underTest = new DropTableResourceIndex(db.database()); - - @Test - public void should_drop_table() throws SQLException { - underTest.execute(); - - db.assertTableDoesNotExist("resource_index"); - } - - @Test - public void migration_is_reentrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("resource_index"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java deleted file mode 100644 index 6e0c90ee850..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.sql.Types; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -public class MakeColumnGuardedOfOrganizationsNotNullableTest { - private static final String TABLE_ORGANIZATIONS = "organizations"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MakeColumnGuardedOfOrganizationsNotNullableTest.class, "organizations_with_nullable_guarded.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeColumnGuardedOfOrganizationsNotNullable underTest = new MakeColumnGuardedOfOrganizationsNotNullable(dbTester.database()); - - @Test - public void migration_sets_guarded_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_guarded_column_not_nullable_on_populated_table() throws SQLException { - insertOrganization("org_A", true); - insertOrganization("org_B", false); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_guarded() throws SQLException { - insertOrganization("org_c", null); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "guarded", Types.BOOLEAN, null, false); - } - - private void insertOrganization(String uuid, @Nullable Boolean guarded) { - dbTester.executeInsert( - "ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", guarded == null ? null : String.valueOf(guarded), - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java deleted file mode 100644 index 6999c9a4fdc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MakeDefaultOrganizationGuardedTest { - - private static final String TABLE_ORGANIZATIONS = "organizations"; - private static final String DEFAULT_ORGANIZATION_UUID = "def-org"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeDefaultOrganizationGuardedTest.class, "organizations_and_internal_properties.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeDefaultOrganizationGuarded underTest = new MakeDefaultOrganizationGuarded(db.database(), new DefaultOrganizationUuidProviderImpl()); - - @Test - public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void fails_with_ISE_when_default_organization_does_not_exist_in_table_ORGANIZATIONS() throws SQLException { - insertDefaultOrganizationUuid("blabla"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization with uuid 'blabla' does not exist in table ORGANIZATIONS"); - - underTest.execute(); - } - - @Test - public void execute_sets_guarded_of_non_guarded_default_organization_to_true() throws Exception { - setupDefaultOrganization(); - assertThat(isDefaultOrganizationGuarded()).isFalse(); - - underTest.execute(); - - assertThat(isDefaultOrganizationGuarded()).isTrue(); - } - - @Test - public void execute_is_reentrant() throws Exception { - setupDefaultOrganization(); - - underTest.execute(); - - underTest.execute(); - - assertThat(isDefaultOrganizationGuarded()).isTrue(); - } - - private void setupDefaultOrganization() { - insertDefaultOrganizationUuid(DEFAULT_ORGANIZATION_UUID); - insertOrganization(DEFAULT_ORGANIZATION_UUID); - } - - private boolean isDefaultOrganizationGuarded() throws Exception { - try (Connection connection = db.openConnection(); - PreparedStatement selectGuardedForUuidStatement = createSelectGuardedForUuidStatement(connection, DEFAULT_ORGANIZATION_UUID); - ResultSet resultSet = selectGuardedForUuidStatement.executeQuery()) { - assertThat(resultSet.next()).isTrue(); - boolean res = resultSet.getBoolean(1); - assertThat(resultSet.next()).isFalse(); - return res; - } - } - - private static PreparedStatement createSelectGuardedForUuidStatement(Connection connection, String uuid) throws Exception { - PreparedStatement preparedStatement = connection.prepareStatement("select guarded from organizations where uuid=?"); - preparedStatement.setString(1, uuid); - return preparedStatement; - } - - private void insertOrganization(String uuid) { - db.executeInsert( - TABLE_ORGANIZATIONS, - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", String.valueOf(false), - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - } - - private void insertDefaultOrganizationUuid(String defaultOrganizationUuid) { - db.executeInsert( - "INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", defaultOrganizationUuid); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueReentranceTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueReentranceTest.java deleted file mode 100644 index df5cc8210ff..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueReentranceTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class MakeIndexOnOrganizationsKeeUniqueReentranceTest { - private static final String TABLE_ORGANIZATIONS = "organizations"; - private static final String INDEX_NAME = "organization_key"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MakeIndexOnOrganizationsKeeUniqueReentranceTest.class, "organizations_with_unique_index.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeIndexOnOrganizationsKeeUnique underTest = new MakeIndexOnOrganizationsKeeUnique(dbTester.database()); - - @Test - public void execute_makes_index_unique_on_empty_table() throws SQLException { - dbTester.assertIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - - underTest.execute(); - - dbTester.assertUniqueIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - } - - @Test - public void execute_makes_index_unique_on_non_empty_table_without_duplicates() throws SQLException { - dbTester.assertIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - insert("1", "kee_1"); - insert("2", "kee_2"); - - underTest.execute(); - - dbTester.assertUniqueIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - } - - @Test - public void execute_fails_non_empty_table_with_duplicates() throws SQLException { - dbTester.assertIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - insert("1", "kee_1"); - insert("2", "kee_1"); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - - private void insert(String uuid, String kee) { - dbTester.executeInsert(TABLE_ORGANIZATIONS, - "UUID", uuid, - "KEE", kee, - "NAME", "name", - "GUARDED", "false", - "CREATED_AT", "1000", - "UPDATED_AT", "2000"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueTest.java deleted file mode 100644 index ec4599176b0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class MakeIndexOnOrganizationsKeeUniqueTest { - private static final String TABLE_ORGANIZATIONS = "organizations"; - private static final String INDEX_NAME = "organization_key"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MakeIndexOnOrganizationsKeeUniqueTest.class, "organizations_with_non_unique_index.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeIndexOnOrganizationsKeeUnique underTest = new MakeIndexOnOrganizationsKeeUnique(dbTester.database()); - - @Test - public void execute_makes_index_unique_on_empty_table() throws SQLException { - dbTester.assertIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - - underTest.execute(); - - dbTester.assertUniqueIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - } - - @Test - public void execute_makes_index_unique_on_non_empty_table_without_duplicates() throws SQLException { - dbTester.assertIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - insert("1", "kee_1"); - insert("2", "kee_2"); - - underTest.execute(); - - dbTester.assertUniqueIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - } - - @Test - public void execute_fails_non_empty_table_with_duplicates() throws SQLException { - dbTester.assertIndex(TABLE_ORGANIZATIONS, INDEX_NAME, "kee"); - insert("1", "kee_1"); - insert("2", "kee_1"); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - - private void insert(String uuid, String kee) { - dbTester.executeInsert(TABLE_ORGANIZATIONS, - "UUID", uuid, - "KEE", kee, - "NAME", "name", - "GUARDED", "false", - "CREATED_AT", "1000", - "UPDATED_AT", "2000"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java deleted file mode 100644 index 03837743845..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.sql.Types; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeOrganizationUuidOfProjectsNotNullableTest { - private static final String TABLE_PROJECTS = "projects"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidToProjectsTest.class, "projects_with_nullable_organization.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidOfProjectsNotNullable underTest = new MakeOrganizationUuidOfProjectsNotNullable(dbTester.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertComponent("org_A", 1); - insertComponent("org_B", 2); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertComponent(null, 1); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - dbTester.assertColumnDefinition(TABLE_PROJECTS, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertComponent(@Nullable String organizationUuid, int id) { - String uuid = "uuid_" + id; - dbTester.executeInsert( - "projects", - "ID", valueOf(id), - "ORGANIZATION_UUID", organizationUuid, - "UUID", uuid, - "ROOT_UUID", uuid, - "PROJECT_UUID", uuid, - "UUID_PATH", uuid + "."); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java deleted file mode 100644 index 63abbbd1ddf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; - -public class MakeUuidNotNullOnEventsTest { - - private static final String TABLE_EVENTS = "events"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeUuidNotNullOnEventsTest.class, "in_progress_events.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeUuidNotNullOnEvents underTest = new MakeUuidNotNullOnEvents(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertEvent(1, true); - insertEvent(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertEvent(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_EVENTS, "uuid", Types.VARCHAR, 40, false); - } - - private String insertEvent(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_EVENTS, - "ID", valueOf(id), - "ANALYSIS_UUID", valueOf(id + 10), - "COMPONENT_UUID", valueOf(id + 100), - "CREATED_AT", id, - "EVENT_DATE", id, - "UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java deleted file mode 100644 index 236c476f7ca..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateColumnGuardedOfOrganizationsTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateColumnGuardedOfOrganizationsTest.class, "organizations.sql"); - - private PopulateColumnGuardedOfOrganizations underTest = new PopulateColumnGuardedOfOrganizations(dbTester.database()); - - @Test - public void execute_has_no_effect_when_table_is_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_is_reentrant_when_table_is_empty() throws SQLException { - underTest.execute(); - - underTest.execute(); - } - - @Test - public void execute_sets_is_protected_to_false_for_all_rows() throws SQLException { - insertOrganization("u1", null); - insertOrganization("u2", null); - - underTest.execute(); - - assertThat(dbTester.countSql("select count(*) from organizations where guarded is null")).isEqualTo(0); - assertThat(dbTester.countSql("select count(*) from organizations where guarded is not null")).isEqualTo(2); - assertThat(dbTester.countSql("select count(*) from organizations where guarded=false")).isEqualTo(2); - } - - @Test - public void execute_is_reentrant_when_table_had_data() throws SQLException { - insertOrganization("u1", true); - insertOrganization("u2", null); - - underTest.execute(); - - assertThat(dbTester.countSql("select count(*) from organizations where guarded is null")).isEqualTo(0); - assertThat(dbTester.countSql("select count(*) from organizations where guarded is not null")).isEqualTo(2); - assertThat(dbTester.countSql("select count(*) from organizations where guarded=false")).isEqualTo(1); - assertThat(dbTester.countSql("select count(*) from organizations where guarded=true")).isEqualTo(1); - - underTest.execute(); - } - - @Test - public void execute_is_reentrant_when_table_had_partially_migrated_data() throws SQLException { - insertOrganization("u1", false); - insertOrganization("u2", null); - - underTest.execute(); - } - - private void insertOrganization(String uuid, @Nullable Boolean guarded) { - dbTester.executeInsert( - "ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", guarded == null ? null : String.valueOf(guarded), - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java deleted file mode 100644 index 1e4aa2b6cc8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import com.google.common.collect.ImmutableList; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateDefaultPermTemplateColumnsOfOrganizationsTest { - private static final String DEFAULT_TEMPLATE_PROPERTY = "sonar.permission.template.default"; - private static final String DEFAULT_PROJECT_TEMPLATE_PROPERTY = "sonar.permission.template.TRK.default"; - private static final String DEFAULT_VIEW_TEMPLATE_PROPERTY = "sonar.permission.template.VW.default"; - private static final String DEFAULT_DEV_TEMPLATE_PROPERTY = "sonar.permission.template.DEV.default"; - private static final String DEFAULT_ORGANIZATION_UUID = "def org uuid"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateDefaultPermTemplateColumnsOfOrganizationsTest.class, "properties_and_organizations.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RecordingUuidFactory recordingUuidFactory = new RecordingUuidFactory(); - private PopulateDefaultPermTemplateColumnsOfOrganizations underTest = new PopulateDefaultPermTemplateColumnsOfOrganizations(dbTester.database(), - new DefaultOrganizationUuidProviderImpl(), recordingUuidFactory); - - @After - public void clearRecordingUuidFactory() { - recordingUuidFactory.clear(); - } - - @Test - public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void fails_with_ISE_when_default_organization_does_not_exist_in_table_ORGANIZATIONS() throws SQLException { - insertDefaultOrganizationUuid("blabla"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization with uuid 'blabla' does not exist in table ORGANIZATIONS"); - - underTest.execute(); - } - - @Test - public void fails_with_ISE_when_more_than_one_organization_exist() throws SQLException { - setupDefaultOrganization(); - - insertOrganization("other orga uuid"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Can not migrate DB if more than one organization exists. " + - "Remove all organizations but the default one which uuid is '" + DEFAULT_ORGANIZATION_UUID + "'"); - - underTest.execute(); - } - - @Test - public void do_nothing_if_global_default_template_property_does_not_exist() throws SQLException { - setupDefaultOrganization(); - - underTest.execute(); - - verifyTemplateColumns(null, null); - verifyPropertiesDoNotExist(); - } - - @Test - public void execute_sets_project_perm_template_when_global_default_template_is_defined_in_property() throws SQLException { - setupDefaultOrganization(); - insertProperty(DEFAULT_TEMPLATE_PROPERTY, "foo"); - - underTest.execute(); - - verifyTemplateColumns("foo", null); - verifyPropertiesDoNotExist(); - } - - @Test - public void execute_sets_project_perm_template_from_project_default_template_property_over_global_property() throws SQLException { - setupDefaultOrganization(); - insertProperty(DEFAULT_TEMPLATE_PROPERTY, "foo"); - insertProperty(DEFAULT_PROJECT_TEMPLATE_PROPERTY, "bar"); - - underTest.execute(); - - verifyTemplateColumns("bar", null); - verifyPropertiesDoNotExist(); - } - - @Test - public void execute_sets_project_perm_template_from_global_property_and_view_perm_template_from_view_property() throws SQLException { - setupDefaultOrganization(); - insertProperty(DEFAULT_TEMPLATE_PROPERTY, "foo"); - insertProperty(DEFAULT_VIEW_TEMPLATE_PROPERTY, "bar"); - - underTest.execute(); - - verifyTemplateColumns("foo", "bar"); - verifyPropertiesDoNotExist(); - } - - @Test - public void execute_should_update_kee_when_old_kee_is_too_long() throws SQLException { - setupDefaultOrganization(); - insertProperty(DEFAULT_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(100))); - insertProperty(DEFAULT_VIEW_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(100))); - insertProperty(DEFAULT_PROJECT_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(100))); - insertProperty(DEFAULT_DEV_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(100))); - - underTest.execute(); - - verifyTemplateColumns(recordingUuidFactory.getRecordedUuids().get(0), recordingUuidFactory.getRecordedUuids().get(1)); - verifyPropertiesDoNotExist(); - verifyExistenceOfPermissionTemplate(recordingUuidFactory.getRecordedUuids().get(0)); - verifyExistenceOfPermissionTemplate(recordingUuidFactory.getRecordedUuids().get(1)); - } - - @Test - public void execute_should_update_kee_only_when_old_kee_length_is_41_or_more() throws SQLException { - setupDefaultOrganization(); - insertProperty(DEFAULT_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(40))); - insertProperty(DEFAULT_VIEW_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(40))); - insertProperty(DEFAULT_PROJECT_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(40))); - insertProperty(DEFAULT_DEV_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(40))); - - underTest.execute(); - - assertThat(recordingUuidFactory.getRecordedUuids()).isEmpty(); - - insertProperty(DEFAULT_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(41))); - insertProperty(DEFAULT_VIEW_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(41))); - insertProperty(DEFAULT_PROJECT_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(41))); - insertProperty(DEFAULT_DEV_TEMPLATE_PROPERTY, insertPermissionTemplates(randomAlphanumeric(41))); - - underTest.execute(); - - assertThat(recordingUuidFactory.getRecordedUuids()).hasSize(2); - } - - @Test - public void execute_sets_project_from_project_property_and_view_from_view_property_when_all_properties_are_defined() throws SQLException { - setupDefaultOrganization(); - insertProperty(DEFAULT_TEMPLATE_PROPERTY, "foo"); - insertProperty(DEFAULT_PROJECT_TEMPLATE_PROPERTY, "bar"); - insertProperty(DEFAULT_VIEW_TEMPLATE_PROPERTY, "doh"); - - underTest.execute(); - - verifyTemplateColumns("bar", "doh"); - verifyPropertiesDoNotExist(); - } - - @Test - public void execute_deletes_dev_property_when_it_is_defined() throws SQLException { - setupDefaultOrganization(); - insertProperty(DEFAULT_TEMPLATE_PROPERTY, "foo"); - insertProperty(DEFAULT_DEV_TEMPLATE_PROPERTY, "bar"); - - underTest.execute(); - - verifyPropertiesDoNotExist(); - } - - private void verifyTemplateColumns(@Nullable String project, @Nullable String view) { - Map row = dbTester.selectFirst("select " + - " default_perm_template_project as \"projectDefaultPermTemplate\"," + - " default_perm_template_view as \"viewDefaultPermTemplate\"" + - " from organizations where uuid='" + DEFAULT_ORGANIZATION_UUID + "'"); - assertThat(row.get("projectDefaultPermTemplate")).isEqualTo(project); - assertThat(row.get("viewDefaultPermTemplate")).isEqualTo(view); - } - - @Test - public void migration_is_reentrant() throws SQLException { - setupDefaultOrganization(); - insertProperty(DEFAULT_TEMPLATE_PROPERTY, "foo"); - - underTest.execute(); - - underTest.execute(); - } - - private void verifyPropertiesDoNotExist() { - verifyPropertyDoesNotExist(DEFAULT_TEMPLATE_PROPERTY); - verifyPropertyDoesNotExist(DEFAULT_PROJECT_TEMPLATE_PROPERTY); - verifyPropertyDoesNotExist(DEFAULT_VIEW_TEMPLATE_PROPERTY); - verifyPropertyDoesNotExist(DEFAULT_DEV_TEMPLATE_PROPERTY); - } - - private void verifyPropertyDoesNotExist(String globalPermissionTemplateDefault) { - assertThat(dbTester.countSql("select count(*) as \"cnt\" from PROPERTIES where prop_key='" + globalPermissionTemplateDefault + "'")) - .isEqualTo(0); - } - - private void verifyExistenceOfPermissionTemplate(String kee) { - assertThat(dbTester.countSql("select count(kee) from permission_templates where kee='" + kee +"'")).isEqualTo(1); - } - - private void setupDefaultOrganization() { - insertDefaultOrganizationUuid(DEFAULT_ORGANIZATION_UUID); - insertOrganization(DEFAULT_ORGANIZATION_UUID); - } - - private void insertOrganization(String uuid) { - dbTester.executeInsert( - "ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - } - - private String insertPermissionTemplates(String kee) { - dbTester.executeInsert( - "PERMISSION_TEMPLATES", - "ORGANIZATION_UUID", DEFAULT_ORGANIZATION_UUID, - "NAME", randomAlphanumeric(50), - "KEE", kee, - "DESCRIPTION", randomAlphanumeric(500), - "KEY_PATTERN", "", - "CREATED_AT", new Timestamp(1000L), - "UPDATED_AT", new Timestamp(1000L)); - - return kee; - } - - private void insertDefaultOrganizationUuid(String defaultOrganizationUuid) { - dbTester.executeInsert( - "INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", defaultOrganizationUuid); - } - - private void insertProperty(String key, @Nullable String value) { - dbTester.executeInsert( - "PROPERTIES", - "PROP_KEY", key, - "IS_EMPTY", String.valueOf(value == null), - "TEXT_VALUE", value); - } - - private static final class RecordingUuidFactory implements UuidFactory { - private final List generatedUuids = new ArrayList<>(); - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - @Override - public String create() { - String uuid = uuidFactory.create(); - generatedUuids.add(uuid); - return uuid; - } - - public void clear() { - generatedUuids.clear(); - } - - public List getRecordedUuids() { - return ImmutableList.copyOf(generatedUuids); - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java deleted file mode 100644 index 8983a086026..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidToProjectsTest { - - private static final String ORGANIZATION_UUID = "some uuid"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidToProjectsTest.class, "projects_with_nullable_organization.sql"); - - private PopulateOrganizationUuidToProjects underTest = new PopulateOrganizationUuidToProjects(dbTester.database(), new TestDefaultOrganizationUuidProvider(ORGANIZATION_UUID)); - - @Test - public void execute_has_no_effect_when_table_is_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_is_reentrant_when_table_is_empty() throws SQLException { - underTest.execute(); - - underTest.execute(); - } - - @Test - public void execute_adds_organization_uuid_to_all_rows() throws SQLException { - String root1 = insertRootComponent(1); - insertComponent(11, root1); - insertComponent(12, root1); - String root2 = insertRootComponent(2); - for (int i = 0; i < 100; i++) { - insertComponent(100 + i, root2); - } - // no child root - insertRootComponent(3); - // non root row which root does not exist - insertComponent(4, "non_existent_parent"); - int rowCount = dbTester.countRowsOfTable("projects"); - - underTest.execute(); - - String sql = "select count(*) from projects where organization_uuid is null"; - assertThat(countValueOf(sql)).isEqualTo(0); - assertThat(countValueOf("select count(*) from projects where organization_uuid = '" + ORGANIZATION_UUID + "'")).isEqualTo(rowCount); - } - - @Test - public void execute_is_reentrant_when_table_had_data() throws SQLException { - String root1 = insertRootComponent(1); - insertComponent(11, root1); - insertComponent(12, root1); - insertRootComponent(2); - - underTest.execute(); - - underTest.execute(); - } - - private Long countValueOf(String sql) { - return (Long) dbTester.select(sql).get(0).entrySet().iterator().next().getValue(); - } - - private String insertRootComponent(int id) { - String uuid = "uuid_" + id; - dbTester.executeInsert( - "projects", - "ID", valueOf(id), - "UUID", uuid, - "ROOT_UUID", uuid, - "PROJECT_UUID", uuid, - "UUID_PATH", uuid + "."); - return uuid; - } - - private String insertComponent(int id, String project_uuid) { - String uuid = "uuid_" + id; - dbTester.executeInsert( - "projects", - "ID", valueOf(id), - "UUID", uuid, - "ROOT_UUID", project_uuid, - "PROJECT_UUID", project_uuid, - "UUID_PATH", uuid + "." + project_uuid); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java deleted file mode 100644 index f730686014e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import org.apache.commons.lang.StringUtils; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryImpl; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUuidColumnOfEventsTest { - - private static final String TABLE_EVENTS = "events"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidColumnOfEventsTest.class, "in_progress_events.sql"); - - private PopulateUuidColumnOfEvents underTest = new PopulateUuidColumnOfEvents(db.database(), UuidFactoryImpl.INSTANCE); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_EVENTS)).isEqualTo(0); - } - - @Test - public void migration_generates_uuids() throws SQLException { - insertEvents(1); - insertEvents(2); - insertEvents(3); - - underTest.execute(); - - verifyUuids(3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertEvents(1); - - underTest.execute(); - verifyUuids(1); - - underTest.execute(); - verifyUuids(1); - } - - private void verifyUuids(int expectedCount) { - List> rows = db.select("select uuid from events where uuid is not null"); - Set uuids = rows.stream().map(cols -> cols.get("UUID")).filter(uuid -> StringUtils.isNotBlank((String) uuid)).collect(Collectors.toSet()); - assertThat(uuids).hasSize(expectedCount); - } - - private String insertEvents(long id) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_EVENTS, - "ID", valueOf(id), - "COMPONENT_UUID", valueOf(id + 10), - "ANALYSIS_UUID", valueOf(id + 100), - "EVENT_DATE", 123456, - "CREATED_AT", 456789); - return uuid; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java deleted file mode 100644 index e26d65919a2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v63; - -import java.sql.SQLException; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class UnsetUserRootFlagsTest { - - private static final long CREATED_AT = 1_500L; - private static final long FIXED_AT = 1_600L; - - private TestSystem2 system = new TestSystem2().setNow(FIXED_AT); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(UnsetUserRootFlagsTest.class, "in_progress_users.sql"); - - private UnsetUserRootFlags underTest = new UnsetUserRootFlags(db.database(), system); - - @Test - public void sets_USERS_IS_ROOT_to_false() throws SQLException { - createUser("root1", true); - createUser("nonRoot1", false); - createUser("root2", true); - createUser("nonRoot2", false); - - underTest.execute(); - - verifyNotRoot(CREATED_AT, "nonRoot1", "nonRoot2"); - verifyNotRoot(FIXED_AT, "root1", "root2"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - createUser("root", true); - - underTest.execute(); - verifyNotRoot(FIXED_AT, "root"); - - system.setNow(FIXED_AT + 100L); - underTest.execute(); - verifyNotRoot(FIXED_AT, "root"); - } - - private void verifyNotRoot(long updatedAt, String... logins) { - for (String login : logins) { - Map row = db.selectFirst("select is_root as \"isRoot\", updated_at as \"updatedAt\" from users where login='" + login + "'"); - assertThat(row.get("isRoot")).isEqualTo(false); - assertThat(row.get("updatedAt")).isEqualTo(updatedAt); - } - } - - private String createUser(String login, boolean isRoot) { - db.executeInsert("users", - "login", login, - "is_root", isRoot, - "created_at", CREATED_AT, - "updated_at", CREATED_AT); - return login; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCountTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCountTest.java deleted file mode 100644 index d36693af57d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCountTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddCeActivityWorkerUuidAndExecutionCountTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddCeActivityWorkerUuidAndExecutionCountTest.class, "ce_activity.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddCeActivityWorkerUuidAndExecutionCount underTest = new AddCeActivityWorkerUuidAndExecutionCount(db.database()); - - @Test - public void execute_adds_columns_worker_uuid_and_processing_count() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_activity", "worker_uuid", Types.VARCHAR, 40, true); - db.assertColumnDefinition("ce_activity", "execution_count", Types.INTEGER, null, true); - } - - @Test - public void execute_is_not_reentreant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCountTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCountTest.java deleted file mode 100644 index b8030edc0fa..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCountTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddCeQueueWorkerUuidAndExecutionCountTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddCeQueueWorkerUuidAndExecutionCountTest.class, "ce_queue.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddCeQueueWorkerUuidAndExecutionCount underTest = new AddCeQueueWorkerUuidAndExecutionCount(db.database()); - - @Test - public void execute_adds_columns_worker_uuid_and_processing_count() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_queue", "worker_uuid", Types.VARCHAR, 40, true); - db.assertColumnDefinition("ce_queue", "execution_count", Types.INTEGER, null, true); - } - - @Test - public void execute_is_not_reentreant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivateTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivateTest.java deleted file mode 100644 index f22a31dab0a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivateTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddColumnNewProjectPrivateTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddColumnNewProjectPrivateTest.class, "organizations_without_new_project_private_column.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddColumnNewProjectPrivate underTest = new AddColumnNewProjectPrivate(db.database()); - - @Test - public void execute_adds_nullable_boolean_column_private_to_table_PROJECTS() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("organizations", "new_project_private", Types.BOOLEAN, null, true); - } - - @Test - public void execute_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivateTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivateTest.java deleted file mode 100644 index 644694331f1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivateTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddColumnProjectsPrivateTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddColumnProjectsPrivateTest.class, "projects_without_private_column.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddColumnProjectsPrivate underTest = new AddColumnProjectsPrivate(db.database()); - - @Test - public void execute_adds_nullable_boolean_column_private_to_table_PROJECTS() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("projects", "private", Types.BOOLEAN, null, true); - } - - @Test - public void execute_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizationsTest.java deleted file mode 100644 index 3a683a55c04..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizationsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.INTEGER; - -public class AddDefaultGroupIdToOrganizationsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddDefaultGroupIdToOrganizationsTest.class, "previous-organizations.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddDefaultGroupIdToOrganizations underTest = new AddDefaultGroupIdToOrganizations(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("organizations", "default_group_id", INTEGER, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesTypeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesTypeTest.java deleted file mode 100644 index 39d7480963a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesTypeTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddIndexLoadedTemplatesTypeTest { - private static final String TABLE_LOADED_TEMPLATES = "loaded_templates"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexLoadedTemplatesTypeTest.class, "loaded_templates_without_index.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIndexLoadedTemplatesType underTest = new AddIndexLoadedTemplatesType(db.database()); - - @Test - public void execute_adds_index_ix_loaded_templates_type() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_LOADED_TEMPLATES, "ix_loaded_templates_type", "template_type"); - } - - @Test - public void execute_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParametersTest.java deleted file mode 100644 index cf112954687..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParametersTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddIndexOnActiveRuleParametersTest { - - private static final String TABLE = "active_rule_parameters"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnActiveRuleParametersTest.class, "active_rule_parameters_without_index.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIndexOnActiveRuleParameters underTest = new AddIndexOnActiveRuleParameters(db.database()); - - @Test - public void execute_adds_index() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE, "ix_arp_on_active_rule_id", "active_rule_id"); - } - - @Test - public void execute_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuidTest.java deleted file mode 100644 index 2b5c2a903a7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuidTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class AddQualityProfileOrganizationUuidTest { - - /** @see org.sonar.db.AbstractDbTester#assertColumnDefinition(String, String, int, Integer, Boolean) */ - private static final boolean NULLABLE = true; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddQualityProfileOrganizationUuidTest.class, "initial.sql"); - - public AddQualityProfileOrganizationUuid underTest = new AddQualityProfileOrganizationUuid(db.database()); - - @Test - public void test() throws SQLException { - underTest.execute(); - db.assertColumnDefinition("rules_profiles", "organization_uuid", java.sql.Types.VARCHAR, 40, NULLABLE); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjectsTest.java deleted file mode 100644 index 9be66933528..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjectsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - - -public class AddTagsToProjectsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddTagsToProjectsTest.class, "previous-projects.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddTagsToProjects underTest = new AddTagsToProjects(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("projects", "tags", Types.VARCHAR, 500, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphansTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphansTest.java deleted file mode 100644 index 83e6cc4bb49..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphansTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanLoadedTemplateOrphansTest { - - private static final String TABLE_LOADED_TEMPLATES = "loaded_templates"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanLoadedTemplateOrphansTest.class, "loaded-templates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CleanLoadedTemplateOrphans underTest = new CleanLoadedTemplateOrphans(db.database()); - - @Test - public void execute_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_deletes_rows_with_null_in_template_type_column() throws SQLException { - insertLoadedTemplate(null, "value1"); - insertLoadedTemplate("", "value2"); - insertLoadedTemplate("non_empty", "value3"); - - underTest.execute(); - - assertThat(db.select("select kee as \"value\" from loaded_templates")) - .extracting(s -> s.get("value")) - .containsOnly("value2", "value3"); - } - - private void insertLoadedTemplate(@Nullable String type, String key) { - db.executeInsert( - TABLE_LOADED_TEMPLATES, - "TEMPLATE_TYPE", type, - "KEE", key); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsersTest.java deleted file mode 100644 index ce98fa0b71a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsersTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -public class CleanOrphanRowsInGroupsUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInGroupsUsersTest.class, "initial.sql"); - - private System2 system2 = mock(System2.class); - - private CleanOrphanRowsInGroupsUsers underTest = new CleanOrphanRowsInGroupsUsers(db.database()); - - @Test - public void remove_orphans_when_users_id_does_not_exist() throws Exception { - insertUserGroups(1L, 10L); - insertUserGroups(1L, 11L); - insertUserGroups(2L, 12L); - - underTest.execute(); - - assertThat(db.countRowsOfTable("groups_users")).isZero(); - } - - @Test - public void remove_orphans_when_user_is_disabled() throws Exception { - long user1 = insertUser("user1", false); - insertUserGroups(user1, 10L); - insertUserGroups(user1, 11L); - - underTest.execute(); - - assertThat(db.countRowsOfTable("groups_users")).isZero(); - } - - @Test - public void does_not_remove_group_membership_on_active_users() throws Exception { - long user1 = insertUser("user1", true); - insertUserGroups(user1, 10L); - insertUserGroups(user1, 11L); - long user2 = insertUser("user2", true); - insertUserGroups(user2, 10L); - - underTest.execute(); - - checkUserGroups(user1, 10L, 11L); - checkUserGroups(user2, 10L); - } - - @Test - public void migration_is_reentrant() throws Exception { - insertUserGroups(1L, 10L); - insertUserGroups(2L, 10L); - - underTest.execute(); - assertThat(db.countRowsOfTable("groups_users")).isZero(); - - underTest.execute(); - assertThat(db.countRowsOfTable("groups_users")).isZero(); - } - - private void checkUserGroups(long userId, Long... expectedGroupIds) { - List groups = db.select(format("select gu.group_id from groups_users gu where gu.user_id=%s", userId)).stream() - .map(map -> (Long) map.get("GROUP_ID")) - .collect(Collectors.toList()); - assertThat(groups).containsOnly(expectedGroupIds); - } - - private void insertUserGroups(long userId, Long... groupIds) { - Arrays.stream(groupIds).forEach(groupId -> db.executeInsert( - "GROUPS_USERS", - "USER_ID", userId, - "GROUP_ID", groupId)); - } - - private long insertUser(String login, boolean enabled) { - db.executeInsert( - "USERS", - "LOGIN", login, - "ACTIVE", Boolean.toString(enabled), - "IS_ROOT", "false", - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - return (Long) db.selectFirst(format("select id from users where login='%s'", login)).get("ID"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganizationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganizationTest.java deleted file mode 100644 index 85813ed824b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganizationTest.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.LogTester; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class CreateMembersGroupsInEachOrganizationTest { - - private static final Date PAST = new Date(100_000_000_000L); - private static final Date NOW = new Date(500_000_000_000L); - private static final String DEFAULT_ORGANIZATION_UUID = "def-org"; - private static final String ORGANIZATION_1 = "ORGANIZATION_1"; - private static final String ORGANIZATION_2 = "ORGANIZATION_2"; - private static final String TEMPLATE_1 = "TEMPLATE_1"; - private static final String TEMPLATE_2 = "TEMPLATE_2"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public LogTester logTester = new LogTester(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CreateMembersGroupsInEachOrganizationTest.class, "initial.sql"); - - private System2 system2 = mock(System2.class); - - private CreateMembersGroupsInEachOrganization underTest = new CreateMembersGroupsInEachOrganization(db.database(), system2); - - @Before - public void setUp() throws Exception { - when(system2.now()).thenReturn(NOW.getTime()); - } - - @Test - public void does_nothing_when_organization_disabled() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORGANIZATION_1, TEMPLATE_1); - insertOrganization(ORGANIZATION_2, TEMPLATE_2); - insertPermissionTemplate(ORGANIZATION_1, TEMPLATE_1, "Default"); - insertPermissionTemplate(ORGANIZATION_2, TEMPLATE_2, "Default"); - - underTest.execute(); - - checkNoGroups(); - checkNoPermTemplateGroups(); - } - - @Test - public void insert_members_groups_when_not_existing() throws SQLException { - setupDefaultOrganization(); - enableOrganization(); - insertOrganization(ORGANIZATION_1, null); - insertOrganization(ORGANIZATION_2, null); - - underTest.execute(); - - checkGroups( - tuple(ORGANIZATION_1, "Members", "All members of the organization", NOW, NOW), - tuple(ORGANIZATION_2, "Members", "All members of the organization", NOW, NOW), - tuple(DEFAULT_ORGANIZATION_UUID, "Members", "All members of the organization", NOW, NOW)); - } - - @Test - public void does_not_insert_members_group_when_group_already_exist() throws SQLException { - setupDefaultOrganization(); - enableOrganization(); - insertMembersGroup(DEFAULT_ORGANIZATION_UUID); - insertOrganization(ORGANIZATION_1, null); - insertMembersGroup(ORGANIZATION_1); - insertOrganization(ORGANIZATION_2, null); - insertMembersGroup(ORGANIZATION_2); - - underTest.execute(); - - checkGroups( - tuple(ORGANIZATION_1, "Members", "All members of the organization", PAST, PAST), - tuple(ORGANIZATION_2, "Members", "All members of the organization", PAST, PAST), - tuple(DEFAULT_ORGANIZATION_UUID, "Members", "All members of the organization", PAST, PAST)); - } - - @Test - public void insert_only_missing_members_group_when_some_groups_already_exist() throws SQLException { - setupDefaultOrganization(); - enableOrganization(); - insertMembersGroup(DEFAULT_ORGANIZATION_UUID); - insertOrganization(ORGANIZATION_1, null); - insertMembersGroup(ORGANIZATION_1); - insertOrganization(ORGANIZATION_2, null); - - underTest.execute(); - - checkGroups( - tuple(ORGANIZATION_1, "Members", "All members of the organization", PAST, PAST), - tuple(ORGANIZATION_2, "Members", "All members of the organization", NOW, NOW), - tuple(DEFAULT_ORGANIZATION_UUID, "Members", "All members of the organization", PAST, PAST)); - } - - @Test - public void insert_permission_template_groups_when_not_existing() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - insertOrganization(ORGANIZATION_1, TEMPLATE_1); - long template1 = insertPermissionTemplate(ORGANIZATION_1, TEMPLATE_1, "Default"); - insertOrganization(ORGANIZATION_2, TEMPLATE_2); - long template2 = insertPermissionTemplate(ORGANIZATION_2, TEMPLATE_2, "Default"); - - underTest.execute(); - - long group1 = selectMembersGroupId(ORGANIZATION_1); - long group2 = selectMembersGroupId(ORGANIZATION_2); - checkPermTemplateGroups( - tuple(group1, template1, "user", NOW, NOW), - tuple(group1, template1, "codeviewer", NOW, NOW), - tuple(group2, template2, "user", NOW, NOW), - tuple(group2, template2, "codeviewer", NOW, NOW)); - } - - @Test - public void does_not_insert_permission_template_groups_when_no_default_permission_template() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - insertOrganization(ORGANIZATION_1, TEMPLATE_1); - insertOrganization(ORGANIZATION_2, TEMPLATE_2); - - underTest.execute(); - - checkNoPermTemplateGroups(); - } - - @Test - public void does_not_insert_permission_template_groups_when_already_existing() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - insertOrganization(ORGANIZATION_1, TEMPLATE_1); - long template1 = insertPermissionTemplate(ORGANIZATION_1, TEMPLATE_1, "Default"); - long group1 = insertMembersGroup(ORGANIZATION_1); - insertPermissionTemplateGroup(group1, "user", template1); - insertPermissionTemplateGroup(group1, "codeviewer", template1); - - insertOrganization(ORGANIZATION_2, TEMPLATE_2); - long template2 = insertPermissionTemplate(ORGANIZATION_2, TEMPLATE_2, "Default"); - long group2 = insertMembersGroup(ORGANIZATION_2); - insertPermissionTemplateGroup(group2, "user", template2); - insertPermissionTemplateGroup(group2, "codeviewer", template2); - - underTest.execute(); - - checkPermTemplateGroups( - tuple(group1, template1, "user", PAST, PAST), - tuple(group1, template1, "codeviewer", PAST, PAST), - tuple(group2, template2, "user", PAST, PAST), - tuple(group2, template2, "codeviewer", PAST, PAST)); - } - - @Test - public void insert_only_missing_permission_template_groups() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - insertOrganization(ORGANIZATION_1, TEMPLATE_1); - long template1 = insertPermissionTemplate(ORGANIZATION_1, TEMPLATE_1, "Default"); - long group1 = insertMembersGroup(ORGANIZATION_1); - insertPermissionTemplateGroup(group1, "user", template1); - insertPermissionTemplateGroup(group1, "codeviewer", template1); - - insertOrganization(ORGANIZATION_2, TEMPLATE_2); - long template2 = insertPermissionTemplate(ORGANIZATION_2, TEMPLATE_2, "Default"); - long group2 = insertMembersGroup(ORGANIZATION_2); - - underTest.execute(); - - checkPermTemplateGroups( - tuple(group1, template1, "user", PAST, PAST), - tuple(group1, template1, "codeviewer", PAST, PAST), - tuple(group2, template2, "user", NOW, NOW), - tuple(group2, template2, "codeviewer", NOW, NOW)); - } - - @Test - public void migration_is_reentrant() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - insertOrganization(ORGANIZATION_1, TEMPLATE_1); - long template1 = insertPermissionTemplate(ORGANIZATION_1, TEMPLATE_1, "Default"); - insertOrganization(ORGANIZATION_2, TEMPLATE_2); - long template2 = insertPermissionTemplate(ORGANIZATION_2, TEMPLATE_2, "Default"); - - underTest.execute(); - - long group1 = selectMembersGroupId(ORGANIZATION_1); - long group2 = selectMembersGroupId(ORGANIZATION_2); - checkPermTemplateGroups( - tuple(group1, template1, "user", NOW, NOW), - tuple(group1, template1, "codeviewer", NOW, NOW), - tuple(group2, template2, "user", NOW, NOW), - tuple(group2, template2, "codeviewer", NOW, NOW)); - } - - private void checkGroups(Tuple... expectedTuples) { - List tuples = db.select("select name, description, organization_uuid, created_at, updated_at from groups").stream() - .map(map -> new Tuple(map.get("ORGANIZATION_UUID"), map.get("NAME"), map.get("DESCRIPTION"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList()); - assertThat(tuples).containsOnly(expectedTuples); - } - - private void checkNoGroups(){ - checkGroups(); - } - - private void checkPermTemplateGroups(Tuple... expectedTuples) { - List tuples = db.select("select group_id, template_id, permission_reference, created_at, updated_at from perm_templates_groups").stream() - .map(map -> new Tuple(map.get("GROUP_ID"), map.get("TEMPLATE_ID"), map.get("PERMISSION_REFERENCE"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList()); - assertThat(tuples).containsOnly(expectedTuples); - } - - private void checkNoPermTemplateGroups(){ - checkPermTemplateGroups(); - } - - private long selectMembersGroupId(String organization) { - return (Long) db.selectFirst(format("select id from groups where name='%s' and organization_uuid='%s'", "Members", organization)).get("ID"); - } - - private void insertOrganization(String uuid, @Nullable String defaultPermissionTemplateProject) { - db.executeInsert( - "ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "DEFAULT_PERM_TEMPLATE_PROJECT", defaultPermissionTemplateProject, - "GUARDED", "false", - "CREATED_AT", 1_000L, - "UPDATED_AT", 1_000L); - } - - private long insertPermissionTemplate(String organizationUuid, String key, String name) { - db.executeInsert( - "PERMISSION_TEMPLATES", - "KEE", key, - "ORGANIZATION_UUID", organizationUuid, - "NAME", name, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return (Long) db.selectFirst(format("select id from permission_templates where kee='%s'", key)).get("ID"); - } - - private void insertPermissionTemplateGroup(@Nullable Long groupId, String permission, @Nullable Long templateId) { - db.executeInsert( - "PERM_TEMPLATES_GROUPS", - "GROUP_ID", groupId, - "TEMPLATE_ID", templateId, - "PERMISSION_REFERENCE", permission, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private long insertMembersGroup(String organizationUuid) { - db.executeInsert( - "GROUPS", - "NAME", "Members", - "DESCRIPTION", "All members of the organization", - "ORGANIZATION_UUID", organizationUuid, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return (Long) db.selectFirst(format("select id from groups where name='%s' and organization_uuid='%s'", "Members", organizationUuid)).get("ID"); - } - - private void setupDefaultOrganization() { - db.executeInsert("ORGANIZATIONS", - "UUID", DEFAULT_ORGANIZATION_UUID, - "KEE", DEFAULT_ORGANIZATION_UUID, "NAME", - DEFAULT_ORGANIZATION_UUID, "GUARDED", false, - "CREATED_AT", 1_000L, - "UPDATED_AT", 1_000L); - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", DEFAULT_ORGANIZATION_UUID); - } - - private void enableOrganization(){ - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.enabled", - "IS_EMPTY", "false", - "TEXT_VALUE", "true"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTableTest.java deleted file mode 100644 index d2e3a42f727..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTableTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateOrganizationMembersTableTest { - private static final String TABLE = "organization_members"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateOrganizationMembersTableTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateOrganizationMembersTable underTest = new CreateOrganizationMembersTable(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "organization_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "user_id", Types.INTEGER, null, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "organization_uuid", "user_id"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadataTest.java deleted file mode 100644 index 60ec71c50e8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadataTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateRulesMetadataTest { - private static final String TABLE_RULES_METADATA = "rules_metadata"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateRulesMetadataTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateRulesMetadata underTest = new CreateRulesMetadata(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_RULES_METADATA)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "rule_id", Types.INTEGER, null, false); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "organization_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "note_data", Types.CLOB, null, true); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "note_user_login", Types.VARCHAR, 255, true); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "note_created_at", Types.BIGINT, null, true); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "note_updated_at", Types.BIGINT, null, true); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "remediation_function", Types.VARCHAR, 20, true); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "remediation_gap_mult", Types.VARCHAR, 20, true); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "remediation_base_effort", Types.VARCHAR, 20, true); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "tags", Types.VARCHAR, 4000, true); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "created_at", Types.BIGINT, null, false); - dbTester.assertColumnDefinition(TABLE_RULES_METADATA, "updated_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_RULES_METADATA, "pk_rules_metadata", "rule_id", "organization_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DbVersion64Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DbVersion64Test.java deleted file mode 100644 index 7485fc605c1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DbVersion64Test.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion64Test { - private DbVersion64 underTest = new DbVersion64(); - - @Test - public void migrationNumber_starts_at_1600() { - verifyMinimumMigrationNumber(underTest, 1600); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 45); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSettingTest.java deleted file mode 100644 index 530d0539bf2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSettingTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteDefaultGroupSettingTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteDefaultGroupSettingTest.class, "initial.sql"); - - private DeleteDefaultGroupSetting underTest = new DeleteDefaultGroupSetting(db.database()); - - @Test - public void delete_setting() throws SQLException { - insertDefaultGroupProperty(); - - underTest.execute(); - - assertThat(db.countRowsOfTable("properties")).isZero(); - } - - @Test - public void does_not_fail_when_setting_does_not_exist() throws Exception { - underTest.execute(); - - assertThat(db.countRowsOfTable("properties")).isZero(); - } - - @Test - public void does_not_delete_other_setting() throws Exception { - insertDefaultGroupProperty(); - insertProperty("sonar.prop", "a value"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("properties")).isEqualTo(1); - } - - @Test - public void migration_is_reentrant() throws Exception { - insertDefaultGroupProperty(); - - underTest.execute(); - assertThat(db.countRowsOfTable("properties")).isZero(); - - underTest.execute(); - assertThat(db.countRowsOfTable("properties")).isZero(); - } - - private void insertDefaultGroupProperty() { - insertProperty("sonar.defaultGroup", "123"); - } - - private void insertProperty(String key, String value) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", key, - "TEXT_VALUE", value, - "IS_EMPTY", "false", - "CREATED_AT", "1000"); - } - - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsersTest.java deleted file mode 100644 index c040d369b7b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsersTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeletePermissionTemplatesLinkedToRemovedUsersTest { - - private static long PAST_TIME = 10_000_000_000L; - private static long TEMPLATE_ID = 1000L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeletePermissionTemplatesLinkedToRemovedUsersTest.class, "initial.sql"); - - private DeletePermissionTemplatesLinkedToRemovedUsers underTest = new DeletePermissionTemplatesLinkedToRemovedUsers(db.database()); - - @Test - public void remove_permission_template_users_from_disabled_users() throws Exception { - long userId1 = insertUser(false); - long userId2 = insertUser(false); - insertPermissionTemplateUser(userId1, TEMPLATE_ID, "user"); - insertPermissionTemplateUser(userId1, TEMPLATE_ID, "codeviewer"); - insertPermissionTemplateUser(userId2, TEMPLATE_ID, "user"); - - underTest.execute(); - - checkNoCheckPermissionTemplateUsers(); - } - - @Test - public void remove_permission_template_users_from_non_existing_users() throws Exception { - insertPermissionTemplateUser(123L, TEMPLATE_ID, "user"); - insertPermissionTemplateUser(321L, TEMPLATE_ID, "codeviewer"); - - underTest.execute(); - - checkNoCheckPermissionTemplateUsers(); - } - - @Test - public void does_not_remove_permission_template_users_from_active_user() throws Exception { - long activeUserId = insertUser(true); - long inactiveUserId = insertUser(false); - long permissionTemplateUserOnActiveUser = insertPermissionTemplateUser(activeUserId, TEMPLATE_ID, "user"); - insertPermissionTemplateUser(inactiveUserId, TEMPLATE_ID, "user"); - - underTest.execute(); - - checkPermissionTemplateUsers(permissionTemplateUserOnActiveUser); - } - - @Test - public void does_not_fail_when_no_permission_template_users() throws Exception { - insertUser(false); - - underTest.execute(); - - checkNoCheckPermissionTemplateUsers(); - } - - @Test - public void migration_is_reentrant() throws Exception { - long userId = insertUser(false); - insertPermissionTemplateUser(userId, TEMPLATE_ID, "user"); - - underTest.execute(); - checkNoCheckPermissionTemplateUsers(); - - underTest.execute(); - checkNoCheckPermissionTemplateUsers(); - } - - private void checkNoCheckPermissionTemplateUsers() { - checkPermissionTemplateUsers(); - } - - private void checkPermissionTemplateUsers(Long... expectedIds) { - List ids = db.select("select ptu.id from perm_templates_users ptu").stream() - .map(map -> (Long) map.get("ID")) - .collect(Collectors.toList()); - assertThat(ids).containsOnly(expectedIds); - } - - private long insertPermissionTemplateUser(long userId, long templateId, String permission) { - db.executeInsert( - "PERM_TEMPLATES_USERS", - "USER_ID", userId, - "TEMPLATE_ID", templateId, - "PERMISSION_REFERENCE", permission, - "CREATED_AT", new Date(PAST_TIME), - "UPDATED_AT", new Date(PAST_TIME)); - return (long) db.selectFirst(format("select id from perm_templates_users where template_id='%s' and user_id='%s' and permission_reference='%s'", - templateId, userId, permission)).get("ID"); - } - - private long insertUser(boolean enabled) { - String login = randomAlphabetic(10); - db.executeInsert( - "USERS", - "LOGIN", login, - "ACTIVE", Boolean.toString(enabled), - "IS_ROOT", "false", - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - return (Long) db.selectFirst(format("select id from users where login='%s'", login)).get("ID"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRulesTest.java deleted file mode 100644 index 345819aa5fe..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRulesTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropMetadataColumnsFromRulesTest { - - private static final String TABLE_RULES = "rules"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMetadataColumnsFromRulesTest.class, "rules.sql"); - - private DropMetadataColumnsFromRules underTest = new DropMetadataColumnsFromRules(db.database()); - - @Test - public void execute_drops_metadata_columns_from_table_RULES() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist(TABLE_RULES, "note_data"); - db.assertColumnDoesNotExist(TABLE_RULES, "note_user_login"); - db.assertColumnDoesNotExist(TABLE_RULES, "note_created_at"); - db.assertColumnDoesNotExist(TABLE_RULES, "note_updated_at"); - db.assertColumnDoesNotExist(TABLE_RULES, "remediation_function"); - db.assertColumnDoesNotExist(TABLE_RULES, "remediation_gap_mult"); - db.assertColumnDoesNotExist(TABLE_RULES, "remediation_base_effort"); - db.assertColumnDoesNotExist(TABLE_RULES, "tags"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKeyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKeyTest.java deleted file mode 100644 index b9fab26622d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKeyTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropUniqueIndexOnQualityProfileKeyTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnQualityProfileKeyTest.class, "initial.sql"); - - public DropUniqueIndexOnQualityProfileKey underTest = new DropUniqueIndexOnQualityProfileKey(db.database()); - - @Test - public void test() throws SQLException { - underTest.execute(); - db.assertIndexDoesNotExist("rules_profiles", "uniq_qprof_key"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest.java deleted file mode 100644 index c8420cca429..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import java.sql.SQLException; - -public class DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest.class, "initial.sql"); - - public DropUniqueIndexOnQualityProfileOrganizationUuidAndKey underTest = new DropUniqueIndexOnQualityProfileOrganizationUuidAndKey(db.database()); - - @Test - public void test() throws SQLException { - underTest.execute(); - db.assertIndexDoesNotExist("rules_profiles", "uniq_qprof_org_and_key"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumnTest.java deleted file mode 100644 index b009bad56ff..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumnTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class ExtendLoadedTemplateTypeColumnTest { - - private static final String TABLE_LOADED_TEMPLATES = "loaded_templates"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(ExtendLoadedTemplateTypeColumnTest.class, "loaded-templates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private ExtendLoadedTemplateTypeColumn underTest = new ExtendLoadedTemplateTypeColumn(db.database()); - - @Test - public void extend_and_make_non_nullable_column_template_type() throws SQLException { - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_makes_analysis_uuid_not_nullable_on_populated_table() throws SQLException { - insertLoadedTemplate("type1", "val1"); - insertLoadedTemplate("type2", "val2"); - - underTest.execute(); - - verifyColumnDefinitions(); - } - - @Test - public void migration_fails_if_type_column_has_null_values() throws SQLException { - insertLoadedTemplate(null, "some value"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void insertLoadedTemplate(String type, String key) { - db.executeInsert( - TABLE_LOADED_TEMPLATES, - "TEMPLATE_TYPE", type, - "KEE", key); - } - - private void verifyColumnDefinitions() { - db.assertColumnDefinition(TABLE_LOADED_TEMPLATES, "template_type", Types.VARCHAR, 64, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullableTest.java deleted file mode 100644 index 7a0195171c4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullableTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import java.util.List; -import java.util.Random; -import java.util.stream.Stream; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MakeCeActivityExecutionCountNotNullableTest { - - private static final String TABLE_CE_ACTIVITY = "ce_activity"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeCeActivityExecutionCountNotNullableTest.class, "ce_activity.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeCeActivityExecutionCountNotNullable underTest = new MakeCeActivityExecutionCountNotNullable(db.database()); - - @Test - public void execute_makes_column_execution_count_not_nullable_when_table_is_empty() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void execute_set_column_execution_count_to_0_or_1_and_not_nullable_depending_on_status_of_the_task() throws SQLException { - insertCeActivity("u1", Status.SUCCESS); - insertCeActivity("u2", Status.FAILED); - insertCeActivity("u3", Status.CANCELED); - - underTest.execute(); - - verifyColumnDefinition(); - assertThat(getUuidsForExecutionCount(0)).containsOnly("u3"); - assertThat(getUuidsForExecutionCount(1)).containsOnly("u1", "u2"); - } - - private List getUuidsForExecutionCount(int executionCount) { - return db.select("select uuid as \"UUID\" from ce_activity where execution_count=" + executionCount) - .stream() - .flatMap(row -> Stream.of(row.get("UUID"))) - .collect(MoreCollectors.toList()); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_CE_ACTIVITY, "execution_count", Types.INTEGER, null, false); - } - - private void insertCeActivity(String uuid, Status status) { - db.executeInsert(TABLE_CE_ACTIVITY, - "UUID", uuid, - "TASK_TYPE", uuid + "_type", - "STATUS", status.name(), - "IS_LAST", new Random().nextBoolean() + "", - "IS_LAST_KEY", "key", - "SUBMITTED_AT", new Random().nextLong() + "", - "CREATED_AT", new Random().nextLong() + "", - "UPDATED_AT", new Random().nextLong() + ""); - } - - public enum Status { - SUCCESS, FAILED, CANCELED - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullableTest.java deleted file mode 100644 index e9335a42501..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullableTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import java.util.List; -import java.util.Random; -import java.util.stream.Stream; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MakeCeQueueExecutionCountNotNullableTest { - - private static final String TABLE_CE_QUEUE = "ce_queue"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeCeQueueExecutionCountNotNullableTest.class, "ce_queue.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeCeQueueExecutionCountNotNullable underTest = new MakeCeQueueExecutionCountNotNullable(db.database()); - - @Test - public void execute_makes_column_execution_count_not_nullable_when_table_is_empty() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void execute_set_column_execution_count_to_0_and_not_nullable_no_matter_status_of_the_task() throws SQLException { - insertCeQueue("u1", Status.IN_PROGRESS); - insertCeQueue("u2", Status.PENDING); - - underTest.execute(); - - verifyColumnDefinition(); - assertThat(getUuidsForExecutionCount(0)).containsOnly("u1", "u2"); - assertThat(getUuidsForExecutionCount(1)).isEmpty(); - } - - private List getUuidsForExecutionCount(int executionCount) { - return db.select("select uuid as \"UUID\" from ce_queue where execution_count=" + executionCount) - .stream() - .flatMap(row -> Stream.of(row.get("UUID"))) - .collect(MoreCollectors.toList()); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_CE_QUEUE, "execution_count", Types.INTEGER, null, false); - } - - private void insertCeQueue(String uuid, Status status) { - db.executeInsert(TABLE_CE_QUEUE, - "UUID", uuid, - "TASK_TYPE", uuid + "_type", - "STATUS", status.name(), - "CREATED_AT", new Random().nextLong() + "", - "UPDATED_AT", new Random().nextLong() + ""); - } - - public enum Status { - PENDING, IN_PROGRESS - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullableTest.java deleted file mode 100644 index 910803f3592..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class MakeColumnNewProjectPrivateNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeColumnNewProjectPrivateNotNullableTest.class, "organizations_with_nullable_new_project_private_column.sql"); - - private MakeColumnNewProjectPrivateNotNullable underTest = new MakeColumnNewProjectPrivateNotNullable(db.database()); - - @Test - public void execute_makes_column_private_not_nullable() throws SQLException { - db.assertColumnDefinition("organizations", "new_project_private", Types.BOOLEAN, null, true); - - underTest.execute(); - - db.assertColumnDefinition("organizations", "new_project_private", Types.BOOLEAN, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullableTest.java deleted file mode 100644 index 99d202f7826..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class MakeColumnProjectsPrivateNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeColumnProjectsPrivateNotNullableTest.class, "projects_with_nullable_private_column.sql"); - - private MakeColumnProjectsPrivateNotNullable underTest = new MakeColumnProjectsPrivateNotNullable(db.database()); - - @Test - public void execute_makes_column_private_not_nullable() throws SQLException { - db.assertColumnDefinition("projects", "private", Types.BOOLEAN, null, true); - - underTest.execute(); - - db.assertColumnDefinition("projects", "private", Types.BOOLEAN, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissionsTest.java deleted file mode 100644 index 66f9dbf6450..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissionsTest.java +++ /dev/null @@ -1,492 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class MakeComponentsPrivateBasedOnPermissionsTest { - private static final String ROLE_USER = "user"; - private static final String ROLE_CODEVIEWER = "codeviewer"; - private static final String PROJECT_QUALIFIER = "TRK"; - private static final String VIEW_QUALIFIER = "VW"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeComponentsPrivateBasedOnPermissionsTest.class, "projects_and_group_roles_and_user_roles.sql"); - - private final Random random = new Random(); - private final String randomPublicConditionRole = random.nextBoolean() ? ROLE_CODEVIEWER : ROLE_USER; - private final String randomQualifier = random.nextBoolean() ? PROJECT_QUALIFIER : VIEW_QUALIFIER; - private final String randomRole = "role_" + random.nextInt(12); - private MakeComponentsPrivateBasedOnPermissions underTest = new MakeComponentsPrivateBasedOnPermissions(db.database()); - - @Test - public void execute_does_nothing_on_empty_tables() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_makes_project_private_if_Anyone_has_only_user_permission_and_project_has_at_least_one_other_group_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_USER, pId1, null); - insertGroupPermission("foo", pId1, random.nextInt(10)); - - underTest.execute(); - - assertThat(isPrivate("p1")).isTrue(); - } - - @Test - public void execute_makes_project_private_if_Anyone_has_only_user_permission_and_project_has_one_user_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_USER, pId1, null); - insertUserPermission("foo", pId1, random.nextInt(10)); - - underTest.execute(); - - assertThat(isPrivate("p1")).isTrue(); - } - - @Test - public void execute_keeps_project_public_if_Anyone_has_only_user_permission_and_project_has_no_user_nor_other_group_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_USER, pId1, null); - - underTest.execute(); - - assertThat(isPrivate("p1")).isFalse(); - } - - @Test - public void execute_makes_project_private_if_Anyone_has_only_codeviewer_permission_and_project_has_one_other_group_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_CODEVIEWER, pId1, null); - insertGroupPermission("foo", pId1, random.nextInt(10)); - - underTest.execute(); - - assertThat(isPrivate("p1")).isTrue(); - } - - @Test - public void execute_makes_project_private_if_Anyone_has_only_codeviewer_permission_and_project_has_one_user_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_CODEVIEWER, pId1, null); - insertUserPermission("foo", pId1, random.nextInt(10)); - - underTest.execute(); - - assertThat(isPrivate("p1")).isTrue(); - } - - @Test - public void execute_keeps_project_public_if_Anyone_has_only_codeviewer_permission_and_project_has_no_user_nor_other_group_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_CODEVIEWER, pId1, null); - - underTest.execute(); - - assertThat(isPrivate("p1")).isFalse(); - } - - @Test - public void execute_makes_project_private_if_Anyone_has_neither_user_nor_codeviewer_permission_and_project_has_one_other_group_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(randomRole, pId1, null); - insertGroupPermission("foo", pId1, random.nextInt(10)); - - underTest.execute(); - - assertThat(isPrivate("p1")).isTrue(); - } - - @Test - public void execute_makes_project_private_if_Anyone_has_neither_user_nor_codeviewer_permission_and_project_has_one_user_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(randomRole, pId1, null); - insertUserPermission("foo", pId1, random.nextInt(10)); - - underTest.execute(); - - assertThat(isPrivate("p1")).isTrue(); - } - - @Test - public void execute_keeps_project_public_if_Anyone_has_neither_user_nor_codeviewer_permission_and_project_has_no_user_nor_other_group_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission("foo", pId1, null); - - underTest.execute(); - - assertThat(isPrivate("p1")).isFalse(); - } - - @Test - public void execute_keeps_project_public_if_Anyone_has_both_user_and_codeviewer_permission_and_project_has_one_other_group_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_USER, pId1, null); - insertGroupPermission(ROLE_CODEVIEWER, pId1, null); - insertGroupPermission("foo", pId1, random.nextInt(10)); - - underTest.execute(); - - assertThat(isPrivate("p1")).isFalse(); - } - - @Test - public void execute_keeps_project_public_if_Anyone_has_both_user_and_codeviewer_permission_and_project_has_user_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_USER, pId1, null); - insertGroupPermission(ROLE_CODEVIEWER, pId1, null); - insertUserPermission("foo", pId1, random.nextInt(10)); - - underTest.execute(); - - assertThat(isPrivate("p1")).isFalse(); - } - - @Test - public void execute_keeps_project_public_if_Anyone_has_both_user_and_codeviewer_permission_and_project_has_no_user_nor_other_group_permission() throws SQLException { - long pId1 = insertRootComponent("p1", false); - insertGroupPermission(ROLE_USER, pId1, null); - insertGroupPermission(ROLE_CODEVIEWER, pId1, null); - - underTest.execute(); - - assertThat(isPrivate("p1")).isFalse(); - } - - @Test - public void execute_keeps_project_public_if_it_has_no_user_nor_group_permission_at_all() throws SQLException { - insertRootComponent("p1", false); - - underTest.execute(); - - assertThat(isPrivate("p1")).isFalse(); - } - - @Test - public void execute_does_not_change_private_projects_to_public_when_they_actually_should_be() throws SQLException { - long p1Id = insertRootComponent("p1", true); // both user and codeviewer - long p2Id = insertRootComponent("p2", true); // only user but no other permission - long p3Id = insertRootComponent("p3", true); // only codeviewer but no other permission - long p4Id = insertRootComponent("p4", true); // neither codeviewer nor user but no other permission - insertGroupPermission(ROLE_CODEVIEWER, p1Id, null); - insertGroupPermission(ROLE_USER, p1Id, null); - insertGroupPermission(ROLE_CODEVIEWER, p2Id, null); - insertGroupPermission(ROLE_USER, p3Id, null); - insertGroupPermission(randomRole, p4Id, null); - - underTest.execute(); - - assertThat(isPrivate("p1")).isTrue(); - assertThat(isPrivate("p2")).isTrue(); - assertThat(isPrivate("p3")).isTrue(); - assertThat(isPrivate("p4")).isTrue(); - } - - @Test - public void execute_changes_non_root_rows_to_private_based_on_permissions_of_their_root_row() throws SQLException { - // root stays public, children are unchanged - long pId1 = insertRootComponent("root1", false); - insertGroupPermission(randomPublicConditionRole, pId1, null); - insertComponent("u1", "root1", false); - // root becomes privates, children are changed accordingly - long pId2 = insertRootComponent("root2", false); - int someUserId = random.nextInt(50); - insertGroupPermission(randomRole, pId2, someUserId); - insertComponent("u2", "root2", false); - insertComponent("u3", "root2", true); - - underTest.execute(); - - assertThat(isPrivate("root1")).isFalse(); - assertThat(isPrivate("u1")).isFalse(); - assertThat(isPrivate("root2")).isTrue(); - assertThat(isPrivate("u2")).isTrue(); - assertThat(isPrivate("u3")).isTrue(); - } - - @Test - public void execute_does_not_fix_inconsistencies_of_non_root_rows_if_root_stays_public_or_is_already_private() throws SQLException { - // root stays public, children are unchanged - long pId1 = insertRootComponent("root1", false); - insertGroupPermission(randomPublicConditionRole, pId1, null); - insertComponent("u1", "root1", false); - insertComponent("u2", "root1", true); // inconsistent information is not fixed - // root is already private but children are inconsistent => not fixed - insertRootComponent("root2", true); - insertGroupPermission(randomPublicConditionRole, pId1, null); - insertComponent("u3", "root2", false); - insertComponent("u4", "root2", true); - - underTest.execute(); - - assertThat(isPrivate("root1")).isFalse(); - assertThat(isPrivate("u1")).isFalse(); - assertThat(isPrivate("u2")).isTrue(); - assertThat(isPrivate("root2")).isTrue(); - assertThat(isPrivate("u3")).isFalse(); - assertThat(isPrivate("u4")).isTrue(); - } - - @Test - public void execute_does_change_non_root_rows_which_root_does_not_exist() throws SQLException { - // non existent root, won't be changed - long pId1 = insertComponent("u1", "non existent root", false); - insertGroupPermission(randomPublicConditionRole, pId1, null); - insertComponent("u2", "non existent root", true); - - underTest.execute(); - - assertThat(isPrivate("u1")).isFalse(); - assertThat(isPrivate("u2")).isTrue(); - } - - @Test - public void execute_deletes_any_permission_to_group_Anyone_for_root_components_which_are_made_private() throws SQLException { - long idRoot1 = insertRootComponent("root1", false); - int someGroupId = random.nextInt(50); - int someUserId = random.nextInt(50); - insertGroupPermission(randomRole, idRoot1, null); - insertGroupPermission(randomRole, idRoot1, someGroupId); - insertUserPermission(randomRole, idRoot1, someUserId); - - underTest.execute(); - - assertThat(isPrivate("root1")).isTrue(); - assertThat(permissionsOfGroupAnyone(idRoot1)).isEmpty(); - assertThat(permissionsOfGroup(idRoot1, someGroupId)).containsOnly(randomRole, ROLE_USER, ROLE_CODEVIEWER); - assertThat(permissionsOfUser(idRoot1, someUserId)).containsOnly(randomRole, ROLE_USER, ROLE_CODEVIEWER); - } - - @Test - public void execute_ensures_any_user_of_with_at_least_one_permission_on_root_component_which_is_made_private_also_has_permissions_USER_and_CODEVIEWER() throws SQLException { - long idRoot = insertRootComponent("root1", false); - String someRole = "role_" + random.nextInt(12); - int user1 = insertUser(); - int user2 = insertUser(); - insertUserPermission(someRole, idRoot, user1); - - underTest.execute(); - - assertThat(isPrivate("root1")).isTrue(); - assertThat(permissionsOfGroupAnyone(idRoot)).isEmpty(); - assertThat(permissionsOfUser(idRoot, user1)).containsOnly(someRole, ROLE_USER, ROLE_CODEVIEWER); - assertThat(permissionsOfUser(idRoot, user2)).isEmpty(); - } - - @Test - public void execute_ensures_any_group_of_with_at_least_one_permission_on_root_component_which_is_made_private_also_has_permissions_USER_and_CODEVIEWER() throws SQLException { - long idRoot = insertRootComponent("root1", false); - String someRole = "role_" + random.nextInt(12); - int group1 = insertGroup(); - int group2 = insertGroup(); - insertGroupPermission(someRole, idRoot, group1); - - underTest.execute(); - - assertThat(isPrivate("root1")).isTrue(); - assertThat(permissionsOfGroup(idRoot, group1)).containsOnly(someRole, ROLE_USER, ROLE_CODEVIEWER); - assertThat(permissionsOfGroup(idRoot, group2)).isEmpty(); - } - - @Test - public void execute_does_not_delete_permissions_to_group_Anyone_for_root_components_which_are_already_private() throws SQLException { - long idRoot = insertRootComponent("root1", true); - String someRole = "role_" + random.nextInt(12); - int someGroupId = random.nextInt(50); - int someUserId = random.nextInt(50); - insertGroupPermission(someRole, idRoot, null); - insertGroupPermission(someRole, idRoot, someGroupId); - insertGroupPermission(randomPublicConditionRole, idRoot, someGroupId); - insertUserPermission(someRole, idRoot, someUserId); - insertUserPermission(randomPublicConditionRole, idRoot, someUserId); - - underTest.execute(); - - assertThat(isPrivate("root1")).isTrue(); - assertThat(permissionsOfGroupAnyone(idRoot)).containsOnly(someRole); - assertThat(permissionsOfGroup(idRoot, someGroupId)).containsOnly(someRole, ROLE_USER, ROLE_CODEVIEWER); - assertThat(permissionsOfUser(idRoot, someUserId)).containsOnly(someRole, ROLE_USER, ROLE_CODEVIEWER); - } - - @Test - public void execute_ensures_any_user_of_with_at_least_one_permission_on_root_component_which_is_already_private_also_has_permissions_USER_and_CODEVIEWER() throws SQLException { - long idRoot = insertRootComponent("root1", true); - String someRole = "role_" + random.nextInt(12); - int user1 = insertUser(); - int user2 = insertUser(); - insertUserPermission(someRole, idRoot, user1); - - underTest.execute(); - - assertThat(isPrivate("root1")).isTrue(); - assertThat(permissionsOfGroupAnyone(idRoot)).isEmpty(); - assertThat(permissionsOfUser(idRoot, user1)).containsOnly(someRole, ROLE_USER, ROLE_CODEVIEWER); - assertThat(permissionsOfUser(idRoot, user2)).isEmpty(); - } - - @Test - public void execute_ensures_any_group_of_with_at_least_one_permission_on_root_component_which_is_already_private_also_has_permissions_USER_and_CODEVIEWER() throws SQLException { - long idRoot = insertRootComponent("root1", true); - String someRole = "role_" + random.nextInt(12); - int group1 = insertGroup(); - int group2 = insertGroup(); - insertGroupPermission(someRole, idRoot, group1); - - underTest.execute(); - - assertThat(isPrivate("root1")).isTrue(); - assertThat(permissionsOfGroup(idRoot, group1)).containsOnly(someRole, ROLE_USER, ROLE_CODEVIEWER); - assertThat(permissionsOfGroup(idRoot, group2)).isEmpty(); - } - - @Test - public void execute_deletes_any_USER_or_BROWSE_permission_of_public_project() throws SQLException { - long idRoot = insertRootComponent("root1", false); - int someGroupId = random.nextInt(55); - int someUserId = random.nextInt(55); - String someRole = "role_" + random.nextInt(12); - Stream.of(ROLE_USER, ROLE_CODEVIEWER, someRole) - .forEach(role -> { - insertGroupPermission(role, idRoot, null); - insertGroupPermission(role, idRoot, someGroupId); - insertUserPermission(role, idRoot, someUserId); - }); - assertThat(isPrivate("root1")).isFalse(); - assertThat(permissionsOfGroupAnyone(idRoot)).containsOnly(ROLE_USER, ROLE_CODEVIEWER, someRole); - assertThat(permissionsOfGroup(idRoot, someGroupId)).containsOnly(ROLE_USER, ROLE_CODEVIEWER, someRole); - assertThat(permissionsOfUser(idRoot, someUserId)).containsOnly(ROLE_USER, ROLE_CODEVIEWER, someRole); - - underTest.execute(); - - assertThat(isPrivate("root1")).isFalse(); - assertThat(permissionsOfGroupAnyone(idRoot)).containsOnly(someRole); - assertThat(permissionsOfGroup(idRoot, someGroupId)).containsOnly(someRole); - assertThat(permissionsOfUser(idRoot, someUserId)).containsOnly(someRole); - } - - private long insertRootComponent(String uuid, boolean isPrivate) { - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", "org_" + uuid, - "SCOPE", "PRJ", - "QUALIFIER", randomQualifier, - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_" + uuid, - "PROJECT_UUID", uuid, - "PRIVATE", valueOf(isPrivate)); - return (long) db.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID"); - } - - private long insertComponent(String uuid, String projectUuid, boolean isPrivate) { - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", "org_" + uuid, - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_" + uuid, - "PROJECT_UUID", projectUuid, - "PRIVATE", valueOf(isPrivate)); - return (long) db.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID"); - } - - private void insertGroupPermission(String role, @Nullable Long resourceId, @Nullable Integer groupId) { - db.executeInsert( - "GROUP_ROLES", - "ORGANIZATION_UUID", "org" + random.nextInt(50), - "GROUP_ID", groupId == null ? null : valueOf(groupId), - "RESOURCE_ID", resourceId == null ? null : valueOf(resourceId), - "ROLE", role); - } - - private int groupCount = Math.abs(random.nextInt(22)); - - private int insertGroup() { - String name = "group" + groupCount++; - db.executeInsert( - "GROUPS", - "ORGANIZATION_UUID", "org" + random.nextInt(12), - "NAME", name); - return ((Long) db.selectFirst("select id as \"ID\" from groups where name='" + name + "'").get("ID")).intValue(); - } - - private void insertUserPermission(String role, @Nullable Long resourceId, int userId) { - db.executeInsert( - "USER_ROLES", - "ORGANIZATION_UUID", "org_" + random.nextInt(66), - "USER_ID", valueOf(userId), - "RESOURCE_ID", resourceId == null ? null : valueOf(resourceId), - "ROLE", role); - } - - private int userCount = Math.abs(random.nextInt(22)); - - private int insertUser() { - String login = "user" + userCount++; - db.executeInsert( - "USERS", - "LOGIN", login, - "IS_ROOT", String.valueOf(false)); - return ((Long) db.selectFirst("select id as \"ID\" from users where login='" + login + "'").get("ID")).intValue(); - } - - private boolean isPrivate(String uuid) { - Map row = db.selectFirst("select private as \"PRIVATE\" from projects where uuid = '" + uuid + "'"); - return (boolean) row.get("PRIVATE"); - } - - private Set permissionsOfGroupAnyone(long resourceId) { - return db.select("select role from group_roles where group_id is null and resource_id = " + resourceId) - .stream() - .flatMap(map -> map.entrySet().stream()) - .map(entry -> (String) entry.getValue()) - .collect(MoreCollectors.toSet()); - } - - private Set permissionsOfGroup(long resourceId, int groupId) { - return db.select("select role from group_roles where group_id = " + groupId + " and resource_id = " + resourceId) - .stream() - .flatMap(map -> map.entrySet().stream()) - .map(entry -> (String) entry.getValue()) - .collect(MoreCollectors.toSet()); - } - - private Set permissionsOfUser(long resourceId, int userId) { - return db.select("select role from user_roles where resource_id = " + resourceId + " and user_id = " + userId) - .stream() - .flatMap(map -> map.entrySet().stream()) - .map(entry -> (String) entry.getValue()) - .collect(MoreCollectors.toSet()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullableTest.java deleted file mode 100644 index adbb73a84e6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullableTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.sql.Types; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class MakeProjectUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectUuidNotNullableTest.class, "projects_with_nullable_project_uuid.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeProjectUuidNotNullable underTest = new MakeProjectUuidNotNullable(db.database()); - - @Test - public void execute_makes_column_project_uuid_not_nullable_on_empty_table() throws SQLException { - db.assertColumnDefinition("projects", "project_uuid", Types.VARCHAR, 50, true); - - underTest.execute(); - - db.assertColumnDefinition("projects", "project_uuid", Types.VARCHAR, 50, false); - } - - @Test - public void execute_makes_column_project_uuid_not_nullable_on_table_without_null_project_uuid() throws SQLException { - db.assertColumnDefinition("projects", "project_uuid", Types.VARCHAR, 50, true); - insertComponent("u1", "u1"); - insertComponent("u2", "u1"); - - underTest.execute(); - - db.assertColumnDefinition("projects", "project_uuid", Types.VARCHAR, 50, false); - } - - @Test - public void execute_fails_on_table_with_null_project_uuid() throws SQLException { - db.assertColumnDefinition("projects", "project_uuid", Types.VARCHAR, 50, true); - insertComponent("u1", "u1"); - insertComponent("u2", "u1"); - insertComponent("u3", null); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - - private void insertComponent(String uuid, @Nullable String projectUuid) { - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", "org_" + uuid, - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_" + uuid, - "PROJECT_UUID", projectUuid); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUniqueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUniqueTest.java deleted file mode 100644 index 7faac262954..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUniqueTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import java.sql.SQLException; - -public class MakeQualityProfileKeyUniqueTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityProfileKeyUniqueTest.class, "initial.sql"); - - public MakeQualityProfileKeyUnique underTest = new MakeQualityProfileKeyUnique(db.database()); - - @Test - public void test() throws SQLException { - underTest.execute(); - db.assertUniqueIndex("rules_profiles", "uniq_qprof_key", "kee"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUniqueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUniqueTest.java deleted file mode 100644 index ab093160db8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUniqueTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class MakeQualityProfileOrganizationUuidAndKeyUniqueTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityProfileOrganizationUuidAndKeyUniqueTest.class, "initial.sql"); - - public MakeQualityProfileOrganizationUuidAndKeyUnique underTest = new MakeQualityProfileOrganizationUuidAndKeyUnique(db.database()); - - @Test - public void test() throws SQLException { - underTest.execute(); - db.assertUniqueIndex("rules_profiles", "uniq_qprof_org_and_key", "organization_uuid", "kee"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizationsTest.java deleted file mode 100644 index 62cfcb179bc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizationsTest.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateColumnDefaultGroupIdOfOrganizationsTest { - - private static final long PAST = 100_000_000_000L; - private static final long NOW = 500_000_000_000L; - - private static final String DEFAULT_ORGANIZATION_UUID = "def-org"; - private static final String ORGANIZATION_1 = "ORGANIZATION_1"; - private static final String ORGANIZATION_2 = "ORGANIZATION_2"; - private static final String SONAR_USERS_NAME = "sonar-users"; - private static final String MEMBERS_NAME = "Members"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateColumnDefaultGroupIdOfOrganizationsTest.class, "initial.sql"); - - private System2 system2 = mock(System2.class); - - private PopulateColumnDefaultGroupIdOfOrganizations underTest = new PopulateColumnDefaultGroupIdOfOrganizations(db.database(), system2); - - @Before - public void setUp() throws Exception { - when(system2.now()).thenReturn(NOW); - } - - @Test - public void set_sonar_users_group_id_on_default_organization_when_organization_disabled() throws Exception { - setupDefaultOrganization(); - long groupId = insertGroup(DEFAULT_ORGANIZATION_UUID, SONAR_USERS_NAME); - - underTest.execute(); - - checkOrganizations(tuple(DEFAULT_ORGANIZATION_UUID, groupId, NOW)); - } - - @Test - public void set_members_group_id_on_organizations_when_organization_enabled() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - long group1 = insertGroup(ORGANIZATION_1, MEMBERS_NAME); - insertOrganization(ORGANIZATION_1, null); - long group2 = insertGroup(ORGANIZATION_2, MEMBERS_NAME); - insertOrganization(ORGANIZATION_2, null); - - underTest.execute(); - - checkOrganizations(tuple(ORGANIZATION_1, group1, NOW), tuple(ORGANIZATION_2, group2, NOW), tuple(DEFAULT_ORGANIZATION_UUID, null, PAST)); - } - - @Test - public void does_nothing_when_default_group_id_already_set() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - long group1 = insertGroup(ORGANIZATION_1, MEMBERS_NAME); - insertOrganization(ORGANIZATION_1, group1); - long group2 = insertGroup(ORGANIZATION_2, MEMBERS_NAME); - insertOrganization(ORGANIZATION_2, group2); - - underTest.execute(); - - checkOrganizations(tuple(ORGANIZATION_1, group1, PAST), tuple(ORGANIZATION_2, group2, PAST), tuple(DEFAULT_ORGANIZATION_UUID, null, PAST)); - } - - @Test - public void set_members_group_id_on_organizations_only_when_not_already_et() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - long group1 = insertGroup(ORGANIZATION_1, MEMBERS_NAME); - insertOrganization(ORGANIZATION_1, null); - long group2 = insertGroup(ORGANIZATION_2, MEMBERS_NAME); - insertOrganization(ORGANIZATION_2, group2); - - underTest.execute(); - - checkOrganizations(tuple(ORGANIZATION_1, group1, NOW), tuple(ORGANIZATION_2, group2, PAST), tuple(DEFAULT_ORGANIZATION_UUID, null, PAST)); - } - - @Test - public void migration_is_reentrant() throws Exception { - setupDefaultOrganization(); - enableOrganization(); - long group1 = insertGroup(ORGANIZATION_1, MEMBERS_NAME); - insertOrganization(ORGANIZATION_1, null); - long group2 = insertGroup(ORGANIZATION_2, MEMBERS_NAME); - insertOrganization(ORGANIZATION_2, null); - - underTest.execute(); - checkOrganizations(tuple(ORGANIZATION_1, group1, NOW), tuple(ORGANIZATION_2, group2, NOW), tuple(DEFAULT_ORGANIZATION_UUID, null, PAST)); - - underTest.execute(); - checkOrganizations(tuple(ORGANIZATION_1, group1, NOW), tuple(ORGANIZATION_2, group2, NOW), tuple(DEFAULT_ORGANIZATION_UUID, null, PAST)); - } - - private void checkOrganizations(Tuple... expectedTuples) { - List tuples = db.select("select o.uuid, o.default_group_id, o.updated_at from organizations o").stream() - .map(map -> new Tuple(map.get("UUID"), map.get("DEFAULT_GROUP_ID"), map.get("UPDATED_AT"))) - .collect(Collectors.toList()); - assertThat(tuples).containsOnly(expectedTuples); - } - - private void insertOrganization(String uuid, @Nullable Long defaultGroupId) { - db.executeInsert( - "ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "DEFAULT_GROUP_ID", defaultGroupId, - "GUARDED", "false", - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private long insertGroup(String organization, String name) { - db.executeInsert( - "GROUPS", - "NAME", name, - "DESCRIPTION", name, - "ORGANIZATION_UUID", organization, - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - return (Long) db.selectFirst(format("select id from groups where name='%s' and organization_uuid='%s'", name, organization)).get("ID"); - } - - private void setupDefaultOrganization() { - db.executeInsert("ORGANIZATIONS", - "UUID", DEFAULT_ORGANIZATION_UUID, - "KEE", DEFAULT_ORGANIZATION_UUID, "NAME", - DEFAULT_ORGANIZATION_UUID, "GUARDED", false, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", DEFAULT_ORGANIZATION_UUID); - } - - private void enableOrganization() { - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.enabled", - "IS_EMPTY", "false", - "TEXT_VALUE", "true"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivateTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivateTest.java deleted file mode 100644 index bf2efcc6d03..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivateTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateColumnProjectsPrivateTest { - private static final Boolean NO_PRIVATE_FLAG = null; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateColumnProjectsPrivateTest.class, "projects_with_nullable_private_column.sql"); - - private PopulateColumnProjectsPrivate underTest = new PopulateColumnProjectsPrivate(db.database()); - - @Test - public void execute_has_no_effect_if_table_PROJECTS_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("PROJECTS")).isEqualTo(0); - } - - @Test - public void execute_updates_rows_with_null_private_column_to_false() throws SQLException { - insertRow(1, NO_PRIVATE_FLAG); - insertRow(2, NO_PRIVATE_FLAG); - insertRow(3, NO_PRIVATE_FLAG); - - assertThat(countRowsWithPrivateFlag(null)).isEqualTo(3); - assertThat(countRowsWithPrivateFlag(true)).isEqualTo(0); - assertThat(countRowsWithPrivateFlag(false)).isEqualTo(0); - - underTest.execute(); - - assertThat(countRowsWithPrivateFlag(null)).isEqualTo(0); - assertThat(countRowsWithPrivateFlag(true)).isEqualTo(0); - assertThat(countRowsWithPrivateFlag(false)).isEqualTo(3); - } - - @Test - public void execute_does_not_change_rows_with_non_null_private_column() throws SQLException { - insertRow(2, true); - insertRow(3, false); - - underTest.execute(); - - assertThat(countRowsWithPrivateFlag(null)).isEqualTo(0); - assertThat(countRowsWithPrivateFlag(true)).isEqualTo(1); - assertThat(countRowsWithPrivateFlag(false)).isEqualTo(1); - } - - @Test - public void execute_is_reentreant() throws SQLException { - insertRow(1, true); - insertRow(2, false); - insertRow(3, NO_PRIVATE_FLAG); - - underTest.execute(); - - underTest.execute(); - } - - private int countRowsWithPrivateFlag(@Nullable Boolean privateFlag) { - if (privateFlag == null) { - return db.countSql("select count(1) from projects where private is null"); - } - return db.countSql("select count(1) from projects where private=" + privateFlag); - } - - private void insertRow(int id, @Nullable Boolean privateFlag) { - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", "org_" + id, - "UUID", "uuid_" + id, - "UUID_PATH", "uuid_path_" + id, - "ROOT_UUID", "root_uuid_" + id, - "PRIVATE", privateFlag == null ? null : privateFlag.toString()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest.java deleted file mode 100644 index fa6c1754ad5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl; - -import static java.lang.String.format; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang.math.RandomUtils.nextLong; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationMembersTableTest { - - private static final String TABLE = "organization_members"; - - private static final String DEFAULT_ORGANIZATION_UUID = "def org uuid"; - - private static final String PERMISSION_PROVISIONING = "provisioning"; - private static final String PERMISSION_ADMIN = "admin"; - private static final String PERMISSION_BROWSE = "user"; - private static final String PERMISSION_CODEVIEWER = "codeviewer"; - - private static final String ORG1_UUID = "ORG1_UUID"; - private static final String ORG2_UUID = "ORG2_UUID"; - - private static final String USER1_LOGIN = "USER1"; - private static final String USER2_LOGIN = "USER2"; - private static final String USER3_LOGIN = "USER3"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationMembersTableTest.class, "initial.sql"); - - private PopulateOrganizationMembersTable underTest = new PopulateOrganizationMembersTable(db.database(), new DefaultOrganizationUuidProviderImpl()); - - @Test - public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void fails_with_ISE_when_default_organization_does_not_exist_in_table_ORGANIZATIONS() throws SQLException { - setDefaultOrganizationProperty("blabla"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization with uuid 'blabla' does not exist in table ORGANIZATIONS"); - - underTest.execute(); - } - - @Test - public void execute_has_no_effect_when_table_is_empty() throws SQLException { - setupDefaultOrganization(); - - underTest.execute(); - } - - @Test - public void execute_is_reentrant_when_table_is_empty() throws SQLException { - setupDefaultOrganization(); - - underTest.execute(); - underTest.execute(); - } - - @Test - public void migrate_user_having_direct_global_permissions() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORG1_UUID); - insertOrganization(ORG2_UUID); - int userId = insertUser(USER1_LOGIN); - insertUserRole(userId, PERMISSION_PROVISIONING, ORG1_UUID, null); - insertUserRole(userId, PERMISSION_ADMIN, ORG1_UUID, null); - insertUserRole(userId, PERMISSION_ADMIN, ORG2_UUID, null); - - underTest.execute(); - - verifyUserMembership(userId, ORG1_UUID, ORG2_UUID, DEFAULT_ORGANIZATION_UUID); - } - - @Test - public void migrate_user_having_direct_project_permissions() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORG1_UUID); - insertOrganization(ORG2_UUID); - int userId = insertUser(USER1_LOGIN); - insertUserRole(userId, PERMISSION_BROWSE, ORG1_UUID, 1); - insertUserRole(userId, PERMISSION_CODEVIEWER, ORG1_UUID, 1); - insertUserRole(userId, PERMISSION_ADMIN, ORG2_UUID, 2); - - underTest.execute(); - - verifyUserMembership(userId, ORG1_UUID, ORG2_UUID, DEFAULT_ORGANIZATION_UUID); - } - - @Test - public void migrate_user_having_global_permissions_from_group() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORG1_UUID); - insertOrganization(ORG2_UUID); - int userId = insertUser(USER1_LOGIN); - int group1Id = insertNewGroup(ORG1_UUID); - int group2Id = insertNewGroup(ORG2_UUID); - insertUserGroup(userId, group1Id); - insertUserGroup(userId, group2Id); - - underTest.execute(); - - verifyUserMembership(userId, ORG1_UUID, ORG2_UUID, DEFAULT_ORGANIZATION_UUID); - } - - @Test - public void user_without_any_permission_should_be_member_of_default_organization() throws Exception { - setupDefaultOrganization(); - int userId = insertUser(USER1_LOGIN); - - underTest.execute(); - - verifyUserMembership(userId, DEFAULT_ORGANIZATION_UUID, DEFAULT_ORGANIZATION_UUID); - } - - @Test - public void migrate_users_having_any_kind_of_permission() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORG1_UUID); - insertOrganization(ORG2_UUID); - int user1 = insertUser(USER1_LOGIN); - int user2 = insertUser(USER2_LOGIN); - int user3 = insertUser(USER3_LOGIN); - int groupId = insertNewGroup(ORG1_UUID); - insertUserGroup(user2, groupId); - insertUserRole(user1, PERMISSION_PROVISIONING, ORG1_UUID, null); - insertUserRole(user1, PERMISSION_BROWSE, ORG2_UUID, 1); - - underTest.execute(); - - verifyUserMembership(user1, ORG1_UUID, ORG2_UUID, DEFAULT_ORGANIZATION_UUID); - verifyUserMembership(user2, ORG1_UUID, DEFAULT_ORGANIZATION_UUID); - verifyUserMembership(user3, DEFAULT_ORGANIZATION_UUID); - } - - @Test - public void migrate_missing_membership_on_direct_permission() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORG1_UUID); - insertOrganization(ORG2_UUID); - int userId = insertUser(USER1_LOGIN); - insertUserRole(userId, PERMISSION_ADMIN, ORG1_UUID, null); - insertUserRole(userId, PERMISSION_PROVISIONING, ORG2_UUID, null); - // Membership on organization 1 already exists, migration will add membership on organization 2 and default organization - insertOrganizationMember(userId, ORG1_UUID); - - underTest.execute(); - - verifyUserMembership(userId, ORG1_UUID, ORG2_UUID, DEFAULT_ORGANIZATION_UUID); - } - - @Test - public void migrate_missing_membership_on_group_permission() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORG1_UUID); - insertOrganization(ORG2_UUID); - int userId = insertUser(USER1_LOGIN); - int group1Id = insertNewGroup(ORG1_UUID); - int group2Id = insertNewGroup(ORG2_UUID); - insertUserGroup(userId, group1Id); - insertUserGroup(userId, group2Id); - // Membership on organization 1 already exists, migration will add membership on organization 2 and default organization - insertOrganizationMember(userId, ORG1_UUID); - - underTest.execute(); - - verifyUserMembership(userId, ORG1_UUID, ORG2_UUID, DEFAULT_ORGANIZATION_UUID); - } - - @Test - public void migrate_active_users_to_default_organization() throws Exception { - setupDefaultOrganization(); - int user1Id = insertUser(USER1_LOGIN, false); - int user2Id = insertUser(USER2_LOGIN, false); - int user3Id = insertUser(USER3_LOGIN, false); - int group1Id = insertNewGroup(ORG1_UUID); - insertUserRole(user1Id, PERMISSION_ADMIN, ORG1_UUID, null); - insertUserGroup(user2Id, group1Id); - - underTest.execute(); - - verifyUserMembership(user1Id); - verifyUserMembership(user2Id); - verifyUserMembership(user3Id); - } - - @Test - public void ignore_already_associated_users() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORG1_UUID); - int userId = insertUser(USER1_LOGIN); - insertUserRole(userId, PERMISSION_PROVISIONING, ORG1_UUID, null); - // User is already associated to organization 1 and to default organization, it should not fail - insertOrganizationMember(userId, ORG1_UUID); - insertOrganizationMember(userId, DEFAULT_ORGANIZATION_UUID); - - underTest.execute(); - - verifyUserMembership(userId, ORG1_UUID, DEFAULT_ORGANIZATION_UUID); - } - - @Test - public void migration_is_reentrant() throws Exception { - setupDefaultOrganization(); - insertOrganization(ORG1_UUID); - int userId = insertUser(USER1_LOGIN); - insertUserRole(userId, PERMISSION_PROVISIONING, ORG1_UUID, null); - verifyUserMembership(userId); - - underTest.execute(); - verifyUserMembership(userId, ORG1_UUID, DEFAULT_ORGANIZATION_UUID); - - underTest.execute(); - verifyUserMembership(userId, ORG1_UUID, DEFAULT_ORGANIZATION_UUID); - } - - private void insertOrganizationMember(int userId, String organizationUuid) { - db.executeInsert(TABLE, "USER_ID", userId, "ORGANIZATION_UUID", organizationUuid); - } - - private void insertOrganization(String uuid) { - db.executeInsert("ORGANIZATIONS", "UUID", uuid, "KEE", uuid, "NAME", uuid, "GUARDED", false, "CREATED_AT", nextLong(), "UPDATED_AT", nextLong()); - } - - private int insertUser(String login) { - return insertUser(login, true); - } - - private int insertUser(String login, boolean enabled) { - db.executeInsert("USERS", "LOGIN", login, "NAME", login, "ACTIVE", enabled, "IS_ROOT", false); - return ((Long) db.selectFirst(format("select ID from users where login='%s'", login)).get("ID")).intValue(); - } - - private void insertUserRole(int userId, String permission, String organizationUuid, @Nullable Integer componentId) { - ImmutableMap.Builder builder = ImmutableMap.builder() - .putAll(ImmutableMap.of("USER_ID", userId, "ROLE", permission, "ORGANIZATION_UUID", organizationUuid)); - Optional.ofNullable(componentId).ifPresent(id -> builder.put("RESOURCE_ID", id)); - db.executeInsert("USER_ROLES", builder.build()); - } - - private int insertNewGroup(String organizationUuid) { - String groupName = randomAlphabetic(10); - db.executeInsert("GROUPS", "NAME", groupName, "ORGANIZATION_UUID", organizationUuid); - return ((Long) db.selectFirst(format("select ID from groups where name='%s' and organization_uuid='%s'", groupName, organizationUuid)).get("ID")).intValue(); - } - - private void insertUserGroup(int userId, int groupId) { - db.executeInsert("GROUPS_USERS", "USER_ID", userId, "GROUP_ID", groupId); - } - - private void setupDefaultOrganization() { - setDefaultOrganizationProperty(DEFAULT_ORGANIZATION_UUID); - insertOrganization(DEFAULT_ORGANIZATION_UUID); - } - - private void setDefaultOrganizationProperty(String defaultOrganizationUuid) { - db.executeInsert( - "INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", defaultOrganizationUuid); - } - - private void verifyUserMembership(int userId, String... organizationUuids) { - List> rows = db.select(format("SELECT ORGANIZATION_UUID FROM " + TABLE + " WHERE USER_ID = %s", userId)); - List userOrganizationUuids = rows.stream() - .map(values -> (String) values.get("ORGANIZATION_UUID")) - .collect(MoreCollectors.toList()); - assertThat(userOrganizationUuids).containsOnly(organizationUuids); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest.java deleted file mode 100644 index 9a4bc6b0415..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Date; -import java.util.Map; -import javax.annotation.CheckForNull; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateRulesMetadataTest { - private static final String TABLE_RULES_METADATA = "rules_metadata"; - private static final String TABLE_RULES = "rules"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesMetadataTest.class, "rules_and_rules_metadata_and_organization_and_internal_properties.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private System2 system2 = mock(System2.class); - private PopulateRulesMetadata underTest = new PopulateRulesMetadata(db.database(), new DefaultOrganizationUuidProviderImpl(), system2); - - @Test - public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void fails_with_ISE_when_default_organization_does_not_exist_in_table_ORGANIZATIONS() throws SQLException { - db.defaultOrganization().insertInternalProperty("blabla"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization with uuid 'blabla' does not exist in table ORGANIZATIONS"); - - underTest.execute(); - } - - @Test - public void execute_has_no_effect_if_loaded_templates_table_is_empty() throws Exception { - db.defaultOrganization().setupDefaultOrganization(); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_RULES_METADATA)).isEqualTo(0); - } - - @Test - public void execute_has_no_effect_if_rules_is_empty() throws Exception { - db.defaultOrganization().setupDefaultOrganization(); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_RULES_METADATA)).isEqualTo(0); - assertThat(db.countRowsOfTable(TABLE_RULES)).isEqualTo(0); - } - - @Test - public void execute_creates_row_with_data_from_table_rules_for_each_row_in_table_rules() throws SQLException { - String defaultOrganizationUuid = db.defaultOrganization().setupDefaultOrganization(); - Metadata[] metadatas = { - new Metadata(), - new Metadata("foo"), - new Metadata().withNote("bar"), - new Metadata().withRemediation("doh"), - new Metadata().withTags("taggeah!") - }; - Dates noDates = new Dates(); - Dates dates = new Dates(122_334); - long now = 666_666_666L; - Dates defaultDates = new Dates(now, now); - long[] ruleIds = { - insertRule("r10", noDates, metadatas[0]), - insertRule("r11", dates, metadatas[0]), - insertRule("r20", noDates, metadatas[1]), - insertRule("r21", dates, metadatas[1]), - insertRule("r30", noDates, metadatas[2]), - insertRule("r31", dates, metadatas[2]), - insertRule("r40", noDates, metadatas[3]), - insertRule("r41", dates, metadatas[3]), - insertRule("r50", noDates, metadatas[4]), - insertRule("r51", dates, metadatas[4]) - }; - when(system2.now()).thenReturn(now); - - underTest.execute(); - - verifyRulesMetadata(ruleIds[0], defaultOrganizationUuid, defaultDates, metadatas[0]); - verifyRulesMetadata(ruleIds[1], defaultOrganizationUuid, dates, metadatas[0]); - verifyRulesMetadata(ruleIds[2], defaultOrganizationUuid, defaultDates, metadatas[1]); - verifyRulesMetadata(ruleIds[3], defaultOrganizationUuid, dates, metadatas[1]); - verifyRulesMetadata(ruleIds[4], defaultOrganizationUuid, defaultDates, metadatas[2]); - verifyRulesMetadata(ruleIds[5], defaultOrganizationUuid, dates, metadatas[2]); - verifyRulesMetadata(ruleIds[6], defaultOrganizationUuid, defaultDates, metadatas[3]); - verifyRulesMetadata(ruleIds[7], defaultOrganizationUuid, dates, metadatas[3]); - verifyRulesMetadata(ruleIds[8], defaultOrganizationUuid, defaultDates, metadatas[4]); - verifyRulesMetadata(ruleIds[9], defaultOrganizationUuid, dates, metadatas[4]); - } - - @Test - public void execute_creates_does_not_update_rows_in_table_RULES_METADATA() throws SQLException { - db.defaultOrganization().setupDefaultOrganization(); - long ruleId = insertRule("r1", new Dates(999), new Metadata("foo")); - insertRuleMetadata(ruleId, "other org uuid", new Dates(1_000)); - - underTest.execute(); - - verifyRulesMetadata(ruleId, "other org uuid", new Dates(1_000), new Metadata()); - } - - @Test - public void execute_is_reentrant() throws SQLException { - db.defaultOrganization().setupDefaultOrganization(); - insertRule("r1", new Dates(999), new Metadata("foo")); - insertRule("r2", new Dates(10_888), new Metadata("bar")); - - underTest.execute(); - - underTest.execute(); - } - - private void insertRuleMetadata(long ruleId, String organizationUuid, Dates dates) { - db.executeInsert( - "rules_metadata", - "RULE_ID", ruleId, - "ORGANIZATION_UUID", organizationUuid, - "CREATED_AT", dates.getCreatedAt(), - "UPDATED_AT", dates.getUpdatedAt()); - } - - private void verifyRulesMetadata(long ruleId, String organizationUuid, Dates dates, Metadata metadata) { - Map row = db.selectFirst("select" + - " ORGANIZATION_UUID as \"organization\"," + - " NOTE_DATA as \"noteData\"," + - " NOTE_USER_LOGIN as \"noteUserLogin\"," + - " NOTE_CREATED_AT as \"noteCreatedAt\"," + - " NOTE_UPDATED_AT as \"noteUpdatedAt\"," + - " REMEDIATION_FUNCTION as \"function\"," + - " REMEDIATION_GAP_MULT as \"gap\"," + - " REMEDIATION_BASE_EFFORT as \"baseEffort\"," + - " TAGS as \"tags\"," + - " CREATED_AT as \"createdAt\"," + - " UPDATED_AT as \"updateAt\"" + - " from rules_metadata" + - " where rule_id = " + ruleId); - assertThat(row.get("organization")).isEqualTo(organizationUuid); - assertThat(row.get("noteData")).isEqualTo(metadata.noteData); - assertThat(row.get("noteUserLogin")).isEqualTo(metadata.noteUserLogin); - assertThat(row.get("noteCreatedAt")).isEqualTo(metadata.noteDates.getCreatedAt()); - assertThat(row.get("noteUpdatedAt")).isEqualTo(metadata.noteDates.getUpdatedAt()); - assertThat(row.get("function")).isEqualTo(metadata.remediationFunction); - assertThat(row.get("gap")).isEqualTo(metadata.remediationGapMult); - assertThat(row.get("baseEffort")).isEqualTo(metadata.remediationBaseEffort); - assertThat(row.get("tags")).isEqualTo(metadata.tags); - assertThat(row.get("createdAt")).isEqualTo(dates.getCreatedAt()); - assertThat(row.get("updateAt")).isEqualTo(dates.getUpdatedAt()); - } - - private long insertRule(String key, Dates dates, Metadata metadata) { - db.executeInsert( - TABLE_RULES, - "PLUGIN_RULE_KEY", key, - "PLUGIN_NAME", "name_" + key, - "NOTE_DATA", metadata.noteData, - "NOTE_USER_LOGIN", metadata.noteUserLogin, - "NOTE_CREATED_AT", metadata.noteDates.getCreatedAtDate(), - "NOTE_UPDATED_AT", metadata.noteDates.getUpdatedAtDate(), - "REMEDIATION_FUNCTION", metadata.remediationFunction, - "REMEDIATION_GAP_MULT", metadata.remediationGapMult, - "REMEDIATION_BASE_EFFORT", metadata.remediationBaseEffort, - "TAGS", metadata.tags, - "CREATED_AT", dates.getCreatedAt(), - "UPDATED_AT", dates.getUpdatedAt()); - return (long) db.selectFirst("select ID as \"id\" from RULES where PLUGIN_RULE_KEY='" + key + "'") - .get("id"); - } - - private static final class Metadata { - private String noteData; - private String noteUserLogin; - private Dates noteDates; - private String remediationFunction; - private String remediationGapMult; - private String remediationBaseEffort; - private String tags; - - private Metadata() { - this.noteData = null; - this.noteUserLogin = null; - this.noteDates = new Dates(); - this.remediationFunction = null; - this.remediationGapMult = null; - this.remediationBaseEffort = null; - this.tags = null; - } - - private Metadata(String seed) { - withNote(seed); - withRemediation(seed); - this.tags = seed + "_tags"; - } - - private Metadata withNote(String seed) { - this.noteData = seed + "_noteData"; - this.noteUserLogin = seed + "_noteUserLogin"; - this.noteDates = new Dates(seed.hashCode()); - return this; - } - - private Metadata withTags(String tags) { - this.tags = tags; - return this; - } - - private Metadata withRemediation(String seed) { - this.remediationFunction = seed + "_Function"; - this.remediationGapMult = seed + "_GapMult"; - this.remediationBaseEffort = seed + "_BaseEffort"; - return this; - } - } - - private static final class Dates { - private final Long createdAt; - private final Long updatedAt; - - private Dates() { - this.createdAt = null; - this.updatedAt = null; - } - - private Dates(long seed) { - this.createdAt = seed + 5_778_765L; - this.updatedAt = seed + 9_111_100L; - } - - public Dates(long createdAt, long updatedAt) { - this.createdAt = createdAt; - this.updatedAt = updatedAt; - } - - @CheckForNull - public Long getCreatedAt() { - return createdAt; - } - - @CheckForNull - public Date getCreatedAtDate() { - return createdAt == null ? null : new Date(createdAt); - } - - @CheckForNull - public Long getUpdatedAt() { - return updatedAt; - } - - @CheckForNull - public Date getUpdatedAtDate() { - return updatedAt == null ? null : new Date(updatedAt); - } - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuidTest.java deleted file mode 100644 index 4e08dfa7708..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuidTest.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Random; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class PurgeComponentsWithoutProjectUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PurgeComponentsWithoutProjectUuidTest.class, "projects_and_children_tables.sql"); - - private Random random = new Random(); - - private PurgeComponentsWithoutProjectUuid underTest = new PurgeComponentsWithoutProjectUuid(db.database()); - - @Test - public void execute_has_no_effect_when_every_tables_are_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_deletes_rows_from_PROJECTS_where_project_uuid_is_null() throws SQLException { - insertComponent("u1", "u1"); - insertComponent("u2", "u1"); - insertComponent("u3", null); - - underTest.execute(); - - assertThat(db.select("select uuid from projects").stream() - .flatMap(map -> map.entrySet().stream()) - .map(entry -> (String) entry.getValue()) - .collect(MoreCollectors.toList())) - .containsOnly("u1", "u2"); - } - - @Test - public void executes_deletes_from_child_table_DUPLICATIONS_INDEX() throws SQLException { - insertComponent("u1", "foo"); - insertComponent("u2", null); - Stream.of("u1", "u2").forEach(componentUuid -> { - String snapshotUuid = "s" + componentUuid; - insertSnapshot(snapshotUuid, componentUuid); - insertDuplicationsIndex(snapshotUuid, componentUuid); - insertDuplicationsIndex(snapshotUuid, "other_component" + random.nextInt(30)); - }); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from duplications_index where analysis_uuid = '" + "su1" + "'")).isEqualTo(2); - assertThat(db.countSql("select count(1) from duplications_index where analysis_uuid = '" + "su2" + "'")).isEqualTo(0); - } - - @Test - public void execute_deletes_from_child_table_PROJECT_MEASURES() throws SQLException { - insertComponent("u1", "foo"); - insertComponent("u2", null); - Stream.of("u1", "u2").forEach(componentUuid -> { - String snapshotUuid1 = "s1" + componentUuid; - insertSnapshot(snapshotUuid1, componentUuid); - insertProjectMeasure(snapshotUuid1, componentUuid); - String snapshotUuid2 = "s2" + componentUuid; - insertSnapshot(snapshotUuid2, "other_component" + random.nextInt(30)); - insertProjectMeasure(snapshotUuid2, componentUuid); - }); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from project_measures where component_uuid = '" + "u1" + "'")).isEqualTo(2); - assertThat(db.countSql("select count(1) from project_measures where component_uuid = '" + "u2" + "'")).isEqualTo(0); - } - - @Test - public void execute_deletes_from_child_table_CE_ACTIVITY() throws SQLException { - insertComponent("u1", "foo"); - insertComponent("u2", null); - Stream.of("u1", "u2").forEach(componentUuid -> { - insertCeActivity("ce1" + componentUuid, componentUuid); - }); - insertCeActivity("ce2", null); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from ce_activity where component_uuid = '" + "u1" + "'")).isEqualTo(1); - assertThat(db.countSql("select count(1) from ce_activity where component_uuid = '" + "u2" + "'")).isEqualTo(0); - assertThat(db.countSql("select count(1) from ce_activity where component_uuid is null")).isEqualTo(1); - } - - @Test - public void execute_deletes_from_child_table_EVENTS() throws SQLException { - insertComponent("u1", "foo"); - insertComponent("u2", null); - String snapshotOfOtherComponent = "bar"; - insertSnapshot(snapshotOfOtherComponent, "foo"); - Stream.of("u1", "u2").forEach(componentUuid -> { - String snapshot1 = "s1" + componentUuid; - insertSnapshot(snapshot1, componentUuid); - insertEvent("e1" + componentUuid, snapshot1, null); - insertEvent("e2" + componentUuid, snapshot1, componentUuid); - insertEvent("e3" + componentUuid, snapshotOfOtherComponent, componentUuid); - }); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from events where component_uuid = '" + "u1" + "'")).isEqualTo(2); - assertThat(db.countSql("select count(1) from events where analysis_uuid = '" + "s1u1" + "'")).isEqualTo(2); - assertThat(db.countSql("select count(1) from events where component_uuid = '" + "u2" + "'")).isEqualTo(0); - assertThat(db.countSql("select count(1) from events where analysis_uuid = '" + "s1u2" + "'")).isEqualTo(0); - assertThat(db.countSql("select count(1) from events where analysis_uuid = '" + snapshotOfOtherComponent + "'")).isEqualTo(1); - } - - @Test - public void execute_deletes_from_child_table_PROJECT_LINKS() throws SQLException { - insertComponent("u1", "foo"); - insertComponent("u2", null); - Stream.of("u1", "u2").forEach(componentUuid -> { - insertProjectLink(componentUuid); - }); - insertProjectLink(null); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from project_links where component_uuid = '" + "u1" + "'")).isEqualTo(1); - assertThat(db.countSql("select count(1) from project_links where component_uuid = '" + "u2" + "'")).isEqualTo(0); - assertThat(db.countSql("select count(1) from project_links where component_uuid is null")).isEqualTo(1); - } - - @Test - public void execute_deletes_from_child_table_SNAPSHOTS() throws SQLException { - insertComponent("u1", "foo"); - insertComponent("u2", null); - Stream.of("u1", "u2").forEach(componentUuid -> { - insertSnapshot("s1" + componentUuid, componentUuid); - }); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from snapshots where component_uuid = '" + "u1" + "'")).isEqualTo(1); - assertThat(db.countSql("select count(1) from snapshots where component_uuid = '" + "u2" + "'")).isEqualTo(0); - } - - @Test - public void execute_deletes_from_child_table_ISSUES() throws SQLException { - insertComponent("u1", "foo"); - insertComponent("u2", null); - Stream.of("u1", "u2").forEach(componentUuid -> { - insertIssue("s1" + componentUuid, componentUuid); - }); - insertIssue("s2", null); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from issues where component_uuid = '" + "u1" + "'")).isEqualTo(1); - assertThat(db.countSql("select count(1) from issues where component_uuid = '" + "u2" + "'")).isEqualTo(0); - assertThat(db.countSql("select count(1) from issues where component_uuid is null")).isEqualTo(1); - } - - @Test - public void execute_deletes_from_child_table_FILE_SOURCES() throws SQLException { - insertComponent("u1", "foo"); - insertComponent("u2", null); - Stream.of("u1", "u2").forEach(componentUuid -> { - insertFileSource(componentUuid, "foo"); - insertFileSource("bar", componentUuid); - insertFileSource(componentUuid, componentUuid); - }); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from file_sources where project_uuid = '" + "u1" + "' or file_uuid = '" + "u1" + "'")).isEqualTo(3); - assertThat(db.countSql("select count(1) from file_sources where project_uuid = '" + "u2" + "' or file_uuid = '" + "u2" + "'")).isEqualTo(0); - } - - @Test - public void execute_deletes_from_child_table_GROUP_ROLES() throws SQLException { - long project1 = insertComponent("u1", "foo"); - long project2 = insertComponent("u2", null); - Stream.of(project1, project2).forEach(componentId -> { - insertGroupRole(componentId); - }); - insertGroupRole(null); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from group_roles where RESOURCE_ID = " + project1)).isEqualTo(1); - assertThat(db.countSql("select count(1) from group_roles where RESOURCE_ID = " + project2)).isEqualTo(0); - assertThat(db.countSql("select count(1) from group_roles where RESOURCE_ID is null")).isEqualTo(1); - } - - @Test - public void execute_deletes_from_child_table_USER_ROLES() throws SQLException { - long project1 = insertComponent("u1", "foo"); - long project2 = insertComponent("u2", null); - Stream.of(project1, project2).forEach(componentId -> { - insertUserRole(componentId); - }); - insertUserRole(null); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from user_roles where resource_id = " + project1)).isEqualTo(1); - assertThat(db.countSql("select count(1) from user_roles where resource_id = " + project2)).isEqualTo(0); - assertThat(db.countSql("select count(1) from user_roles where resource_id is null")).isEqualTo(1); - } - - @Test - public void execute_deletes_from_child_table_PROPERTIES() throws SQLException { - long project1 = insertComponent("u1", "foo"); - long project2 = insertComponent("u2", null); - Stream.of(project1, project2).forEach(componentId -> { - insertProperties(componentId); - }); - insertProperties(null); - - underTest.execute(); - - assertThat(db.countSql("select count(1) from properties where resource_id = " + project1)).isEqualTo(1); - assertThat(db.countSql("select count(1) from properties where resource_id = " + project2)).isEqualTo(0); - assertThat(db.countSql("select count(1) from properties where resource_id is null")).isEqualTo(1); - } - - private long insertComponent(String uuid, @Nullable String projectUuid) { - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", "org_" + uuid, - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_" + uuid, - "PROJECT_UUID", projectUuid); - return (long) db.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID"); - } - - private void insertSnapshot(String uuid, String componentUuid) { - db.executeInsert( - "SNAPSHOTS", - "UUID", uuid, - "COMPONENT_UUID", componentUuid, - "STATUS", random.nextBoolean() ? "U" : "P", - "ISLAST", valueOf(random.nextBoolean())); - } - - private void insertDuplicationsIndex(String snapshotUuid, String componentUuid) { - db.executeInsert( - "DUPLICATIONS_INDEX", - "ANALYSIS_UUID", snapshotUuid, - "COMPONENT_UUID", componentUuid, - "HASH", "hash_" + random.nextInt(100), - "INDEX_IN_FILE", valueOf(random.nextInt(50)), - "START_LINE", valueOf(random.nextInt(50)), - "END_LINE", valueOf(random.nextInt(50))); - } - - private void insertProjectMeasure(String snapshotUuid, String componentUuid) { - db.executeInsert( - "PROJECT_MEASURES", - "METRIC_ID", valueOf(random.nextInt(50)), - "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", snapshotUuid); - } - - private void insertCeActivity(String uuid, @Nullable String componentUuid) { - db.executeInsert( - "CE_ACTIVITY", - "UUID", uuid, - "TASK_TYPE", "type_" + random.nextInt(10), - "STATUS", "status" + random.nextInt(10), - "COMPONENT_UUID", componentUuid, - "IS_LAST", valueOf(random.nextBoolean()), - "IS_LAST_KEY", "isLastKey" + random.nextInt(20), - "SUBMITTED_AT", valueOf(random.nextInt(555)), - "CREATED_AT", valueOf(random.nextInt(555)), - "UPDATED_AT", valueOf(random.nextInt(555))); - } - - private void insertEvent(String uuid, String analysisUuid, @Nullable String componentUuid) { - db.executeInsert( - "EVENTS", - "UUID", uuid, - "ANALYSIS_UUID", analysisUuid, - "COMPONENT_UUID", componentUuid, - "EVENT_DATE", random.nextInt(), - "CREATED_AT", random.nextInt()); - } - - private void insertProjectLink(@Nullable String componentUuid) { - db.executeInsert( - "PROJECT_LINKS", - "COMPONENT_UUID", componentUuid, - "HREF", "href_" + random.nextInt()); - } - - private void insertIssue(String s, @Nullable String componentUuid) { - db.executeInsert( - "ISSUES", - "KEE", s, - "COMPONENT_UUID", componentUuid, - "MANUAL_SEVERITY", valueOf(random.nextBoolean())); - } - - private void insertFileSource(String projectUuid, String fileUuid) { - db.executeInsert( - "FILE_SOURCES", - "PROJECT_UUID", projectUuid, - "FILE_UUID", fileUuid, - "CREATED_AT", valueOf(random.nextInt(555)), - "UPDATED_AT", valueOf(random.nextInt(555))); - } - - private void insertGroupRole(@Nullable Long componentId) { - db.executeInsert( - "GROUP_ROLES", - "ORGANIZATION_UUID", "org_" + random.nextInt(20), - "GROUP_ID", random.nextBoolean() ? null : random.nextInt(), - "RESOURCE_ID", componentId == null ? null : valueOf(componentId), - "ROLE", "role_" + random.nextInt(10)); - } - - private void insertUserRole(@Nullable Long componentId) { - db.executeInsert( - "USER_ROLES", - "ORGANIZATION_UUID", "org_" + random.nextInt(20), - "USER_ID", random.nextBoolean() ? null : random.nextInt(), - "RESOURCE_ID", componentId == null ? null : valueOf(componentId), - "ROLE", "role_" + random.nextInt(10)); - } - - private void insertProperties(@Nullable Long componentId) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", "prop_" + random.nextInt(15), - "RESOURCE_ID", componentId == null ? null : valueOf(componentId), - "IS_EMPTY", valueOf(random.nextBoolean())); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroupsTest.java deleted file mode 100644 index a3e1919a9bf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroupsTest.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.LogTester; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl; - -import static java.lang.String.format; -import static org.apache.commons.lang.math.RandomUtils.nextLong; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.sonar.api.utils.log.LoggerLevel.WARN; - -public class RestoreSonarUsersGroupsTest { - - private static final Date PAST = new Date(100_000_000_000L); - private static final Date NOW = new Date(500_000_000_000L); - private static final String DEFAULT_ORGANIZATION_UUID = "def-org"; - private static final String SONAR_USERS_NAME = "sonar-users"; - private static final String SONAR_USERS_PENDING_DESCRIPTION = ""; - private static final String SONAR_USERS_FINAL_DESCRIPTION = "Any new users created will automatically join this group"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public LogTester logTester = new LogTester(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RestoreSonarUsersGroupsTest.class, "initial.sql"); - - private System2 system2 = mock(System2.class); - - private RestoreSonarUsersGroups underTest = new RestoreSonarUsersGroups(db.database(), system2, new DefaultOrganizationUuidProviderImpl()); - - @Before - public void setUp() throws Exception { - when(system2.now()).thenReturn(NOW.getTime()); - } - - @Test - public void insert_sonar_users_group_when_it_does_not_exist() throws SQLException { - setupDefaultOrganization(); - setDefaultGroup("default-group"); - - underTest.execute(); - - checkSonarUsersHasBeenCreated(); - } - - @Test - public void display_log_when_creating_sonar_users_group() throws SQLException { - setupDefaultOrganization(); - setDefaultGroup("default-group"); - - underTest.execute(); - - checkSonarUsersHasBeenCreated(); - assertThat(logTester.logs(WARN)).containsOnly("The default group has been updated from 'default-group' to 'sonar-users'. Please verify your permission schema that everything is in order"); - } - - @Test - public void copy_permission_from_existing_default_group_to_sonar_users_when_it_does_not_exist() throws Exception { - setupDefaultOrganization(); - long defaultGroupId = setDefaultGroup("default-group"); - insertGroupRole(defaultGroupId, "user", null); - insertGroupRole(defaultGroupId, "admin", 1L); - insertPermissionTemplate(defaultGroupId, "user", 10L); - - underTest.execute(); - - checkSonarUsersHasBeenCreated(); - checkUserRolesOnSonarUsers(tuple("user", null, DEFAULT_ORGANIZATION_UUID), tuple("admin", 1L, DEFAULT_ORGANIZATION_UUID)); - checkPermissionTemplatesOnSonarUsers(tuple("user", 10L, NOW, NOW)); - } - - @Test - public void update_sonar_users_group_when_existing_with_incorrect_description() throws Exception { - setupDefaultOrganization(); - insertGroup(SONAR_USERS_NAME, "Other description", PAST, PAST); - - underTest.execute(); - - checkSonarUsersHasBeenUpdated(); - } - - @Test - public void update_sonar_users_group_when_default_group_setting_is_null() throws SQLException { - setupDefaultOrganization(); - insertDefaultGroupProperty(null); - insertGroup(SONAR_USERS_NAME, "Other description", PAST, PAST); - - underTest.execute(); - - checkSonarUsersHasBeenUpdated(); - } - - @Test - public void does_nothing_when_sonar_users_exist_with_right_description() throws SQLException { - setupDefaultOrganization(); - insertGroup(SONAR_USERS_NAME, SONAR_USERS_FINAL_DESCRIPTION, PAST, PAST); - - underTest.execute(); - - checkSonarUsersHasNotBeenUpdated(); - } - - @Test - public void display_log_when_moving_default_group_to_sonar_users_group() throws SQLException { - setupDefaultOrganization(); - insertGroup(SONAR_USERS_NAME, "wrong desc", PAST, PAST); - setDefaultGroup("default-group"); - - underTest.execute(); - - checkSonarUsersHasBeenUpdated(); - assertThat(logTester.logs(WARN)).containsOnly("The default group has been updated from 'default-group' to 'sonar-users'. Please verify your permission schema that everything is in order"); - } - - @Test - public void does_not_copy_permission_existing_default_group_to_sonar_users_when_it_already_exists() throws Exception { - setupDefaultOrganization(); - long defaultGroupId = setDefaultGroup("default-group"); - insertGroupRole(defaultGroupId, "user", null); - insertGroupRole(defaultGroupId, "admin", 1L); - insertPermissionTemplate(defaultGroupId, "user", 10L); - // sonar-users has no permission on it - insertGroup(SONAR_USERS_NAME, SONAR_USERS_FINAL_DESCRIPTION, PAST, PAST); - - underTest.execute(); - - checkSonarUsersHasNotBeenUpdated(); - // No permission set on sonar-users - checkUserRolesOnSonarUsers(); - checkPermissionTemplatesOnSonarUsers(); - } - - @Test - public void does_not_display_log_when_default_group_is_sonar_users() throws SQLException { - setupDefaultOrganization(); - insertGroup(SONAR_USERS_NAME, SONAR_USERS_FINAL_DESCRIPTION, PAST, PAST); - insertDefaultGroupProperty(SONAR_USERS_NAME); - - underTest.execute(); - - assertThat(logTester.logs(WARN)).isEmpty(); - } - - @Test - public void continue_migration_when_description_is_pending() throws Exception { - setupDefaultOrganization(); - // Default group with is permissions - long defaultGroupId = setDefaultGroup("default-group"); - insertGroupRole(defaultGroupId, "admin", 1L); - insertGroupRole(defaultGroupId, "user", 2L); - insertGroupRole(defaultGroupId, "codeviewer", null); - insertPermissionTemplate(defaultGroupId, "user", 10L); - insertPermissionTemplate(defaultGroupId, "admin", 11L); - // sonar-users group with partial permissions from default group - long sonarUsersGroupId = insertGroup(SONAR_USERS_NAME, SONAR_USERS_PENDING_DESCRIPTION, PAST, PAST); - insertGroupRole(sonarUsersGroupId, "admin", 1L); - insertPermissionTemplate(sonarUsersGroupId, "user", 10L); - - underTest.execute(); - - checkSonarUsersHasBeenUpdated(); - checkUserRolesOnSonarUsers(tuple("admin", 1L, DEFAULT_ORGANIZATION_UUID), tuple("user", 2L, DEFAULT_ORGANIZATION_UUID), tuple("codeviewer", null, DEFAULT_ORGANIZATION_UUID)); - checkPermissionTemplatesOnSonarUsers(tuple("user", 10L, PAST, PAST), tuple("admin", 11L, NOW, NOW)); - } - - @Test - public void does_not_update_other_groups() throws SQLException { - setupDefaultOrganization(); - insertGroup("another-group", "another-group", PAST, PAST); - insertGroup(SONAR_USERS_NAME, SONAR_USERS_FINAL_DESCRIPTION, PAST, PAST); - - underTest.execute(); - - checkSonarUsersHasNotBeenUpdated(); - assertThat(db.countRowsOfTable("groups")).isEqualTo(2); - } - - @Test - public void migration_is_reentrant() throws Exception { - setupDefaultOrganization(); - long defaultGroupId = setDefaultGroup("default-group"); - insertGroupRole(defaultGroupId, "user", null); - insertGroupRole(defaultGroupId, "admin", 1L); - insertPermissionTemplate(defaultGroupId, "user", 10L); - - underTest.execute(); - checkSonarUsersHasBeenCreated(); - checkUserRolesOnSonarUsers(tuple("user", null, DEFAULT_ORGANIZATION_UUID), tuple("admin", 1L, DEFAULT_ORGANIZATION_UUID)); - checkPermissionTemplatesOnSonarUsers(tuple("user", 10L, NOW, NOW)); - - underTest.execute(); - checkSonarUsersHasBeenCreated(); - checkUserRolesOnSonarUsers(tuple("user", null, DEFAULT_ORGANIZATION_UUID), tuple("admin", 1L, DEFAULT_ORGANIZATION_UUID)); - checkPermissionTemplatesOnSonarUsers(tuple("user", 10L, NOW, NOW)); - } - - @Test - public void fail_when_no_default_group_in_setting_and_sonar_users_does_not_exist() throws Exception { - setupDefaultOrganization(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default group setting sonar.defaultGroup is defined to a 'sonar-users' group but it doesn't exist."); - - underTest.execute(); - } - - @Test - public void fail_when_default_group_setting_is_set_to_an_unknown_group() throws SQLException { - setupDefaultOrganization(); - insertDefaultGroupProperty("unknown"); - insertGroup(SONAR_USERS_NAME, SONAR_USERS_FINAL_DESCRIPTION, PAST, PAST); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default group setting sonar.defaultGroup is defined to an unknown group."); - - underTest.execute(); - } - - private void checkSonarUsersHasBeenCreated() { - Map group = selectSonarUsersGroup(); - checkSonarUsersCommonInfo(group); - assertThat(group.get("CREATED_AT")).isEqualTo(NOW); - assertThat(group.get("UPDATED_AT")).isEqualTo(NOW); - } - - private void checkSonarUsersHasBeenUpdated() { - Map group = selectSonarUsersGroup(); - checkSonarUsersCommonInfo(group); - assertThat(group.get("CREATED_AT")).isEqualTo(PAST); - assertThat(group.get("UPDATED_AT")).isEqualTo(NOW); - } - - private void checkSonarUsersHasNotBeenUpdated() { - Map group = selectSonarUsersGroup(); - checkSonarUsersCommonInfo(group); - assertThat(group.get("CREATED_AT")).isEqualTo(PAST); - assertThat(group.get("UPDATED_AT")).isEqualTo(PAST); - } - - private void checkSonarUsersCommonInfo(Map group) { - assertThat(group.get("NAME")).isEqualTo("sonar-users"); - assertThat(group.get("DESCRIPTION")).isEqualTo("Any new users created will automatically join this group"); - assertThat(group.get("ORGANIZATION_UUID")).isEqualTo(DEFAULT_ORGANIZATION_UUID); - } - - private void checkUserRolesOnSonarUsers(Tuple... expectedTuples) { - List tuples = db.select("select gr.role, gr.resource_id, gr.organization_uuid from group_roles gr " + - "inner join groups g on g.id=gr.group_id " + - "where g.name='sonar-users'").stream() - .map(map -> new Tuple(map.get("ROLE"), map.get("RESOURCE_ID"), map.get("ORGANIZATION_UUID"))) - .collect(Collectors.toList()); - assertThat(tuples).containsOnly(expectedTuples); - } - - private void checkPermissionTemplatesOnSonarUsers(Tuple... expectedTuples) { - List tuples = db.select("select ptg.permission_reference, ptg.template_id, ptg.created_at, ptg.updated_at from perm_templates_groups ptg " + - "inner join groups g on g.id=ptg.group_id " + - "where g.name='sonar-users'").stream() - .map(map -> new Tuple(map.get("PERMISSION_REFERENCE"), map.get("TEMPLATE_ID"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList()); - assertThat(tuples).containsOnly(expectedTuples); - } - - private Map selectSonarUsersGroup() { - return db.selectFirst("select name, description, organization_uuid, created_at, updated_at from groups where name='sonar-users'"); - } - - private long insertGroup(String name, String description, Date createdAt, Date updatedAt) { - db.executeInsert( - "GROUPS", - "NAME", name, - "DESCRIPTION", description, - "ORGANIZATION_UUID", DEFAULT_ORGANIZATION_UUID, - "CREATED_AT", createdAt, - "UPDATED_AT", updatedAt); - return (Long) db.selectFirst(format("select id from groups where name='%s'", name)).get("ID"); - } - - private void insertDefaultGroupProperty(@Nullable String groupName) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", "sonar.defaultGroup", - "TEXT_VALUE", groupName, - "IS_EMPTY", Boolean.toString(groupName == null), - "CREATED_AT", "1000"); - } - - private void insertGroupRole(@Nullable Long groupId, String permission, @Nullable Long projectId) { - db.executeInsert( - "GROUP_ROLES", - "ORGANIZATION_UUID", DEFAULT_ORGANIZATION_UUID, - "GROUP_ID", groupId, - "RESOURCE_ID", projectId, - "ROLE", permission); - } - - private void insertPermissionTemplate(@Nullable Long groupId, String permission, @Nullable Long templateId) { - db.executeInsert( - "PERM_TEMPLATES_GROUPS", - "GROUP_ID", groupId, - "TEMPLATE_ID", templateId, - "PERMISSION_REFERENCE", permission, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private void setupDefaultOrganization() { - db.executeInsert("ORGANIZATIONS", - "UUID", DEFAULT_ORGANIZATION_UUID, - "KEE", DEFAULT_ORGANIZATION_UUID, "NAME", - DEFAULT_ORGANIZATION_UUID, "GUARDED", false, - "CREATED_AT", nextLong(), - "UPDATED_AT", nextLong()); - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", DEFAULT_ORGANIZATION_UUID); - } - - private long setDefaultGroup(String name) { - insertDefaultGroupProperty(name); - return insertGroup(name, name, PAST, PAST); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroupTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroupTest.java deleted file mode 100644 index 6bd1287fc0b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroupTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -public class SetAllUsersIntoSonarUsersGroupTest { - - private static final String SONAR_USERS_NAME = "sonar-users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetAllUsersIntoSonarUsersGroupTest.class, "initial.sql"); - - private SetAllUsersIntoSonarUsersGroup underTest = new SetAllUsersIntoSonarUsersGroup(db.database()); - - @Test - public void set_users_into_sonar_users_group() throws Exception { - long sonarUsersGroupId = insertGroup(SONAR_USERS_NAME); - long userId = insertUser("user", true); - - underTest.execute(); - - checkUserGroups(userId, sonarUsersGroupId); - } - - @Test - public void does_not_remove_existing_sonar_users_group_membership() throws Exception { - long sonarUsersGroupId = insertGroup(SONAR_USERS_NAME); - long userId = insertUser("user", true); - insertUserGroups(userId, sonarUsersGroupId); - - underTest.execute(); - - checkUserGroups(userId, sonarUsersGroupId); - } - - @Test - public void does_not_remove_existing_group_membership() throws Exception { - long sonarUsersGroupId = insertGroup(SONAR_USERS_NAME); - long anotherGroupId = insertGroup("another-group"); - long userId = insertUser("user", true); - insertUserGroups(userId, anotherGroupId); - - underTest.execute(); - - checkUserGroups(userId, sonarUsersGroupId, anotherGroupId); - } - - @Test - public void ignore_disabled_users() throws Exception { - insertGroup(SONAR_USERS_NAME); - long userId = insertUser("user", false); - - underTest.execute(); - - checkUserGroups(userId); - } - - @Test - public void migration_is_renentrant() throws Exception { - long sonarUsersGroupId = insertGroup(SONAR_USERS_NAME); - long userId = insertUser("user", true); - - underTest.execute(); - checkUserGroups(userId, sonarUsersGroupId); - - underTest.execute(); - checkUserGroups(userId, sonarUsersGroupId); - } - - private void checkUserGroups(long userId, Long... expectedGroupIds) { - List groups = db.select(format("select gu.group_id from groups_users gu where gu.user_id=%s", userId)).stream() - .map(map -> (Long) map.get("GROUP_ID")) - .collect(Collectors.toList()); - assertThat(groups).containsOnly(expectedGroupIds); - } - - private long insertUser(String login, boolean enabled) { - db.executeInsert( - "USERS", - "LOGIN", login, - "ACTIVE", Boolean.toString(enabled), - "IS_ROOT", "false", - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - return (Long) db.selectFirst(format("select id from users where login='%s'", login)).get("ID"); - } - - private long insertGroup(String name) { - db.executeInsert( - "GROUPS", - "NAME", name, - "DESCRIPTION", name, - "ORGANIZATION_UUID", "ORGANIZATION_UUID", - "CREATED_AT", new Date(), - "UPDATED_AT", new Date()); - return (Long) db.selectFirst(format("select id from groups where name='%s'", name)).get("ID"); - } - - private void insertUserGroups(long userId, Long... groupIds) { - Arrays.stream(groupIds).forEach(groupId -> db.executeInsert( - "GROUPS_USERS", - "USER_ID", userId, - "GROUP_ID", groupId)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest.java deleted file mode 100644 index b27b1b468fd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SetCopyComponentUuidOnLocalViewsTest { - - private static final String TABLE_PROJECTS = "projects"; - - private static final String QUALIFIER_SUB_VIEW = "SVW"; - private static final String QUALIFIER_VIEW = "VW"; - private static final String SCOPE_PROJECT = "PRJ"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetCopyComponentUuidOnLocalViewsTest.class, "in_progress_projects.sql"); - - private SetCopyComponentUuidOnLocalViews underTest = new SetCopyComponentUuidOnLocalViews(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROJECTS)).isZero(); - } - - @Test - public void set_copy_component_uuid_on_sub_views() throws Exception { - insertProject("VIEW1", "VIEW1_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW2", "VIEW2_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW1:VIEW2", "LOCAL_VIEW2_UUID", null, QUALIFIER_SUB_VIEW, SCOPE_PROJECT); - - underTest.execute(); - - verifyOnlyOneComponentHasCopyComponentUuid("LOCAL_VIEW2_UUID", "VIEW2_UUID"); - } - - @Test - public void set_copy_component_uuid_on_imbricated_sub_views() throws Exception { - insertProject("VIEW1", "VIEW1_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW2", "VIEW2_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW3", "VIEW3_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW1:VIEW2", "LOCAL_VIEW2_UUID", null, QUALIFIER_SUB_VIEW, SCOPE_PROJECT); - insertProject("VIEW2:VIEW3", "LOCAL_VIEW3_UUID", null, QUALIFIER_SUB_VIEW, SCOPE_PROJECT); - insertProject("VIEW1:VIEW2:VIEW3", "LOCAL_VIEW3_BIS_UUID", null, QUALIFIER_SUB_VIEW, SCOPE_PROJECT); - - underTest.execute(); - - verifyComponentsHavingCopyComponentUuid( - new Component("LOCAL_VIEW2_UUID", "VIEW2_UUID"), - new Component("LOCAL_VIEW3_UUID", "VIEW3_UUID"), - new Component("LOCAL_VIEW3_BIS_UUID", "VIEW3_UUID")); - } - - @Test - public void migration_doest_not_update_copy_component_uuid_if_already_exists() throws Exception { - insertProject("VIEW1", "VIEW1_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW2", "VIEW2_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW1:VIEW2", "LOCAL_VIEW2_UUID", "ALREADY_EXISTING", QUALIFIER_SUB_VIEW, SCOPE_PROJECT); - - underTest.execute(); - - verifyOnlyOneComponentHasCopyComponentUuid("LOCAL_VIEW2_UUID", "ALREADY_EXISTING"); - } - - @Test - public void migration_ignores_sub_view_having_bad_key_format() throws Exception { - insertProject("VIEW1", "VIEW1_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW2", "VIEW2_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - // Missing ':' in the key - insertProject("VIEW1_VIEW2", "LOCAL_VIEW2_UUID", null, QUALIFIER_SUB_VIEW, SCOPE_PROJECT); - - underTest.execute(); - - verifyComponentsHavingCopyComponentUuid(); - } - - @Test - public void migration_does_nothing_when_no_root_views() throws Exception { - insertProject("VIEW1:VIEW2", "LOCAL_VIEW2_UUID", null, QUALIFIER_SUB_VIEW, SCOPE_PROJECT, false); - - underTest.execute(); - - verifyComponentsHavingCopyComponentUuid(); - } - - @Test - public void migration_ignores_disabled_views() throws Exception { - insertProject("VIEW1", "VIEW1_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT, false); - insertProject("VIEW2", "VIEW2_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT, false); - insertProject("VIEW1:VIEW2", "LOCAL_VIEW2_UUID", null, QUALIFIER_SUB_VIEW, SCOPE_PROJECT, false); - - underTest.execute(); - - verifyComponentsHavingCopyComponentUuid(); - } - - @Test - public void migration_is_re_entrant() throws Exception { - insertProject("VIEW1", "VIEW1_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW2", "VIEW2_UUID", null, QUALIFIER_VIEW, SCOPE_PROJECT); - insertProject("VIEW1:VIEW2", "LOCAL_VIEW2_UUID", null, QUALIFIER_SUB_VIEW, SCOPE_PROJECT); - - underTest.execute(); - verifyOnlyOneComponentHasCopyComponentUuid("LOCAL_VIEW2_UUID", "VIEW2_UUID"); - - underTest.execute(); - verifyOnlyOneComponentHasCopyComponentUuid("LOCAL_VIEW2_UUID", "VIEW2_UUID"); - } - - - private void insertProject(String key, String uuid, @Nullable String copyComponentUuid, String qualifier, String scope) { - insertProject(key, uuid, copyComponentUuid, qualifier, scope, true); - } - - private void insertProject(String key, String uuid, @Nullable String copyComponentUuid, String qualifier, String scope, boolean enabled) { - Map values = new HashMap<>(ImmutableMap.builder() - .put("KEE", key) - .put("QUALIFIER", qualifier) - .put("SCOPE", scope) - .put("UUID", uuid) - .put("UUID_PATH", "UUID_PATH") - .put("ROOT_UUID", "ROOT_UUID") - .put("PROJECT_UUID", "ROOT_UUID") - .put("ORGANIZATION_UUID", "ORGANIZATION_UUID") - .put("ENABLED", enabled) - .build()); - if (copyComponentUuid != null) { - values.put("COPY_COMPONENT_UUID", copyComponentUuid); - } - db.executeInsert(TABLE_PROJECTS, values); - } - - private void verifyOnlyOneComponentHasCopyComponentUuid(String uuid, String copyComponentUuid) { - verifyComponentsHavingCopyComponentUuid(new Component(uuid, copyComponentUuid)); - } - - private void verifyComponentsHavingCopyComponentUuid(Component... expectedComponents) { - Map expectedComponentsByUuid = Arrays.stream(expectedComponents).collect(MoreCollectors.uniqueIndex(Component::getUuid)); - - List> rows = db.select("SELECT uuid, copy_component_uuid FROM " + TABLE_PROJECTS + " WHERE copy_component_uuid IS NOT NULL"); - Map components = rows.stream() - .map(map -> new Component((String) map.get("UUID"), (String) map.get("COPY_COMPONENT_UUID"))) - .collect(MoreCollectors.uniqueIndex(Component::getUuid)); - assertThat(components.keySet()).containsExactlyElementsOf(expectedComponentsByUuid.keySet()); - components.entrySet().forEach(entry -> { - Component expectedComponent = expectedComponentsByUuid.get(entry.getKey()); - assertThat(expectedComponent.getUuid()).isEqualTo(entry.getKey()); - assertThat(expectedComponent.getCopyComponentUuid()).isEqualTo(entry.getValue().getCopyComponentUuid()); - }); - } - - private static class Component { - private final String uuid; - private final String copyComponentUuid; - - Component(String uuid, @Nullable String copyComponentUuid) { - this.uuid = uuid; - this.copyComponentUuid = copyComponentUuid; - } - - String getUuid() { - return uuid; - } - - @CheckForNull - String getCopyComponentUuid() { - return copyComponentUuid; - } - - @Override - public String toString() { - return "Component{" + - "uuid='" + uuid + '\'' + - ", copyComponentUuid='" + copyComponentUuid + '\'' + - '}'; - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalseTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalseTest.java deleted file mode 100644 index 8842e31388e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalseTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.apache.commons.lang.RandomStringUtils; -import org.assertj.core.api.Assertions; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class SetNewProjectPrivateToFalseTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetNewProjectPrivateToFalseTest.class, "initial.sql"); - - public SetNewProjectPrivateToFalse underTest = new SetNewProjectPrivateToFalse(db.database()); - - @Test - public void should_set_field() throws SQLException { - db.executeInsert("ORGANIZATIONS", - "UUID", RandomStringUtils.randomAlphabetic(10), - "KEE", RandomStringUtils.randomAlphabetic(10), - "NAME", RandomStringUtils.randomAlphabetic(10), - "GUARDED", false, - "NEW_PROJECT_PRIVATE", true, - "CREATED_AT", 1_000L, - "UPDATED_AT", 1_000L); - - Assertions.assertThat(db.selectFirst("SELECT NEW_PROJECT_PRIVATE FROM ORGANIZATIONS")).containsValue(true); - - underTest.execute(); - - Assertions.assertThat(db.selectFirst("SELECT NEW_PROJECT_PRIVATE FROM ORGANIZATIONS")).containsValue(false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroupTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroupTest.java deleted file mode 100644 index 69cfe35426e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroupTest.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -public class SetOrganizationMembersIntoMembersGroupTest { - - private static final String MEMBERS_NAME = "Members"; - private static final String ORGANIZATION_1 = "ORGANIZATION_1"; - private static final String ORGANIZATION_2 = "ORGANIZATION_2"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetOrganizationMembersIntoMembersGroupTest.class, "initial.sql"); - - private SetOrganizationMembersIntoMembersGroup underTest = new SetOrganizationMembersIntoMembersGroup(db.database()); - - @Test - public void set_users_into_group_members() throws Exception { - long user1 = insertUser("user1", true); - long user2 = insertUser("user2", true); - long user3 = insertUser("user3", true); - long group1 = insertGroup(ORGANIZATION_1, MEMBERS_NAME); - long group2 = insertGroup(ORGANIZATION_2, MEMBERS_NAME); - insertOrganizationMember(user1, ORGANIZATION_1); - insertOrganizationMember(user2, ORGANIZATION_2); - insertOrganizationMember(user3, ORGANIZATION_1); - - underTest.execute(); - - checkUserGroups(user1, group1); - checkUserGroups(user2, group2); - checkUserGroups(user3, group1); - } - - @Test - public void set_users_into_group_members_when_some_users_already_belongs_to_group() throws Exception { - long user1 = insertUser("user1", true); - long user2 = insertUser("user2", true); - long user3 = insertUser("user3", true); - long group1 = insertGroup(ORGANIZATION_1, MEMBERS_NAME); - long group2 = insertGroup(ORGANIZATION_2, MEMBERS_NAME); - insertOrganizationMember(user1, ORGANIZATION_1); - insertOrganizationMember(user2, ORGANIZATION_2); - insertOrganizationMember(user3, ORGANIZATION_1); - insertUserGroups(user1, group1); - - underTest.execute(); - - checkUserGroups(user1, group1); - checkUserGroups(user2, group2); - checkUserGroups(user3, group1); - } - - @Test - public void does_nothing_if_members_group_does_not_exist() throws Exception { - long user1 = insertUser("user1", true); - insertGroup(ORGANIZATION_1, "other"); - insertGroup(ORGANIZATION_2, "other"); - insertOrganizationMember(user1, ORGANIZATION_1); - - underTest.execute(); - - checkUserGroups(user1); - } - - @Test - public void does_not_fail_when_users_already_belongs_to_group_members() throws Exception { - long user1 = insertUser("user1", true); - long user2 = insertUser("user2", true); - long group1 = insertGroup(ORGANIZATION_1, MEMBERS_NAME); - long group2 = insertGroup(ORGANIZATION_2, MEMBERS_NAME); - insertOrganizationMember(user1, ORGANIZATION_1); - insertOrganizationMember(user2, ORGANIZATION_2); - insertUserGroups(user1, group1); - insertUserGroups(user2, group2); - - underTest.execute(); - - checkUserGroups(user1, group1); - checkUserGroups(user2, group2); - } - - @Test - public void ignore_disabled_users() throws Exception { - long user = insertUser("user", false); - insertGroup(ORGANIZATION_1, MEMBERS_NAME); - insertOrganizationMember(user, ORGANIZATION_1); - - underTest.execute(); - - checkUserGroups(user); - } - - @Test - public void migration_is_renentrant() throws Exception { - long user = insertUser("user1", true); - long group = insertGroup(ORGANIZATION_1, MEMBERS_NAME); - insertOrganizationMember(user, ORGANIZATION_1); - - underTest.execute(); - checkUserGroups(user, group); - - underTest.execute(); - checkUserGroups(user, group); - } - - private void checkUserGroups(long userId, Long... expectedGroupIds) { - List groups = db.select(format("select gu.group_id from groups_users gu where gu.user_id=%s", userId)).stream() - .map(map -> (Long) map.get("GROUP_ID")) - .collect(Collectors.toList()); - assertThat(groups).containsOnly(expectedGroupIds); - } - - private long insertUser(String login, boolean enabled) { - db.executeInsert( - "USERS", - "LOGIN", login, - "ACTIVE", Boolean.toString(enabled), - "IS_ROOT", "false", - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - return (Long) db.selectFirst(format("select id from users where login='%s'", login)).get("ID"); - } - - private void insertOrganizationMember(long userId, String organizationUuid) { - db.executeInsert("ORGANIZATION_MEMBERS", "USER_ID", userId, "ORGANIZATION_UUID", organizationUuid); - } - - private long insertGroup(String organization, String name) { - db.executeInsert( - "GROUPS", - "NAME", name, - "DESCRIPTION", name, - "ORGANIZATION_UUID", organization, - "CREATED_AT", new Date(), - "UPDATED_AT", new Date()); - return (Long) db.selectFirst(format("select id from groups where name='%s' and organization_uuid='%s'", name, organization)).get("ID"); - } - - private void insertUserGroups(long userId, Long... groupIds) { - Arrays.stream(groupIds).forEach(groupId -> db.executeInsert( - "GROUPS_USERS", - "USER_ID", userId, - "GROUP_ID", groupId)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefaultTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefaultTest.java deleted file mode 100644 index eade6cf5d63..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefaultTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.assertj.core.api.Assertions; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; -import org.sonar.server.platform.db.migration.version.v63.TestDefaultOrganizationUuidProvider; - -public class SetQualityProfileOrganizationUuidToDefaultTest { - - private static final String DEFAULT_ORG = "some uuid"; - private static final String PROFILE_KEY = "java-sonar-way-999999"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetQualityProfileOrganizationUuidToDefaultTest.class, "initial.sql"); - - private DefaultOrganizationUuidProvider defaultOrganization = new TestDefaultOrganizationUuidProvider(DEFAULT_ORG); - - public SetQualityProfileOrganizationUuidToDefault underTest = new SetQualityProfileOrganizationUuidToDefault(db.database(), defaultOrganization); - - @Test - public void should_change_profile_without_organization() throws SQLException { - db.executeInsert("RULES_PROFILES", "NAME", "java", "kee", PROFILE_KEY); - - underTest.execute(); - - Assertions.assertThat(db.selectFirst("SELECT ORGANIZATION_UUID FROM RULES_PROFILES WHERE KEE = '" + PROFILE_KEY + "'")).containsValue(DEFAULT_ORG); - } - - @Test - public void should_keep_existing_organization() throws SQLException { - String otherOrg = "existing uuid"; - db.executeInsert("RULES_PROFILES", "NAME", "java", "kee", PROFILE_KEY, "organization_uuid", otherOrg); - - underTest.execute(); - - Assertions.assertThat(db.selectFirst("SELECT ORGANIZATION_UUID FROM RULES_PROFILES WHERE KEE = '" + PROFILE_KEY + "'")).containsValue(otherOrg); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToNotNullableTest.java deleted file mode 100644 index ef7fe1bbfdd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class SetQualityProfileOrganizationUuidToNotNullableTest { - - /** @see org.sonar.db.AbstractDbTester#assertColumnDefinition(String, String, int, Integer, Boolean) */ - private static final boolean NOT_NULLABLE = false; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetQualityProfileOrganizationUuidToNotNullableTest.class, "initial.sql"); - - public MakeQualityProfileOrganizationUuidNotNullable underTest = new MakeQualityProfileOrganizationUuidNotNullable(db.database()); - - @Test - public void test() throws SQLException { - underTest.execute(); - db.assertColumnDefinition("rules_profiles", "organization_uuid", java.sql.Types.VARCHAR, 40, NOT_NULLABLE); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplateTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplateTest.java deleted file mode 100644 index fc205aca308..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplateTest.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.apache.commons.lang.RandomStringUtils; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl; - -import static java.lang.String.valueOf; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang.math.RandomUtils.nextLong; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class SupportPrivateProjectInDefaultPermissionTemplateTest { - - private static final String DEFAULT_ORGANIZATION_UUID = "def org uuid"; - private static final String OTHER_ORGANIZATION_UUID = "not def org uuid"; - private static final String PERMISSION_USER = "user"; - private static final String PERMISSION_CODEVIEWER = "codeviewer"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SupportPrivateProjectInDefaultPermissionTemplateTest.class, "organizations_and_groups_and_permission_templates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private SupportPrivateProjectInDefaultPermissionTemplate underTest = new SupportPrivateProjectInDefaultPermissionTemplate(db.database(), - new DefaultOrganizationUuidProviderImpl()); - - @Test - public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void fails_with_ISE_when_default_organization_does_not_exist_in_table_ORGANIZATIONS() throws SQLException { - setDefaultOrganizationProperty("blabla"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization with uuid 'blabla' does not exist in table ORGANIZATIONS"); - - underTest.execute(); - } - - @Test - public void execute_fails_with_ISE_when_default_organization_has_no_default_groupId() throws SQLException { - setupDefaultOrganization(null, "pt1", "pt2"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("No default group id is defined for default organization (uuid=def org uuid)"); - - underTest.execute(); - } - - @Test - public void execute_fails_with_ISE_when_default_group_of_default_organization_does_not_exist() throws SQLException { - setupDefaultOrganization(112, "pT1", "pT2"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Permission template with uuid pT1 not found"); - - underTest.execute(); - } - - @Test - public void execute_does_nothing_when_default_organization_has_default_permission_template_for_projects() throws SQLException { - int groupId = insertGroup(DEFAULT_ORGANIZATION_UUID); - setupDefaultOrganization(groupId, null, null); - - underTest.execute(); - } - - @Test - public void execute_fails_with_ISE_when_default_organization_has_default_permission_template_for_views_but_not_for_projects() throws SQLException { - int groupId = insertGroup(DEFAULT_ORGANIZATION_UUID); - setupDefaultOrganization(groupId, null, "pt1"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Inconsistent state for default organization (uuid=def org uuid): no project default template is defined but view default template is"); - - underTest.execute(); - } - - @Test - public void execute_ignores_default_permission_template_for_view_of_default_organization_if_it_does_not_exist_and_removes_the_reference() throws SQLException { - int groupId = insertGroup(DEFAULT_ORGANIZATION_UUID); - IdAndUuid projectDefPermTemplate = insertPermissionTemplate(DEFAULT_ORGANIZATION_UUID); - setupDefaultOrganization(groupId, projectDefPermTemplate.uuid, "fooBar"); - - underTest.execute(); - - assertThat( - db.select("select default_perm_template_project as \"project\", default_perm_template_view as \"view\" from organizations where uuid='" + DEFAULT_ORGANIZATION_UUID + "'")) - .extracting((row) -> row.get("project"), (row) -> row.get("view")) - .containsOnly(tuple(projectDefPermTemplate.uuid, null)); - } - - @Test - public void execute_does_not_fail_when_default_organization_has_default_permission_template_for_view() throws SQLException { - int groupId = insertGroup(DEFAULT_ORGANIZATION_UUID); - IdAndUuid projectDefPermTemplate = insertPermissionTemplate(DEFAULT_ORGANIZATION_UUID); - setupDefaultOrganization(groupId, projectDefPermTemplate.uuid, null); - - underTest.execute(); - } - - @Test - public void execute_adds_permission_USER_and_CODEVIEWER_to_default_group_of_default_organization_in_its_default_project_template() throws SQLException { - int groupId = insertGroup(DEFAULT_ORGANIZATION_UUID); - IdAndUuid projectDefPermTemplate = insertPermissionTemplate(DEFAULT_ORGANIZATION_UUID); - setupDefaultOrganization(groupId, projectDefPermTemplate.uuid, null); - int otherGroupId = insertGroup(OTHER_ORGANIZATION_UUID); - IdAndUuid otherProjectDefPermTemplate = insertPermissionTemplate(OTHER_ORGANIZATION_UUID); - insertOrganization(OTHER_ORGANIZATION_UUID, otherGroupId, otherProjectDefPermTemplate.uuid, null); - - underTest.execute(); - - verifyPermissionOfGroupInTemplate(projectDefPermTemplate, groupId, PERMISSION_USER, PERMISSION_CODEVIEWER); - verifyPermissionOfGroupInTemplate(otherProjectDefPermTemplate, otherGroupId); - } - - @Test - public void execute_does_not_fail_if_default_group_already_has_permission_USER_and_adds_only_CODEVIEWER_to_default_group_of_default_organization_in_its_default_project_template() - throws SQLException { - int groupId = insertGroup(DEFAULT_ORGANIZATION_UUID); - IdAndUuid projectDefPermTemplate = insertPermissionTemplate(DEFAULT_ORGANIZATION_UUID); - insertGroupPermission(projectDefPermTemplate, groupId, PERMISSION_USER); - setupDefaultOrganization(groupId, projectDefPermTemplate.uuid, null); - int otherGroupId = insertGroup(OTHER_ORGANIZATION_UUID); - IdAndUuid otherProjectDefPermTemplateUuid = insertPermissionTemplate(OTHER_ORGANIZATION_UUID); - insertOrganization(OTHER_ORGANIZATION_UUID, otherGroupId, otherProjectDefPermTemplateUuid.uuid, null); - - underTest.execute(); - - verifyPermissionOfGroupInTemplate(projectDefPermTemplate, groupId, PERMISSION_USER, PERMISSION_CODEVIEWER); - verifyPermissionOfGroupInTemplate(otherProjectDefPermTemplateUuid, otherGroupId); - } - - @Test - public void execute_does_not_fail_if_default_group_already_has_permission_CODEVIEWER_and_adds_only_USER_to_default_group_of_default_organization_in_its_default_project_template() - throws SQLException { - int groupId = insertGroup(DEFAULT_ORGANIZATION_UUID); - IdAndUuid projectDefPermTemplate = insertPermissionTemplate(DEFAULT_ORGANIZATION_UUID); - insertGroupPermission(projectDefPermTemplate, groupId, PERMISSION_CODEVIEWER); - setupDefaultOrganization(groupId, projectDefPermTemplate.uuid, null); - int otherGroupId = insertGroup(OTHER_ORGANIZATION_UUID); - IdAndUuid otherProjectDefPermTemplateUuid = insertPermissionTemplate(OTHER_ORGANIZATION_UUID); - insertOrganization(OTHER_ORGANIZATION_UUID, otherGroupId, otherProjectDefPermTemplateUuid.uuid, null); - - underTest.execute(); - - verifyPermissionOfGroupInTemplate(projectDefPermTemplate, groupId, PERMISSION_USER, PERMISSION_CODEVIEWER); - verifyPermissionOfGroupInTemplate(otherProjectDefPermTemplateUuid, otherGroupId); - } - - @Test - public void execute_is_reentrant() - throws SQLException { - int groupId = insertGroup(DEFAULT_ORGANIZATION_UUID); - IdAndUuid projectDefPermTemplate = insertPermissionTemplate(DEFAULT_ORGANIZATION_UUID); - setupDefaultOrganization(groupId, projectDefPermTemplate.uuid, null); - int otherGroupId = insertGroup(OTHER_ORGANIZATION_UUID); - IdAndUuid otherProjectDefPermTemplateUuid = insertPermissionTemplate(OTHER_ORGANIZATION_UUID); - insertOrganization(OTHER_ORGANIZATION_UUID, otherGroupId, otherProjectDefPermTemplateUuid.uuid, null); - - underTest.execute(); - - underTest.execute(); - - verifyPermissionOfGroupInTemplate(projectDefPermTemplate, groupId, PERMISSION_USER, PERMISSION_CODEVIEWER); - verifyPermissionOfGroupInTemplate(otherProjectDefPermTemplateUuid, otherGroupId); - } - - private void insertGroupPermission(IdAndUuid permissionTemplate, int groupId, String permission) { - db.executeInsert( - "PERM_TEMPLATES_GROUPS", - "GROUP_ID", groupId, - "TEMPLATE_ID", permissionTemplate.id, - "PERMISSION_REFERENCE", permission); - } - - private void verifyPermissionOfGroupInTemplate(IdAndUuid permTemplate, int groupId, String... permissions) { - verifyPermissionOfGroupInTemplate(permTemplate.uuid, groupId, permissions); - } - - private void verifyPermissionOfGroupInTemplate(String permTemplateUuid, int groupId, String... permissions) { - assertThat( - db.select("select permission_reference as \"permission\" from perm_templates_groups ptg inner join permission_templates pt on pt.kee='" + permTemplateUuid - + "' where ptg.template_id=pt.id and group_id=" + groupId) - .stream() - .flatMap(row -> Stream.of((String) row.get("permission"))) - .collect(MoreCollectors.toList())) - .containsOnly(permissions); - } - - private void setupDefaultOrganization(@Nullable Integer defaultGroupId, @Nullable String projectPermTemplateUuid, @Nullable String viewPermTemplateUuid) { - setDefaultOrganizationProperty(DEFAULT_ORGANIZATION_UUID); - insertOrganization(DEFAULT_ORGANIZATION_UUID, defaultGroupId, projectPermTemplateUuid, viewPermTemplateUuid); - } - - private void setDefaultOrganizationProperty(String defaultOrganizationUuid) { - db.executeInsert( - "INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", defaultOrganizationUuid); - } - - private void insertOrganization(String uuid, @Nullable Integer defaultGroupId, @Nullable String projectPermTemplateUuid, @Nullable String viewPermTemplateUuid) { - db.executeInsert("ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", false, - "default_group_id", defaultGroupId == null ? null : valueOf(defaultGroupId), - "default_perm_template_project", projectPermTemplateUuid, - "default_perm_template_view", viewPermTemplateUuid, - "CREATED_AT", nextLong(), - "UPDATED_AT", nextLong()); - } - - private int insertGroup(String organizationUuid) { - String name = "name" + randomAlphabetic(20); - db.executeInsert( - "GROUPS", - "ORGANIZATION_UUID", organizationUuid, - "NAME", name); - - return ((Long) db.selectFirst("select id as \"ID\" from groups where name='" + name + "'").get("ID")).intValue(); - } - - private IdAndUuid insertPermissionTemplate(String organizationUuid) { - String random = RandomStringUtils.randomAlphanumeric(20); - String uuid = "ptUuid" + random; - db.executeInsert( - "PERMISSION_TEMPLATES", - "ORGANIZATION_UUID", organizationUuid, - "NAME", "name" + random, - "KEE", uuid); - return new IdAndUuid( - ((Long) db.selectFirst("select id as \"ID\" from permission_templates where kee='" + uuid + "'").get("ID")).intValue(), - uuid); - } - - private static final class IdAndUuid { - private final int id; - private final String uuid; - - private IdAndUuid(int id, String uuid) { - this.id = id; - this.uuid = uuid; - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplatesTest.java deleted file mode 100644 index 07b8a7644de..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplatesTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SupportProjectVisibilityInTemplatesTest { - private static final Integer GROUP_ANYONE = null; - private static final String PERMISSION_USER = "user"; - private static final String PERMISSION_CODEVIEWER = "codeviewer"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SupportProjectVisibilityInTemplatesTest.class, "permission_templates_and_groups.sql"); - - private SupportProjectVisibilityInTemplates underTest = new SupportProjectVisibilityInTemplates(db.database()); - - @Test - public void execute_has_no_effect_if_tables_are_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_has_no_effect_if_templates_has_no_group() throws SQLException { - insertPermissionTemplate("key"); - - underTest.execute(); - - assertUnchanged("key"); - assertNoGroup(); - } - - @Test - public void execute_deletes_permission_USER_of_group_AnyOne_in_permission_template() throws SQLException { - int ptId = insertPermissionTemplate("key"); - insertGroupPermission(ptId, GROUP_ANYONE, PERMISSION_USER); - - underTest.execute(); - - assertUnchanged("key"); - assertNoGroup(); - } - - @Test - public void execute_does_not_delete_permissions_different_from_USER_and_CODEVIEWER_for_group_AnyOne_in_permission_template() throws SQLException { - int ptId = insertPermissionTemplate("key"); - insertGroupPermission(ptId, GROUP_ANYONE, "admin"); - insertGroupPermission(ptId, GROUP_ANYONE, "issueadmin"); - insertGroupPermission(ptId, GROUP_ANYONE, "scan"); - insertGroupPermission(ptId, GROUP_ANYONE, "foo"); - - underTest.execute(); - - assertUnchanged("key"); - assertHasGroupPermissions(ptId, GROUP_ANYONE, "admin", "issueadmin", "scan", "foo"); - } - - @Test - public void execute_does_not_delete_any_permissions_from_other_group_in_permission_template() throws SQLException { - int ptId = insertPermissionTemplate("key"); - insertGroupPermission(ptId, 12, PERMISSION_USER); - insertGroupPermission(ptId, 12, PERMISSION_CODEVIEWER); - insertGroupPermission(ptId, 12, "admin"); - insertGroupPermission(ptId, 12, "issueadmin"); - insertGroupPermission(ptId, 12, "scan"); - insertGroupPermission(ptId, 12, "bar"); - - underTest.execute(); - - assertUnchanged("key"); - assertHasGroupPermissions(ptId, 12, PERMISSION_CODEVIEWER, PERMISSION_USER, "admin", "issueadmin", "scan", "bar"); - } - - @Test - public void execute_deletes_permission_CODEVIEWER_of_group_AnyOne_in_permission_template() throws SQLException { - int ptId = insertPermissionTemplate("key"); - insertGroupPermission(ptId, GROUP_ANYONE, PERMISSION_CODEVIEWER); - - underTest.execute(); - - assertUnchanged("key"); - assertNoGroup(); - } - - @Test - public void execute_is_reentrant() throws SQLException { - int ptId1 = insertPermissionTemplate("key1"); - insertGroupPermission(ptId1, GROUP_ANYONE, PERMISSION_USER); - insertGroupPermission(ptId1, GROUP_ANYONE, PERMISSION_CODEVIEWER); - insertGroupPermission(ptId1, 11, PERMISSION_USER); - insertGroupPermission(ptId1, 12, "foo"); - insertGroupPermission(ptId1, 12, PERMISSION_CODEVIEWER); - insertGroupPermission(ptId1, 12, "bar"); - int ptId2 = insertPermissionTemplate("key2"); - insertGroupPermission(ptId2, GROUP_ANYONE, PERMISSION_CODEVIEWER); - insertGroupPermission(ptId2, GROUP_ANYONE, "moh"); - insertGroupPermission(ptId2, 50, PERMISSION_USER); - insertGroupPermission(ptId2, 51, "admin"); - - underTest.execute(); - - verifyFor_execute_is_reentrant(ptId1, ptId2); - - underTest.execute(); - - verifyFor_execute_is_reentrant(ptId1, ptId2); - } - - private void verifyFor_execute_is_reentrant(int ptId1, int ptId2) { - assertUnchanged("key1"); - assertHasGroupPermissions(ptId1, GROUP_ANYONE); - assertHasGroupPermissions(ptId1, 11, PERMISSION_USER); - assertHasGroupPermissions(ptId1, 12, PERMISSION_CODEVIEWER, "foo", "bar"); - assertUnchanged("key2"); - assertHasGroupPermissions(ptId2, GROUP_ANYONE, "moh"); - assertHasGroupPermissions(ptId2, 50, PERMISSION_USER); - assertHasGroupPermissions(ptId2, 51, "admin"); - } - - private void insertGroupPermission(int templateId, @Nullable Integer groupId, String permission) { - db.executeInsert( - "perm_templates_groups", - "group_id", groupId, - "template_id", templateId, - "permission_reference", permission); - } - - private int insertPermissionTemplate(String key) { - db.executeInsert( - "permission_templates", - "organization_uuid", "org_" + key, - "name", "name_" + key, - "kee", key); - return ((Long) db.selectFirst("select id as \"ID\" from permission_templates where kee='" + key + "'").get("ID")).intValue(); - } - - private void assertUnchanged(String key) { - Map row = db.selectFirst("select" + - " organization_uuid as \"organizationUuid\"," + - " name as \"name\"," + - " description as \"desc\"," + - " key_pattern \"pattern\"," + - " created_at as \"createdAt\"," + - " updated_at as \"updatedAt\"" + - " from permission_templates where kee='" + key + "'"); - assertThat(row.get("organizationUuid")).isEqualTo("org_" + key); - assertThat(row.get("name")).isEqualTo("name_" + key); - assertThat(row.get("desc")).isNull(); - assertThat(row.get("pattern")).isNull(); - assertThat(row.get("createdAt")).isNull(); - assertThat(row.get("updatedAt")).isNull(); - } - - private void assertNoGroup() { - assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(0); - } - - private void assertHasGroupPermissions(int templateId, @Nullable Integer groupId, String... permissions) { - assertThat(db.select("select permission_reference as \"perm\" from perm_templates_groups" + - " where" + - " template_id=" + templateId + "" + - " and group_id " + (groupId == null ? " is null" : "=" + groupId))) - .extracting(map -> (String) map.get("perm")) - .containsOnly(permissions); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplatesTest.java deleted file mode 100644 index 9b7530ed577..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplatesTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v64; - -import java.sql.SQLException; -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.v63.DefaultOrganizationUuidProviderImpl; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.commons.codec.digest.DigestUtils.md5Hex; -import static org.assertj.core.api.Assertions.assertThat; - -public class UpgradeQualityTemplateLoadedTemplatesTest { - - private static final String TABLE_ORGANIZATIONS = "organizations"; - private static final String DEFAULT_ORGANIZATION_UUID = "def-org"; - private static final String TABLE_LOADED_TEMPLATES = "loaded_templates"; - private static final String QUALITY_PROFILE_TYPE = "QUALITY_PROFILE"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(UpgradeQualityTemplateLoadedTemplatesTest.class, "organizations_internal_properties_and_loaded_templates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UpgradeQualityTemplateLoadedTemplates underTest = new UpgradeQualityTemplateLoadedTemplates(db.database(), new DefaultOrganizationUuidProviderImpl()); - - @Test - public void fails_with_ISE_when_no_default_organization_is_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void fails_with_ISE_when_default_organization_does_not_exist_in_table_ORGANIZATIONS() throws SQLException { - insertDefaultOrganizationUuid("blabla"); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization with uuid 'blabla' does not exist in table ORGANIZATIONS"); - - underTest.execute(); - } - - @Test - public void execute_has_no_effect_if_loaded_templates_table_is_empty() throws Exception { - setupDefaultOrganization(); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_LOADED_TEMPLATES)).isEqualTo(0); - } - - @Test - public void execute_has_no_effect_if_loaded_templates_has_no_row_with_type_QUALITY_PROFILE() throws Exception { - setupDefaultOrganization(); - insertLoadedTemplate("foo", "bar"); - - underTest.execute(); - - assertThat(loadedTemplateExists("foo", "bar")).isTrue(); - assertThat(db.countRowsOfTable(TABLE_LOADED_TEMPLATES)).isEqualTo(1); - } - - @Test - public void execute_updates_any_row_with_type_QUALITY_PROFILE_to_type_based_on_current_key_md5_and_default_organization_uuid_as_key() throws SQLException { - setupDefaultOrganization(); - - // put accents to ensure UTF-8 byte array of String is used - String key1 = "fé@è:bar"; - String key2 = "bar"; - insertLoadedTemplate(QUALITY_PROFILE_TYPE, key1); - // matching on type is case sensitive - insertLoadedTemplate(QUALITY_PROFILE_TYPE.toLowerCase(), key1); - insertLoadedTemplate(QUALITY_PROFILE_TYPE, key2); - insertLoadedTemplate("other type", key2); - - underTest.execute(); - - assertThat(loadedTemplateExists(QUALITY_PROFILE_TYPE + '.' + md5Hex(key1.getBytes(UTF_8)), DEFAULT_ORGANIZATION_UUID)).isTrue(); - assertThat(loadedTemplateExists(QUALITY_PROFILE_TYPE.toLowerCase(), key1)).isTrue(); - assertThat(loadedTemplateExists("other type", key2)).isTrue(); - assertThat(loadedTemplateExists(QUALITY_PROFILE_TYPE + '.' + md5Hex(key2.getBytes(UTF_8)), DEFAULT_ORGANIZATION_UUID)).isTrue(); - assertThat(db.countRowsOfTable(TABLE_LOADED_TEMPLATES)).isEqualTo(4); - } - - @Test - public void execute_is_reentrant() throws Exception { - setupDefaultOrganization(); - String key = "blabla"; - insertLoadedTemplate(QUALITY_PROFILE_TYPE, key); - - underTest.execute(); - - underTest.execute(); - - assertThat(loadedTemplateExists(QUALITY_PROFILE_TYPE + '.' + md5Hex(key.getBytes(UTF_8)), DEFAULT_ORGANIZATION_UUID)).isTrue(); - assertThat(db.countRowsOfTable(TABLE_LOADED_TEMPLATES)).isEqualTo(1); - } - - private void setupDefaultOrganization() { - insertDefaultOrganizationUuid(DEFAULT_ORGANIZATION_UUID); - insertOrganization(DEFAULT_ORGANIZATION_UUID); - } - - private void insertOrganization(String uuid) { - db.executeInsert( - TABLE_ORGANIZATIONS, - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", String.valueOf(false), - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - } - - private void insertDefaultOrganizationUuid(String defaultOrganizationUuid) { - db.executeInsert( - "INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", defaultOrganizationUuid); - } - - private void insertLoadedTemplate(String type, String key) { - db.executeInsert( - TABLE_LOADED_TEMPLATES, - "TEMPLATE_TYPE", type, - "KEE", key); - } - - private boolean loadedTemplateExists(String type, String key) { - return !db.selectFirst(String.format("select id from loaded_templates where template_type='%s' and kee='%s'", type, key)).isEmpty(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfilesTest.java deleted file mode 100644 index f57fceacfa9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfilesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; - - -public class AddBuiltInFlagToRulesProfilesTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddBuiltInFlagToRulesProfilesTest.class, "rules_profiles_6_4.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddBuiltInFlagToRulesProfiles underTest = new AddBuiltInFlagToRulesProfiles(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("rules_profiles", "is_built_in", BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAtTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAtTest.java deleted file mode 100644 index a7d66a0559d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAtTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import 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 AddIndexOnEsQueueCreatedAtTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnEsQueueCreatedAtTest.class, "initial.sql"); - - private DdlChange underTest = new AddIndexOnEsQueueCreatedAt(db.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - - db.assertIndex("es_queue", "es_queue_created_at", "created_at"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest.java deleted file mode 100644 index a9173fd85f4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class AddIndexRulesProfileUuidOnQProfileChangesTest { - - private static final String TABLE_NAME = "qprofile_changes"; - private static final String COLUMN_NAME = "rules_profile_uuid"; - private static final String INDEX_NAME = "qp_changes_rules_profile_uuid"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexRulesProfileUuidOnQProfileChangesTest.class, "initial.sql"); - - private AddIndexRulesProfileUuidOnQProfileChanges underTest = new AddIndexRulesProfileUuidOnQProfileChanges(db.database()); - - @Test - public void add_index_ON_RULES_PROFILE_UUID_of_QPROFILE_CHANGES() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_NAME, INDEX_NAME,COLUMN_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboardedTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboardedTest.java deleted file mode 100644 index 7d3f3addc6c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboardedTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddUsersOnboardedTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUsersOnboardedTest.class, "users_without_onboarded_column.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUsersOnboarded underTest = new AddUsersOnboarded(db.database()); - - @Test - public void execute_adds_nullable_boolean_column_private_to_table_PROJECTS() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("users", "onboarded", Types.BOOLEAN, null, true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRolesTest.java deleted file mode 100644 index 53e4ce6482e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRolesTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanOrphanRowsInGroupRolesTest { - private static final String TABLE_GROUP_ROLES = "group_roles"; - private static final String PROJECT_SCOPE = "PRJ"; - private static final String QUALIFIER_VW = "VW"; - private static final String QUALIFIER_TRK = "TRK"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInGroupRolesTest.class, "group_roles_and_projects.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CleanOrphanRowsInGroupRoles underTest = new CleanOrphanRowsInGroupRoles(db.database()); - - @Test - public void execute_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isZero(); - } - - @Test - public void execute_does_not_delete_rows_without_resource_id() throws SQLException { - insertGroupRole(null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(1); - - } - - @Test - public void execute_deletes_rows_of_non_existent_component() throws SQLException { - insertGroupRole(new Random().nextInt()); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(0); - } - - @Test - public void execute_deletes_rows_of_component_without_qualifier_PRJ() throws SQLException { - String scope = randomAlphanumeric(3); - insertGroupRole(insertComponent(scope, QUALIFIER_TRK)); - insertGroupRole(insertComponent(scope, QUALIFIER_VW)); - insertGroupRole(insertComponent(scope, randomAlphanumeric(3))); - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(3); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(0); - } - - @Test - public void execute_keeps_rows_with_qualifier_TRK() throws SQLException { - executeKeepsRowsWithSpecifiedQualifierAndScopeProject(QUALIFIER_TRK); - } - - @Test - public void execute_keeps_rows_with_qualifier_VW() throws SQLException { - executeKeepsRowsWithSpecifiedQualifierAndScopeProject(QUALIFIER_VW); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_DEV() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("DEV"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_DEV_PRJ() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("DEV_PRJ"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_BRC() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("BRC"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_DIR() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("DIR"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_FIL() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("FIL"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_UTS() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("UTS"); - } - - @Test - public void execute_deletes_rows_of_component_with_unknown_qualifier() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject(randomAlphanumeric(3)); - } - - private void executeDeletesRowsWithSpecifiedQualifierAndScopeProject(String qualifier) throws SQLException { - int componentId = insertComponent(PROJECT_SCOPE, qualifier); - insertGroupRole(componentId); - insertAnyoneRole(componentId); - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(2); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(0); - } - - private void executeKeepsRowsWithSpecifiedQualifierAndScopeProject(String qualifier) throws SQLException { - int componentId = insertComponent(PROJECT_SCOPE, qualifier); - insertGroupRole(componentId); - insertAnyoneRole(componentId); - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(2); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(2); - } - - private void insertAnyoneRole(@Nullable Integer componentId) { - insertGroupRole(null, componentId); - } - - private void insertGroupRole(@Nullable Integer componentId) { - insertGroupRole(new Random().nextInt(), componentId); - } - - private void insertGroupRole(@Nullable Integer groupId, @Nullable Integer componentId) { - db.executeInsert( - TABLE_GROUP_ROLES, - "organization_uuid", randomAlphanumeric(3), - "group_id", groupId == null ? null : valueOf(groupId), - "resource_id", componentId == null ? null : valueOf(componentId), - "role", randomAlphanumeric(5)); - } - - private int insertComponent(@Nullable String scope, @Nullable String qualifier) { - return insertComponent(randomAlphanumeric(30), scope, qualifier); - } - - private int insertComponent(String uuid, @Nullable String scope, @Nullable String qualifier) { - db.executeInsert( - "projects", - "organization_uuid", randomAlphanumeric(3), - "uuid", uuid, - "uuid_path", "path_of_" + uuid, - "root_uuid", uuid, - "project_uuid", uuid, - "scope", scope, - "qualifier", qualifier, - "private", valueOf(new Random().nextBoolean()), - "enabled", valueOf(new Random().nextBoolean())); - return ((Long) db.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID")).intValue(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasuresTest.java deleted file mode 100644 index 8ed61ccc57a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasuresTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanOrphanRowsInManualMeasuresTest { - - private static final String TABLE_MANUAL_MEASURES = "MANUAL_MEASURES"; - private static final String SCOPE_PROJECT = "PRJ"; - private static final String QUALIFIER_PROJECT = "TRK"; - private static final String QUALIFIER_VIEW = "VW"; - private static final String QUALIFIER_MODULE = "BRC"; - private static final String QUALIFIER_SUBVIEW = "SVW"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInManualMeasuresTest.class, "manual_measures_and_projects.sql"); - - private final Random random = new Random(); - private CleanOrphanRowsInManualMeasures underTest = new CleanOrphanRowsInManualMeasures(db.database()); - - @Test - public void execute_has_no_effect_if_MANUAL_MEASURES_is_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_deletes_all_rows_in_MANUAL_MEASURES_when_PROJECTS_is_empty() throws SQLException { - insertManualMeasure(randomAlphabetic(5)); - insertManualMeasure(null); - insertManualMeasure(randomAlphabetic(5)); - insertManualMeasure(null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MANUAL_MEASURES)).isZero(); - } - - @Test - public void execute_deletes_rows_without_component_uuid() throws SQLException { - insertManualMeasure(null); - insertManualMeasure(null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MANUAL_MEASURES)).isZero(); - } - - @Test - public void execute_deletes_rows_which_component_does_not_exist() throws SQLException { - insertManualMeasure(randomAlphabetic(3)); - insertManualMeasure(randomAlphabetic(6)); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MANUAL_MEASURES)).isZero(); - } - - @Test - public void execute_deletes_rows_which_component_is_not_a_project_nor_a_view_nor_a_module_nor_a_subview() throws SQLException { - Long[] validMeasureIds = { - insertManualMeasure(insertComponent(SCOPE_PROJECT, QUALIFIER_PROJECT, true)), - insertManualMeasure(insertComponent(SCOPE_PROJECT, QUALIFIER_VIEW, true)), - insertManualMeasure(insertComponent(SCOPE_PROJECT, QUALIFIER_MODULE, true)), - insertManualMeasure(insertComponent(SCOPE_PROJECT, QUALIFIER_SUBVIEW, true)) - }; - insertManualMeasure(insertComponent(SCOPE_PROJECT, QUALIFIER_PROJECT, false)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, QUALIFIER_VIEW, false)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, QUALIFIER_MODULE, false)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, QUALIFIER_SUBVIEW, false)); - String invalidScope = randomAlphabetic(3); - insertManualMeasure(insertComponent(invalidScope, QUALIFIER_PROJECT, true)); - insertManualMeasure(insertComponent(invalidScope, QUALIFIER_VIEW, true)); - insertManualMeasure(insertComponent(invalidScope, QUALIFIER_MODULE, true)); - insertManualMeasure(insertComponent(invalidScope, QUALIFIER_SUBVIEW, true)); - insertManualMeasure(insertComponent(invalidScope, QUALIFIER_PROJECT, false)); - insertManualMeasure(insertComponent(invalidScope, QUALIFIER_VIEW, false)); - insertManualMeasure(insertComponent(invalidScope, QUALIFIER_MODULE, false)); - insertManualMeasure(insertComponent(invalidScope, QUALIFIER_SUBVIEW, false)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, "DIR", true)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, "FIL", true)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, "DIR", false)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, "FIL", false)); - insertManualMeasure(insertComponent("DIR", "DIR", true)); - insertManualMeasure(insertComponent("FIL", "FIL", true)); - insertManualMeasure(insertComponent("FIL", "TRK", true)); - insertManualMeasure(insertComponent("DIR", "DIR", false)); - insertManualMeasure(insertComponent("FIL", "FIL", false)); - insertManualMeasure(insertComponent("FIL", "TRK", false)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, randomAlphabetic(3), true)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, randomAlphabetic(3), true)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, randomAlphabetic(3), false)); - insertManualMeasure(insertComponent(SCOPE_PROJECT, randomAlphabetic(3), false)); - - underTest.execute(); - - assertThat(db.select("select id as \"ID\" from " + TABLE_MANUAL_MEASURES).stream().map(row -> (Long) row.get("ID"))) - .containsOnly(validMeasureIds); - } - - private long insertManualMeasure(@Nullable String componentUuid) { - String uuid = UuidFactoryFast.getInstance().create(); - db.executeInsert( - TABLE_MANUAL_MEASURES, - "METRIC_ID", random.nextInt(), - "COMPONENT_UUID", componentUuid, - "TEXT_VALUE", uuid); - return (Long) db.selectFirst("select id as \"ID\" from " + TABLE_MANUAL_MEASURES + " where text_value = '" + uuid + "'").get("ID"); - } - - private String insertComponent(String scope, String qualifier, boolean enabled) { - String uuid = randomAlphabetic(5); - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", randomAlphabetic(5), - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_uuid_" + uuid, - "PROJECT_UUID", randomAlphabetic(5), - "SCOPE", scope, - "QUALIFIER", qualifier, - "PRIVATE", String.valueOf(random.nextBoolean()), - "ENABLED", String.valueOf(enabled)); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinksTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinksTest.java deleted file mode 100644 index d77679bb70a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinksTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanOrphanRowsInProjectLinksTest { - private static final String TABLE_PROJECT_LINKS = "project_links"; - private static final String SCOPE_PROJECT = "PRJ"; - private static final String QUALIFIER_VIEW = "VW"; - private static final String QUALIFIER_PROJECT = "TRK"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInProjectLinksTest.class, "project_links_and_projects.sql"); - - private final Random random = new Random(); - private CleanOrphanRowsInProjectLinks underTest = new CleanOrphanRowsInProjectLinks(db.database()); - - @Test - public void execute_has_no_effect_when_table_is_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_remove_all_data_from_project_links_if_projects_is_empty() throws SQLException { - String componentUuid = randomAlphanumeric(6); - insertProjectLink(componentUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROJECT_LINKS)).isZero(); - } - - @Test - public void execute_remove_row_from_project_links_which_component_is_not_an_enabled_project_or_view() throws SQLException { - Long link1 = insertProjectLink(insertComponent(SCOPE_PROJECT, QUALIFIER_PROJECT, true)); - Long link2 = insertProjectLink(insertComponent(SCOPE_PROJECT, QUALIFIER_VIEW, true)); - insertProjectLink(insertComponent(SCOPE_PROJECT, QUALIFIER_PROJECT, false)); - insertProjectLink(insertComponent(SCOPE_PROJECT, QUALIFIER_VIEW, false)); - insertProjectLink(insertComponent(randomAlphabetic(3), QUALIFIER_PROJECT, true)); - insertProjectLink(insertComponent(randomAlphabetic(3), QUALIFIER_PROJECT, false)); - insertProjectLink(insertComponent(randomAlphabetic(3), QUALIFIER_VIEW, true)); - insertProjectLink(insertComponent(randomAlphabetic(3), QUALIFIER_VIEW, false)); - insertProjectLink(insertComponent(SCOPE_PROJECT, randomAlphabetic(3), true)); - insertProjectLink(insertComponent(SCOPE_PROJECT, randomAlphabetic(3), false)); - - underTest.execute(); - - assertThat(db.select("select id as \"ID\" from project_links").stream().map(row -> ((Long) row.get("ID")))) - .containsOnly(link1, link2); - } - - @Test - public void execute_removes_row_from_project_links_which_component_does_not_exist() throws SQLException { - String projectUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_PROJECT, true); - insertProjectLink(projectUuid + "_2"); - long linkId = insertProjectLink(projectUuid); - - underTest.execute(); - - assertThat(db.select("select id as \"ID\" from project_links").stream().map(row -> ((Long) row.get("ID")))) - .containsOnly(linkId); - } - - private long insertProjectLink(String componentUuid) { - String href = randomAlphanumeric(30); - db.executeInsert( - TABLE_PROJECT_LINKS, - "component_uuid", componentUuid, - "href", href); - return (long) db.selectFirst("select id as \"ID\" from project_links where component_uuid = '" + componentUuid + "' and href='" + href + "'") - .get("ID"); - } - - private String insertComponent(String scope, String qualifier, boolean enabled) { - String uuid = randomAlphabetic(5); - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", randomAlphabetic(5), - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_uuid_" + uuid, - "PROJECT_UUID", randomAlphabetic(5), - "SCOPE", scope, - "QUALIFIER", qualifier, - "PRIVATE", String.valueOf(random.nextBoolean()), - "ENABLED", String.valueOf(enabled)); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInPropertiesTest.java deleted file mode 100644 index 645230a41bf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInPropertiesTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanOrphanRowsInPropertiesTest { - - private static final String TABLE_PROPERTIES = "PROPERTIES"; - private static final String SCOPE_PROJECT = "PRJ"; - private static final String QUALIFIER_PROJECT = "TRK"; - private static final String QUALIFIER_VIEW = "VW"; - private static final String QUALIFIER_MODULE = "BRC"; - private static final String QUALIFIER_SUBVIEW = "SVW"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInPropertiesTest.class, "properties_and_projects.sql"); - - private final Random random = new Random(); - private CleanOrphanRowsInProperties underTest = new CleanOrphanRowsInProperties(db.database()); - - @Test - public void execute_has_no_effect_is_PROPERTIES_is_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_deletes_all_properties_with_resource_id_if_PROJECTS_is_empty() throws SQLException { - insertProperty(random.nextInt()); - insertProperty(random.nextInt()); - insertProperty(random.nextInt()); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void execute_does_not_delete_properties_without_resource_id_if_PROJECTS_is_empty() throws SQLException { - long propId1 = insertProperty(null); - long propId2 = insertProperty(null); - - underTest.execute(); - - assertThat(db.select("select id as \"ID\" from properties").stream().map(row -> (Long) row.get("ID"))) - .containsOnly(propId1, propId2); - } - - @Test - public void execute_deletes_properties_which_component_does_not_exist() throws SQLException { - Long propId1 = insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_PROJECT, true)); - insertProperty(random.nextInt()); - - underTest.execute(); - - assertThat(db.select("select id as \"ID\" from properties").stream().map(row -> (Long) row.get("ID"))) - .containsOnly(propId1); - } - - @Test - public void execute_deletes_properties_which_component_is_neither_project_nor_view_nor_module_nor_subview_not_enabled() throws SQLException { - Long[] validPropIds = { - insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_PROJECT, true)), - insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_VIEW, true)), - insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_MODULE, true)), - insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_SUBVIEW, true)), - }; - insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_PROJECT, false)); - insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_VIEW, false)); - insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_MODULE, false)); - insertProperty(insertComponent(SCOPE_PROJECT, QUALIFIER_SUBVIEW, false)); - String notProjectScope = randomAlphabetic(3); - insertProperty(insertComponent(notProjectScope, QUALIFIER_PROJECT, true)); - insertProperty(insertComponent(notProjectScope, QUALIFIER_VIEW, true)); - insertProperty(insertComponent(notProjectScope, QUALIFIER_MODULE, true)); - insertProperty(insertComponent(notProjectScope, QUALIFIER_SUBVIEW, true)); - insertProperty(insertComponent(notProjectScope, QUALIFIER_PROJECT, false)); - insertProperty(insertComponent(notProjectScope, QUALIFIER_VIEW, false)); - insertProperty(insertComponent(notProjectScope, QUALIFIER_MODULE, false)); - insertProperty(insertComponent(notProjectScope, QUALIFIER_SUBVIEW, false)); - insertProperty(insertComponent(SCOPE_PROJECT, "DIR", true)); - insertProperty(insertComponent(SCOPE_PROJECT, "FIL", true)); - insertProperty(insertComponent(SCOPE_PROJECT, randomAlphabetic(3), true)); - - underTest.execute(); - - assertThat(db.select("select id as \"ID\" from properties").stream().map(row -> (Long) row.get("ID"))) - .containsOnly(validPropIds); - } - - private long insertProperty(@Nullable Integer resourceId) { - String key = UuidFactoryFast.getInstance().create(); - db.executeInsert( - TABLE_PROPERTIES, - "PROP_KEY", key, - "RESOURCE_ID", resourceId == null ? null : String.valueOf(resourceId), - "IS_EMPTY", String.valueOf(random.nextBoolean())); - return (Long) db.selectFirst("select id as \"ID\" from properties where prop_key='" + key + "'").get("ID"); - } - - private int insertComponent(String scope, String qualifier, boolean enabled) { - String uuid = randomAlphabetic(5); - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", randomAlphabetic(5), - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_uuid_" + uuid, - "PROJECT_UUID", randomAlphabetic(5), - "SCOPE", scope, - "QUALIFIER", qualifier, - "PRIVATE", String.valueOf(random.nextBoolean()), - "ENABLED", String.valueOf(enabled)); - return ((Long) db.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID")).intValue(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRolesTest.java deleted file mode 100644 index dc92963686e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRolesTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanOrphanRowsInUserRolesTest { - private static final String TABLE_USER_ROLES = "user_roles"; - private static final String PROJECT_SCOPE = "PRJ"; - private static final String QUALIFIER_VW = "VW"; - private static final String QUALIFIER_TRK = "TRK"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInUserRolesTest.class, "user_roles_and_projects.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CleanOrphanRowsInUserRoles underTest = new CleanOrphanRowsInUserRoles(db.database()); - - @Test - public void execute_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isZero(); - } - - @Test - public void execute_does_not_delete_rows_without_resource_id() throws SQLException { - insertUserRole(null); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(1); - - } - - @Test - public void execute_deletes_rows_of_non_existent_component() throws SQLException { - insertUserRole(new Random().nextInt()); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(0); - } - - @Test - public void execute_deletes_rows_of_component_without_qualifier_PRJ() throws SQLException { - String scope = randomAlphanumeric(3); - insertUserRole(insertComponent(scope, QUALIFIER_TRK)); - insertUserRole(insertComponent(scope, QUALIFIER_VW)); - insertUserRole(insertComponent(scope, randomAlphanumeric(3))); - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(3); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(0); - } - - @Test - public void execute_keeps_rows_with_qualifier_TRK() throws SQLException { - executeKeepsRowsWithSpecifiedQualifierAndScopeProject(QUALIFIER_TRK); - } - - @Test - public void execute_keeps_rows_with_qualifier_VW() throws SQLException { - executeKeepsRowsWithSpecifiedQualifierAndScopeProject(QUALIFIER_VW); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_DEV() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("DEV"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_DEV_PRJ() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("DEV_PRJ"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_BRC() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("BRC"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_DIR() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("DIR"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_FIL() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("FIL"); - } - - @Test - public void execute_deletes_rows_of_component_with_qualifier_UTS() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject("UTS"); - } - - @Test - public void execute_deletes_rows_of_component_with_unknown_qualifier() throws SQLException { - executeDeletesRowsWithSpecifiedQualifierAndScopeProject(randomAlphanumeric(3)); - } - - private void executeDeletesRowsWithSpecifiedQualifierAndScopeProject(String qualifier) throws SQLException { - int componentId = insertComponent(PROJECT_SCOPE, qualifier); - insertUserRole(componentId); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(0); - } - - private void executeKeepsRowsWithSpecifiedQualifierAndScopeProject(String qualifier) throws SQLException { - int componentId = insertComponent(PROJECT_SCOPE, qualifier); - insertUserRole(componentId); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(1); - } - - private void insertUserRole(@Nullable Integer componentId) { - db.executeInsert( - TABLE_USER_ROLES, - "organization_uuid", randomAlphanumeric(3), - "user_id", valueOf(new Random().nextInt()), - "resource_id", componentId == null ? null : valueOf(componentId), - "role", randomAlphanumeric(5)); - } - - private int insertComponent(@Nullable String scope, @Nullable String qualifier) { - return insertComponent(randomAlphanumeric(30), scope, qualifier); - } - - private int insertComponent(String uuid, @Nullable String scope, @Nullable String qualifier) { - db.executeInsert( - "projects", - "organization_uuid", randomAlphanumeric(3), - "uuid", uuid, - "uuid_path", "path_of_" + uuid, - "root_uuid", uuid, - "project_uuid", uuid, - "scope", scope, - "qualifier", qualifier, - "private", valueOf(new Random().nextBoolean()), - "enabled", valueOf(new Random().nextBoolean())); - return ((Long) db.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID")).intValue(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTableTest.java deleted file mode 100644 index 7a9075535ac..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateEsQueueTableTest { - - private static final String TABLE = "es_queue"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateEsQueueTableTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateEsQueueTable underTest = new CreateEsQueueTable(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "doc_type", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "doc_id", Types.VARCHAR, 4000, false); - db.assertColumnDefinition(TABLE, "doc_id_type", Types.VARCHAR, 20, true); - db.assertColumnDefinition(TABLE, "doc_routing", Types.VARCHAR, 4000, true); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfilesTest.java deleted file mode 100644 index 0f4908ebcbf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfilesTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableDefaultQProfilesTest { - private static final String TABLE = "default_qprofiles"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableDefaultQProfilesTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableDefaultQProfiles underTest = new CreateTableDefaultQProfiles(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "organization_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "language", Types.VARCHAR, 20, false); - db.assertColumnDefinition(TABLE, "qprofile_uuid", Types.VARCHAR, 255, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", Types.BIGINT, null, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "organization_uuid", "language"); - db.assertUniqueIndex(TABLE, "uniq_default_qprofiles_uuid", "qprofile_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfilesTest.java deleted file mode 100644 index 52eb86bb17f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfilesTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class CreateTableOrgQProfilesTest { - - private static final String TABLE = "org_qprofiles"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableOrgQProfilesTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableOrgQProfiles underTest = new CreateTableOrgQProfiles(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 255, false); - db.assertPrimaryKey(TABLE, "pk_org_qprofiles", "uuid"); - db.assertColumnDefinition(TABLE, "organization_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "rules_profile_uuid", Types.VARCHAR, 255, false); - db.assertColumnDefinition(TABLE, "last_used", Types.BIGINT, null, true); - db.assertColumnDefinition(TABLE, "user_updated_at", Types.BIGINT, null, true); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", Types.BIGINT, null, false); - db.assertIndex(TABLE, "qprofiles_org_uuid", "organization_uuid"); - db.assertIndex(TABLE, "qprofiles_rp_uuid", "rules_profile_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java deleted file mode 100644 index 1740cfb721d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion65Test { - private DbVersion65 underTest = new DbVersion65(); - - @Test - public void migrationNumber_starts_at_1700() { - verifyMinimumMigrationNumber(underTest, 1700); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 36); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSettingTest.java deleted file mode 100644 index 1cb4a6d7feb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSettingTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import org.apache.commons.lang.RandomStringUtils; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteCeWorkerCountSettingTest { - - private static final String TABLE_PROPERTIES = "properties"; - private static final String PROPERTY_SONAR_CE_WORKER_COUNT = "sonar.ce.workerCount"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteCeWorkerCountSettingTest.class, "properties.sql"); - - private DeleteCeWorkerCountSetting underTest = new DeleteCeWorkerCountSetting(db.database()); - - @Test - public void execute_does_not_fail_when_table_is_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_deletes_ce_worker_count_property() throws SQLException { - insertProperty(PROPERTY_SONAR_CE_WORKER_COUNT); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void execute_is_case_sensitive() throws SQLException { - insertProperty(PROPERTY_SONAR_CE_WORKER_COUNT.toUpperCase()); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(1); - } - - @Test - public void execute_does_not_delete_other_property() throws SQLException { - insertProperty(RandomStringUtils.randomAlphanumeric(3)); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(1); - } - - public void insertProperty(String propertyName) { - Random random = new Random(); - db.executeInsert( - TABLE_PROPERTIES, - "prop_key", propertyName, - "is_empty", valueOf(random.nextBoolean()), - "text_value", random.nextBoolean() ? null : RandomStringUtils.randomAlphabetic(2)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfilesTest.java deleted file mode 100644 index 8009753d713..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfilesTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.List; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteLoadedTemplatesOnQProfilesTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteLoadedTemplatesOnQProfilesTest.class, "initial.sql"); - - private DeleteLoadedTemplatesOnQProfiles underTest = new DeleteLoadedTemplatesOnQProfiles(db.database()); - - @Test - public void does_nothing_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("loaded_templates")).isEqualTo(0); - } - - @Test - public void deletes_rows_with_qprofile_type() throws SQLException { - insertRow("ORG_UUID_1", "QUALITY_PROFILE.HASH_OF_ORG_UUID_1"); - insertRow("ORG_UUID_2", "QUALITY_PROFILE.HASH_OF_ORG_UUID_2"); - insertRow("foo", "QUALITY_GATE"); - - underTest.execute(); - - assertThat(selectAllKeys()).containsExactly("foo"); - } - - private void insertRow(String key, String type) { - db.executeInsert( - "LOADED_TEMPLATES", - "KEE", key, - "TEMPLATE_TYPE", type); - } - - private List selectAllKeys() { - return db.select("select kee as TEMPLATE_KEY from loaded_templates") - .stream() - .map(e -> (String)e.get("TEMPLATE_KEY")) - .collect(MoreCollectors.toList()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfilesTest.java deleted file mode 100644 index c5c86d50fb5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfilesTest.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.Date; -import java.sql.SQLException; -import java.util.List; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteOrphansFromRulesProfilesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteOrphansFromRulesProfilesTest.class, "initial.sql"); - - private DeleteOrphansFromRulesProfiles underTest = new DeleteOrphansFromRulesProfiles(db.database()); - - - @Test - public void migration() throws SQLException { - long rulesProfileId1 = insertRulesProfile("RP_UUID_1", "Sonar Way", "Java", 1_000L, true); - long rulesProfileId2 = insertRulesProfile("RP_UUID_2", "Sonar Way", "JavaScript", 1_000L, false); - insertRulesProfile("RP_UUID_3", "Sonar Way", "PL/SQL", 1_000L, false); - insertRulesProfile("RP_UUID_4", "Sonar Way", "Cobol", 1_000L, false); - insertRulesProfile("RP_UUID_5", "Sonar Way", "Cobol", 1_000L, false); - insertRulesProfile("RP_UUID_6", "Sonar Way", "Cobol", 1_000L, true); - - insertOrgQProfile("ORG_QP_UUID_1", "ORG_UUID_1", "RP_UUID_1"); - insertOrgQProfile("ORG_QP_UUID_2", "ORG_UUID_1", "RP_UUID_2"); - - long activeRuleId1 = insertActiveRule(rulesProfileId1, 1); - long activeRuleId2 = insertActiveRule(rulesProfileId2, 1); - insertActiveRule(-1, 1); - insertActiveRule(-2, 1); - - long param1 = insertActiveRuleParameter(activeRuleId1, 1); - long param2 = insertActiveRuleParameter(activeRuleId1, 2); - long param3 = insertActiveRuleParameter(activeRuleId2, 2); - insertActiveRuleParameter(-1, 1); - insertActiveRuleParameter(-2, 1); - - insertQProfileChange("QPC_UUID1", "RP_UUID_1", "A"); - insertQProfileChange("QPC_UUID2", "RP_UUID_2", "B"); - insertQProfileChange("QPC_UUID3", "RP_UUID_3", "A"); - insertQProfileChange("QPC_UUID4", "RP_UUID_4", "A"); - - underTest.execute(); - - assertThat(selectRulesProfiles()).containsExactlyInAnyOrder("RP_UUID_1", "RP_UUID_2"); - assertThat(selectActiveRules()).containsExactlyInAnyOrder(activeRuleId1, activeRuleId2); - assertThat(selectActiveRuleParameters()).containsExactlyInAnyOrder(param1, param2, param3); - assertThat(selectQProfileChanges()).containsExactlyInAnyOrder("QPC_UUID1", "QPC_UUID2"); - } - - @Test - public void delete_rules_profiles_without_reference_in_qprofiles() throws SQLException { - insertRulesProfile("RP_UUID_1", "Sonar Way", "Java", 1_000L, true); - insertRulesProfile("RP_UUID_2", "Sonar Way", "JavaScript", 1_000L, false); - insertRulesProfile("RP_UUID_5", "Sonar Way", "Cobol", 1_000L, false); - insertRulesProfile("RP_UUID_6", "Sonar Way", "Cobol", 1_000L, true); - insertOrgQProfile("ORG_QP_UUID_1", "ORG_UUID_1", "RP_UUID_5"); - insertOrgQProfile("ORG_QP_UUID_2", "ORG_UUID_1", "RP_UUID_6"); - - underTest.execute(); - - assertThat(selectRulesProfiles()).containsExactlyInAnyOrder("RP_UUID_5", "RP_UUID_6"); - } - - @Test - public void delete_active_rules_without_rules_profiles() throws SQLException { - long rulesProfileId1 = insertRulesProfile("RP_UUID_1", "Sonar Way", "Java", 1_000L, true); - long rulesProfileId2 = insertRulesProfile("RP_UUID_2", "Sonar Way", "JavaScript", 1_000L, false); - - insertOrgQProfile("ORG_QP_UUID_1", "ORG_UUID_1", "RP_UUID_1"); - insertOrgQProfile("ORG_QP_UUID_2", "ORG_UUID_1", "RP_UUID_2"); - - long activeRule1 = insertActiveRule(rulesProfileId1, 1); - long activeRule2 = insertActiveRule(rulesProfileId2, 1); - insertActiveRule(-1, 1); - insertActiveRule(-2, 1); - - underTest.execute(); - - assertThat(selectActiveRules()).containsExactlyInAnyOrder(activeRule1, activeRule2); - } - - @Test - public void delete_active_rule_parameters_without_active_rules() throws SQLException { - long rulesProfileId1 = insertRulesProfile("RP_UUID_1", "Sonar Way", "Java", 1_000L, true); - long rulesProfileId2 = insertRulesProfile("RP_UUID_2", "Sonar Way", "JavaScript", 1_000L, false); - - insertOrgQProfile("ORG_QP_UUID_1", "ORG_UUID_1", "RP_UUID_1"); - insertOrgQProfile("ORG_QP_UUID_2", "ORG_UUID_1", "RP_UUID_2"); - - long activeRuleId1 = insertActiveRule(rulesProfileId1, 1); - long activeRuleId2 = insertActiveRule(rulesProfileId2, 1); - - long param1 = insertActiveRuleParameter(activeRuleId1, 1); - long param2 = insertActiveRuleParameter(activeRuleId1, 2); - long param3 = insertActiveRuleParameter(activeRuleId2, 2); - - insertActiveRuleParameter(-1, 1); - insertActiveRuleParameter(-2, 1); - - underTest.execute(); - - assertThat(selectActiveRuleParameters()).containsExactlyInAnyOrder(param1, param2, param3); - } - - @Test - public void delete_qprofile_changes_without_rules_profiles() throws SQLException { - long rulesProfileId1 = insertRulesProfile("RP_UUID_1", "Sonar Way", "Java", 1_000L, true); - long rulesProfileId2 = insertRulesProfile("RP_UUID_2", "Sonar Way", "JavaScript", 1_000L, false); - - insertOrgQProfile("ORG_QP_UUID_1", "ORG_UUID_1", "RP_UUID_1"); - insertOrgQProfile("ORG_QP_UUID_2", "ORG_UUID_1", "RP_UUID_2"); - - insertQProfileChange("QPC_UUID1", "RP_UUID_1", "A"); - insertQProfileChange("QPC_UUID2", "RP_UUID_2", "B"); - insertQProfileChange("QPC_UUID3", "RP_UUID_3", "A"); - insertQProfileChange("QPC_UUID4", "RP_UUID_4", "A"); - - underTest.execute(); - - assertThat(selectQProfileChanges()).containsExactlyInAnyOrder("QPC_UUID1", "QPC_UUID2"); - } - - @Test - public void reentrant_migration() throws SQLException { - long rulesProfileId1 = insertRulesProfile("RP_UUID_1", "Sonar Way", "Java", 1_000L, true); - long rulesProfileId2 = insertRulesProfile("RP_UUID_2", "Sonar Way", "JavaScript", 1_000L, false); - insertRulesProfile("RP_UUID_3", "Sonar Way", "PL/SQL", 1_000L, false); - insertRulesProfile("RP_UUID_4", "Sonar Way", "Cobol", 1_000L, false); - insertRulesProfile("RP_UUID_5", "Sonar Way", "Cobol", 1_000L, false); - insertRulesProfile("RP_UUID_6", "Sonar Way", "Cobol", 1_000L, true); - - insertOrgQProfile("ORG_QP_UUID_1", "ORG_UUID_1", "RP_UUID_1"); - insertOrgQProfile("ORG_QP_UUID_2", "ORG_UUID_1", "RP_UUID_2"); - - long activeRuleId1 = insertActiveRule(rulesProfileId1, 1); - long activeRuleId2 = insertActiveRule(rulesProfileId2, 1); - insertActiveRule(-1, 1); - insertActiveRule(-2, 1); - - insertActiveRuleParameter(activeRuleId1, 1); - insertActiveRuleParameter(activeRuleId1, 2); - insertActiveRuleParameter(activeRuleId2, 2); - insertActiveRuleParameter(-1, 1); - insertActiveRuleParameter(-2, 1); - - insertQProfileChange("QPC_UUID1", "RP_UUID_1", "A"); - insertQProfileChange("QPC_UUID2", "RP_UUID_2", "B"); - insertQProfileChange("QPC_UUID3", "RP_UUID_3", "A"); - insertQProfileChange("QPC_UUID4", "RP_UUID_4", "A"); - - underTest.execute(); - underTest.execute(); - - assertThat(countRows("rules_profiles")).isEqualTo(2); - assertThat(countRows("active_rules")).isEqualTo(2); - assertThat(countRows("active_rule_parameters")).isEqualTo(3); - assertThat(countRows("qprofile_changes")).isEqualTo(2); - } - - private int countRows(String table) { - return db.countSql(format("select count(*) from %s", table)); - } - - private List selectRulesProfiles() { - return db.select("select kee as \"kee\" from rules_profiles") - .stream() - .map(row -> (String) row.get("kee")) - .collect(MoreCollectors.toList()); - } - - private List selectQProfileChanges() { - return db.select("select kee as \"kee\" from qprofile_changes") - .stream() - .map(row -> (String) row.get("kee")) - .collect(MoreCollectors.toList()); - } - - private List selectActiveRules() { - return db.select("select id as \"id\" from active_rules") - .stream() - .map(row -> (Long) row.get("id")) - .collect(MoreCollectors.toList()); - } - - private List selectActiveRuleParameters() { - return db.select("select id as \"id\" from active_rule_parameters") - .stream() - .map(row -> (Long) row.get("id")) - .collect(MoreCollectors.toList()); - } - - private long insertRulesProfile(String rulesProfileUuid, String name, String language, Long userUpdatedAt, boolean isBuiltIn) { - db.executeInsert("RULES_PROFILES", - "NAME", name, - "LANGUAGE", language, - "KEE", rulesProfileUuid, - "USER_UPDATED_AT", userUpdatedAt, - "IS_BUILT_IN", isBuiltIn, - "LAST_USED", 1_000L, - "CREATED_AT", new Date(1_000L), - "UPDATED_AT", new Date(1_000L)); - - return (Long) db.selectFirst( - format("select id as \"id\" from rules_profiles where kee='%s'", rulesProfileUuid)).get("id"); - } - - private void insertOrgQProfile(String orgQProfileUuid, String orgUuid, String rulesProfileUuid) { - db.executeInsert("ORG_QPROFILES", - "UUID", orgQProfileUuid, - "ORGANIZATION_UUID", orgUuid, - "RULES_PROFILE_UUID", rulesProfileUuid, - "CREATED_AT", 1_000L, - "UPDATED_AT", 2_000L); - } - - private long insertActiveRule(long profileId, long ruleId) { - db.executeInsert("ACTIVE_RULES", - "PROFILE_ID", profileId, - "RULE_ID", ruleId, - "FAILURE_LEVEL", 1, - "INHERITANCE", "", - "CREATED_AT", 1_000L, - "UPDATED_AT", 2_000L); - - return (Long) db.selectFirst( - format("select id as \"id\" from active_rules where profile_id = %d and rule_id = %d", profileId, ruleId)).get("id"); - } - - private long insertActiveRuleParameter(long activeRuleId, long rulesParameterId) { - db.executeInsert("ACTIVE_RULE_PARAMETERS", - "ACTIVE_RULE_ID", activeRuleId, - "RULES_PARAMETER_ID", rulesParameterId, - "RULES_PARAMETER_KEY", "", - "VALUE", ""); - - return (Long) db.selectFirst( - format("select id as \"id\" from active_rule_parameters where active_rule_id=%d and rules_parameter_id=%d", activeRuleId, rulesParameterId)).get("id"); - } - - private void insertQProfileChange(String uuid, String rulesProfileUuid, String changeType) { - db.executeInsert("QPROFILE_CHANGES", - "KEE", uuid, - "QPROFILE_KEY", rulesProfileUuid, - "CHANGE_TYPE", changeType, - "USER_LOGIN", "", - "CHANGE_DATA", "", - "CREATED_AT", 1_000L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuidTest.java deleted file mode 100644 index 52f2d48e7b7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuidTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropIndexEventsComponentUuidTest { - private static final String TABLE_EVENTS = "events"; - private static final String INDEX_EVENTS_COMPONENT_UUID = "events_component_uuid"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexEventsComponentUuidTest.class, "events.sql"); - - private DropIndexEventsComponentUuid underTest = new DropIndexEventsComponentUuid(db.database()); - - @Test - public void execute_drops_index_EVENTS_COMPONENT_UUID() throws SQLException { - db.assertIndex(TABLE_EVENTS, INDEX_EVENTS_COMPONENT_UUID, "component_uuid"); - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_EVENTS, INDEX_EVENTS_COMPONENT_UUID); - } -} - diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuidTest.java deleted file mode 100644 index b8882700901..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuidTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropIndexManualMeasuresComponentUuidTest { - private static final String TABLE_MANUAL_MEASURES = "manual_measures"; - private static final String INDEX_MANUAL_MEASURES_COMPONENT_UUID = "manual_measures_component_uuid"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexManualMeasuresComponentUuidTest.class, "manual_measures.sql"); - - private DropIndexManualMeasuresComponentUuid underTest = new DropIndexManualMeasuresComponentUuid(db.database()); - - @Test - public void execute_drops_index_EVENTS_COMPONENT_UUID() throws SQLException { - db.assertIndex(TABLE_MANUAL_MEASURES, INDEX_MANUAL_MEASURES_COMPONENT_UUID, "component_uuid"); - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_MANUAL_MEASURES, INDEX_MANUAL_MEASURES_COMPONENT_UUID); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfilesTest.java deleted file mode 100644 index 59d80927b9c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfilesTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropIsDefaultColumnFromRulesProfilesTest { - - private static final String TABLE_NAME = "rules_profiles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIsDefaultColumnFromRulesProfilesTest.class, "initial.sql"); - - private DropIsDefaultColumnFromRulesProfiles underTest = new DropIsDefaultColumnFromRulesProfiles(db.database()); - - @Test - public void column_is_dropped() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist(TABLE_NAME, "is_default"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfilesTest.java deleted file mode 100644 index f48051bdf5d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfilesTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropOrgColumnsFromRulesProfilesTest { - - private static final String TABLE_NAME = "rules_profiles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrgColumnsFromRulesProfilesTest.class, "initial.sql"); - - private DropOrgColumnsFromRulesProfiles underTest = new DropOrgColumnsFromRulesProfiles(db.database()); - - @Test - public void columns_are_dropped() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist(TABLE_NAME, "organization_uuid"); - db.assertColumnDoesNotExist(TABLE_NAME, "parent_kee"); - db.assertColumnDoesNotExist(TABLE_NAME, "last_used"); - db.assertColumnDoesNotExist(TABLE_NAME, "user_updated_at"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropTableAuthorsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropTableAuthorsTest.java deleted file mode 100644 index 91297b4f54f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DropTableAuthorsTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropTableAuthorsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTableAuthorsTest.class, "authors.sql"); - - private DropTableAuthors underTest = new DropTableAuthors(db.database()); - - @Test - public void execute_drop_index_UNIQ_AUTHOR_LOGINS_and_table_AUTHORS() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist("authors", "uniq_author_logins"); - db.assertTableDoesNotExist("authors"); - } - - @Test - public void execute_is_reentrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("authors"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssuesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssuesTest.java deleted file mode 100644 index 47166a39801..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssuesTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -public class EnsureIssueProjectUuidConsistencyOnIssuesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(EnsureIssueProjectUuidConsistencyOnIssuesTest.class, "issues_and_projects.sql"); - - private final Random random = new Random(); - private EnsureIssueProjectUuidConsistencyOnIssues underTest = new EnsureIssueProjectUuidConsistencyOnIssues(db.database()); - - @Test - public void execute_has_no_effect_if_tables_are_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_fixes_project_uuid_of_issue_when_inconsistent_with_PROJECTS_PROJECT_UUID() throws SQLException { - String projectUuid = randomAlphabetic(5); - String componentUuid = insertComponent(projectUuid); - String inconsistentIssueKey = insertIssue(componentUuid, randomAlphabetic(9)); - String consistentIssueKey = insertIssue(componentUuid, projectUuid); - - underTest.execute(); - - assertThat(getProjectUuid(inconsistentIssueKey)).isEqualTo(projectUuid); - assertThat(getProjectUuid(consistentIssueKey)).isEqualTo(projectUuid); - } - - @Test - public void execute_ignores_issues_which_component_does_not_exist() throws SQLException { - String projectUuid = randomAlphabetic(3); - String issueKey = insertIssue(randomAlphabetic(8), projectUuid); - - underTest.execute(); - - assertThat(getProjectUuid(issueKey)).isEqualTo(projectUuid); - } - - @Test - public void execute_ignores_issues_which_null_project_uuid() throws SQLException { - String issueKey = insertIssue(randomAlphabetic(8), null); - - underTest.execute(); - - assertThat(getProjectUuid(issueKey)).isNull(); - } - - @Test - public void execute_ignores_issues_which_null_component_uuid() throws SQLException { - String projectUuid = randomAlphabetic(5); - String issueKey = insertIssue(null, projectUuid); - - underTest.execute(); - - assertThat(getProjectUuid(issueKey)).isEqualTo(projectUuid); - } - - private String getProjectUuid(String issueKey) { - return (String) db.selectFirst("select project_uuid as \"PROJECT_UUID\" from issues where kee = '" + issueKey + "'") - .get("PROJECT_UUID"); - } - - private String insertIssue(@Nullable String componentUuid, @Nullable String projectUuid) { - String issueKey = randomAlphabetic(3); - db.executeInsert( - "ISSUES", - "KEE", issueKey, - "COMPONENT_UUID", componentUuid, - "PROJECT_UUID", projectUuid, - "MANUAL_SEVERITY", String.valueOf(random.nextBoolean())); - return issueKey; - } - - private String insertComponent(String projectUuid) { - String uuid = randomAlphabetic(5); - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", randomAlphabetic(5), - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_uuid_" + uuid, - "PROJECT_UUID", projectUuid, - "PRIVATE", String.valueOf(random.nextBoolean()), - "ENABLED", String.valueOf(random.nextBoolean())); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullableTest.java deleted file mode 100644 index 47561a20d9b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullableTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.sql.Types; -import java.util.Random; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; - -public class MakeEventsComponentUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeEventsComponentUuidNotNullableTest.class, "events.sql"); - - private final Random random = new Random(); - private MakeEventsComponentUuidNotNullable underTest = new MakeEventsComponentUuidNotNullable(db.database()); - - @Test - public void execute_makes_column_component_uuid_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumn(); - } - - @Test - public void execute_makes_column_component_uuid_not_nullable_on_populated_table() throws SQLException { - insertEvent(); - insertEvent(); - insertEvent(); - - underTest.execute(); - - verifyColumn(); - } - - private void verifyColumn() { - db.assertColumnDefinition("events", "component_uuid", Types.VARCHAR, 50, false); - } - - private void insertEvent() { - db.executeInsert( - "events", - "UUID", randomAlphabetic(5), - "ANALYSIS_UUID", randomAlphabetic(5), - "COMPONENT_UUID", randomAlphabetic(5), - "EVENT_DATE", random.nextInt(), - "CREATED_AT", random.nextInt()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullableTest.java deleted file mode 100644 index 2ff5040cac1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.sql.Types; -import java.util.Random; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; - -public class MakeManualMeasuresComponentUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeManualMeasuresComponentUuidNotNullableTest.class, "manual_measures.sql"); - - private final Random random = new Random(); - private MakeManualMeasuresComponentUuidNotNullable underTest = new MakeManualMeasuresComponentUuidNotNullable(db.database()); - - @Test - public void execute_makes_column_component_uuid_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumn(); - } - - @Test - public void execute_makes_column_component_uuid_not_nullable_on_populated_table() throws SQLException { - insertManualMeasure(); - insertManualMeasure(); - insertManualMeasure(); - - underTest.execute(); - - verifyColumn(); - } - - private void verifyColumn() { - db.assertColumnDefinition("manual_measures", "component_uuid", Types.VARCHAR, 50, false); - } - - private void insertManualMeasure() { - db.executeInsert( - "manual_measures", - "METRIC_ID", random.nextInt(), - "COMPONENT_UUID", randomAlphabetic(5)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullableTest.java deleted file mode 100644 index 0acf5cee49c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullableTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - - -public class MakeRulesProfilesIsBuiltInNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesProfilesIsBuiltInNotNullableTest.class, "initial.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeRulesProfilesIsBuiltInNotNullable underTest = new MakeRulesProfilesIsBuiltInNotNullable(db.database()); - - @Test - public void execute_makes_column_not_null() throws SQLException { - db.assertColumnDefinition("rules_profiles", "is_built_in", Types.BOOLEAN, null, true); - insertRow(1); - insertRow(2); - - underTest.execute(); - - db.assertColumnDefinition("rules_profiles", "is_built_in", Types.BOOLEAN, null, false); - } - - private void insertRow(int id) { - db.executeInsert( - "RULES_PROFILES", - "NAME", "name_" + id, - "ORGANIZATION_UUID", "org_" + id, - "KEE", "kee" + id, - "IS_DEFAULT", false, - "IS_BUILT_IN", false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullableTest.java deleted file mode 100644 index 450b7aa21f9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullableTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class MakeUsersOnboardedNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeUsersOnboardedNotNullableTest.class, "users_with_nullable_onboarded_column.sql"); - - private MakeUsersOnboardedNotNullable underTest = new MakeUsersOnboardedNotNullable(db.database()); - - @Test - public void execute_makes_column_component_uuid_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumn(); - } - - @Test - public void execute_makes_column_component_uuid_not_nullable_on_populated_table() throws SQLException { - insertUser(); - insertUser(); - insertUser(); - - underTest.execute(); - - verifyColumn(); - } - - private void verifyColumn() { - db.assertColumnDefinition("users", "onboarded", Types.BOOLEAN, null, false); - } - - private void insertUser() { - db.executeInsert( - "users", - "ONBOARDED", true, - "IS_ROOT", true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuidTest.java deleted file mode 100644 index 2b1e94bb3ab..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuidTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateEventsComponentUuidTest { - private static final String TABLE_EVENTS = "events"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateEventsComponentUuidTest.class, "events_and_snapshots.sql"); - - private final Random random = new Random(); - - private PopulateEventsComponentUuid underTest = new PopulateEventsComponentUuid(db.database()); - - @Test - public void execute_has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_deletes_all_events_if_snapshots_is_empty() throws SQLException { - insertEvent(randomAlphabetic(5), null); - insertEvent(randomAlphabetic(5), randomAlphabetic(10)); - - underTest.execute(); - - assertThat(getAllEventUuids()).isEmpty(); - } - - @Test - public void execute_populates_components_uuid_of_events_which_analysis_exists() throws SQLException { - String componentUuid = "foo"; - String existingAnalysisUuid = insertSnapshot(componentUuid); - String missingAnalysisUuid = randomAlphabetic(5); - String uuid = insertEvent(existingAnalysisUuid, null); - insertEvent(missingAnalysisUuid, null); - - underTest.execute(); - - assertThat(getAllEventUuids()).containsOnly(uuid); - assertThat(getComponentUuidOf(uuid)).isEqualTo(componentUuid); - } - - @Test - public void execute_fixes_inconsistent_component_uuid_of_event_which_analysis_exists() throws SQLException { - String analysisUuid1 = insertSnapshot("foo"); - String analysisUuid2 = insertSnapshot("bar"); - String eventUuid1 = insertEvent(analysisUuid1, "foo"); - String eventUuid2 = insertEvent(analysisUuid2, "moh"); - - underTest.execute(); - - assertThat(getAllEventUuids()).containsOnly(eventUuid1, eventUuid2); - assertThat(getComponentUuidOf(eventUuid1)).isEqualTo("foo"); - assertThat(getComponentUuidOf(eventUuid2)).isEqualTo("bar"); - } - - @Test - public void execute_deletes_events_without_component_uuid_which_analysis_does_not_exist() throws SQLException { - String analysisUuid1 = insertSnapshot("foo"); - String eventUuid1 = insertEvent(analysisUuid1, "foo"); - insertEvent(randomAlphabetic(3), "moh"); - insertEvent(randomAlphabetic(3), null); - - underTest.execute(); - - assertThat(getAllEventUuids()).containsOnly(eventUuid1); - } - - private String insertSnapshot(String componentUuid) { - String uuid = randomAlphabetic(10); - db.executeInsert( - "snapshots", - "UUID", uuid, - "COMPONENT_UUID", componentUuid, - "STATUS", "U", - "ISLAST", String.valueOf(true)); - return uuid; - } - - private String insertEvent(String analysisUuid, @Nullable String componentUuid) { - String uuid = randomAlphabetic(5); - db.executeInsert( - TABLE_EVENTS, - "UUID", uuid, - "ANALYSIS_UUID", analysisUuid, - "COMPONENT_UUID", componentUuid, - "EVENT_DATE", random.nextInt(), - "CREATED_AT", random.nextInt()); - return uuid; - } - - private Stream getAllEventUuids() { - return db.select("select uuid as \"UUID\" from events").stream().map(row -> (String) row.get("UUID")); - } - - private String getComponentUuidOf(String eventUuid) { - return (String) db.selectFirst("select component_uuid as \"COMPONENT_UUID\" from events where uuid = '" + eventUuid + "'") - .get("COMPONENT_UUID"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfilesTest.java deleted file mode 100644 index 1ba1f93d07d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfilesTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Map; -import java.util.Random; -import java.util.stream.IntStream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrgQProfilesTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrgQProfilesTest.class, "initial.sql"); - - private System2 system2 = new AlwaysIncreasingSystem2(); - private PopulateOrgQProfiles underTest = new PopulateOrgQProfiles(db.database(), system2); - - @Test - public void migration_is_reentrant() throws SQLException { - insertRulesProfile("ORG_1", "java", "u1", null, true, 1_000L, 1_100L); - insertRulesProfile("ORG_2", "js", "u2", "u1", true, 1_000L, 1_100L); - - // org1 is already processed - insertOrgQProfile("u1", "ORG_1", "RPU1"); - - underTest.execute(); - - assertThat(countRows()).isEqualTo(2); - Map qprofile1 = selectOrgQProfile("u1", "ORG_1"); - Map qprofile2 = selectOrgQProfile("u2", "ORG_2"); - - assertThat(qprofile1.get("UUID")).isEqualTo("u1"); - assertThat(qprofile1.get("ORGANIZATION_UUID")).isEqualTo("ORG_1"); - assertThat(qprofile1.get("RULES_PROFILE_UUID")).isEqualTo("RPU1"); // Ok if not overridden ? - assertThat(qprofile1.get("PARENT_UUID")).isNull(); - - assertThat(qprofile2.get("UUID")).isEqualTo("u2"); - assertThat(qprofile2.get("ORGANIZATION_UUID")).isEqualTo("ORG_2"); - assertThat(qprofile2.get("RULES_PROFILE_UUID")).isEqualTo("u2"); - assertThat(qprofile2.get("PARENT_UUID")).isEqualTo("u1"); - assertThat(qprofile2.get("LAST_USED")).isEqualTo(1_000L); - assertThat(qprofile2.get("USER_UPDATED_AT")).isEqualTo(1_100L); - } - - @Test - public void migration_must_create_as_much_as_rules_profile() throws SQLException { - Random random = new Random(); - int nbRulesProfile = 100 + random.nextInt(100); - IntStream.range(0, nbRulesProfile).forEach( - i -> insertRulesProfile("ORG_" + i, "java", "uuid" + i, random.nextBoolean() ? "ORG_" + random.nextInt(i + 1) : null, random.nextBoolean(), null, null)); - - underTest.execute(); - - assertThat(countRows()).isEqualTo(nbRulesProfile); - } - - private int countRows() { - return db.countRowsOfTable("org_qprofiles"); - } - - private void insertRulesProfile(String orgUuid, String language, String uuid, String parentKee, boolean isDefault, @Nullable Long lastUsed, @Nullable Long userUpdatedAt) { - db.executeInsert("RULES_PROFILES", - "NAME", "name_" + uuid, - "KEE", uuid, - "ORGANIZATION_UUID", orgUuid, - "PARENT_KEE", parentKee, - "LANGUAGE", language, - "IS_DEFAULT", isDefault, - "IS_BUILT_IN", true, - "LAST_USED", lastUsed, - "USER_UPDATED_AT", userUpdatedAt); - } - - private void insertOrgQProfile(String uuid, String orgUuid, String rulesProfileUuid) { - db.executeInsert("ORG_QPROFILES", - "ORGANIZATION_UUID", orgUuid, - "RULES_PROFILE_UUID", rulesProfileUuid, - "UUID", uuid, - "CREATED_AT", system2.now(), - "UPDATED_AT", system2.now()); - } - - private Map selectOrgQProfile(String uuid, String orgUuid) { - return db.selectFirst(format("select * from org_qprofiles where uuid='%s' and organization_uuid='%s'", uuid, orgUuid)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfilesTest.java deleted file mode 100644 index 63441a8b0ff..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfilesTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; - -public class PopulateTableDefaultQProfilesTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateTableDefaultQProfilesTest.class, "initial.sql"); - - private System2 system2 = new AlwaysIncreasingSystem2(); - private PopulateTableDefaultQProfiles underTest = new PopulateTableDefaultQProfiles(db.database(), system2); - - @Test - public void migration_is_reentrant() throws SQLException { - insertRulesProfile("ORG_1", "java", "u1", true); - insertRulesProfile("ORG_2", "js", "u2", true); - - // org1 is already processed - insertDefaultQProfile("ORG_1", "java", "u1"); - - underTest.execute(); - - assertThat(countRows()).isEqualTo(2); - assertThat(selectDefaultProfile("ORG_1", "java")).isEqualTo("u1"); - assertThat(selectDefaultProfile("ORG_2", "js")).isEqualTo("u2"); - } - - @Test - public void DEFAULT_QPROFILES_is_populated_by_copying_the_RULES_PROFILES_marked_as_default() throws SQLException { - insertRulesProfile("ORG_1", "java", "u1", false); - insertRulesProfile("ORG_1", "java", "u2", true); - insertRulesProfile("ORG_1", "js", "u3", true); - - underTest.execute(); - - assertThat(countRows()).isEqualTo(2); - assertThat(selectDefaultProfile("ORG_1", "java")).isEqualTo("u2"); - assertThat(selectDefaultProfile("ORG_1", "js")).isEqualTo("u3"); - } - - @Test - public void duplicated_rows_of_table_RULES_PROFILES_are_ignored() throws SQLException { - // two java profiles are marked as default. - // The second one (as ordered by id) is ignored. - insertRulesProfile("ORG_1", "java", "u1", false); - insertRulesProfile("ORG_1", "java", "u2", true); - insertRulesProfile("ORG_1", "java", "u3", true); - - underTest.execute(); - - assertThat(countRows()).isEqualTo(1); - assertThat(selectDefaultProfile("ORG_1", "java")).isEqualTo("u2"); - } - - private int countRows() { - return db.countRowsOfTable("default_qprofiles"); - } - - private void insertRulesProfile(String orgUuid, String language, String uuid, boolean isDefault) { - db.executeInsert("RULES_PROFILES", - "NAME", "name_" + uuid, - "KEE", uuid, - "ORGANIZATION_UUID", orgUuid, - "LANGUAGE", language, - "IS_DEFAULT", isDefault, - "IS_BUILT_IN", true); - } - - private void insertDefaultQProfile(String orgUuid, String language, String uuid) { - db.executeInsert("DEFAULT_QPROFILES", - "ORGANIZATION_UUID", orgUuid, - "LANGUAGE", language, - "QPROFILE_UUID", uuid); - } - - private String selectDefaultProfile(String orgUuid, String language) { - return (String)db.selectFirst("select qprofile_uuid as QPROFILE_UUID from default_qprofiles where organization_uuid='" + orgUuid + "' and language='" + language + "'") - .get("QPROFILE_UUID"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboardedTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboardedTest.java deleted file mode 100644 index 32f20211fa9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboardedTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; - -public class PopulateUsersOnboardedTest { - - private final static long PAST = 100_000_000_000L; - private final static long NOW = 500_000_000_000L; - - private System2 system2 = new TestSystem2().setNow(NOW); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUsersOnboardedTest.class, "users_with_onboarded_column.sql"); - - public PopulateUsersOnboarded underTest = new PopulateUsersOnboarded(db.database(), system2); - - @Test - public void set_onboarded_to_true() throws SQLException { - insertUser("admin"); - insertUser("user"); - assertUsers(tuple("admin", false, PAST), tuple("user", false, PAST)); - - underTest.execute(); - - assertUsers(tuple("admin", true, NOW), tuple("user", true, NOW)); - } - - private void insertUser(String login) { - db.executeInsert("USERS", "LOGIN", login, "ONBOARDED", false, "IS_ROOT", true, "CREATED_AT", PAST, "UPDATED_AT", PAST); - } - - private void assertUsers(Tuple... expectedTuples) { - assertThat(db.select("SELECT LOGIN, ONBOARDED, UPDATED_AT FROM USERS") - .stream() - .map(map -> new Tuple(map.get("LOGIN"), map.get("ONBOARDED"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperDataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperDataTest.java deleted file mode 100644 index 61730df9a4c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperDataTest.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Random; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -public class PurgeDeveloperDataTest { - - private static final String TABLE_PROJECT_MEASURE = "PROJECT_MEASURES"; - private static final String TABLE_CE_ACTIVITY = "CE_ACTIVITY"; - private static final String TABLE_SNAPSHOTS = "SNAPSHOTS"; - private static final String TABLE_GROUP_ROLES = "GROUP_ROLES"; - private static final String TABLE_USER_ROLES = "USER_ROLES"; - private static final String SCOPE_PROJECT = "PRJ"; - private static final String QUALIFIER_DEVELOPER = "DEV"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PurgeDeveloperDataTest.class, "projects_and_child_tables.sql"); - - private final Random random = new Random(); - private PurgeDeveloperData underTest = new PurgeDeveloperData(db.database()); - - @Test - public void execute_has_no_effect_when_table_PROJECTS_is_empty() throws SQLException { - insertProjectMeasure(randomAlphabetic(5), randomAlphabetic(5)); - insertCeActivity(randomAlphabetic(3)); - insertSnapshot(randomAlphabetic(3)); - insertGroupRole(random.nextInt()); - insertUserRole(random.nextInt()); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROJECT_MEASURE)).isEqualTo(1); - assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITY)).isEqualTo(1); - assertThat(db.countRowsOfTable(TABLE_SNAPSHOTS)).isEqualTo(1); - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(1); - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(1); - } - - @Test - public void execute_deletes_developer_and_children_of_a_developer_ignoring_scope_and_qualifier() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - insertComponent(randomAlphabetic(3), randomAlphabetic(3), devUuid); - insertComponent(randomAlphabetic(3), randomAlphabetic(3), devUuid); - String notADevChild = insertComponent(randomAlphabetic(3), randomAlphabetic(3), null); - String notADev = insertComponent(SCOPE_PROJECT, randomAlphabetic(3), null); - - underTest.execute(); - - assertThat(db.select("select uuid as \"UUID\" from projects").stream().map(row -> row.get("UUID"))) - .containsOnly(notADev, notADevChild); - } - - @Test - public void execute_deletes_PROJECT_MEASURE_of_developer() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - insertProjectMeasure(devUuid, randomAlphabetic(3)); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROJECT_MEASURE)).isZero(); - } - - @Test - public void execute_deletes_CE_ACTIVITY_of_developer() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - insertCeActivity(devUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITY)).isZero(); - } - - @Test - public void execute_deletes_SNAPSHOT_of_developer() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - insertSnapshot(devUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_SNAPSHOTS)).isZero(); - } - - @Test - public void execute_deletes_roles_of_developer() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - long devId = idOfComponent(devUuid); - insertUserRole(devId); - insertGroupRole(devId); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isZero(); - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isZero(); - } - - @Test - public void execute_deletes_PROJECT_MEASURE_of_children_of_developer() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - String childUuid = insertComponent(randomAlphabetic(3), randomAlphabetic(3), devUuid); - insertProjectMeasure(childUuid, randomAlphabetic(3)); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROJECT_MEASURE)).isEqualTo(0); - } - - @Test - public void execute_does_not_delete_CE_ACTIVITY_of_children_of_developer() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - String childUuid = insertComponent(randomAlphabetic(3), randomAlphabetic(3), devUuid); - insertCeActivity(childUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITY)).isEqualTo(1); - } - - @Test - public void execute_does_not_delete_SNAPSHOT_of_children_of_developer() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - String childUuid = insertComponent(randomAlphabetic(3), randomAlphabetic(3), devUuid); - insertSnapshot(childUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_SNAPSHOTS)).isEqualTo(1); - } - - @Test - public void execute_does_not_delete_roles_of_children_of_developer() throws SQLException { - String devUuid = insertComponent(SCOPE_PROJECT, QUALIFIER_DEVELOPER, null); - String childUuid = insertComponent(randomAlphabetic(3), randomAlphabetic(3), devUuid); - long childId = idOfComponent(childUuid); - insertUserRole(childId); - insertGroupRole(childId); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(1); - assertThat(db.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(1); - } - - private String insertComponent(String scope, String qualifier, @Nullable String projectUuid) { - String uuid = UuidFactoryFast.getInstance().create(); - db.executeInsert( - "PROJECTS", - "ORGANIZATION_UUID", randomAlphabetic(3), - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", randomAlphabetic(4), - "PROJECT_UUID", projectUuid == null ? uuid : projectUuid, - "SCOPE", scope, - "QUALIFIER", qualifier, - "PRIVATE", valueOf(random.nextBoolean()), - "ENABLED", valueOf(random.nextBoolean())); - return uuid; - } - - private long idOfComponent(String uuid) { - return (Long) db.selectFirst("select id \"ID\" from projects where uuid = '" + uuid + "'").get("ID"); - } - - private void insertProjectMeasure(String componentUuid, String analysisUuid) { - db.executeInsert( - TABLE_PROJECT_MEASURE, - "METRIC_ID", valueOf(random.nextInt()), - "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", analysisUuid); - } - - private void insertCeActivity(String componentUuid) { - db.executeInsert( - TABLE_CE_ACTIVITY, - "UUID", randomAlphabetic(5), - "TASK_TYPE", randomAlphabetic(3), - "COMPONENT_UUID", componentUuid, - "STATUS", randomAlphabetic(2), - "IS_LAST", valueOf(random.nextBoolean()), - "IS_LAST_KEY", randomAlphabetic(5), - "EXECUTION_COUNT", valueOf(random.nextInt()), - "SUBMITTED_AT", valueOf(random.nextLong()), - "CREATED_AT", valueOf(random.nextLong()), - "UPDATED_AT", valueOf(random.nextInt())); - } - - private void insertSnapshot(String componentUuid) { - db.executeInsert( - TABLE_SNAPSHOTS, - "UUID", randomAlphabetic(4), - "COMPONENT_UUID", componentUuid, - "STATUS", randomAlphabetic(3), - "ISLAST", valueOf(random.nextBoolean())); - } - - private void insertGroupRole(long componentId) { - db.executeInsert( - TABLE_GROUP_ROLES, - "ORGANIZATION_UUID", randomAlphabetic(3), - "RESOURCE_ID", valueOf(componentId), - "ROLE", randomAlphabetic(4)); - } - - private void insertUserRole(long componentId) { - db.executeInsert( - TABLE_USER_ROLES, - "ORGANIZATION_UUID", randomAlphabetic(3), - "RESOURCE_ID", valueOf(componentId), - "ROLE", randomAlphabetic(4)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuidTest.java deleted file mode 100644 index 8b4e6d7f0a6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuidTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class RecreateIndexEventsComponentUuidTest { - private static final String TABLE_EVENTS = "events"; - private static final String INDEX_EVENTS_COMPONENT_UUID = "events_component_uuid"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RecreateIndexEventsComponentUuidTest.class, "events.sql"); - - private RecreateIndexEventsComponentUuid underTest = new RecreateIndexEventsComponentUuid(db.database()); - - @Test - public void execute_adds_index_EVENTS_COMPONENT_UUID() throws SQLException { - db.assertIndexDoesNotExist(TABLE_EVENTS, INDEX_EVENTS_COMPONENT_UUID); - - underTest.execute(); - - db.assertIndex(TABLE_EVENTS, INDEX_EVENTS_COMPONENT_UUID, "component_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuidTest.java deleted file mode 100644 index aa5c3b5383b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuidTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class RecreateIndexManualMeasuresComponentUuidTest { - private static final String TABLE_MANUAL_MEASURES = "manual_measures"; - private static final String INDEX_MANUAL_MEASURES_COMPONENT_UUID = "manual_measures_component_uuid"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RecreateIndexManualMeasuresComponentUuidTest.class, "manual_measures.sql"); - - private RecreateIndexManualMeasuresComponentUuid underTest = new RecreateIndexManualMeasuresComponentUuid(db.database()); - - @Test - public void execute_adds_index_EVENTS_COMPONENT_UUID() throws SQLException { - db.assertIndexDoesNotExist(TABLE_MANUAL_MEASURES, INDEX_MANUAL_MEASURES_COMPONENT_UUID); - - underTest.execute(); - - db.assertIndex(TABLE_MANUAL_MEASURES, INDEX_MANUAL_MEASURES_COMPONENT_UUID, "component_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest.java deleted file mode 100644 index c42fe91eab8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest { - - private static final String TABLE_NAME = "qprofile_changes"; - private static final String OLD_COLUMN_NAME = "qprofile_key"; - private static final String NEW_COLUMN_NAME = "rules_profile_uuid"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest.class, "initial.sql"); - - private RenameQProfileKeyToRulesProfileUuidOnQProfileChanges underTest = new RenameQProfileKeyToRulesProfileUuidOnQProfileChanges(db.database()); - - @Test - public void change_column_name_from_QPROFILE_KEY_to_RULES_PROFILE_UUID() throws Exception { - db.assertColumnDefinition(TABLE_NAME, OLD_COLUMN_NAME, Types.VARCHAR, 255); - underTest.execute(); - db.assertColumnDefinition(TABLE_NAME, NEW_COLUMN_NAME, Types.VARCHAR, 255); - db.assertColumnDoesNotExist(TABLE_NAME, OLD_COLUMN_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalseTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalseTest.java deleted file mode 100644 index c0849edefb5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalseTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SetRulesProfilesIsBuiltInToFalseTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetRulesProfilesIsBuiltInToFalseTest.class, "initial.sql"); - - private SetRulesProfilesIsBuiltInToFalse underTest = new SetRulesProfilesIsBuiltInToFalse(db.database()); - - @Test - public void has_no_effect_if_table_RULES_PROFILES_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("rules_profiles")).isEqualTo(0); - } - - @Test - public void updates_rows_with_null_is_build_in_column_to_false() throws SQLException { - insertRow(1, null); - insertRow(2, null); - - assertThat(countRowsWitValue(null)).isEqualTo(2); - assertThat(countRowsWitValue(false)).isEqualTo(0); - - underTest.execute(); - - assertThat(countRowsWitValue(null)).isEqualTo(0); - assertThat(countRowsWitValue(false)).isEqualTo(2); - } - - @Test - public void support_large_number_of_rows() throws SQLException { - for (int i = 0; i < 2_000; i++) { - insertRow(i, null); - } - - underTest.execute(); - - assertThat(countRowsWitValue(null)).isEqualTo(0); - assertThat(countRowsWitValue(false)).isEqualTo(2_000); - } - - @Test - public void execute_is_reentreant() throws SQLException { - insertRow(1, null); - insertRow(2, false); - - underTest.execute(); - - underTest.execute(); - - assertThat(countRowsWitValue(null)).isEqualTo(0); - assertThat(countRowsWitValue(false)).isEqualTo(2); - } - - private int countRowsWitValue(@Nullable Boolean value) { - if (value == null) { - return db.countSql("select count(1) from rules_profiles where is_built_in is null"); - } - return db.countSql("select count(1) from rules_profiles where is_built_in=" + value); - } - - private void insertRow(int id, @Nullable Boolean builtIn) { - db.executeInsert( - "RULES_PROFILES", - "NAME", "name_" + id, - "ORGANIZATION_UUID", "org_" + id, - "KEE", "kee" + id, - "IS_DEFAULT", false, - "IS_BUILT_IN", builtIn == null ? null : builtIn.toString()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest.java deleted file mode 100644 index 0902116a324..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest.class, "initial.sql"); - - private SetRulesProfilesIsBuiltInToTrueForDefaultOrganization underTest = new SetRulesProfilesIsBuiltInToTrueForDefaultOrganization(db.database()); - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("rules_profiles")).isEqualTo(0); - } - - @Test - public void mark_rules_profiles_of_default_org_as_built_in() throws SQLException { - enableOrganization(); - String defaultOrganizationUuid = "ORG_UUID_1"; - setDefaultOrganization(defaultOrganizationUuid); - IntStream.rangeClosed(1, 3).forEach(i -> { - insertProfile(defaultOrganizationUuid, "RP_UUID_" + i, false); - insertProfile("ORG_UUID_404", "RP_UUID_404_" + i, false); - }); - - underTest.execute(); - - assertThat(selectRulesProfiles(true)).containsExactlyInAnyOrder("RP_UUID_1", "RP_UUID_2", "RP_UUID_3"); - assertThat(selectRulesProfiles(false)).containsExactlyInAnyOrder("RP_UUID_404_1", "RP_UUID_404_2", "RP_UUID_404_3"); - } - - @Test - public void do_nothing_if_org_disabled() throws SQLException { - String defaultOrganizationUuid = "ORG_UUID_1"; - setDefaultOrganization(defaultOrganizationUuid); - IntStream.rangeClosed(1, 3).forEach(i -> { - insertProfile(defaultOrganizationUuid, "RP_UUID_" + i, false); - insertProfile("ORG_UUID_404", "RP_UUID_404_" + i, false); - }); - - underTest.execute(); - - assertThat(selectRulesProfiles(false)).containsExactlyInAnyOrder("RP_UUID_1", "RP_UUID_2", "RP_UUID_3", "RP_UUID_404_1", "RP_UUID_404_2", "RP_UUID_404_3"); - } - - @Test - public void reentrant_migration() throws SQLException { - enableOrganization(); - String defaultOrganizationUuid = "ORG_UUID_1"; - setDefaultOrganization(defaultOrganizationUuid); - IntStream.rangeClosed(1, 3).forEach(i -> { - insertProfile(defaultOrganizationUuid, "RP_UUID_" + i, false); - insertProfile("ORG_UUID_404", "RP_UUID_404_" + i, false); - }); - - underTest.execute(); - underTest.execute(); - - assertThat(selectRulesProfiles(true)).containsExactlyInAnyOrder("RP_UUID_1", "RP_UUID_2", "RP_UUID_3"); - assertThat(selectRulesProfiles(false)).containsExactlyInAnyOrder("RP_UUID_404_1", "RP_UUID_404_2", "RP_UUID_404_3"); - } - - @Test - public void reentrant_of_crashed_migration() throws SQLException { - enableOrganization(); - String defaultOrganizationUuid = "ORG_UUID_1"; - setDefaultOrganization(defaultOrganizationUuid); - insertProfile(defaultOrganizationUuid, "RP_UUID_1", true); - insertProfile(defaultOrganizationUuid, "RP_UUID_2", false); - insertProfile(defaultOrganizationUuid, "RP_UUID_3", false); - - underTest.execute(); - - assertThat(selectRulesProfiles(true)).containsExactlyInAnyOrder("RP_UUID_1", "RP_UUID_2", "RP_UUID_3"); - } - - @Test - public void fail_if_no_default_org_and_org_activated() throws SQLException { - enableOrganization(); - insertProfile("ORG_UUID_1", "RP_UUID_1", false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Missing internal property: 'organization.default'"); - - underTest.execute(); - } - - private Set selectRulesProfiles(boolean isBuiltIn) { - return db.select("select rp.kee as \"uuid\", rp.is_built_in as \"isBuiltIn\" from rules_profiles rp") - .stream() - .filter(row -> (boolean) row.get("isBuiltIn") == isBuiltIn) - .map(row -> (String) row.get("uuid")) - .collect(Collectors.toSet()); - } - - private void enableOrganization() { - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.enabled", - "TEXT_VALUE", "true", - "IS_EMPTY", false); - } - - private void setDefaultOrganization(String uuid) { - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.default", - "TEXT_VALUE", uuid, - "IS_EMPTY", false); - } - - private void insertProfile(String orgUuid, String rulesProfileUuid, boolean isBuiltIn) { - db.executeInsert("ORG_QPROFILES", - "ORGANIZATION_UUID", orgUuid, - "UUID", "OQP_UUID_" + rulesProfileUuid, - "RULES_PROFILE_UUID", rulesProfileUuid, - "CREATED_AT", 1_000L, - "UPDATED_AT", 2_000L); - db.executeInsert("RULES_PROFILES", - "NAME", "name_" + rulesProfileUuid, - "KEE", rulesProfileUuid, - "LANGUAGE", "LANG_" + rulesProfileUuid, - "IS_BUILT_IN", isBuiltIn); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfilesTest.java deleted file mode 100644 index df9ddc0a601..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfilesTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v65; - -import java.sql.SQLException; -import java.util.List; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.stream.MoreCollectors; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class UpdateOrgQProfilesToPointToBuiltInProfilesTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(UpdateOrgQProfilesToPointToBuiltInProfilesTest.class, "initial.sql"); - - private UpdateOrgQProfilesToPointToBuiltInProfiles underTest = new UpdateOrgQProfilesToPointToBuiltInProfiles(db.database()); - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("rules_profiles")).isEqualTo(0); - } - - @Test - public void has_no_effect_if_organization_are_disabled() throws SQLException { - String defaultOrgUuid = "DEFAULT_ORG_UUID"; - setDefaultOrganization(defaultOrgUuid); - String sonarWayJava = "RP_UUID_1"; - String sonarWayJavascript = "RP_UUID_2"; - insertProfile(defaultOrgUuid, "OQP_UUID_1", sonarWayJava, "Sonar way", "Java", true, 1_000_000_000L); - insertProfile(defaultOrgUuid, "OQP_UUID_2", sonarWayJavascript, "Sonar way", "Javascript", true, null); - insertProfile(defaultOrgUuid, "OQP_UUID_3", "RP_UUID_3", "Sonar way", "Cobol", true, null); - insertProfile(defaultOrgUuid, "OQP_UUID_4", "RP_UUID_4", "My Sonar way", "Java", false, null); - - underTest.execute(); - - assertThat(selectRulesProfiles()).containsExactlyInAnyOrder( - tuple("OQP_UUID_1", sonarWayJava), - tuple("OQP_UUID_2", sonarWayJavascript), - tuple("OQP_UUID_3", "RP_UUID_3"), - tuple("OQP_UUID_4", "RP_UUID_4")); - } - - @Test - public void update_org_qprofiles_to_point_to_built_in_rules_profiles() throws SQLException { - enableOrganization(); - String defaultOrgUuid = "DEFAULT_ORG_UUID"; - setDefaultOrganization(defaultOrgUuid); - String sonarWayJava = "RP_UUID_1"; - String sonarWayJavascript = "RP_UUID_2"; - insertProfile(defaultOrgUuid, "OQP_UUID_1", sonarWayJava, "Sonar way", "Java", true, 1_000_000_000L); - insertProfile(defaultOrgUuid, "OQP_UUID_2", sonarWayJavascript, "Sonar way", "Javascript", true, null); - insertProfile(defaultOrgUuid, "OQP_UUID_3", "RP_UUID_3", "Sonar way", "Cobol", true, null); - insertProfile("ORG_UUID_1", "OQP_UUID_4", "RP_UUID_4", "Sonar way", "Java", false, null); - insertProfile("ORG_UUID_1", "OQP_UUID_5", "RP_UUID_5", "My Sonar way", "Java", false, null); - insertProfile("ORG_UUID_2", "OQP_UUID_6", "RP_UUID_6", "Sonar way", "Javascript", false, null); - insertProfile("ORG_UUID_2", "OQP_UUID_7", "RP_UUID_7", "Sonar way", "Python", false, null); - insertProfile("ORG_UUID_2", "OQP_UUID_8", "RP_UUID_8", "Sonar way", "Java", false, 2_000_000_000L); - - underTest.execute(); - - assertThat(selectRulesProfiles()).containsExactlyInAnyOrder( - tuple("OQP_UUID_1", sonarWayJava), - tuple("OQP_UUID_2", sonarWayJavascript), - tuple("OQP_UUID_3", "RP_UUID_3"), - tuple("OQP_UUID_4", sonarWayJava), - tuple("OQP_UUID_5", "RP_UUID_5"), - tuple("OQP_UUID_6", sonarWayJavascript), - tuple("OQP_UUID_7", "RP_UUID_7"), - tuple("OQP_UUID_8", "RP_UUID_8")); - } - - @Test - public void migration_is_reentrant() throws SQLException { - enableOrganization(); - String defaultOrgUuid = "DEFAULT_ORG_UUID"; - setDefaultOrganization(defaultOrgUuid); - String sonarWayJava = "RP_UUID_1"; - String sonarWayJavascript = "RP_UUID_2"; - insertProfile(defaultOrgUuid, "OQP_UUID_1", sonarWayJava, "Sonar way", "Java", true, 1_000_000_000L); - insertProfile(defaultOrgUuid, "OQP_UUID_2", sonarWayJavascript, "Sonar way", "Javascript", true, null); - insertProfile("ORG_UUID_1", "OQP_UUID_4", "RP_UUID_4", "Sonar way", "Java", false, null); - insertProfile("ORG_UUID_1", "OQP_UUID_5", "RP_UUID_5", "My Sonar way", "Java", false, null); - - underTest.execute(); - underTest.execute(); - - assertThat(selectRulesProfiles()).containsExactlyInAnyOrder( - tuple("OQP_UUID_1", sonarWayJava), - tuple("OQP_UUID_2", sonarWayJavascript), - tuple("OQP_UUID_4", sonarWayJava), - tuple("OQP_UUID_5", "RP_UUID_5")); - } - - @Test - public void crashed_migration_is_reentrant() throws SQLException { - enableOrganization(); - String defaultOrgUuid = "DEFAULT_ORG_UUID"; - setDefaultOrganization(defaultOrgUuid); - String sonarWayJava = "RP_UUID_1"; - String sonarWayJavascript = "RP_UUID_2"; - insertProfile(defaultOrgUuid, "OQP_UUID_1", sonarWayJava, "Sonar way", "Java", true, 1_000_000_000L); - insertProfile(defaultOrgUuid, "OQP_UUID_2", sonarWayJavascript, "Sonar way", "Javascript", true, null); - insertOrgQProfile("ORG_UUID_1", "OQP_UUID_3", sonarWayJava); - insertProfile("ORG_UUID_1", "OQP_UUID_4", "RP_UUID_4", "Sonar way", "Javascript", false, null); - insertProfile("ORG_UUID_1", "OQP_UUID_5", "RP_UUID_5", "My Sonar way", "Java", false, null); - - underTest.execute(); - - assertThat(selectRulesProfiles()).containsExactlyInAnyOrder( - tuple("OQP_UUID_1", sonarWayJava), - tuple("OQP_UUID_2", sonarWayJavascript), - tuple("OQP_UUID_3", sonarWayJava), - tuple("OQP_UUID_4", sonarWayJavascript), - tuple("OQP_UUID_5", "RP_UUID_5")); - } - - @Test - public void fail_if_no_default_org_and_org_activated() throws SQLException { - enableOrganization(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Missing internal property: 'organization.default'"); - - underTest.execute(); - } - - private List selectRulesProfiles() { - return db.select("select oqp.uuid as \"uuid\", oqp.rules_profile_uuid as \"rulesProfileUuid\" from org_qprofiles oqp") - .stream() - .map(row -> tuple(row.get("uuid"), row.get("rulesProfileUuid"))) - .collect(MoreCollectors.toList()); - } - - private void enableOrganization() { - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.enabled", - "TEXT_VALUE", "true", - "IS_EMPTY", false); - } - - private void setDefaultOrganization(String uuid) { - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.default", - "TEXT_VALUE", uuid, - "IS_EMPTY", false); - } - - private void insertProfile(String orgUuid, String orgQProfileUuid, String rulesProfileUuid, String name, String language, boolean isBuiltIn, @Nullable Long userUpdatedAt) { - db.executeInsert("ORG_QPROFILES", - "ORGANIZATION_UUID", orgUuid, - "UUID", orgQProfileUuid, - "RULES_PROFILE_UUID", rulesProfileUuid, - "CREATED_AT", 1_000L, - "UPDATED_AT", 2_000L, - "USER_UPDATED_AT", userUpdatedAt); - db.executeInsert("RULES_PROFILES", - "NAME", name, - "KEE", rulesProfileUuid, - "LANGUAGE", language, - "IS_BUILT_IN", isBuiltIn); - } - - private void insertOrgQProfile(String orgUuid, String orgQProfileUuid, String rulesProfileUuid) { - db.executeInsert("ORG_QPROFILES", - "ORGANIZATION_UUID", orgUuid, - "UUID", orgQProfileUuid, - "RULES_PROFILE_UUID", rulesProfileUuid, - "CREATED_AT", 1_000L, - "UPDATED_AT", 2_000L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTableTest.java deleted file mode 100644 index 571fa0e07f1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - - -public class AddErrorTypeColumnToCeActivityTableTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddErrorTypeColumnToCeActivityTableTest.class, "ce_activity_6_5.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddErrorTypeColumnToCeActivityTable underTest = new AddErrorTypeColumnToCeActivityTable(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("ce_activity", "error_type", java.sql.Types.VARCHAR, 20, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRulesTest.java deleted file mode 100644 index 7253232c5d5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRulesTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddPluginKeyToRulesTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddPluginKeyToRulesTest.class, "rules_6_5.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddPluginKeyToRules underTest = new AddPluginKeyToRules(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("rules", "plugin_key", java.sql.Types.VARCHAR, 200, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristicsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristicsTest.java deleted file mode 100644 index ca418508767..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristicsTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.sql.SQLException; -import java.sql.Types; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class CreateTableCeTaskCharacteristicsTest { - private static final String TABLE = "ce_task_characteristics"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableCeTaskCharacteristicsTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableCeTaskCharacteristics underTest = new CreateTableCeTaskCharacteristics(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - db.assertColumnDefinition(TABLE, "task_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "kee", Types.VARCHAR, 512, false); - db.assertColumnDefinition(TABLE, "text_value", Types.VARCHAR, 512, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTablePluginsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTablePluginsTest.java deleted file mode 100644 index 69686dcd0a8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTablePluginsTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTablePluginsTest { - - private static final String TABLE = "plugins"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTablePluginsTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTablePlugins underTest = new CreateTablePlugins(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertPrimaryKey(TABLE, "pk_plugins", "uuid"); - db.assertColumnDefinition(TABLE, "kee", Types.VARCHAR, 200, false); - db.assertColumnDefinition(TABLE, "base_plugin_key", Types.VARCHAR, 200, true); - db.assertColumnDefinition(TABLE, "file_hash", Types.VARCHAR, 200, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", Types.BIGINT, null, false); - - db.assertUniqueIndex(TABLE, "plugins_key", "kee"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranchesTest.java deleted file mode 100644 index 9130b3c1622..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranchesTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableProjectBranchesTest { - private static final String TABLE = "project_branches"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableProjectBranchesTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableProjectBranches underTest = new CreateTableProjectBranches(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 50, false); - db.assertColumnDefinition(TABLE, "project_uuid", Types.VARCHAR, 50, false); - db.assertColumnDefinition(TABLE, "kee", Types.VARCHAR, 255, false); - db.assertColumnDefinition(TABLE, "branch_type", Types.VARCHAR, 5, true); - db.assertColumnDefinition(TABLE, "merge_branch_uuid", Types.VARCHAR, 50, true); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", Types.BIGINT, null, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroupsTest.java deleted file mode 100644 index 6fbffee84b6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroupsTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableQProfileEditGroupsTest { - - private static final String TABLE = "qprofile_edit_groups"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableQProfileEditGroupsTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableQProfileEditGroups underTest = new CreateTableQProfileEditGroups(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "group_id", Types.INTEGER, null, false); - db.assertColumnDefinition(TABLE, "qprofile_uuid", Types.VARCHAR, 255, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - db.assertIndex(TABLE, "qprofile_edit_groups_qprofile", "qprofile_uuid"); - db.assertUniqueIndex(TABLE, "qprofile_edit_groups_unique", "group_id", "qprofile_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsersTest.java deleted file mode 100644 index 5a80e76bf0f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsersTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableQProfileEditUsersTest { - - private static final String TABLE = "qprofile_edit_users"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableQProfileEditUsersTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableQProfileEditUsers underTest = new CreateTableQProfileEditUsers(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "user_id", Types.INTEGER, null, false); - db.assertColumnDefinition(TABLE, "qprofile_uuid", Types.VARCHAR, 255, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - db.assertIndex(TABLE, "qprofile_edit_users_qprofile", "qprofile_uuid"); - db.assertUniqueIndex(TABLE, "qprofile_edit_users_unique", "user_id", "qprofile_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66Test.java deleted file mode 100644 index 8d21413ba0c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion66Test { - - private DbVersion66 underTest = new DbVersion66(); - - @Test - public void migrationNumber_starts_at_1801() { - verifyMinimumMigrationNumber(underTest, 1801); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 13); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest.java deleted file mode 100644 index 877876f00ba..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import java.util.Random; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.resources.Scopes; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.VIEW; - -public class DeleteLeakSettingsOnViewsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteLeakSettingsOnViewsTest.class, "settings_and_projects.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DeleteLeakSettingsOnViews underTest = new DeleteLeakSettingsOnViews(db.database()); - - @Test - public void migrate_leak_settings_on_views() throws SQLException { - long viewId = insertComponent(Scopes.PROJECT, VIEW); - long subViewId = insertComponent(Scopes.PROJECT, SUBVIEW); - insertProperty("sonar.leak.period", viewId); - insertProperty("sonar.leak.period", subViewId); - - underTest.execute(); - - assertPropertiesIsEmpty(); - } - - @Test - public void migrate_old_leak_settings_on_views() throws SQLException { - long viewId = insertComponent(Scopes.PROJECT, VIEW); - long subViewId = insertComponent(Scopes.PROJECT, SUBVIEW); - insertProperty("sonar.timemachine.period1", viewId); - insertProperty("sonar.timemachine.period1", subViewId); - - underTest.execute(); - - assertPropertiesIsEmpty(); - } - - @Test - public void does_nothing_on_leak_settings_not_on_views() throws SQLException { - long projectId = insertComponent(Scopes.PROJECT, PROJECT); - insertProperty("sonar.leak.period", projectId); - insertProperty("sonar.leak.period", null); - - underTest.execute(); - - assertProperties( - tuple("sonar.leak.period", projectId), - tuple("sonar.leak.period", null)); - } - - @Test - public void does_nothing_on_non_leak_settings() throws SQLException { - long projectId = insertComponent(Scopes.PROJECT, PROJECT); - insertProperty("sonar.component", projectId); - insertProperty("sonar.global", null); - - underTest.execute(); - - assertProperties( - tuple("sonar.component", projectId), - tuple("sonar.global", null)); - } - - private void assertPropertiesIsEmpty(){ - assertThat(db.countRowsOfTable("properties")).isZero(); - } - - private void assertProperties(Tuple... expectedTuples) { - assertThat(db.select("SELECT PROP_KEY, RESOURCE_ID FROM PROPERTIES") - .stream() - .map(map -> new Tuple(map.get("PROP_KEY"), map.get("RESOURCE_ID"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - public void insertProperty(String propertyName, @Nullable Long componentId) { - db.executeInsert( - "properties", - "prop_key", propertyName, - "resource_id", componentId, - "is_empty", "false", - "text_value", randomAlphabetic(2)); - } - - private long insertComponent(@Nullable String scope, @Nullable String qualifier) { - String uuid = Uuids.createFast(); - db.executeInsert( - "projects", - "organization_uuid", randomAlphanumeric(3), - "uuid", uuid, - "uuid_path", "path_of_" + uuid, - "root_uuid", uuid, - "project_uuid", uuid, - "scope", scope, - "qualifier", qualifier, - "private", valueOf(new Random().nextBoolean()), - "enabled", valueOf(new Random().nextBoolean())); - return ((Long) db.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID")).intValue(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsersTest.java deleted file mode 100644 index b66f41554ce..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsersTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class FixEmptyIdentityProviderInUsersTest { - - private final static long PAST = 100_000_000_000l; - private final static long NOW = 500_000_000_000l; - - private System2 system2 = new TestSystem2().setNow(NOW); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(FixEmptyIdentityProviderInUsersTest.class, "users.sql"); - - private FixEmptyIdentityProviderInUsers underTest = new FixEmptyIdentityProviderInUsers(db.database(), system2); - - @Test - public void execute_has_no_effect_if_tables_are_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void migrate_user_without_external_identity_info() throws SQLException { - insertUser("userWithoutExternalIdentityInfo", null, null); - - underTest.execute(); - - assertUsers(tuple("userWithoutExternalIdentityInfo", "userWithoutExternalIdentityInfo", "sonarqube", NOW)); - } - - @Test - public void migrate_user_with_partial_external_identity_info() throws SQLException { - insertUser("userWithoutExternalIdentity", "user", null); - insertUser("userWithoutExternalIdentityProvider", null, "github"); - - underTest.execute(); - - assertUsers(tuple("userWithoutExternalIdentity", "userWithoutExternalIdentity", "sonarqube", NOW), - tuple("userWithoutExternalIdentityProvider", "userWithoutExternalIdentityProvider", "sonarqube", NOW)); - } - - @Test - public void does_not_migrate_user_with_external_identity_info() throws SQLException { - insertUser("userWithIdentityInfo", "user", "sonarqube"); - - underTest.execute(); - - assertUsers(tuple("userWithIdentityInfo", "user", "sonarqube", PAST)); - } - - private void insertUser(String login, @Nullable String externalIdentity, @Nullable String externalIdentityProvider) { - ImmutableMap.Builder map = ImmutableMap.builder() - .put("LOGIN", login) - .put("IS_ROOT", true) - .put("ONBOARDED", true) - .put("CREATED_AT", PAST) - .put("UPDATED_AT", PAST); - if (externalIdentity != null) { - map.put("EXTERNAL_IDENTITY", externalIdentity); - } - if (externalIdentityProvider != null) { - map.put("EXTERNAL_IDENTITY_PROVIDER", externalIdentityProvider); - } - db.executeInsert("USERS", map.build()); - } - - private void assertUsers(Tuple... expectedTuples) { - assertThat(db.select("SELECT LOGIN, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, UPDATED_AT FROM USERS") - .stream() - .map(map -> new Tuple(map.get("LOGIN"), map.get("EXTERNAL_IDENTITY"), map.get("EXTERNAL_IDENTITY_PROVIDER"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest.java deleted file mode 100644 index 19ba119e1ea..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateMainProjectBranchesTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateMainProjectBranchesTest.class, "initial.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - private PopulateMainProjectBranches underTest = new PopulateMainProjectBranches(db.database(), system2); - - @Test - public void migrate() throws SQLException { - String project = insertProject(); - - underTest.execute(); - - assertProjectBranches(tuple("master", project, project, "LONG", NOW, NOW)); - } - - @Test - public void does_nothing_on_non_projects() throws SQLException { - insertProject(null, "BRC"); - insertProject(null, "VW"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("project_branches")).isZero(); - } - - @Test - public void does_nothing_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("project_branches")).isZero(); - } - - @Test - public void does_nothing_if_already_migrated() throws SQLException { - String project = insertProject(); - insertMainBranch(project); - - underTest.execute(); - - assertProjectBranches(tuple("master", project, project, "LONG", PAST, PAST)); - } - - private void assertProjectBranches(Tuple... expectedTuples) { - assertThat(db.select("SELECT KEE, UUID, PROJECT_UUID, BRANCH_TYPE, CREATED_AT, UPDATED_AT FROM PROJECT_BRANCHES") - .stream() - .map(map -> new Tuple(map.get("KEE"), map.get("UUID"), map.get("PROJECT_UUID"), map.get("BRANCH_TYPE"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private String insertProject() { - return insertProject(null, "PRJ"); - } - - private String insertProject(@Nullable String mainBranchUuid, String scope) { - String uuid = Uuids.createFast(); - db.executeInsert("PROJECTS", - "ORGANIZATION_UUID", "default-org", - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "main_branch_project_uuid", mainBranchUuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", "true", - "qualifier", "TRK", - "scope", scope); - return uuid; - } - - private void insertMainBranch(String uuid) { - db.executeInsert("PROJECT_BRANCHES", - "uuid", uuid, - "project_uuid", uuid, - "kee", "master", - "branch_type", "LONG", - "created_at", PAST, - "updated_at", PAST); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PurgeTablePropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PurgeTablePropertiesTest.java deleted file mode 100644 index 8c7ea2218ed..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PurgeTablePropertiesTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PurgeTablePropertiesTest { - - private static final String TABLE_PROPERTIES = "properties"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PurgeTablePropertiesTest.class, "properties.sql"); - - private PurgeTableProperties underTest = new PurgeTableProperties(db.database()); - - @Test - public void migration_has_no_effect_on_empty_db() throws Exception { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(0); - } - - @Test - public void migration_deletes_properties_by_keys() throws Exception { - // to be deleted - insert("views.analysisDelayingInMinutes"); - insert("views.status"); - insert("sonar.issuesdensity.weight"); - // to be kept - insert("views.status.differentSuffix"); - insert("views.foo"); - - underTest.execute(); - - verifyRemainingKeys("views.status.differentSuffix", "views.foo"); - } - - @Test - public void migration_deletes_properties_by_key_prefixes() throws Exception { - // to be deleted - insert("sonar.sqale.foo"); - insert("sonar.sqale.bar"); - // to be kept - insert("sonar.sqale"); - insert("sqale"); - - underTest.execute(); - - verifyRemainingKeys("sonar.sqale", "sqale"); - } - - private void insert(String key) { - // test the different combinations of keys - db.executeInsert(TABLE_PROPERTIES, "prop_key", key, "text_value", "foo", "is_empty", false); - db.executeInsert(TABLE_PROPERTIES, "prop_key", key, "text_value", "foo", "is_empty", false, "user_id", 100); - db.executeInsert(TABLE_PROPERTIES, "prop_key", key, "text_value", "foo", "is_empty", false, "resource_id", 200); - } - - private void verifyRemainingKeys(String... expectedKeys) { - assertThat(selectKeys()) - // verify that the 3 different combinations of rows are still present - .hasSize(expectedKeys.length * 3) - .containsOnly(expectedKeys); - } - - private List selectKeys() { - List> rows = db.select("select prop_key as \"key\" from properties"); - return rows.stream() - .map(row -> (String) row.get("key")) - .collect(Collectors.toList()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest.java deleted file mode 100644 index d48d2919e8e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddAnalysisUuidToWebhookDeliveriesTest { - - private static final String TABLE = "webhook_deliveries"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddAnalysisUuidToWebhookDeliveriesTest.class, "initial.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddAnalysisUuidToWebhookDeliveries underTest = new AddAnalysisUuidToWebhookDeliveries(db.database()); - - @Test - public void add_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsersTest.java deleted file mode 100644 index 67b31d2f00d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsersTest.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import com.google.common.collect.ImmutableList; -import java.sql.SQLException; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Random; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanupDisabledUsersTest { - - private final static long PAST = 100_000_000_000L; - private final static long NOW = 500_000_000_000L; - private final static Random RANDOM = new Random(); - private final static String SELECT_USERS = "select name, scm_accounts, user_local, login, crypted_password, salt, email, external_identity, external_identity_provider, active, is_root, onboarded, created_at, updated_at from users"; - - private System2 system2 = new TestSystem2().setNow(NOW); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanupDisabledUsersTest.class, "users.sql"); - - private CleanupDisabledUsers underTest = new CleanupDisabledUsers(db.database(), system2); - - @Test - public void do_nothing_when_no_data() throws SQLException { - assertThat(db.countRowsOfTable("USERS")).isEqualTo(0); - underTest.execute(); - assertThat(db.countRowsOfTable("USERS")).isEqualTo(0); - } - - @Test - public void execute_must_update_database() throws SQLException { - final List users = generateAndInsertUsers(); - - underTest.execute(); - - assertDatabaseContainsExactly(applyCleanupOnUsers(users)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - final List users = generateAndInsertUsers(); - - underTest.execute(); - underTest.execute(); - - assertDatabaseContainsExactly(applyCleanupOnUsers(users)); - } - - private List generateAndInsertUsers() { - List users = ImmutableList.of( - new User("user1", null, null, null, null, null, false), - new User("user2", randomAlphanumeric(10), null, null, null, null, false), - new User("user3", null, randomAlphanumeric(10), null, null, null, false), - new User("user4", null, null, randomAlphanumeric(10), null, null, false), - new User("user5", null, null, null, randomAlphanumeric(10), null, false), - new User("user6", null, null, null, null, randomAlphanumeric(10), false), - new User("user7", randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), false), - new User("user8", randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), true), - new User("user9", randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), true) - ); - - users.forEach(User::insert); - return users; - } - - private List applyCleanupOnUsers(List users) { - return users.stream().map( - u -> { - User cleanedupUser = u.clone(); - - // If a user is active => no change - if (cleanedupUser.active) { - return cleanedupUser; - } - - // updated_at field will only be updated if there is a real change so if at least one field is not null - if (cleanedupUser.cryptedPassword != null || cleanedupUser.salt != null || cleanedupUser.email != null || - cleanedupUser.externalIdentityProvider != null || cleanedupUser.externalIdentity != null) { - cleanedupUser.updatedAt = NOW; - } - - // Cleanup fields, all those fields must be null - cleanedupUser.cryptedPassword = null; - cleanedupUser.salt = null; - cleanedupUser.email = null; - cleanedupUser.externalIdentityProvider = null; - cleanedupUser.externalIdentity = null; - - return cleanedupUser; - }).collect(Collectors.toList()); - } - - private void assertDatabaseContainsExactly(List expectedUsers) { - assertThat(db.select(SELECT_USERS)).isEqualTo( - expectedUsers.stream().map(User::toMap).collect(Collectors.toList()) - ); - } - - private class User { - private String login; - private String cryptedPassword; - private String salt; - private String email; - private String externalIdentity; - private String externalIdentityProvider; - private String name; - private String scmAccounts; - private boolean userLocal; - private boolean active; - private boolean isRoot; - private boolean onBoarded; - private long updatedAt; - private long createdAt; - - private User(String login, @Nullable String cryptedPassword, @Nullable String salt, @Nullable String email, - @Nullable String externalIdentity, @Nullable String externalIdentityProvider, boolean active) { - this.login = login; - this.cryptedPassword = cryptedPassword; - this.salt = salt; - this.email = email; - this.externalIdentity = externalIdentity; - this.externalIdentityProvider = externalIdentityProvider; - this.active = active; - this.isRoot = RANDOM.nextBoolean(); - this.onBoarded = RANDOM.nextBoolean(); - this.userLocal = RANDOM.nextBoolean(); - this.scmAccounts = randomAlphanumeric(1500); - this.name = randomAlphanumeric(200); - this.updatedAt = PAST; - this.createdAt = PAST; - } - - private void insert() { - db.executeInsert("USERS", toMap()); - } - - private Map toMap() { - HashMap map = new HashMap<>(); - map.put("LOGIN", login); - map.put("IS_ROOT", isRoot); - map.put("ONBOARDED", onBoarded); - map.put("ACTIVE", active); - map.put("CREATED_AT", createdAt); - map.put("UPDATED_AT", updatedAt); - map.put("CRYPTED_PASSWORD", cryptedPassword); - map.put("SALT", salt); - map.put("EMAIL", email); - map.put("EXTERNAL_IDENTITY", externalIdentity); - map.put("EXTERNAL_IDENTITY_PROVIDER", externalIdentityProvider); - map.put("NAME", name); - map.put("SCM_ACCOUNTS", scmAccounts); - map.put("USER_LOCAL", userLocal); - - return Collections.unmodifiableMap(map); - } - - @Override - public User clone() { - User user = new User(this.login, this.cryptedPassword, this.salt, this.email, this.externalIdentity, this.externalIdentityProvider, this.active); - - user.name = this.name; - user.scmAccounts = this.scmAccounts; - user.userLocal = this.userLocal; - user.onBoarded = this.onBoarded; - user.isRoot = this.isRoot; - - return user; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof User)) { - return false; - } - User user = (User) o; - return active == user.active && - isRoot == user.isRoot && - onBoarded == user.onBoarded && - Objects.equals(login, user.login) && - Objects.equals(cryptedPassword, user.cryptedPassword) && - Objects.equals(salt, user.salt) && - Objects.equals(email, user.email) && - Objects.equals(externalIdentity, user.externalIdentity) && - Objects.equals(externalIdentityProvider, user.externalIdentityProvider); - } - - @Override - public int hashCode() { - return Objects.hash(login, cryptedPassword, salt, email, externalIdentity, externalIdentityProvider, active, isRoot, onBoarded); - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerIdTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerIdTest.java deleted file mode 100644 index e6b66c4739c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerIdTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CopyDeprecatedServerIdTest { - - private static final String DEPRECATED_KEY = "sonar.server_id"; - private static final String TARGET_KEY = "sonar.core.id"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CopyDeprecatedServerIdTest.class, "properties.sql"); - - private CopyDeprecatedServerId underTest = new CopyDeprecatedServerId(db.database()); - - @Test - public void override_server_id_with_deprecated_value_if_present() throws SQLException { - insertProperty(DEPRECATED_KEY, "foo"); - insertProperty(TARGET_KEY, "bar"); - - underTest.execute(); - - assertThatTargetKeyHasValue("foo"); - assertThatDeprecatedKeyDoesNotExist(); - } - - @Test - public void set_server_id_with_deprecated_value_if_present() throws SQLException { - // the target property does not exist - insertProperty(DEPRECATED_KEY, "foo"); - - underTest.execute(); - - assertThatTargetKeyHasValue("foo"); - assertThatDeprecatedKeyDoesNotExist(); - } - - @Test - public void keep_existing_server_id_if_deprecated_value_if_absent() throws SQLException { - insertProperty(TARGET_KEY, "foo"); - - underTest.execute(); - - assertThatTargetKeyHasValue("foo"); - assertThatDeprecatedKeyDoesNotExist(); - } - - private void assertThatTargetKeyHasValue(String expected) { - String value = (String) db.selectFirst("SELECT TEXT_VALUE FROM PROPERTIES WHERE PROP_KEY = '" + TARGET_KEY + "'") - .get("TEXT_VALUE"); - assertThat(value).isEqualTo(expected); - } - - private void assertThatDeprecatedKeyDoesNotExist() { - assertThat(db.select("SELECT * FROM PROPERTIES WHERE PROP_KEY = '" + DEPRECATED_KEY + "'")) - .isEmpty(); - } - - public void insertProperty(String key, String value) { - db.executeInsert( - "properties", - "prop_key", key, - "is_empty", "false", - "text_value", value); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisPropertiesTest.java deleted file mode 100644 index a686c3ecd9d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisPropertiesTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableAnalysisPropertiesTest { - private static final String TABLE = "analysis_properties"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableAnalysisPropertiesTest.class, "empty.sql"); - - private CreateTableAnalysisProperties underTest = new CreateTableAnalysisProperties(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "snapshot_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "kee", Types.VARCHAR, 512, false); - db.assertColumnDefinition(TABLE, "text_value", Types.VARCHAR, 4000, true); - db.assertColumnDefinition(TABLE, "clob_value", Types.CLOB, 2147483647, true); - db.assertColumnDefinition(TABLE, "is_empty", Types.BOOLEAN, null, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - - db.assertIndex(TABLE, "ix_snapshot_uuid", "snapshot_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67Test.java deleted file mode 100644 index fbce21e96e7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion67Test { - - private DbVersion67 underTest = new DbVersion67(); - - @Test - public void migrationNumber_starts_at_1830() { - verifyMinimumMigrationNumber(underTest, 1830); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 8); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DropOldLicensesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DropOldLicensesTest.java deleted file mode 100644 index 0e3552bba08..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DropOldLicensesTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -public class DropOldLicensesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOldLicensesTest.class, "properties.sql"); - - private DropOldLicenses underTest = new DropOldLicenses(db.database()); - - @Test - public void remove_old_licenses() throws SQLException { - insertProperty("sonar.cpp.license.secured"); - insertProperty("sonar.cpp.licenseHash.secured"); - insertProperty("sonar.objc.license.secured"); - insertProperty("sonar.objc.licenseHash.secured"); - - underTest.execute(); - - assertPropertiesIsEmpty(); - } - - @Test - public void ignore_existing_none_related_licenses_settings() throws SQLException { - insertProperty("my.property"); - insertProperty("custom.license"); - - underTest.execute(); - - assertProperties("my.property", "custom.license"); - } - - private void assertPropertiesIsEmpty() { - assertProperties(); - } - - private void assertProperties(String... expectedSettingKeys) { - assertThat(db.select("SELECT PROP_KEY FROM PROPERTIES") - .stream() - .map(map -> (String)map.get("PROP_KEY")) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedSettingKeys); - } - - public void insertProperty(String propertyKey) { - db.executeInsert( - "properties", - "prop_key", propertyKey, - "is_empty", "false", - "text_value", randomAlphabetic(2)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersionTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersionTest.java deleted file mode 100644 index 336bee65762..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersionTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class MigratePreviousAnalysisToPreviousVersionTest { - - private final static String SELECT_PROPERTIES = "SELECT prop_key, is_empty, text_value, clob_value FROM properties"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigratePreviousAnalysisToPreviousVersionTest.class, "properties.sql"); - - private MigratePreviousAnalysisToPreviousVersion underTest = new MigratePreviousAnalysisToPreviousVersion(db.database()); - - @Test - public void migration_must_update_the_database() throws SQLException { - insertProperty("sonar.leak.period", "any.value_here", null, false); - insertProperty("sonar.leak.period", "previous_version", null, false); - insertProperty("sonar.leak.period", "previous_analysis", null, false); - insertProperty("whatever.property", "nothingspecial", null, false); - insertProperty("whatever.property", null, "nothing.special", false); - - underTest.execute(); - - assertPropertyContainsInAnyOrder( - tuple("sonar.leak.period", "any.value_here", null, false), - tuple("sonar.leak.period", "previous_version", null, false), - tuple("sonar.leak.period", "previous_version", null, false), // Single change - tuple("whatever.property", "nothingspecial", null, false), - tuple("whatever.property", null, "nothing.special", false) - ); - } - - @Test - public void migration_must_be_reentrant() throws SQLException { - insertProperty("sonar.leak.period", "any.value_here", null, false); - insertProperty("sonar.leak.period", "previous_version", null, false); - insertProperty("sonar.leak.period", "previous_analysis", null, false); - insertProperty("whatever.property", "nothingspecial", null, false); - insertProperty("whatever.property", null, "nothing.special", false); - - underTest.execute(); - underTest.execute(); - - assertPropertyContainsInAnyOrder( - tuple("sonar.leak.period", "any.value_here", null, false), - tuple("sonar.leak.period", "previous_version", null, false), - tuple("sonar.leak.period", "previous_version", null, false), // Single change - tuple("whatever.property", "nothingspecial", null, false), - tuple("whatever.property", null, "nothing.special", false) - ); - } - - @Test - public void migration_is_doing_nothing_when_no_data() throws SQLException { - assertThat(db.countRowsOfTable("properties")).isEqualTo(0); - underTest.execute(); - assertThat(db.countRowsOfTable("properties")).isEqualTo(0); - } - - private void insertProperty(String propKey, @Nullable String textValue, @Nullable String clobValue, boolean isEmpty) { - HashMap map = new HashMap<>(); - map.put("PROP_KEY", propKey); - map.put("TEXT_VALUE", textValue); - map.put("CLOB_VALUE", clobValue); - map.put("IS_EMPTY", isEmpty); - db.executeInsert("PROPERTIES", map); - } - - private void assertPropertyContainsInAnyOrder(Tuple... tuples) { - assertThat(db.select(SELECT_PROPERTIES) - .stream() - .map(p -> new Tuple(p.get("PROP_KEY"), p.get("TEXT_VALUE"), p.get("CLOB_VALUE"), p.get("IS_EMPTY"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(tuples); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.java deleted file mode 100644 index 15a64157604..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; -import org.apache.commons.lang.math.RandomUtils; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - -public class PopulateAnalysisUuidColumnOnWebhookDeliveriesTest { - private static final String TABLE_WEBHOOK_DELIVERY = "webhook_deliveries"; - private static final String TABLE_CE_ACTIVITIY = "ce_activity"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.class, "initial.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateAnalysisUuidColumnOnWebhookDeliveries underTest = new PopulateAnalysisUuidColumnOnWebhookDeliveries(db.database()); - - @Test - public void migration_must_set_analysis_uuid() throws SQLException { - String ceTaskUuid = randomAlphanumeric(40); - String analysisUuid = randomAlphanumeric(40); - String webhookDeliveryUuid = randomAlphanumeric(40); - insertWebhookDelivery(webhookDeliveryUuid,null, ceTaskUuid); - insertCeActivity(ceTaskUuid, analysisUuid); - - assertThat(db.countRowsOfTable(TABLE_WEBHOOK_DELIVERY)).isEqualTo(1); - assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITIY)).isEqualTo(1); - underTest.execute(); - - List> maps = selectAllWebhookDeliveries(); - assertThat(maps).hasSize(1); - assertThat(maps.get(0)).containsExactly( - entry("ANALYSIS_UUID", analysisUuid), entry("UUID", webhookDeliveryUuid), entry("CE_TASK_UUID", ceTaskUuid)); - } - - @Test - public void migration_should_be_reentrant() throws SQLException { - for (int i = 0; i < 10; i++) { - insertWebhookDelivery(randomAlphanumeric(40),null, randomAlphanumeric(40)); - insertCeActivity(randomAlphanumeric(40), randomAlphanumeric(40)); - } - - underTest.execute(); - List> firstExecutionResult = selectAllWebhookDeliveries(); - underTest.execute(); - assertThat(selectAllWebhookDeliveries()).isEqualTo(firstExecutionResult); - } - - private List> selectAllWebhookDeliveries() { - return db.select("select uuid, ce_task_uuid, analysis_uuid from webhook_deliveries"); - } - - private void insertCeActivity(String uuid, String analysisUuid) { - db.executeInsert(TABLE_CE_ACTIVITIY, - "UUID", uuid, - "TASK_TYPE", randomAlphanumeric(5), - "ANALYSIS_UUID", analysisUuid, - "STATUS", randomAlphanumeric(5), - "IS_LAST", RandomUtils.nextBoolean(), - "IS_LAST_KEY", randomAlphanumeric(50), - "EXECUTION_COUNT", RandomUtils.nextInt(10), - "SUBMITTED_AT", RandomUtils.nextInt(), - "CREATED_AT", RandomUtils.nextInt(), - "UPDATED_AT", RandomUtils.nextInt() - ); - } - - private void insertWebhookDelivery(String uuid, @Nullable String analysisUuid, String ceTaskUuid) { - db.executeInsert(TABLE_WEBHOOK_DELIVERY, - "UUID", uuid, - "COMPONENT_UUID", randomAlphanumeric(30), - "ANALYSIS_UUID", analysisUuid, - "CE_TASK_UUID", ceTaskUuid, - "NAME", randomAlphanumeric(15), - "URL", randomAlphanumeric(15), - "SUCCESS", RandomUtils.nextBoolean(), - "PAYLOAD", randomAlphanumeric(200), - "CREATED_AT", RandomUtils.nextInt() - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.java deleted file mode 100644 index 065551fcc0a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v67; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest { - private static final String TABLE = "webhook_deliveries"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.class, "initial.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries underTest = new UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries(db.database()); - - @Test - public void update_column() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - db.assertColumnDefinition(TABLE, "ce_task_uuid", Types.VARCHAR, 40, true); - db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizationsTest.java deleted file mode 100644 index d97367108c0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizationsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddDefaultQualityGateUuidToOrganizationsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddDefaultQualityGateUuidToOrganizationsTest.class, "organizations.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddDefaultQualityGateUuidToOrganizations underTest = new AddDefaultQualityGateUuidToOrganizations(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("organizations", "default_quality_gate_uuid", VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsersTest.java deleted file mode 100644 index 24c6ee8ce02..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsersTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; -import static java.sql.Types.VARCHAR; -import static org.junit.rules.ExpectedException.none; -import static org.sonar.db.CoreDbTester.createForSchema; - -public class AddHomepageToUsersTest { - - @Rule - public final CoreDbTester dbTester = createForSchema(AddHomepageToUsersTest.class, "initial.sql"); - - @Rule - public ExpectedException expectedException = none(); - - private AddHomepageToUsers underTest = new AddHomepageToUsers(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("users", "homepage_type", VARCHAR, 40, true); - dbTester.assertColumnDefinition("users", "homepage_parameter", VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest.java deleted file mode 100644 index 9d8cdead8ef..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; - -public class AddIsBuiltInToQualityGatesTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddIsBuiltInToQualityGatesTest.class, "quality_gates.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIsBuiltInToQualityGates underTest = new AddIsBuiltInToQualityGates(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("quality_gates", "is_built_in", BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndexTest.java deleted file mode 100644 index e4f697addad..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndexTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddLiveMeasuresMetricIndexTest { - private static final String TABLE = "live_measures"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddLiveMeasuresMetricIndexTest.class, "live_measures.sql"); - - private AddLiveMeasuresMetricIndex underTest = new AddLiveMeasuresMetricIndex(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertUniqueIndex(TABLE, "live_measures_component", "component_uuid", "metric_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndexTest.java deleted file mode 100644 index 719ee1dee10..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndexTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddSnapshotIsLastIndexTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddSnapshotIsLastIndexTest.class, "snapshots.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddSnapshotIsLastIndex underTest = new AddSnapshotIsLastIndex(dbTester.database()); - - @Test - public void add_index_on_snapshots_islast_column() throws SQLException { - underTest.execute(); - - dbTester.assertIndex("snapshots", "ix_snapshot_is_last", "islast"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGatesTest.java deleted file mode 100644 index 2c1e049dd65..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGatesTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddUuidToQualityGatesTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddUuidToQualityGatesTest.class, "quality_gates.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUuidToQualityGates underTest = new AddUuidToQualityGates(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("quality_gates", "uuid", VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganizationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganizationTest.java deleted file mode 100644 index 34cb2d1c182..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganizationTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class AssociateQualityGatesToDefaultOrganizationTest { - private static final long PAST = 10_000_000_000L; - private static final String TABLE_ORGANIZATIONS = "organizations"; - private static final String TABLE_QUALITY_GATES = "quality_gates"; - private static final String TABLE_INTERNAL_PROPERTIES = "internal_properties"; - private static final String DEFAULT_ORGANIZATION_KEE = "organization.default"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AssociateQualityGatesToDefaultOrganizationTest.class, "org_quality_gates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private AssociateQualityGatesToDefaultOrganization underTest = new AssociateQualityGatesToDefaultOrganization(db.database(), uuidFactory); - - @Test - public void should_throw_ISE_if_no_default_organization() throws SQLException { - insertOrganization(uuidFactory.create()); - insertOrganization(uuidFactory.create()); - insertQualityGate(uuidFactory.create(), "QualityGate1", false); - insertQualityGate(uuidFactory.create(), "QualityGate2", true); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void should_associate_all_quality_gates_to_default_organization() throws SQLException { - String defaultOrgUuid = uuidFactory.create(); - String anotherOrgUuid = uuidFactory.create(); - insertOrganization(defaultOrgUuid); - insertOrganization(anotherOrgUuid); - - String qgUuid1 = uuidFactory.create(); - String qgUuid2 = uuidFactory.create(); - String qgUuid3 = uuidFactory.create(); - insertQualityGate(qgUuid1, "QualityGate1", false); - insertQualityGate(qgUuid2, "QualityGate2", false); - insertQualityGate(qgUuid3, "QualityGate3", true); - - insertDefaultOrgProperty(defaultOrgUuid); - - underTest.execute(); - - assertThat(selectAllOrgQualityGates()) - .extracting(map -> map.get("ORGANIZATION_UUID"), map -> map.get("QUALITY_GATE_UUID")) - .containsExactlyInAnyOrder( - tuple(defaultOrgUuid, qgUuid1), - tuple(defaultOrgUuid, qgUuid2) - ); - } - - @Test - public void is_reentrant() throws SQLException { - String orgUuid1 = uuidFactory.create(); - String orgUuid2 = uuidFactory.create(); - insertOrganization(orgUuid1); - insertOrganization(orgUuid2); - - String qgUuid1 = uuidFactory.create(); - String qgUuid2 = uuidFactory.create(); - String qgUuid3 = uuidFactory.create(); - insertQualityGate(qgUuid1, "QualityGate1", false); - insertQualityGate(qgUuid2, "QualityGate2", false); - insertQualityGate(qgUuid3, "QualityGate3", true); - - insertDefaultOrgProperty(orgUuid1); - - underTest.execute(); - underTest.execute(); - - assertThat(selectAllOrgQualityGates()) - .extracting(map -> map.get("ORGANIZATION_UUID"), map -> map.get("QUALITY_GATE_UUID")) - .containsExactlyInAnyOrder( - tuple(orgUuid1, qgUuid1), - tuple(orgUuid1, qgUuid2) - ); - } - - private List> selectAllOrgQualityGates() { - return db.select("select organization_uuid, quality_gate_uuid from org_quality_gates"); - } - - private void insertDefaultOrgProperty(String uuid) { - db.executeInsert( - TABLE_INTERNAL_PROPERTIES, - "KEE", DEFAULT_ORGANIZATION_KEE, - "IS_EMPTY", String.valueOf(false), - "TEXT_VALUE", uuid, - "CREATED_AT", PAST); - } - - private void insertOrganization(String uuid) { - db.executeInsert( - TABLE_ORGANIZATIONS, - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", String.valueOf(false), - "NEW_PROJECT_PRIVATE", String.valueOf(true), - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private void insertQualityGate(String uuid, String name, Boolean builtIn) { - db.executeInsert( - TABLE_QUALITY_GATES, - "UUID", uuid, - "NAME", name, - "IS_BUILT_IN", builtIn.toString(), - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGateTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGateTest.java deleted file mode 100644 index 0cf21171490..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGateTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; - -public class CreateBuiltInQualityGateTest { - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - private System2 system2 = new TestSystem2().setNow(NOW); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CreateBuiltInQualityGateTest.class, "quality_gates.sql"); - - private CreateBuiltInQualityGate underTest = new CreateBuiltInQualityGate(db.database(), system2, UuidFactoryFast.getInstance()); - - @Test - public void should_create_builtin_quality_gate() throws SQLException { - underTest.execute(); - - assertThat(selectAllQualityGates()) - .extracting(map -> map.get("NAME"), map -> map.get("IS_BUILT_IN"), map -> map.get("CREATED_AT")) - .containsExactlyInAnyOrder( - tuple("Sonar way", true, new Date(NOW)) - ); - } - - @Test - public void should_not_create_builtin_quality_gate_if_existing() throws SQLException { - insertQualityGate("Whatever", true); - - underTest.execute(); - - assertThat(selectAllQualityGates()) - .extracting(map -> map.get("NAME"), map -> map.get("IS_BUILT_IN"), map -> map.get("CREATED_AT")) - .containsExactlyInAnyOrder( - tuple("Whatever", true, new Date(PAST)) - ); - } - - - private List> selectAllQualityGates() { - return db.select("select id, uuid, name, is_built_in, created_at, updated_at from quality_gates"); - } - - private void insertQualityGate(String name, boolean builtIn) { - db.executeInsert( - "QUALITY_GATES", - "UUID", Uuids.createFast(), - "NAME", name, - "IS_BUILT_IN", String.valueOf(builtIn), - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTableTest.java deleted file mode 100644 index a0a6a3807dd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTableTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -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.version.v67.CreateTableAnalysisPropertiesTest; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateOrgQualityGatesTableTest { - - private static final String TABLE = "org_quality_gates"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableAnalysisPropertiesTest.class, "empty.sql"); - - private CreateOrgQualityGatesTable underTest = new CreateOrgQualityGatesTable(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "organization_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "quality_gate_uuid", Types.VARCHAR, 40, false); - - db.assertUniqueIndex(TABLE, "uniq_org_quality_gates", "organization_uuid", "quality_gate_uuid"); - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "organization_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "quality_gate_uuid", Types.VARCHAR, 40, false); - - db.assertUniqueIndex(TABLE, "uniq_org_quality_gates", "organization_uuid", "quality_gate_uuid"); - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasuresTest.java deleted file mode 100644 index 17865dfdd11..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasuresTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableLiveMeasuresTest { - private static final String TABLE = "live_measures"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateTableLiveMeasuresTest.class, "empty.sql"); - - private CreateTableLiveMeasures underTest = new CreateTableLiveMeasures(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "project_uuid", Types.VARCHAR, 50, false); - db.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 50, false); - db.assertColumnDefinition(TABLE, "metric_id", Types.INTEGER, null, false); - db.assertColumnDefinition(TABLE, "value", Types.DOUBLE, null, true); - db.assertColumnDefinition(TABLE, "text_value", Types.VARCHAR, 4_000, true); - db.assertColumnDefinition(TABLE, "variation", Types.DOUBLE, null, true); - db.assertColumnDefinition(TABLE, "measure_data", Types.BLOB, null, true); - db.assertColumnDefinition(TABLE, "update_marker", Types.VARCHAR, 40, true); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", Types.BIGINT, null, false); - - db.assertIndex(TABLE, "live_measures_project", "project_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresPTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresPTest.java deleted file mode 100644 index 631888ee0a7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresPTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class CreateTempTableLiveMeasuresPTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTempTableLiveMeasuresPTest.class, "empty.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTempTableLiveMeasuresP underTest = new CreateTempTableLiveMeasuresP(dbTester.database()); - - @Test - public void create_table_live_measures_p() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("live_measures_p", "project_uuid", Types.VARCHAR, 50, false); - dbTester.assertPrimaryKey("live_measures_p", "pk_live_measures_p", "project_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70Test.java deleted file mode 100644 index c237a6c0b16..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DbVersion70Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion70Test { - - private DbVersion70 underTest = new DbVersion70(); - - @Test - public void migrationNumber_starts_at_1900() { - verifyMinimumMigrationNumber(underTest, 1930); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 30); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasuresTest.java deleted file mode 100644 index 8befae37dc5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasuresTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.commons.lang.math.RandomUtils; -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 DeleteFileMeasuresTest { - private static final AtomicInteger GENERATOR = new AtomicInteger(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteFileMeasuresTest.class, "initial.sql"); - - private DataChange underTest = new DeleteFileMeasures(db.database()); - - @Test - public void delete_file_and_person_measures() throws SQLException { - String projectUuid = "P1"; - insertComponent(projectUuid, projectUuid, "PRJ", "TRK"); - insertComponent("D1", projectUuid, "DIR", "DIR"); - insertComponent("F1", projectUuid, "FIL", "FIL"); - insertComponent("F2", projectUuid, "FIL", "UTS"); - insertSnapshot("S1", projectUuid, false); - insertSnapshot("S2", projectUuid, true); - // past measures - long m1 = insertMeasure(projectUuid, "S1"); - long m2 = insertMeasure("D1", "S1"); - long m3 = insertMeasure("F1", "S1"); - long m4 = insertMeasure("F2", "S1"); - long m5 = insertPersonMeasure(projectUuid, "S1"); - long m6 = insertPersonMeasure("F1", "S1"); - // last measures - long m7 = insertMeasure(projectUuid, "S2"); - long m8 = insertMeasure("D1", "S2"); - long m9 = insertMeasure("F1", "S2"); - long m10 = insertMeasure("F2", "S2"); - long m11 = insertPersonMeasure(projectUuid, "S2"); - long m12 = insertPersonMeasure("F1", "S2"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("PROJECTS")).isEqualTo(4); - assertThat(db.countRowsOfTable("SNAPSHOTS")).isEqualTo(2); - assertThatMeasuresAreExactly(m1, m2, m5, m7, m8, m11); - - // migration is re-entrant - underTest.execute(); - assertThat(db.countRowsOfTable("PROJECTS")).isEqualTo(4); - assertThat(db.countRowsOfTable("SNAPSHOTS")).isEqualTo(2); - assertThatMeasuresAreExactly(m1, m2, m7, m5, m8, m11); - } - - private void assertThatMeasuresAreExactly(long... expectedMeasureIds) { - long[] ids = db.select("select id as \"id\" from project_measures") - .stream() - .mapToLong(m -> (Long) m.get("id")) - .toArray(); - assertThat(ids).containsOnly(expectedMeasureIds); - } - - private void insertComponent(String uuid, String projectUuid, String scope, String qualifier) { - db.executeInsert("PROJECTS", - "ORGANIZATION_UUID", "O1", - "KEE", "" + GENERATOR.incrementAndGet(), - "UUID", uuid, - "PROJECT_UUID", projectUuid, - "MAIN_BRANCH_PROJECT_UUID", "" + GENERATOR.incrementAndGet(), - "UUID_PATH", ".", - "ROOT_UUID", "" + GENERATOR.incrementAndGet(), - "PRIVATE", "true", - "QUALIFIER", qualifier, - "SCOPE", scope); - } - - private void insertSnapshot(String uuid, String projectUuid, boolean last) { - db.executeInsert("SNAPSHOTS", - "UUID", uuid, - "COMPONENT_UUID", projectUuid, - "STATUS", "P", - "ISLAST", last); - } - - private long insertMeasure(String componentUuid, String analysisUuid) { - long id = GENERATOR.incrementAndGet(); - db.executeInsert("PROJECT_MEASURES", - "ID", id, - "METRIC_ID", "42", - "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", analysisUuid); - return id; - } - - private long insertPersonMeasure(String componentUuid, String analysisUuid) { - long id = GENERATOR.incrementAndGet(); - db.executeInsert("PROJECT_MEASURES", - "ID", id, - "METRIC_ID", "42", - "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", analysisUuid, - "PERSON_ID", RandomUtils.nextInt(100)); - return id; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSettingTest.java deleted file mode 100644 index 667c0f058e6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSettingTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -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 DeleteGlobalSonarQualityGateSettingTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteGlobalSonarQualityGateSettingTest.class, "properties.sql"); - - private DataChange underTest = new DeleteGlobalSonarQualityGateSetting(db.database()); - - @Test - public void delete_sonar_quality_gate_setting() throws SQLException { - insertSetting("sonar.qualitygate", null); - insertSetting("sonar.qualitygate", 1L); - insertSetting("other", null); - insertSetting("other", 2L); - - underTest.execute(); - - assertSettings( - tuple("sonar.qualitygate", 1L), - tuple("other", null), - tuple("other", 2L)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSetting("sonar.qualitygate", null); - insertSetting("sonar.qualitygate", 1L); - - underTest.execute(); - assertSettings(tuple("sonar.qualitygate", 1L)); - - underTest.execute(); - assertSettings(tuple("sonar.qualitygate", 1L)); - } - - @Test - public void does_nothing_when_no_sonar_quality_gate_setting() throws SQLException { - insertSetting("other", null); - - underTest.execute(); - - assertSettings(tuple("other", null)); - } - - @Test - public void does_nothing_on_empty_table() throws SQLException { - underTest.execute(); - - assertSettings(); - } - - private void assertSettings(Tuple... expectedTuples) { - assertThat(db.select("SELECT PROP_KEY, RESOURCE_ID FROM PROPERTIES") - .stream() - .map(map -> new Tuple(map.get("PROP_KEY"), map.get("RESOURCE_ID"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void insertSetting(String key, @Nullable Long componentId) { - db.executeInsert( - "properties", - "PROP_KEY", key, - "RESOURCE_ID", componentId, - "IS_EMPTY", false, - "CREATED_AT", 1000); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasuresTest.java deleted file mode 100644 index e0d21418e16..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasuresTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.commons.lang.math.RandomUtils; -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 DeletePersonMeasuresTest { - private static final AtomicInteger GENERATOR = new AtomicInteger(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeletePersonMeasuresTest.class, "initial.sql"); - - private DataChange underTest = new DeletePersonMeasures(db.database()); - - @Test - public void delete_person_measures() throws SQLException { - insertComponent("P1", "PRJ", "TRK"); - insertComponent("D1", "DIR", "DIR"); - insertComponent("F1", "FIL", "FIL"); - insertComponent("F2", "FIL", "UTS"); - insertSnapshot("S1", "P1", false); - insertSnapshot("S2", "P1", true); - // past measures - long m1 = insertMeasure("P1", "S1"); - long m2 = insertMeasure("D1", "S1"); - long m3 = insertMeasure("F1", "S1"); - long m4 = insertMeasure("F2", "S1"); - long m5 = insertPersonMeasure("P1", "S1"); - long m6 = insertPersonMeasure("F1", "S1"); - // last measures - long m7 = insertMeasure("P1", "S2"); - long m8 = insertMeasure("D1", "S2"); - long m9 = insertMeasure("F1", "S2"); - long m10 = insertMeasure("F2", "S2"); - long m11 = insertPersonMeasure("P1", "S2"); - long m12 = insertPersonMeasure("F1", "S2"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("PROJECTS")).isEqualTo(4); - assertThat(db.countRowsOfTable("SNAPSHOTS")).isEqualTo(2); - assertThatMeasuresAreExactly(m1, m2, m3, m4, m7, m8, m9, m10); - - // migration is re-entrant - underTest.execute(); - assertThat(db.countRowsOfTable("PROJECTS")).isEqualTo(4); - assertThat(db.countRowsOfTable("SNAPSHOTS")).isEqualTo(2); - assertThatMeasuresAreExactly(m1, m2, m3, m4, m7, m8, m9, m10); - } - - private void assertThatMeasuresAreExactly(long... expectedMeasureIds) { - long[] ids = db.select("select id as \"id\" from project_measures") - .stream() - .mapToLong(m -> (Long) m.get("id")) - .toArray(); - assertThat(ids).containsOnly(expectedMeasureIds); - } - - private void insertComponent(String uuid, String scope, String qualifier) { - db.executeInsert("PROJECTS", - "ORGANIZATION_UUID", "O1", - "KEE", "" + GENERATOR.incrementAndGet(), - "UUID", uuid, - "PROJECT_UUID", "" + GENERATOR.incrementAndGet(), - "MAIN_BRANCH_PROJECT_UUID", "" + GENERATOR.incrementAndGet(), - "UUID_PATH", ".", - "ROOT_UUID", "" + GENERATOR.incrementAndGet(), - "PRIVATE", "true", - "QUALIFIER", qualifier, - "SCOPE", scope); - } - - private void insertSnapshot(String uuid, String projectUuid, boolean last) { - db.executeInsert("SNAPSHOTS", - "UUID", uuid, - "COMPONENT_UUID", projectUuid, - "STATUS", "P", - "ISLAST", last); - } - - private long insertMeasure(String componentUuid, String analysisUuid) { - long id = GENERATOR.incrementAndGet(); - db.executeInsert("PROJECT_MEASURES", - "ID", id, - "METRIC_ID", "42", - "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", analysisUuid); - return id; - } - - private long insertPersonMeasure(String componentUuid, String analysisUuid) { - long id = GENERATOR.incrementAndGet(); - db.executeInsert("PROJECT_MEASURES", - "ID", id, - "METRIC_ID", "42", - "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", analysisUuid, - "PERSON_ID", RandomUtils.nextInt(100)); - return id; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasuresTest.java deleted file mode 100644 index b85c1ec7647..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasuresTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import 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 DropIndexOnPersonMeasuresTest { - - private static final String TABLE = "project_measures"; - private static final String INDEX = "measures_person"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnPersonMeasuresTest.class, "initial.sql"); - - private DdlChange underTest = new DropIndexOnPersonMeasures(db.database()); - - @Test - public void drop_index() throws SQLException { - db.assertIndex(TABLE, INDEX, "person_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE, INDEX); - } -} - - diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTableTest.java deleted file mode 100644 index 18fbf03a629..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTableTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropLoadedTemplatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropLoadedTemplatesTableTest.class, "loaded_templates.sql"); - - private DropLoadedTemplatesTable underTest = new DropLoadedTemplatesTable(db.database()); - - @Test - public void delete_tables() throws SQLException { - underTest.execute(); - - db.assertTableDoesNotExist("loaded_templates"); - } - - @Test - public void migration_is_re_entrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("loaded_templates"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndexTest.java deleted file mode 100644 index 536f34872ef..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndexTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropSnapshotIsLastIndexTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropSnapshotIsLastIndexTest.class, "snapshots.sql"); - - private DropSnapshotIsLastIndex underTest = new DropSnapshotIsLastIndex(db.database()); - - @Test - public void drop_index_on_snapshots_islast() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist("snapshots", "ix_snapshot_is_last"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresPTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresPTest.java deleted file mode 100644 index 5a160e591bd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresPTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropTempTableLiveMeasuresPTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTempTableLiveMeasuresPTest.class, "live_measures_p.sql"); - - private DropTempTableLiveMeasuresP underTest = new DropTempTableLiveMeasuresP(db.database()); - - @Test - public void drop_table_live_measures_p() throws SQLException { - String tableName = "live_measures_p"; - - db.assertTableExists(tableName); - - underTest.execute(); - - db.assertTableDoesNotExist(tableName); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesNameTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesNameTest.java deleted file mode 100644 index 5ad60669324..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesNameTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class DropUniqueIndexOnQualityGatesNameTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(DropUniqueIndexOnQualityGatesNameTest.class, "quality_gates.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DropUniqueIndexOnQualityGatesName underTest = new DropUniqueIndexOnQualityGatesName(dbTester.database()); - - @Test - public void unique_index_on_name_is_removed() throws SQLException { - underTest.execute(); - - dbTester.assertIndexDoesNotExist("quality_gates", "uniq_quality_gates"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullableTest.java deleted file mode 100644 index 126fcfd1319..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class MakeQualityGatesIsBuiltInNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityGatesIsBuiltInNotNullableTest.class, "quality_gates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeQualityGatesIsBuiltInNotNullable underTest = new MakeQualityGatesIsBuiltInNotNullable(db.database()); - - @Test - public void execute_makes_column_not_null() throws SQLException { - db.assertColumnDefinition("quality_gates", "is_built_in", Types.BOOLEAN, null, true); - insertRow(1); - insertRow(2); - - underTest.execute(); - - db.assertColumnDefinition("quality_gates", "is_built_in", Types.BOOLEAN, null, false); - } - - private void insertRow(int id) { - db.executeInsert( - "QUALITY_GATES", - "NAME", "name_" + id, - "IS_BUILT_IN", false - ); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGatesTest.java deleted file mode 100644 index 5fd595d7c89..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGatesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class MakeUuidNotNullableOnQualityGatesTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(MakeUuidNotNullableOnQualityGatesTest.class, "quality_gates.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeUuidNotNullableOnQualityGates underTest = new MakeUuidNotNullableOnQualityGates(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("quality_gates", "uuid", VARCHAR, 40, false); - dbTester.assertUniqueIndex("quality_gates", "uniq_quality_gates_uuid", "uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGateTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGateTest.java deleted file mode 100644 index 878af9a627f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGateTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateDefaultQualityGateTest { - private final static long PAST = 10_000_000_000L; - private static final long NOW = 50_000_000_000L; - private static final String TABLE_ORGANIZATIONS = "organizations"; - private static final String TABLE_QUALITY_GATES = "quality_gates"; - - private System2 system2 = new TestSystem2().setNow(NOW); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateDefaultQualityGateTest.class, "organizations.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateDefaultQualityGate underTest = new PopulateDefaultQualityGate(db.database(), system2); - - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - insertQualityGate(Uuids.createFast(), "Sonar way", true); - - underTest.execute(); - - assertThat(db.countRowsOfTable("organizations")).isEqualTo(0); - } - - @Test - public void should_populate_defaultQualityGate_column() throws SQLException { - String builtInQGUuid = Uuids.createFast(); - insertQualityGate(builtInQGUuid, "Sonar way", true); - String orgUuid1 = Uuids.createFast(); - String orgUuid2 = Uuids.createFast(); - insertOrganization(orgUuid1); - insertOrganization(orgUuid2); - - underTest.execute(); - - // all organizations have the builtIn quality gate - assertThat( - db.countSql("select count(uuid) from organizations where default_quality_gate_uuid != '" + builtInQGUuid + "'") - ).isEqualTo(0); - assertThat( - db.countSql("select count(uuid) from organizations where default_quality_gate_uuid = '" + builtInQGUuid + "'") - ).isEqualTo(2); - - // updated_at must have been updated - assertThat( - db.countSql("select count(uuid) from organizations where updated_at = " + NOW ) - ).isEqualTo(2); - } - - @Test - public void is_reentrant() throws SQLException { - String builtInQGUuid = Uuids.createFast(); - insertQualityGate(builtInQGUuid, "Sonar way", true); - insertOrganization(Uuids.createFast()); - insertOrganization(Uuids.createFast()); - - underTest.execute(); - underTest.execute(); - - assertThat( - db.countSql("select count(uuid) from organizations where default_quality_gate_uuid != '" + builtInQGUuid + "'") - ).isEqualTo(0); - - assertThat( - db.countSql("select count(uuid) from organizations where default_quality_gate_uuid = '" + builtInQGUuid + "'") - ).isEqualTo(2); - } - - @Test - public void should_fail_with_ISE_when_no_builtIn() throws SQLException { - insertOrganization(Uuids.createFast()); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Unable to find the builtin quality gate"); - - underTest.execute(); - } - - @Test - public void should_fail_if_there_is_multiple_builtin_qualitygates() throws SQLException { - insertQualityGate(Uuids.createFast(), "Sonar way", true); - insertQualityGate(Uuids.createFast(), "Sonar way2", true); - insertOrganization(Uuids.createFast()); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("There are too many built in quality gates, one and only one is expected"); - - underTest.execute(); - } - - private void insertOrganization(String uuid) { - db.executeInsert( - TABLE_ORGANIZATIONS, - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", String.valueOf(false), - "NEW_PROJECT_PRIVATE", String.valueOf(true), - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - } - - private void insertQualityGate(String uuid, String name, Boolean builtIn) { - db.executeInsert( - TABLE_QUALITY_GATES, - "UUID", uuid, - "NAME", name, - "IS_BUILT_IN", builtIn.toString(), - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java deleted file mode 100644 index e25e9e8410c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateLiveMeasuresTest { - - private System2 system2 = new TestSystem2().setNow(1_500_000_000_000L); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateLiveMeasuresTest.class, "initial.sql"); - - private PopulateLiveMeasures underTest = new PopulateLiveMeasures(db.database(), system2); - - @Test - public void do_nothing_when_no_data() throws SQLException { - assertThat(db.countRowsOfTable("PROJECT_MEASURES")).isEqualTo(0); - underTest.execute(); - assertThat(db.countRowsOfTable("LIVE_MEASURES")).isEqualTo(0); - } - - @Test - public void execute_must_update_database() throws SQLException { - generateProjectMeasures(); - - underTest.execute(); - - assertThat(getLiveMeasures()).extracting( - field("COMPONENT_UUID"), - field("PROJECT_UUID"), - field("METRIC_ID"), - field("VALUE"), - field("TEXT_VALUE"), - field("VARIATION"), - field("MEASURE_DATA")).containsExactlyInAnyOrder(generateLiveMeasures()); - - assertThat(db.select("select project_uuid as \"PROJECT_UUID\" from live_measures_p")) - .extracting(t -> t.get("PROJECT_UUID")) - .containsOnly("PRJ1", "PRJ2"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - generateProjectMeasures(); - - underTest.execute(); - underTest.execute(); - - assertThat(getLiveMeasures()).extracting( - field("COMPONENT_UUID"), - field("PROJECT_UUID"), - field("METRIC_ID"), - field("VALUE"), - field("TEXT_VALUE"), - field("VARIATION"), - field("MEASURE_DATA")).containsExactlyInAnyOrder(generateLiveMeasures()); - } - - @Test - public void migration_is_reentrant_on_partially_processed_1st_project() throws SQLException { - generateProjectMeasures(); - - db.executeInsert( - "LIVE_MEASURES", - "UUID", "foo", - "COMPONENT_UUID", "PRJ1", - "PROJECT_UUID", "PRJ1", - "METRIC_ID", 1010, - "CREATED_AT", 1L, - "UPDATED_AT", 1L - ); - - underTest.execute(); - - assertThat(getLiveMeasures()).extracting( - field("COMPONENT_UUID"), - field("PROJECT_UUID"), - field("METRIC_ID"), - field("VALUE"), - field("TEXT_VALUE"), - field("VARIATION"), - field("MEASURE_DATA")).containsExactlyInAnyOrder(generateLiveMeasures()); - } - - private Function, Object> field(String name) { - return m -> m.get(name); - } - - private void generateProjectMeasures() { - db.executeInsert("PROJECTS", - "UUID", "PRJ1", - "PROJECT_UUID", "PRJ1", - "ORGANIZATION_UUID", "ORG1", - "UUID_PATH", "X", - "ROOT_UUID", "X", - "PRIVATE", "FALSE"); - db.executeInsert("PROJECTS", - "UUID", "DIR1", - "PROJECT_UUID", "PRJ1", - "ORGANIZATION_UUID", "ORG1", - "UUID_PATH", "X", - "ROOT_UUID", "X", - "PRIVATE", "FALSE"); - db.executeInsert("PROJECTS", - "UUID", "FIL1", - "PROJECT_UUID", "PRJ1", - "ORGANIZATION_UUID", "ORG1", - "UUID_PATH", "X", - "ROOT_UUID", "X", - "PRIVATE", "FALSE"); - db.executeInsert("PROJECTS", - "UUID", "PRJ2", - "PROJECT_UUID", "PRJ2", - "ORGANIZATION_UUID", "ORG1", - "UUID_PATH", "X", - "ROOT_UUID", "X", - "PRIVATE", "FALSE"); - db.executeInsert("PROJECTS", - "UUID", "DIR2", - "PROJECT_UUID", "PRJ2", - "ORGANIZATION_UUID", "ORG1", - "UUID_PATH", "X", - "ROOT_UUID", "X", - "PRIVATE", "FALSE"); - db.executeInsert("PROJECTS", - "UUID", "FIL2", - "PROJECT_UUID", "PRJ2", - "ORGANIZATION_UUID", "ORG1", - "UUID_PATH", "X", - "ROOT_UUID", "X", - "PRIVATE", "FALSE"); - db.executeInsert("PROJECTS", - "UUID", "PRJ3", - "PROJECT_UUID", "PRJ3", - "ORGANIZATION_UUID", "ORG1", - "UUID_PATH", "X", - "ROOT_UUID", "X", - "PRIVATE", "FALSE"); - db.executeInsert("PROJECTS", - "UUID", "PRJ4", - "PROJECT_UUID", "PRJ4", - "ORGANIZATION_UUID", "ORG1", - "UUID_PATH", "X", - "ROOT_UUID", "X", - "PRIVATE", "FALSE"); - - // non last snapshot, none of its measures should be copied to live_measures - db.executeInsert("SNAPSHOTS", - "UUID", "1A1", - "ISLAST", "FALSE", - "COMPONENT_UUID", "PRJ1"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "PRJ1", - "ANALYSIS_UUID", "1A1", - "METRIC_ID", "100"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "DIR1", - "ANALYSIS_UUID", "1A1", - "METRIC_ID", "110", - "VALUE", "11"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "FIL1", - "ANALYSIS_UUID", "1A1", - "METRIC_ID", "120", - "VALUE", "12"); - db.executeInsert("SNAPSHOTS", - "UUID", "1A2", - "ISLAST", "FALSE", - "COMPONENT_UUID", "PRJ2"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "PRJ2", - "ANALYSIS_UUID", "1A2", - "METRIC_ID", "200"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "DIR2", - "ANALYSIS_UUID", "1A2", - "METRIC_ID", "210", - "VALUE", "21"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "FIL2", - "ANALYSIS_UUID", "1A2", - "METRIC_ID", "220", - "VALUE", "22"); - // PRJ3 has only non-last snapshot??!!?? => won't go into live_measures_p - db.executeInsert("SNAPSHOTS", - "UUID", "1A3", - "ISLAST", "FALSE", - "COMPONENT_UUID", "PRJ3"); - - // last snapshot, all measure should be copied to live_measures - db.executeInsert("SNAPSHOTS", - "UUID", "2A1", - "ISLAST", "TRUE", - "COMPONENT_UUID", "PRJ1"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "PRJ1", - "ANALYSIS_UUID", "2A1", - "METRIC_ID", "1010", - "VALUE", "101", - "TEXT_VALUE", "TEXT_VALUEx", - "VARIATION_VALUE_1", "345", - "MEASURE_DATA", "FFFF"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "PRJ1", - "ANALYSIS_UUID", "2A1", - "METRIC_ID", "1020", - "VALUE", "102"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "DIR1", - "ANALYSIS_UUID", "2A1", - "METRIC_ID", "1030", - "VALUE", "103"); - // FIL1 has no measure for this snapshot => will trigger infinite loop if not taken into account - db.executeInsert("SNAPSHOTS", - "UUID", "2A2", - "ISLAST", "TRUE", - "COMPONENT_UUID", "PRJ2"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "PRJ2", - "ANALYSIS_UUID", "2A2", - "METRIC_ID", "2010", - "VALUE", "201", - "TEXT_VALUE", "TEXT_VALUEx", - "VARIATION_VALUE_1", "345", - "MEASURE_DATA", "FFFF"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "PRJ2", - "ANALYSIS_UUID", "2A2", - "METRIC_ID", "2020", - "VALUE", "202"); - db.executeInsert("PROJECT_MEASURES", - "COMPONENT_UUID", "DIR2", - "ANALYSIS_UUID", "2A2", - "METRIC_ID", "2030", - "VALUE", "203"); - // FIL2 has no measure for this snapshot => will trigger infinite loop if not taken into account - // PRJ5 has last snapshot without measure => won't go into live_measures_p - db.executeInsert("SNAPSHOTS", - "UUID", "2A4", - "ISLAST", "FALSE", - "COMPONENT_UUID", "PRJ4"); - } - - private List> getLiveMeasures() { - return db.select("SELECT * FROM LIVE_MEASURES"); - } - - private Tuple[] generateLiveMeasures() { - return new Tuple[] { - tuple("PRJ1", "PRJ1", 1010L, 101.0, "TEXT_VALUEx", 345.0, new byte[] {-1, -1}), - tuple("PRJ1", "PRJ1", 1020L, 102.0, null, null, null), - tuple("DIR1", "PRJ1", 1030L, 103.0, null, null, null), - tuple("PRJ2", "PRJ2", 2010L, 201.0, "TEXT_VALUEx", 345.0, new byte[] {-1, -1}), - tuple("PRJ2", "PRJ2", 2020L, 202.0, null, null, null), - tuple("DIR2", "PRJ2", 2030L, 203.0, null, null, null) - }; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGatesTest.java deleted file mode 100644 index 317fa2e6eb3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGatesTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; - -public class PopulateOrgQualityGatesTest { - - private static final long PAST = 10_000_000_000L; - private static final String TABLE_ORGANIZATIONS = "organizations"; - private static final String TABLE_QUALITY_GATES = "quality_gates"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrgQualityGates.class, "org_quality_gates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateOrgQualityGates underTest = new PopulateOrgQualityGates(db.database(), UuidFactoryFast.getInstance()); - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("org_quality_gates")).isEqualTo(0); - } - - @Test - public void should_associate_builtin_to_all_organizations() throws SQLException { - String orgUuid1 = Uuids.createFast(); - String orgUuid2 = Uuids.createFast(); - String qgUuid = Uuids.createFast(); - insertOrganization(orgUuid1); - insertOrganization(orgUuid2); - insertQualityGate(qgUuid, "Sonar way", true); - - underTest.execute(); - - assertThat(selectAllOrgQualityGates()) - .extracting(map -> map.get("ORGANIZATION_UUID"), map -> map.get("QUALITY_GATE_UUID")) - .containsExactlyInAnyOrder( - tuple(orgUuid1, qgUuid), - tuple(orgUuid2, qgUuid)); - } - - @Test - public void is_reentrant() throws SQLException { - String orgUuid1 = Uuids.createFast(); - String orgUuid2 = Uuids.createFast(); - String qgUuid = Uuids.createFast(); - insertOrganization(orgUuid1); - insertOrganization(orgUuid2); - insertQualityGate(qgUuid, "Sonar way", true); - - underTest.execute(); - underTest.execute(); - - assertThat(selectAllOrgQualityGates()) - .extracting(map -> map.get("ORGANIZATION_UUID"), map -> map.get("QUALITY_GATE_UUID")) - .containsExactlyInAnyOrder( - tuple(orgUuid1, qgUuid), - tuple(orgUuid2, qgUuid)); - } - - @Test - public void should_fail_with_ISE_when_no_builtIn() throws SQLException { - insertOrganization(Uuids.createFast()); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Unable to find the builtin quality gate"); - - underTest.execute(); - } - - @Test - public void should_fail_if_there_are_two_builtin_qg() throws SQLException { - String orgUuid1 = Uuids.createFast(); - String orgUuid2 = Uuids.createFast(); - String qgUuid1 = Uuids.createFast(); - String qgUuid2 = Uuids.createFast(); - insertOrganization(orgUuid1); - insertOrganization(orgUuid2); - insertQualityGate(qgUuid1, "Sonar way", true); - insertQualityGate(qgUuid2, "Sonar way 2", true); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("There are too many built in quality gates, one and only one is expected"); - - underTest.execute(); - } - - private List> selectAllOrgQualityGates() { - return db.select("select organization_uuid, quality_gate_uuid from org_quality_gates"); - } - - private void insertOrganization(String uuid) { - db.executeInsert( - TABLE_ORGANIZATIONS, - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", String.valueOf(false), - "NEW_PROJECT_PRIVATE", String.valueOf(true), - "CREATED_AT", "1000", - "UPDATED_AT", "1000"); - } - - private void insertQualityGate(String uuid, String name, Boolean builtIn) { - db.executeInsert( - TABLE_QUALITY_GATES, - "UUID", uuid, - "NAME", name, - "IS_BUILT_IN", builtIn.toString(), - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltInTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltInTest.java deleted file mode 100644 index b0b29531c76..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltInTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateQualityGatesIsBuiltInTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQualityGatesIsBuiltInTest.class, "quality_gates.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateQualityGatesIsBuiltIn underTest = new PopulateQualityGatesIsBuiltIn(db.database(), system2); - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("quality_gates")).isEqualTo(0); - } - - @Test - public void updates_sonarqube_way_is_build_in_column_to_true() throws SQLException { - insertQualityGate("SonarQube way", null); - - underTest.execute(); - - assertQualityGates(tuple("SonarQube way", true, new Date(PAST), new Date(NOW))); - } - - @Test - public void updates_none_sonarqube_way_is_build_in_column_to_false() throws SQLException { - insertQualityGate("Other 1", null); - insertQualityGate("Other 2", null); - - underTest.execute(); - - assertQualityGates( - tuple("Other 1", false, new Date(PAST), new Date(NOW)), - tuple("Other 2", false, new Date(PAST), new Date(NOW))); - } - - @Test - public void does_nothing_when_built_in_column_is_set() throws SQLException { - insertQualityGate("SonarQube way", true); - insertQualityGate("Other way", false); - - underTest.execute(); - - assertQualityGates( - tuple("SonarQube way", true, new Date(PAST), new Date(PAST)), - tuple("Other way", false, new Date(PAST), new Date(PAST))); - } - - @Test - public void execute_is_reentreant() throws SQLException { - insertQualityGate("SonarQube way", null); - insertQualityGate("Other way", null); - - underTest.execute(); - - underTest.execute(); - - assertQualityGates( - tuple("SonarQube way", true, new Date(PAST), new Date(NOW)), - tuple("Other way", false, new Date(PAST), new Date(NOW))); - } - - private void assertQualityGates(Tuple... expectedTuples) { - assertThat(db.select("SELECT NAME, IS_BUILT_IN, CREATED_AT, UPDATED_AT FROM QUALITY_GATES") - .stream() - .map(map -> new Tuple(map.get("NAME"), map.get("IS_BUILT_IN"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void insertQualityGate(String name, @Nullable Boolean builtIn) { - db.executeInsert( - "QUALITY_GATES", - "NAME", name, - "IS_BUILT_IN", builtIn == null ? null : builtIn.toString(), - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGatesTest.java deleted file mode 100644 index 103c1012ee4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGatesTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateUuidOnQualityGatesTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidOnQualityGatesTest.class, "quality_gates.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateUuidOnQualityGates underTest = new PopulateUuidOnQualityGates(db.database(), system2, UuidFactoryFast.getInstance()); - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("quality_gates")).isEqualTo(0); - } - - @Test - public void updates_uuid_when_uuid_is_null() throws SQLException { - insertQualityGate("Test 1", null); - insertQualityGate("Test 2", null); - - underTest.execute(); - - List tuples = selectAllQualityGates("NAME", "IS_BUILT_IN", "CREATED_AT", "UPDATED_AT"); - - assertThat(selectAllQualityGates("NAME", "IS_BUILT_IN", "CREATED_AT", "UPDATED_AT")) - .containsExactlyInAnyOrder( - tuple("Test 1", false, new Date(PAST), new Date(NOW)), - tuple("Test 2", false, new Date(PAST), new Date(NOW))); - - selectAllQualityGates("UUID").forEach(c -> assertThat(c).isNotNull()); - } - - @Test - public void does_not_update_uuid_when_uuid_is_not_null() throws SQLException { - insertQualityGate("Test 1", "1"); - insertQualityGate("Test 2", "2"); - - underTest.execute(); - - assertThat(selectAllQualityGates("UUID", "NAME", "IS_BUILT_IN", "CREATED_AT", "UPDATED_AT")) - .containsExactlyInAnyOrder( - tuple("1", "Test 1", false, new Date(PAST), new Date(PAST)), - tuple("2", "Test 2", false, new Date(PAST), new Date(PAST))); - } - - @Test - public void execute_is_reentreant() throws SQLException { - insertQualityGate("Test 1", null); - insertQualityGate("Test 2", null); - - underTest.execute(); - underTest.execute(); - - assertThat(selectAllQualityGates("NAME", "IS_BUILT_IN", "CREATED_AT", "UPDATED_AT")) - .containsExactlyInAnyOrder( - tuple("Test 1", false, new Date(PAST), new Date(NOW)), - tuple("Test 2", false, new Date(PAST), new Date(NOW))); - - selectAllQualityGates("UUID").forEach(c -> assertThat(c).isNotNull()); - } - - private List selectAllQualityGates(String... columns) { - return db.select("SELECT UUID, NAME, IS_BUILT_IN, CREATED_AT, UPDATED_AT FROM QUALITY_GATES") - .stream() - .map(map -> new Tuple(Arrays.stream(columns).map(c -> map.get(c)).collect(toList()).toArray())) - .collect(toList()); - } - - private void insertQualityGate(String name, @Nullable String uuid) { - db.executeInsert( - "QUALITY_GATES", - "NAME", name, - "UUID", uuid, - "IS_BUILT_IN", false, - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrgTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrgTest.java deleted file mode 100644 index f75e4689705..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrgTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -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; -import static org.assertj.core.api.Assertions.tuple; - -public class ReadGlobalSonarQualityGateSettingToDefaultOrgTest { - - private static final long PAST = 10_000_000_000L; - private static final long NOW = 20_000_000_000L; - - private System2 system2 = new TestSystem2().setNow(NOW); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(ReadGlobalSonarQualityGateSettingToDefaultOrgTest.class, "initial.sql"); - - private DataChange underTest = new ReadGlobalSonarQualityGateSettingToDefaultOrg(db.database(), system2); - - @Test - public void read_sonar_quality_gate_setting_and_update_default_organization() throws SQLException { - String defaultQualityGate = insertQualityGate(); - String otherQualityGate = insertQualityGate(); - String defaultOrganization = insertOrganization(otherQualityGate); - String otherOrganization = insertOrganization(otherQualityGate); - insertDefaultOrgProperty(defaultOrganization); - insertSetting("sonar.qualitygate", selectQualityGateId(defaultQualityGate)); - - underTest.execute(); - - assertDefaultQualityGate(defaultOrganization, tuple(defaultQualityGate, NOW)); - } - - @Test - public void does_nothing_when_no_default_quality_gate_setting() throws Exception { - String defaultQualityGate = insertQualityGate(); - String defaultOrganization = insertOrganization(defaultQualityGate); - insertDefaultOrgProperty(defaultOrganization); - insertQualityGate(); - - underTest.execute(); - - assertDefaultQualityGate(defaultOrganization, tuple(defaultQualityGate, PAST)); - } - - @Test - public void migration_is_reentrant() throws Exception { - String defaultOrganization = insertOrganization(null); - insertDefaultOrgProperty(defaultOrganization); - String qualityGate = insertQualityGate(); - insertSetting("sonar.qualitygate", selectQualityGateId(qualityGate)); - - underTest.execute(); - assertDefaultQualityGate(defaultOrganization, tuple(qualityGate, NOW)); - - underTest.execute(); - assertDefaultQualityGate(defaultOrganization, tuple(qualityGate, NOW)); - } - - @Test - public void fail_when_no_default_organization() throws Exception { - String qualityGate = insertQualityGate(); - insertSetting("sonar.qualitygate", selectQualityGateId(qualityGate)); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - private void assertDefaultQualityGate(String uuid, Tuple... expectedTuples) { - assertThat(db.select(String.format("SELECT DEFAULT_QUALITY_GATE_UUID, UPDATED_AT FROM ORGANIZATIONS WHERE UUID='%s'", uuid)) - .stream() - .map(map -> new Tuple(map.get("DEFAULT_QUALITY_GATE_UUID"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private long selectQualityGateId(String uuid){ - return ((Long) db.selectFirst("select id as \"ID\" from quality_gates where uuid='" + uuid + "'").get("ID")).intValue(); - } - - private String insertOrganization(@Nullable String defaultQualityGateUuid) { - String uuid = Uuids.createFast(); - db.executeInsert( - "organizations", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", String.valueOf(false), - "NEW_PROJECT_PRIVATE", String.valueOf(true), - "DEFAULT_QUALITY_GATE_UUID", defaultQualityGateUuid, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return uuid; - } - - private void insertDefaultOrgProperty(String uuid) { - db.executeInsert( - "internal_properties", - "KEE", "organization.default", - "IS_EMPTY", String.valueOf(false), - "TEXT_VALUE", uuid, - "CREATED_AT", PAST); - } - - private String insertQualityGate() { - String uuid = Uuids.createFast(); - db.executeInsert( - "quality_gates", - "UUID", uuid, - "NAME", uuid, - "IS_BUILT_IN", String.valueOf(false), - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - return uuid; - } - - private void insertSetting(String key, Long value) { - db.executeInsert( - "properties", - "PROP_KEY", key, - "TEXT_VALUE", value, - "IS_EMPTY", false, - "CREATED_AT", PAST); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplatesTest.java deleted file mode 100644 index c65525dc7c3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplatesTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.stream.IntStream; -import org.apache.commons.lang.RandomStringUtils; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RemoveQualityGateLoadedTemplatesTest { - public static final String QUALITY_GATE_TYPE = "QUALITY_GATE"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RemoveQualityGateLoadedTemplatesTest.class, "loaded_templates.sql"); - - private RemoveQualityGateLoadedTemplates underTest = new RemoveQualityGateLoadedTemplates(db.database()); - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("loaded_templates")).isEqualTo(0); - } - - @Test - public void migration_should_remove_all_quality_gate_loaded_templates() throws SQLException { - db.executeInsert("loaded_templates", "kee", "KEE_1", "template_type", QUALITY_GATE_TYPE); - db.executeInsert("loaded_templates", "kee", "KEE_2", "template_type", QUALITY_GATE_TYPE); - db.executeInsert("loaded_templates", "kee", "KEE_3", "template_type", QUALITY_GATE_TYPE); - db.executeInsert("loaded_templates", "kee", "KEE_4", "template_type", QUALITY_GATE_TYPE); - db.executeInsert("loaded_templates", "kee", "KEE_5", "template_type", QUALITY_GATE_TYPE); - - underTest.execute(); - - assertThat(db.countRowsOfTable("loaded_templates")).isEqualTo(0); - } - - @Test - public void migration_should_NOT_remove_other_gate_loaded_templates() throws SQLException { - db.executeInsert("loaded_templates", "kee", "KEE_1", "template_type", "WHATEVER1"); - db.executeInsert("loaded_templates", "kee", "KEE_2", "template_type", "WHATEVER2"); - db.executeInsert("loaded_templates", "kee", "KEE_3", "template_type", "WHATEVER3"); - db.executeInsert("loaded_templates", "kee", "KEE_4", "template_type", "WHATEVER4"); - db.executeInsert("loaded_templates", "kee", "KEE_5", "template_type", "WHATEVER5"); - - underTest.execute(); - - assertThat(db.countSql("SELECT count(*) FROM loaded_templates WHERE template_type = '" + QUALITY_GATE_TYPE + "'")).isEqualTo(0); - assertThat(db.countRowsOfTable("loaded_templates")).isEqualTo(5); - } - - @Test - public void migration_is_reentrant() throws SQLException { - db.executeInsert("loaded_templates", "kee", "KEE_1", "template_type", "WHATEVER1"); - db.executeInsert("loaded_templates", "kee", "KEE_2", "template_type", "WHATEVER2"); - db.executeInsert("loaded_templates", "kee", "KEE_3", "template_type", "WHATEVER3"); - db.executeInsert("loaded_templates", "kee", "KEE_4", "template_type", "WHATEVER4"); - db.executeInsert("loaded_templates", "kee", "KEE_5", "template_type", "WHATEVER5"); - - db.executeInsert("loaded_templates", "kee", "KEE_1", "template_type", QUALITY_GATE_TYPE); - db.executeInsert("loaded_templates", "kee", "KEE_2", "template_type", QUALITY_GATE_TYPE); - db.executeInsert("loaded_templates", "kee", "KEE_3", "template_type", QUALITY_GATE_TYPE); - db.executeInsert("loaded_templates", "kee", "KEE_4", "template_type", QUALITY_GATE_TYPE); - db.executeInsert("loaded_templates", "kee", "KEE_5", "template_type", QUALITY_GATE_TYPE); - - underTest.execute(); - underTest.execute(); - - assertThat(db.countSql("SELECT count(*) FROM loaded_templates WHERE template_type = '" + QUALITY_GATE_TYPE + "'")).isEqualTo(0); - assertThat(db.countRowsOfTable("loaded_templates")).isEqualTo(5); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest.java deleted file mode 100644 index 2caa9acb40e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -import java.util.Date; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.LogTester; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class RenameOldSonarQubeWayQualityGateTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - private final static String SONARQUBE_WAY_QUALITY_GATE = "SonarQube way"; - private final static String SONAR_WAY_OUTDATED_QUALITY_GATE = "Sonar way (outdated copy)"; - private final static String SONAR_WAY_QUALITY_GATE = "Sonar way"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQualityGatesIsBuiltInTest.class, "quality_gates.sql"); - @Rule - public LogTester logTester = new LogTester(); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private RenameOldSonarQubeWayQualityGate underTest = new RenameOldSonarQubeWayQualityGate(db.database(), system2); - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("quality_gates")).isEqualTo(0); - } - - @Test - public void should_rename_SonarQubeWay_quality_gate() throws SQLException { - insertQualityGate(SONARQUBE_WAY_QUALITY_GATE, false); - - underTest.execute(); - - assertQualityGates( - tuple(SONAR_WAY_OUTDATED_QUALITY_GATE, false, new Date(PAST), new Date(NOW)) - ); - } - - @Test - public void should_set_builtin_to_false_when_renaming() throws SQLException { - insertQualityGate(SONARQUBE_WAY_QUALITY_GATE, true); - - underTest.execute(); - - assertQualityGates( - tuple(SONAR_WAY_OUTDATED_QUALITY_GATE, false, new Date(PAST), new Date(NOW)) - ); - } - - @Test - public void should_log_a_meaningful_info_if_outdated_copy_exists() { - insertQualityGate(SONARQUBE_WAY_QUALITY_GATE, false); - insertQualityGate(SONAR_WAY_OUTDATED_QUALITY_GATE, false); - - try { - underTest.execute(); - } catch (Exception ex) { - logTester.logs().contains("There is already a quality profile with name [Sonar way (outdated copy)]"); - } - } - - - @Test - public void should_update_only_SonarQubeWay() throws SQLException { - insertQualityGate("Whatever", true); - insertQualityGate("Whatever2", false); - insertQualityGate(SONAR_WAY_QUALITY_GATE, true); - insertQualityGate(SONARQUBE_WAY_QUALITY_GATE, false); - - underTest.execute(); - - assertQualityGates( - tuple("Whatever", true, new Date(PAST), new Date(PAST)), - tuple("Whatever2", false, new Date(PAST), new Date(PAST)), - tuple(SONAR_WAY_QUALITY_GATE, true, new Date(PAST), new Date(PAST)), - tuple(SONAR_WAY_OUTDATED_QUALITY_GATE, false, new Date(PAST), new Date(NOW)) - ); - } - - @Test - public void is_reentrant() throws SQLException { - insertQualityGate(SONARQUBE_WAY_QUALITY_GATE, false); - - underTest.execute(); - underTest.execute(); - - assertQualityGates( - tuple(SONAR_WAY_OUTDATED_QUALITY_GATE, false, new Date(PAST), new Date(NOW)) - ); - } - - private void assertQualityGates(Tuple... expectedTuples) { - assertThat(db.select("SELECT NAME, IS_BUILT_IN, CREATED_AT, UPDATED_AT FROM QUALITY_GATES") - .stream() - .map(map -> new Tuple(map.get("NAME"), map.get("IS_BUILT_IN"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - - private void insertQualityGate(String name, boolean builtIn) { - db.executeInsert( - "QUALITY_GATES", - "NAME", name, - "IS_BUILT_IN", String.valueOf(builtIn), - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest.java deleted file mode 100644 index d27750a0362..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v70; - -import java.sql.SQLException; -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.step.DdlChange; - -import static java.sql.Types.VARCHAR; - -public class SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest.class, "organizations.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DdlChange underTest = new SetDefaultQualityGateUuidAsNotNullableInOrganizations(dbTester.database()); - - @Test - public void default_quality_gate_uuid_is_set_as_not_nullable() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("organizations", "default_quality_gate_uuid", VARCHAR, 40, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertColumnDefinition("organizations", "default_quality_gate_uuid", VARCHAR, 40, false); - - underTest.execute(); - dbTester.assertColumnDefinition("organizations", "default_quality_gate_uuid", VARCHAR, 40, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranchesTest.java deleted file mode 100644 index 153e4dbef12..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranchesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddKeyTypeInProjectBranchesTest { - public static final String TABLE_NAME = "project_branches"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddKeyTypeInProjectBranchesTest.class, TABLE_NAME + ".sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddKeyTypeInProjectBranches underTest = new AddKeyTypeInProjectBranches(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition(TABLE_NAME, "key_type", VARCHAR, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranchesTest.java deleted file mode 100644 index e5f7ac5bc91..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranchesTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BLOB; -import static org.sonar.server.platform.db.migration.version.v71.AddPullRequestBinaryInProjectBranches.COLUMN_NAME; -import static org.sonar.server.platform.db.migration.version.v71.AddPullRequestBinaryInProjectBranches.TABLE_NAME; - -public class AddPullRequestBinaryInProjectBranchesTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddPullRequestBinaryInProjectBranchesTest.class, TABLE_NAME + ".sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddPullRequestBinaryInProjectBranches underTest = new AddPullRequestBinaryInProjectBranches(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BLOB, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddRuleScopeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddRuleScopeTest.java deleted file mode 100644 index 7d418dbfc9f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddRuleScopeTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddRuleScopeTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddRuleScopeTest.class, "rules.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddRuleScope underTest = new AddRuleScope(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("rules", "scope", VARCHAR, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTableTest.java deleted file mode 100644 index 39a35114ead..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTableTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.apache.commons.lang.RandomStringUtils.randomNumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.db.CoreDbTester.createForSchema; - -public class AddWebhookKeyToWebhookDeliveriesTableTest { - @Rule - public final CoreDbTester dbTester = createForSchema(AddWebhookKeyToWebhookDeliveriesTableTest.class, "webhook-deliveries.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddWebhookKeyToWebhookDeliveriesTable underTest = new AddWebhookKeyToWebhookDeliveriesTable(dbTester.database()); - - @Test - public void table_has_been_truncated() throws SQLException { - - insertDelivery(); - - underTest.execute(); - - int count = dbTester.countRowsOfTable("webhook_deliveries"); - assertThat(count).isEqualTo(0); - } - - @Test - public void column_webhook_uuid_has_been_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("webhook_deliveries", "webhook_uuid", VARCHAR, 40, false); - } - - @Test - public void column_duration_ms_is_now_not_nullable() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("webhook_deliveries", "duration_ms", BIGINT, null, false); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - - private void insertDelivery() { - dbTester.executeInsert("webhook_deliveries", - "uuid", randomAlphanumeric(40), -// "webhook_uuid", randomAlphanumeric(40), - "component_uuid", randomAlphanumeric(40), - "name", randomAlphabetic(60), - "url", randomAlphabetic(200), - "success", true, - "duration_ms", randomNumeric(7), - "payload", randomAlphanumeric(1000), - "created_at", valueOf(1_55555_555)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferencesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferencesTest.java deleted file mode 100644 index db5470842bb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferencesTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.Random; -import java.util.stream.IntStream; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(DataProviderRunner.class) -public class CleanBrokenProjectToQGReferencesTest { - - private static final String PROPERTY_SONAR_QUALITYGATE = "sonar.qualitygate"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CleanBrokenProjectToQGReferencesTest.class, "properties_and_quality_gates.sql"); - - private CleanBrokenProjectToQGReferences underTest = new CleanBrokenProjectToQGReferences(db.database()); - - @Test - public void do_nothing_when_no_data() throws SQLException { - assertThat(db.countRowsOfTable("PROPERTIES")).isEqualTo(0); - - underTest.execute(); - - assertThat(db.countRowsOfTable("PROPERTIES")).isEqualTo(0); - } - - @Test - public void execute_deletes_all_qualitygate_component_properties_when_there_is_no_qualitygate() throws SQLException { - insertProperty(PROPERTY_SONAR_QUALITYGATE, 30, "12"); - insertProperty(PROPERTY_SONAR_QUALITYGATE, 42, "val1"); - insertProperty(PROPERTY_SONAR_QUALITYGATE, null, "val2"); - - underTest.execute(); - - assertThat(selectPropertyValues()).containsOnly("val2"); - assertThat(db.countRowsOfTable("PROPERTIES")).isEqualTo(1); - } - - @Test - @UseDataProvider("DP_execute_deletes_qualitygate_component_properties_for_non_existing_qualitygate") - public void execute_deletes_qualitygate_component_properties_for_non_existing_qualitygate(int existingQualityGateCount, int missingQualityGateCount) throws SQLException { - String[] qualityGateIds = IntStream.range(0, existingQualityGateCount) - .mapToObj(i -> insertQualityGate()) - .map(s -> { - int componentId = 2 + s; - String qualityGateId = String.valueOf(s); - insertProperty(PROPERTY_SONAR_QUALITYGATE, componentId, qualityGateId); - return qualityGateId; - }) - .toArray(String[]::new); - IntStream.range(0, missingQualityGateCount) - .forEach(i -> { - int componentId = 3_000 + i; - insertProperty(PROPERTY_SONAR_QUALITYGATE, componentId, "non_existing_" + i); - }); - - underTest.execute(); - - assertThat(selectPropertyValues()).containsOnly(qualityGateIds); - assertThat(db.countRowsOfTable("PROPERTIES")).isEqualTo(qualityGateIds.length); - } - - @DataProvider - public static Object[][] DP_execute_deletes_qualitygate_component_properties_for_non_existing_qualitygate() { - Random random = new Random(); - return new Object[][] { - {1, 1}, - {1, 2}, - {2, 1}, - {2 + random.nextInt(5), 1 + random.nextInt(5)}, - }; - } - - @Test - public void execute_deletes_only_project_qualitygate_property() throws SQLException { - String qualityGateId = String.valueOf(insertQualityGate()); - insertProperty(PROPERTY_SONAR_QUALITYGATE, 84651, qualityGateId); - insertProperty(PROPERTY_SONAR_QUALITYGATE, 7_323, "does_not_exist"); - insertProperty(PROPERTY_SONAR_QUALITYGATE, null, "not a project property"); - insertProperty(PROPERTY_SONAR_QUALITYGATE, null, "not_a_qualitygate_id_either"); - - underTest.execute(); - - assertThat(selectPropertyValues()).containsExactly(qualityGateId, "not a project property", "not_a_qualitygate_id_either"); - assertThat(db.countRowsOfTable("PROPERTIES")).isEqualTo(3); - } - - @Test - public void execute_deletes_only_qualitygate_property_for_project() throws SQLException { - String qualityGateId = String.valueOf(insertQualityGate()); - insertProperty(PROPERTY_SONAR_QUALITYGATE, 84651, qualityGateId); - insertProperty("FOO", 84651, "does_not_exist"); - - underTest.execute(); - - assertThat(selectPropertyValues()).containsExactly(qualityGateId, "does_not_exist"); - assertThat(db.countRowsOfTable("PROPERTIES")).isEqualTo(2); - } - - private Stream selectPropertyValues() { - return db.select("select text_value as \"value\" from properties").stream().map(s -> (String) s.get("value")); - } - - private void insertProperty(String key, @Nullable Integer componentId, String value) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", key, - "RESOURCE_ID", componentId, - "IS_EMPTY", value.isEmpty(), - "TEXT_VALUE", value); - } - - private static int qualityGateIdGenerator = 2_999_567 + new Random().nextInt(56); - - private int insertQualityGate() { - int id = qualityGateIdGenerator++; - db.executeInsert( - "QUALITY_GATES", - "ID", id, - "UUID", "uuid_" + id, - "NAME", "name_" + id, - "IS_BUILT_IN", new Random().nextBoolean()); - return id; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphansTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphansTest.java deleted file mode 100644 index 0f37e50caeb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphansTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.util.Random; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanCeChildTablesOrphansTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CleanCeChildTablesOrphansTest.class, "ce_tables.sql"); - - private final Random random = new Random(); - private CleanCeChildTablesOrphans underTest = new CleanCeChildTablesOrphans(db.database()); - - @Test - public void execute_has_no_effect_if_tables_are_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_deletes_rows_of_ce_task_input_which_task_uuid_appears_in_neither_ce_queue_nor_ce_activity() throws SQLException { - String taskInQueueUuid = insertCeQueue(); - String taskInActivityUuid = insertCeActivity(); - insertCeTaskInput(taskInQueueUuid); - insertCeTaskInput(taskInActivityUuid); - insertCeTaskInput("missing_task"); - - underTest.execute(); - - assertThat(db.select("select task_uuid as \"TASK_UUID\" from ce_task_input")) - .extracting(r -> (String) r.get("TASK_UUID")) - .containsOnly(taskInQueueUuid, taskInActivityUuid); - } - - @Test - public void execute_deletes_rows_of_ce_scanner_context_which_task_uuid_appears_in_neither_ce_queue_nor_ce_activity() throws SQLException { - String taskInQueueUuid = insertCeQueue(); - String taskInActivityUuid = insertCeActivity(); - insertCeScannerContext(taskInQueueUuid); - insertCeScannerContext(taskInActivityUuid); - insertCeScannerContext("missing_task"); - - underTest.execute(); - - assertThat(db.select("select task_uuid as \"TASK_UUID\" from ce_scanner_context")) - .extracting(r -> (String) r.get("TASK_UUID")) - .containsOnly(taskInQueueUuid, taskInActivityUuid); - } - - @Test - public void execute_deletes_rows_of_ce_task_characteristics_which_task_uuid_appears_in_neither_ce_queue_nor_ce_activity() throws SQLException { - String taskInQueueUuid = insertCeQueue(); - String taskInActivityUuid = insertCeActivity(); - insertCeTaskCharacteristics(taskInQueueUuid); - insertCeTaskCharacteristics(taskInActivityUuid); - insertCeTaskCharacteristics("missing_task"); - - underTest.execute(); - - assertThat(db.select("select task_uuid as \"TASK_UUID\" from ce_task_characteristics")) - .extracting(r -> (String) r.get("TASK_UUID")) - .containsOnly(taskInQueueUuid, taskInActivityUuid); - } - - @Test - public void execute_is_reentrant() throws SQLException { - String taskInQueueUuid = insertCeQueue(); - String taskInActivityUuid = insertCeActivity(); - insertCeScannerContext(taskInQueueUuid); - insertCeScannerContext(taskInActivityUuid); - insertCeTaskInput(taskInQueueUuid); - insertCeTaskInput(taskInActivityUuid); - insertCeTaskCharacteristics(taskInQueueUuid); - insertCeTaskCharacteristics(taskInActivityUuid); - insertCeTaskInput("missing_task"); - insertCeScannerContext("missing_task"); - insertCeTaskCharacteristics("missing_task"); - - underTest.execute(); - - verifyOrphansDeleted(taskInQueueUuid, taskInActivityUuid); - - underTest.execute(); - - verifyOrphansDeleted(taskInQueueUuid, taskInActivityUuid); - } - - private void verifyOrphansDeleted(String taskInQueueUuid, String taskInActivityUuid) { - assertThat(db.select("select task_uuid as \"TASK_UUID\" from ce_task_input")) - .extracting(r -> (String) r.get("TASK_UUID")) - .containsOnly(taskInQueueUuid, taskInActivityUuid); - assertThat(db.select("select task_uuid as \"TASK_UUID\" from ce_scanner_context")) - .extracting(r -> (String) r.get("TASK_UUID")) - .containsOnly(taskInQueueUuid, taskInActivityUuid); - assertThat(db.select("select task_uuid as \"TASK_UUID\" from ce_task_characteristics")) - .extracting(r -> (String) r.get("TASK_UUID")) - .containsOnly(taskInQueueUuid, taskInActivityUuid); - } - - private String insertCeQueue() { - String uuid = UuidFactoryFast.getInstance().create(); - db.executeInsert( - "ce_queue", - "UUID", uuid, - "TASK_TYPE", randomAlphanumeric(10), - "STATUS", randomAlphanumeric(10), - "EXECUTION_COUNT", random.nextInt(99), - "CREATED_AT", random.nextInt(95654354), - "UPDATED_AT", random.nextInt(95654354)); - return uuid; - } - - private String insertCeActivity() { - String uuid = UuidFactoryFast.getInstance().create(); - db.executeInsert( - "ce_activity", - "UUID", uuid, - "TASK_TYPE", randomAlphanumeric(10), - "STATUS", randomAlphanumeric(10), - "IS_LAST", random.nextBoolean(), - "IS_LAST_KEY", randomAlphanumeric(15), - "EXECUTION_COUNT", random.nextInt(99), - "SUBMITTED_AT", random.nextInt(95654354), - "CREATED_AT", random.nextInt(95654354), - "UPDATED_AT", random.nextInt(95654354)); - return uuid; - } - - private void insertCeTaskInput(String taskUuid) { - db.executeInsert( - "ce_task_input", - "TASK_UUID", taskUuid, - "INPUT_DATA", randomAlphanumeric(123).getBytes(), - "CREATED_AT", random.nextInt(95654354), - "UPDATED_AT", random.nextInt(95654354)); - } - - private void insertCeScannerContext(String taskUuid) { - db.executeInsert( - "ce_scanner_context", - "TASK_UUID", taskUuid, - "CONTEXT_DATA", randomAlphanumeric(123).getBytes(), - "CREATED_AT", random.nextInt(95654354), - "UPDATED_AT", random.nextInt(95654354)); - } - - private void insertCeTaskCharacteristics(String taskUuid) { - for (int i = 0; i < 1 + random.nextInt(3); i++) { - String uuid = UuidFactoryFast.getInstance().create(); - db.executeInsert( - "ce_task_characteristics", - "UUID", uuid, - "TASK_UUID", taskUuid, - "KEE", "kee_" + uuid + i, - "TEXT_VALUE", randomAlphanumeric(18)); - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTableTest.java deleted file mode 100644 index f3202f52d23..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateDeprecatedRuleKeysTableTest { - - private static final String TABLE = "deprecated_rule_keys"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateDeprecatedRuleKeysTableTest.class, "empty.sql"); - - private CreateDeprecatedRuleKeysTable underTest = new CreateDeprecatedRuleKeysTable(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "rule_id", Types.INTEGER, 11, false); - db.assertColumnDefinition(TABLE, "old_repository_key", Types.VARCHAR, 255, false); - db.assertColumnDefinition(TABLE, "old_rule_key", Types.VARCHAR, 200, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, 20, false); - - db.assertUniqueIndex(TABLE, "uniq_deprecated_rule_keys", "old_repository_key", "old_rule_key"); - db.assertUniqueIndex(TABLE, "rule_id_deprecated_rule_keys", "rule_id"); - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2Test.java deleted file mode 100644 index 94c7131343d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2Test.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableProjectLinks2Test { - - private static final String TABLE_NAME = "project_links2"; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableProjectLinks2Test.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableProjectLinks2 underTest = new CreateTableProjectLinks2(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "project_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "link_type", Types.VARCHAR, 20, false); - dbTester.assertColumnDefinition(TABLE_NAME, "name", Types.VARCHAR, 128, true); - dbTester.assertColumnDefinition(TABLE_NAME, "href", Types.VARCHAR, 2048, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", Types.BIGINT, null, false); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", Types.BIGINT, null, false); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTableTest.java deleted file mode 100644 index e3cc4ef0b50..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTableTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateWebhooksTableTest { - - private static final String TABLE = "webhooks"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateWebhooksTableTest.class, "empty.sql"); - - private CreateWebhooksTable underTest = new CreateWebhooksTable(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "name", VARCHAR, 100, false); - db.assertColumnDefinition(TABLE, "url", VARCHAR, 2000, false); - - db.assertColumnDefinition(TABLE, "organization_uuid", VARCHAR, 40, true); - db.assertColumnDefinition(TABLE, "project_uuid", VARCHAR, 40, true); - - db.assertColumnDefinition(TABLE, "created_at", BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", BIGINT, null, true); - - db.assertIndex(TABLE, "organization_webhook", "organization_uuid"); - db.assertIndex(TABLE, "project_webhook", "project_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DbVersion71Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DbVersion71Test.java deleted file mode 100644 index d56a4766e6f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DbVersion71Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion71Test { - - private DbVersion71 underTest = new DbVersion71(); - - @Test - public void migrationNumber_starts_at_2000() { - verifyMinimumMigrationNumber(underTest, 2000); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 24); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopiesTest.java deleted file mode 100644 index 3477bd34d7b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopiesTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.util.stream.IntStream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.SequenceUuidFactory; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteMeasuresOfProjectCopiesTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(DeleteMeasuresOfProjectCopiesTest.class, "initial.sql"); - - private UuidFactory uuidFactory = new SequenceUuidFactory(); - private DataChange underTest = new DeleteMeasuresOfProjectCopies(db.database()); - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void delete_measures_of_project_copies_only() throws SQLException { - String project1 = insertComponent("PRJ", "TRK", null); - String project1Copy = insertComponent("FIL", "TRK", project1); - String fileInProject1 = insertComponent("FIL", "FIL", null); - String project2 = insertComponent("PRJ", "TRK", null); - String project2Copy = insertComponent("FIL", "TRK", project2); - String project3 = insertComponent("PRJ", "TRK", null); - insertMeasures(project1, 3); - insertMeasures(project1Copy, 3); - insertMeasures(project2, 5); - insertMeasures(project2Copy, 5); - insertMeasures(project3, 4); - insertMeasures(fileInProject1, 3); - - underTest.execute(); - - verifyMeasures(project1, 3); - verifyMeasures(project1Copy, 0); - verifyMeasures(fileInProject1, 3); - verifyMeasures(project2, 5); - verifyMeasures(project2Copy, 0); - verifyMeasures(project3, 4); - } - - private String insertComponent(String scope, String qualifier, @Nullable String copyComponentUuid) { - String uuid = uuidFactory.create(); - db.executeInsert("PROJECTS", - "ORGANIZATION_UUID", "O1", - "KEE", uuid, - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", uuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", "true", - "QUALIFIER", qualifier, - "SCOPE", scope, - "COPY_COMPONENT_UUID", copyComponentUuid); - return uuid; - } - - private void insertMeasures(String componentUuid, int number) { - IntStream.range(0, number).forEach(index -> db.executeInsert( - "PROJECT_MEASURES", - "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", uuidFactory.create(), - "METRIC_ID", "111")); - } - - private void verifyMeasures(String componentUuid, int expectedCount) { - int count = db.countSql("select count(*) from project_measures where component_uuid='" + componentUuid + "'"); - assertThat(expectedCount) - .as("UUID " + componentUuid) - .isEqualTo(count); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotPropertiesTest.java deleted file mode 100644 index 57036172959..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotPropertiesTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.log.LogTester; -import org.sonar.api.utils.log.LoggerLevel; -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 DeleteSettingsDefinedInSonarDotPropertiesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteSettingsDefinedInSonarDotPropertiesTest.class, "properties.sql"); - - @Rule - public LogTester logTester = new LogTester(); - - private DataChange underTest = new DeleteSettingsDefinedInSonarDotProperties(db.database()); - - @Test - public void delete_sonar_dot_properties_settings() throws SQLException { - insertSetting("sonar.jdbc.url"); - insertSetting("sonar.path.data"); - insertSetting("sonar.cluster.enabled"); - insertSetting("sonar.updatecenter.activate"); - - underTest.execute(); - - assertNoSettings(); - } - - @Test - public void log_removed_settings() throws SQLException { - insertSetting("sonar.jdbc.url"); - insertSetting("not.to.be.removed"); - - underTest.execute(); - - assertThat(logTester.logs(LoggerLevel.WARN)).containsExactlyInAnyOrder("System setting 'sonar.jdbc.url' was defined in database, it has been removed"); - } - - @Test - public void delete_setting_at_global_and_component_level() throws SQLException { - insertSetting("sonar.jdbc.url", null); - insertSetting("sonar.jdbc.url", 100L); - - underTest.execute(); - - assertNoSettings(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSetting("sonar.jdbc.url"); - - underTest.execute(); - assertNoSettings(); - - underTest.execute(); - assertNoSettings(); - } - - @Test - public void does_nothing_when_no_sonar_dot_properties_settings() throws SQLException { - insertSetting("other"); - - underTest.execute(); - - assertSettings(tuple("other", null)); - } - - @Test - public void does_nothing_on_empty_table() throws SQLException { - underTest.execute(); - - assertSettings(); - } - - private void assertSettings(Tuple... expectedTuples) { - assertThat(db.select("SELECT PROP_KEY, RESOURCE_ID FROM PROPERTIES") - .stream() - .map(map -> new Tuple(map.get("PROP_KEY"), map.get("RESOURCE_ID"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoSettings() { - assertSettings(); - } - - private void insertSetting(String key) { - insertSetting(key, null); - } - - private void insertSetting(String key, @Nullable Long componentId) { - db.executeInsert( - "properties", - "PROP_KEY", key, - "RESOURCE_ID", componentId, - "IS_EMPTY", false, - "CREATED_AT", 1000); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinksTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinksTest.java deleted file mode 100644 index 3f0c0e4bec7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinksTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropTableProjectLinksTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(DropTableProjectLinksTest.class, "project_links.sql"); - - private DropTableProjectLinks underTest = new DropTableProjectLinks(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertTableDoesNotExist("project_links"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - dbTester.assertTableDoesNotExist("project_links"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequestTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequestTest.java deleted file mode 100644 index c0d27646a3c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequestTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; -import org.sonar.scanner.protocol.output.ScannerReport; - -import static org.assertj.core.api.Assertions.assertThat; - -public class IncreaseBranchTypeSizeForPullRequestTest { - private static final String TABLE_NAME = "project_branches"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(IncreaseBranchTypeSizeForPullRequestTest.class, "project_branches.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private IncreaseBranchTypeSizeForPullRequest underTest = new IncreaseBranchTypeSizeForPullRequest(db.database()); - - @Test - public void cannot_insert_PULL_REQUEST_type_before_migration() { - expectedException.expect(IllegalStateException.class); - - insertRow(); - } - - @Test - public void can_insert_PULL_REQUEST_after_execute() throws SQLException { - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(0); - insertRow(); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(1); - } - - private void insertRow() { - db.executeInsert( - "PROJECT_BRANCHES", - "UUID", "dummy_uuid", - "PROJECT_UUID", "dummy_project_uuid", - "KEE", "dummy_key", - "CREATED_AT", 456789, - "UPDATED_AT", 456789, - "BRANCH_TYPE", "PULL_REQUEST"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranchesTest.java deleted file mode 100644 index 95df4968e49..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranchesTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.rule.RuleScope; -import org.sonar.db.CoreDbTester; - -import static org.sonar.server.platform.db.migration.version.v71.MakeKeyTypeNotNullableInProjectBranches.TABLE_NAME; - -public class MakeKeyTypeNotNullableInProjectBranchesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeKeyTypeNotNullableInProjectBranchesTest.class, "project_branches.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeKeyTypeNotNullableInProjectBranches underTest = new MakeKeyTypeNotNullableInProjectBranches(db.database()); - - @Test - public void execute_makes_column_not_null() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "key_type", Types.VARCHAR, null, true); - insertRow(); - - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "key_type", Types.VARCHAR, null, false); - } - - private void insertRow() { - db.executeInsert( - "PROJECT_BRANCHES", - "UUID", "dummy_uuid", - "PROJECT_UUID", "dummy_project_uuid", - "KEE", "dummy_key", - "KEY_TYPE", "BRANCH", - "CREATED_AT", 456789, - "UPDATED_AT", 456789, - "BRANCH_TYPE", "BRANCH"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRulesTest.java deleted file mode 100644 index ea6b75aef59..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRulesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.rule.RuleScope; -import org.sonar.db.CoreDbTester; - -public class MakeScopeNotNullableInRulesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeScopeNotNullableInRulesTest.class, "rules.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeScopeNotNullableInRules underTest = new MakeScopeNotNullableInRules(db.database()); - - @Test - public void execute_makes_column_not_null() throws SQLException { - db.assertColumnDefinition("rules", "scope", Types.VARCHAR, null, true); - insertRow(1); - insertRow(2); - - underTest.execute(); - - db.assertColumnDefinition("rules", "scope", Types.VARCHAR, null, false); - } - - private void insertRow(int id) { - db.executeInsert( - "RULES", - "PLUGIN_RULE_KEY", "key_" + id, - "PLUGIN_NAME", "name_" + id, - "SCOPE", RuleScope.MAIN.name()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTableTest.java deleted file mode 100644 index 8d219d28610..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTableTest.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.Map; -import java.util.Objects; -import java.util.Random; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl; - -import static java.lang.Long.parseLong; -import static java.lang.String.valueOf; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.apache.commons.lang.RandomStringUtils.randomNumeric; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(DataProviderRunner.class) -public class MigrateWebhooksToWebhooksTableTest { - private static final long NOW = 1_500_000_000_000L; - private static final boolean ENABLED = true; - private static final boolean DISABLED = false; - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(MigrateWebhooksToWebhooksTableTest.class, "migrate_webhooks.sql"); - - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private MigrateWebhooksToWebhooksTable underTest = new MigrateWebhooksToWebhooksTable(dbTester.database(), new DefaultOrganizationUuidProviderImpl(), uuidFactory); - - @Test - public void should_do_nothing_if_no_webhooks() throws SQLException { - underTest.execute(); - - assertNoMoreWebhookProperties(); - assertThat(dbTester.countRowsOfTable("webhooks")).isEqualTo(0); - } - - @Test - @UseDataProvider("numberOfGlobalWebhooksToMigration") - public void execute_migrates_any_number_of_global_webhook_to_default_organization(int numberOfGlobalWebhooks) throws SQLException { - String defaultOrganizationUuid = insertDefaultOrganization(); - insertGlobalWebhookProperties(numberOfGlobalWebhooks); - Row[] webhooks = IntStream.range(1, numberOfGlobalWebhooks + 1) - .mapToObj(i -> insertGlobalWebhookProperty(i, "name webhook " + i, "url webhook " + i, defaultOrganizationUuid)) - .map(Row::new) - .toArray(Row[]::new); - - underTest.execute(); - - assertThat(selectWebhooksInDb()) - .containsOnly(webhooks) - .extracting(Row::getUuid) - .doesNotContainNull(); - assertNoMoreWebhookProperties(); - } - - @DataProvider - public static Object[][] numberOfGlobalWebhooksToMigration() { - return new Object[][] { - {1}, - {2}, - {2 + new Random().nextInt(10)} - }; - } - - @Test - public void execute_deletes_inconsistent_properties_for_global_webhook() throws SQLException { - String defaultOrganizationUuid = insertDefaultOrganization(); - insertGlobalWebhookProperties(4); - insertGlobalWebhookProperty(1, null, "no name", defaultOrganizationUuid); - insertGlobalWebhookProperty(2, "no url", null, defaultOrganizationUuid); - insertGlobalWebhookProperty(3, null, null, defaultOrganizationUuid); - Webhook webhook = insertGlobalWebhookProperty(4, "name", "url", defaultOrganizationUuid); - - underTest.execute(); - - assertThat(selectWebhooksInDb()).containsOnly(new Row(webhook)); - assertNoMoreWebhookProperties(); - } - - @Test - @UseDataProvider("DP_execute_migrates_any_number_of_webhooks_for_any_number_of_existing_project") - public void execute_migrates_any_number_of_webhooks_for_any_number_of_existing_project(int webhookCount, int projectCount) throws SQLException { - Project[] projects = IntStream.range(0, projectCount) - .mapToObj(i -> insertProject(ENABLED)) - .toArray(Project[]::new); - Row[] rows = Arrays.stream(projects).flatMap(project -> { - insertProjectWebhookProperties(project, webhookCount); - return IntStream.range(1, webhookCount + 1) - .mapToObj(i -> insertProjectWebhookProperty(project, i, "name webhook " + i, "url webhook " + i)) - .map(Row::new); - }).toArray(Row[]::new); - - underTest.execute(); - - assertThat(selectWebhooksInDb()).containsOnly(rows); - assertNoMoreWebhookProperties(); - } - - @DataProvider - public static Object[][] DP_execute_migrates_any_number_of_webhooks_for_any_number_of_existing_project() { - Random random = new Random(); - return new Object[][] { - {1, 1}, - {2, 1}, - {1, 2}, - {2 + random.nextInt(5), 2 + random.nextInt(5)} - }; - } - - @Test - public void execute_delete_webhooks_of_non_existing_project() throws SQLException { - Project project = insertProject(ENABLED); - Project nonExistingProject = new Project(233, "foo"); - Row[] rows = Stream.of(project, nonExistingProject) - .map(prj -> { - insertProjectWebhookProperties(prj, 1); - return insertProjectWebhookProperty(prj, 1, "name", "url"); - }) - .map(Row::new) - .toArray(Row[]::new); - - underTest.execute(); - - assertThat(selectWebhooksInDb()) - .containsOnly(Arrays.stream(rows).filter(r -> Objects.equals(r.projectUuid, project.uuid)).toArray(Row[]::new)); - assertNoMoreWebhookProperties(); - } - - @Test - public void execute_delete_webhooks_of_disabled_project() throws SQLException { - Project project = insertProject(ENABLED); - Project nonExistingProject = insertProject(DISABLED); - Row[] rows = Stream.of(project, nonExistingProject) - .map(prj -> { - insertProjectWebhookProperties(prj, 1); - return insertProjectWebhookProperty(prj, 1, "name", "url"); - }) - .map(Row::new) - .toArray(Row[]::new); - - underTest.execute(); - - assertThat(selectWebhooksInDb()) - .containsOnly(Arrays.stream(rows).filter(r -> Objects.equals(r.projectUuid, project.uuid)).toArray(Row[]::new)); - assertNoMoreWebhookProperties(); - } - - @Test - public void execute_deletes_inconsistent_properties_for_project_webhook() throws SQLException { - Project project = insertProject(ENABLED); - insertProjectWebhookProperties(project, 4); - insertProjectWebhookProperty(project, 1, null, "no name"); - insertProjectWebhookProperty(project, 2, "no url", null); - insertProjectWebhookProperty(project, 3, null, null); - Webhook webhook = insertProjectWebhookProperty(project, 4, "name", "url"); - - underTest.execute(); - - assertThat(selectWebhooksInDb()).containsOnly(new Row(webhook)); - assertNoMoreWebhookProperties(); - } - - @Test - @UseDataProvider("DP_execute_delete_webhooks_of_components_which_is_not_a_project") - public void execute_delete_webhooks_of_components_which_is_not_a_project(int webhookCount, String scope, String qualifier) throws SQLException { - Project project = insertComponent(scope, qualifier, ENABLED); - insertProjectWebhookProperties(project, webhookCount); - IntStream.range(1, webhookCount + 1) - .forEach(i -> insertProjectWebhookProperty(project, i, "name_" + i, "url_" + i)); - - underTest.execute(); - - assertThat(selectWebhooksInDb()).isEmpty(); - assertNoMoreWebhookProperties(); - } - - @DataProvider - public static Object[][] DP_execute_delete_webhooks_of_components_which_is_not_a_project() { - String[] scopes = {Scopes.DIRECTORY, Scopes.FILE}; - String[] qualifiers = {Qualifiers.VIEW, Qualifiers.SUBVIEW, Qualifiers.MODULE, Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE}; - int[] webhookCounts = { 1, 2, 2 + new Random().nextInt(5)}; - Object[][] res = new Object[scopes.length * qualifiers.length * webhookCounts.length][3]; - int i = 0; - for (int webhookCount : webhookCounts) { - for (String scope : scopes) { - for (String qualifier : qualifiers) { - res[i][0] = webhookCount; - res[i][1] = scope; - res[i][2] = qualifier; - i++; - } - } - } - return res; - } - - @Test - public void should_migrate_global_webhooks() throws SQLException { - insertDefaultOrganization(); - insertProperty("sonar.webhooks.global", "1,2", null, parseLong(randomNumeric(7))); - insertProperty("sonar.webhooks.global.1.name", "a webhook", null, parseLong(randomNumeric(7))); - insertProperty("sonar.webhooks.global.1.url", "http://webhook.com", null, parseLong(randomNumeric(7))); - insertProperty("sonar.webhooks.global.2.name", "a webhook", null, parseLong(randomNumeric(7))); - insertProperty("sonar.webhooks.global.2.url", "http://webhook.com", null, parseLong(randomNumeric(7))); - - underTest.execute(); - - assertNoMoreWebhookProperties(); - assertThat(dbTester.countRowsOfTable("webhooks")).isEqualTo(2); - } - - @Test - public void should_migrate_only_valid_webhooks() throws SQLException { - insertDefaultOrganization(); - insertProperty("sonar.webhooks.global", "1,2,3,4", null, parseLong(randomNumeric(7))); - insertProperty("sonar.webhooks.global.1.url", "http://webhook.com", null, parseLong(randomNumeric(7))); - insertProperty("sonar.webhooks.global.2.name", "a webhook", null, parseLong(randomNumeric(7))); - insertProperty("sonar.webhooks.global.3.name", "a webhook", null, parseLong(randomNumeric(7))); - insertProperty("sonar.webhooks.global.3.url", "http://webhook.com", null, parseLong(randomNumeric(7))); - // nothing for 4 - - underTest.execute(); - - assertNoMoreWebhookProperties(); - assertThat(dbTester.countRowsOfTable("webhooks")).isEqualTo(1); - } - - private void insertProperty(String key, @Nullable String value, @Nullable String resourceId, Long date) { - dbTester.executeInsert("PROPERTIES", - "id", randomNumeric(7), - "prop_key", valueOf(key), - "text_value", value, - "is_empty", value == null || value.isEmpty(), - "resource_id", resourceId == null ? null : valueOf(resourceId), - "created_at", valueOf(date)); - } - - private String insertDefaultOrganization() { - String uuid = UuidFactoryFast.getInstance().create(); - dbTester.executeInsert( - "INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", "false", - "TEXT_VALUE", uuid); - return uuid; - } - - private static long PROJECT_ID_GENERATOR = new Random().nextInt(343_343); - - private Project insertProject(boolean enabled) { - return insertComponent(Scopes.PROJECT, Qualifiers.PROJECT, enabled); - } - - private Project insertComponent(String scope, String qualifier, boolean enabled) { - long projectId = PROJECT_ID_GENERATOR++; - Project res = new Project(projectId, "prj_" + projectId); - dbTester.executeInsert( - "PROJECTS", - "ID", res.id, - "ORGANIZATION_UUID", randomAlphanumeric(15), - "UUID", res.uuid, - "ROOT_UUID", res.uuid, - "PROJECT_UUID", res.uuid, - "UUID_PATH", "." + res.uuid + ".", - "PRIVATE", new Random().nextBoolean(), - "SCOPE", scope, - "QUALIFIER", qualifier, - "ENABLED", enabled - ); - return res; - } - - private void insertGlobalWebhookProperties(int total) { - insertProperty("sonar.webhooks.global", - IntStream.range(0, total).map(i -> i + 1).mapToObj(String::valueOf).collect(Collectors.joining(",")), - null, - NOW); - } - - private Webhook insertGlobalWebhookProperty(int i, @Nullable String name, @Nullable String url, String organizationUuid) { - long createdAt = NOW + new Random().nextInt(5_6532_999); - Webhook res = new Webhook(name, url, organizationUuid, null, createdAt); - if (name != null) { - insertProperty("sonar.webhooks.global." + i + ".name", name, null, createdAt); - } - if (url != null) { - insertProperty("sonar.webhooks.global." + i + ".url", url, null, createdAt); - } - return res; - } - - private void insertProjectWebhookProperties(Project project, int total) { - insertProperty("sonar.webhooks.project", - IntStream.range(0, total).map(i -> i + 1).mapToObj(String::valueOf).collect(Collectors.joining(",")), - valueOf(project.id), - NOW); - } - - private Webhook insertProjectWebhookProperty(Project project, int i, @Nullable String name, @Nullable String url) { - long createdAt = NOW + new Random().nextInt(5_6532_999); - Webhook res = new Webhook(name, url, null, project.uuid, createdAt); - if (name != null) { - insertProperty("sonar.webhooks.project." + i + ".name", name, valueOf(project.id), createdAt); - } - if (url != null) { - insertProperty("sonar.webhooks.project." + i + ".url", url, valueOf(project.id), createdAt); - } - return res; - } - - private Stream selectWebhooksInDb() { - return dbTester.select("select * from webhooks").stream().map(Row::new); - } - - private void assertNoMoreWebhookProperties() { - assertThat(dbTester.countSql("select count(*) from properties where prop_key like 'sonar.webhooks.%'")) - .isEqualTo(0); - } - - private static final class Webhook { - @Nullable - private final String name; - @Nullable - private final String url; - @Nullable - private final String organizationUuid; - @Nullable - private final String projectUuid; - private final long createdAt; - - private Webhook(@Nullable String name, @Nullable String url, @Nullable String organizationUuid, @Nullable String projectUuid, long createdAt) { - this.name = name; - this.url = url; - this.organizationUuid = organizationUuid; - this.projectUuid = projectUuid; - this.createdAt = createdAt; - } - } - - private static class Row { - private final String uuid; - private final String name; - private final String url; - @Nullable - private final String organizationUuid; - @Nullable - private final String projectUuid; - private final long createdAt; - private final long updatedAt; - - private Row(Map row) { - this.uuid = (String) row.get("UUID"); - this.name = (String) row.get("NAME"); - this.url = (String) row.get("URL"); - this.organizationUuid = (String) row.get("ORGANIZATION_UUID"); - this.projectUuid = (String) row.get("PROJECT_UUID"); - this.createdAt = (Long) row.get("CREATED_AT"); - this.updatedAt = (Long) row.get("UPDATED_AT"); - } - - private Row(Webhook webhook) { - this.uuid = "NOT KNOWN YET"; - this.name = webhook.name; - this.url = webhook.url; - this.organizationUuid = webhook.organizationUuid; - this.projectUuid = webhook.projectUuid; - this.createdAt = webhook.createdAt; - this.updatedAt = webhook.createdAt; - } - - public String getUuid() { - return uuid; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Row row = (Row) o; - return createdAt == row.createdAt && - updatedAt == row.updatedAt && - Objects.equals(name, row.name) && - Objects.equals(url, row.url) && - Objects.equals(organizationUuid, row.organizationUuid) && - Objects.equals(projectUuid, row.projectUuid); - } - - @Override - public int hashCode() { - return Objects.hash(name, url, organizationUuid, projectUuid, createdAt, updatedAt); - } - - @Override - public String toString() { - return "Row{" + - "uuid='" + uuid + '\'' + - ", name='" + name + '\'' + - ", url='" + url + '\'' + - ", organizationUuid='" + organizationUuid + '\'' + - ", projectUuid='" + projectUuid + '\'' + - ", createdAt=" + createdAt + - ", updatedAt=" + updatedAt + - '}'; - } - } - - private static final class Project { - private final long id; - private final String uuid; - - private Project(long id, String uuid) { - this.id = id; - this.uuid = uuid; - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2Test.java deleted file mode 100644 index 6781b442b39..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2Test.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.SequenceUuidFactory; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; - -public class PopulateTableProjectLinks2Test { - - private static final long PAST = 5_000_000_000L; - private static final long NOW = 10_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateTableProjectLinks2Test.class, "project_links2.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - private UuidFactory uuidFactory = new SequenceUuidFactory(); - - private PopulateTableProjectLinks2 underTest = new PopulateTableProjectLinks2(db.database(), uuidFactory, system2); - - @Test - public void copy_custom_links() throws SQLException { - String project = insertProject(); - insertProjectLink("Name1", "custom1", "http://link1", project); - insertProjectLink("Name2", "custom2", "http://link2", project); - - underTest.execute(); - - assertProjectLinks2( - tuple("Name1", "custom1", "http://link1", project, NOW, NOW), - tuple("Name2", "custom2", "http://link2", project, NOW, NOW)); - } - - @Test - public void remove_name_of_provided_links() throws SQLException { - String project = insertProject(); - insertProjectLink("Home", "homepage", "http://homepage", project); - insertProjectLink("CI", "ci", "http://ci", project); - insertProjectLink("Jira", "issue", "http://issue", project); - insertProjectLink("SCM", "scm", "http://scm", project); - - underTest.execute(); - - assertProjectLinks2( - tuple(null, "homepage", "http://homepage", project, NOW, NOW), - tuple(null, "ci", "http://ci", project, NOW, NOW), - tuple(null, "issue", "http://issue", project, NOW, NOW), - tuple(null, "scm", "http://scm", project, NOW, NOW)); - } - - @Test - public void copy_links_from_different_projects() throws SQLException { - String project1 = insertProject(); - insertProjectLink("Name", "custom", "http://link1", project1); - String project2 = insertProject(); - insertProjectLink("Name", "custom", "http://link2", project2); - - underTest.execute(); - - assertProjectLinks2( - tuple("Name", "custom", "http://link1", project1, NOW, NOW), - tuple("Name", "custom", "http://link2", project2, NOW, NOW)); - } - - @Test - public void do_not_copy_links_from_developer_connection_link() throws SQLException { - insertProjectLink("Dev", "scm_dev", "http://link1", insertProject()); - - underTest.execute(); - - assertNoProjectLinks2(); - } - - @Test - public void do_not_copy_links_from_components_that_are_not_projects() throws SQLException { - insertProjectLink("Name", "custom", "http://link1", insertComponent("PRJ", "BRC")); - insertProjectLink("Name", "custom", "http://link2", insertComponent("PRJ", "VW")); - insertProjectLink("Name", "custom", "http://link1", insertComponent("DIR", "DIR")); - insertProjectLink("Name", "custom", "http://link1", "UNKNOWN"); - - underTest.execute(); - - assertNoProjectLinks2(); - } - - @Test - public void do_not_copy_already_copied_data() throws SQLException { - String project = insertProject(); - insertProjectLink("Name", "custom", "http://link", project); - insertProjectLink("Home", "homepage", "http://homepage", project); - insertProjectLink2("UUID1", "Name", "custom", "http://link", project, PAST); - insertProjectLink2("UUID2", null, "homepage", "http://homepage", project, PAST); - - underTest.execute(); - - assertThat(db.select("SELECT UUID, NAME, LINK_TYPE, HREF, PROJECT_UUID, CREATED_AT FROM PROJECT_LINKS2") - .stream() - .map(map -> new Tuple(map.get("UUID"), map.get("NAME"), map.get("LINK_TYPE"), map.get("HREF"), map.get("PROJECT_UUID"), map.get("CREATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder( - tuple("UUID1", "Name", "custom", "http://link", project, PAST), - tuple("UUID2", null, "homepage", "http://homepage", project, PAST)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - String project = insertProject(); - insertProjectLink("Name", "custom", "http://link", project); - - underTest.execute(); - underTest.execute(); - - assertProjectLinks2(tuple("Name", "custom", "http://link", project, NOW, NOW)); - } - - @Test - public void has_no_effect_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("project_links2")).isZero(); - } - - private void assertNoProjectLinks2() { - assertProjectLinks2(); - } - - private void assertProjectLinks2(Tuple... expectedTuples) { - assertThat(db.select("SELECT NAME, LINK_TYPE, HREF, PROJECT_UUID, CREATED_AT, UPDATED_AT FROM PROJECT_LINKS2") - .stream() - .map(map -> new Tuple(map.get("NAME"), map.get("LINK_TYPE"), map.get("HREF"), map.get("PROJECT_UUID"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void insertProjectLink(String name, String linkType, String href, String componentUuid) { - db.executeInsert( - "PROJECT_LINKS", - "COMPONENT_UUID", componentUuid, - "NAME", name, - "LINK_TYPE", linkType, - "HREF", href); - } - - private void insertProjectLink2(String uuid, String name, String linkType, String href, String componentUuid, Long createdAt) { - db.executeInsert( - "PROJECT_LINKS2", - "UUID", uuid, - "PROJECT_UUID", componentUuid, - "NAME", name, - "LINK_TYPE", linkType, - "HREF", href, - "CREATED_AT", createdAt, - "UPDATED_AT", createdAt); - } - - private String insertProject() { - return insertComponent("PRJ", "TRK"); - } - - private String insertComponent(String scope, String qualifier) { - String uuid = uuidFactory.create(); - db.executeInsert("PROJECTS", - "ORGANIZATION_UUID", "O1", - "KEE", uuid, - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", uuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", "true", - "QUALIFIER", qualifier, - "SCOPE", scope); - return uuid; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinksTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinksTest.java deleted file mode 100644 index ff39718a743..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinksTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RenameTableProjectLinks2ToProjectLinksTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(RenameTableProjectLinks2ToProjectLinksTest.class, "project_links2.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameTableProjectLinks2ToProjectLinks underTest = new RenameTableProjectLinks2ToProjectLinks(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertTableDoesNotExist("project_links2"); - assertThat(dbTester.countRowsOfTable("project_links")).isZero(); - dbTester.assertIndex("project_links", "project_links_project", "project_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranchesTest.java deleted file mode 100644 index 1b2b520ccb4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranchesTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.sonar.server.platform.db.migration.version.v71.ReplaceIndexInProjectBranches.NEW_INDEX_NAME; -import static org.sonar.server.platform.db.migration.version.v71.ReplaceIndexInProjectBranches.KEE_COLUMN; -import static org.sonar.server.platform.db.migration.version.v71.ReplaceIndexInProjectBranches.KEY_TYPE_COLUMN; -import static org.sonar.server.platform.db.migration.version.v71.ReplaceIndexInProjectBranches.PROJECT_UUID_COLUMN; -import static org.sonar.server.platform.db.migration.version.v71.ReplaceIndexInProjectBranches.TABLE_NAME; - -public class ReplaceIndexInProjectBranchesTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(ReplaceIndexInProjectBranchesTest.class, "project_branches.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private ReplaceIndexInProjectBranches underTest = new ReplaceIndexInProjectBranches(dbTester.database()); - - @Test - public void column_is_part_of_index() throws SQLException { - underTest.execute(); - - dbTester.assertUniqueIndex(TABLE_NAME, NEW_INDEX_NAME, PROJECT_UUID_COLUMN.getName(), KEE_COLUMN.getName(), KEY_TYPE_COLUMN.getName()); - } - - @Test - public void adding_pr_with_same_key_as_existing_branch_fails_before_migration() { - expectedException.expect(IllegalStateException.class); - - String key = "feature/foo"; - insertBranch(1, key); - insertPullRequest(2, key); - } - - @Test - public void adding_pr_with_same_key_as_existing_branch_works_after_migration() throws SQLException { - underTest.execute(); - - String key = "feature/foo"; - insertBranch(1, key); - insertPullRequest(2, key); - } - - private void insertBranch(int id, String name) { - insertRow(id, "SHORT", name, "BRANCH"); - } - - private void insertPullRequest(int id, String pullRequestId) { - insertRow(id, "PULL_REQUEST", pullRequestId, "PULL_REQUEST"); - } - - private void insertRow(int id, String branchType, String key, String keyType) { - dbTester.executeInsert( - "PROJECT_BRANCHES", - "UUID", "dummy_uuid" + id, - "PROJECT_UUID", "dummy_project_uuid", - "KEE", key, - "KEY_TYPE", keyType, - "CREATED_AT", 456789 + id, - "UPDATED_AT", 456789 + id, - "BRANCH_TYPE", branchType); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranchesTest.java deleted file mode 100644 index 42eb8745fb4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranchesTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.server.platform.db.migration.version.v71.SetKeyTypeToBranchInProjectBranches.DEFAULT_KEY_TYPE; -import static org.sonar.server.platform.db.migration.version.v71.SetKeyTypeToBranchInProjectBranches.TABLE_NAME; - -public class SetKeyTypeToBranchInProjectBranchesTest { - private static final long PAST = 10_000_000_000L; - private static final long NOW = 50_000_000_000L; - - private System2 system2 = new TestSystem2().setNow(NOW); - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(SetKeyTypeToBranchInProjectBranchesTest.class, "project_branches.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private SetKeyTypeToBranchInProjectBranches underTest = new SetKeyTypeToBranchInProjectBranches(dbTester.database(), system2); - - @Test - public void has_no_effect_if_table_project_branches_is_empty() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isEqualTo(0); - } - - @Test - public void updates_rows_to_BRANCH() throws SQLException { - insertRow(1, "SHORT"); - insertRow(2, "LONG"); - insertRow(3, "SHORT"); - insertRow(4, "LONG"); - - String countUpdatedAtSQL = "select count(uuid) from " + TABLE_NAME + " where updated_at = "; - - assertThat(countRowsWithValue(null)).isEqualTo(4); - assertThat(countRowsWithValue(DEFAULT_KEY_TYPE)).isEqualTo(0); - assertThat(dbTester.countSql(countUpdatedAtSQL + PAST)).isEqualTo(4); - - underTest.execute(); - - assertThat(countRowsWithValue(null)).isEqualTo(0); - assertThat(countRowsWithValue(DEFAULT_KEY_TYPE)).isEqualTo(4); - assertThat(dbTester.countSql(countUpdatedAtSQL + NOW)).isEqualTo(4); - } - - @Test - public void execute_is_reentreant() throws SQLException { - insertRow(1, "SHORT"); - insertRow(2, "LONG"); - insertRow(3, "SHORT"); - insertRow(4, "LONG"); - - underTest.execute(); - - underTest.execute(); - - assertThat(countRowsWithValue(null)).isEqualTo(0); - assertThat(countRowsWithValue(DEFAULT_KEY_TYPE)).isEqualTo(4); - } - - private int countRowsWithValue(@Nullable String value) { - if (value == null) { - return dbTester.countSql("select count(1) from " + TABLE_NAME + " where key_type is null"); - } - return dbTester.countSql("select count(1) from " + TABLE_NAME + " where key_type = '" + value + "'"); - } - - private void insertRow(int id, String branchType) { - dbTester.executeInsert( - "PROJECT_BRANCHES", - "UUID", "dummy_uuid" + id, - "PROJECT_UUID", "dummy_project_uuid" + id, - "KEE", "dummy_key" + id, - "CREATED_AT", PAST, - "UPDATED_AT", PAST, - "BRANCH_TYPE", branchType); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMainTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMainTest.java deleted file mode 100644 index 58b39407a28..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMainTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.rule.RuleScope; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SetRuleScopeToMainTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(SetRuleScopeToMainTest.class, "rules.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private System2 system = new System2(); - - private SetRuleScopeToMain underTest = new SetRuleScopeToMain(dbTester.database(), system); - - @Test - public void has_no_effect_if_table_rules_is_empty() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(0); - } - - @Test - public void updates_rows_with_null_is_build_in_column_to_false() throws SQLException { - insertRow(1, null); - insertRow(2, null); - - assertThat(countRowsWithValue(null)).isEqualTo(2); - assertThat(countRowsWithValue(RuleScope.MAIN)).isEqualTo(0); - - underTest.execute(); - - assertThat(countRowsWithValue(null)).isEqualTo(0); - assertThat(countRowsWithValue(RuleScope.MAIN)).isEqualTo(2); - } - - @Test - public void execute_is_reentreant() throws SQLException { - insertRow(1, null); - insertRow(2, RuleScope.MAIN); - - underTest.execute(); - - underTest.execute(); - - assertThat(countRowsWithValue(null)).isEqualTo(0); - assertThat(countRowsWithValue(RuleScope.MAIN)).isEqualTo(2); - } - - private int countRowsWithValue(@Nullable RuleScope value) { - if (value == null) { - return dbTester.countSql("select count(1) from rules where scope is null"); - } - return dbTester.countSql("select count(1) from rules where scope='" + value + "'"); - } - - private void insertRow(int id, @Nullable RuleScope scope) { - dbTester.executeInsert( - "RULES", - "PLUGIN_RULE_KEY", "key_" + id, - "PLUGIN_NAME", "name_" + id, - "SCOPE", scope == null ? null : scope.name()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeysTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeysTest.java deleted file mode 100644 index 7815b0c656c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeysTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import com.google.common.collect.ImmutableList; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.stream.IntStream; -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 static java.util.stream.Collectors.toList; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class UpdatePermissionTooLongTemplateKeysTest { - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(UpdatePermissionTooLongTemplateKeysTest.class, "templates.sql"); - - private static final Random RANDOM = new Random(); - - private final RecordingUuidFactory UUID_FACTORY = new RecordingUuidFactory(); - private final UpdatePermissionTooLongTemplateKeys underTest = new UpdatePermissionTooLongTemplateKeys(dbTester.database(), UUID_FACTORY); - - @Test - public void keys_whose_length_is_greater_than_40_should_be_updated() throws SQLException { - // Create 10 permission templates with keys' length greater or equals than 40 - List tooLongKeys = IntStream.range(0, 10) - .mapToObj(i -> insertTemplate(randomAlphanumeric(41 + RANDOM.nextInt(60)))) - .collect(toList()); - - underTest.execute(); - - assertThat(UUID_FACTORY.getRecordedUuids()).hasSize(tooLongKeys.size()); - List kees = dbTester.select("select kee from permission_templates").stream() - .map(r -> (String) r.get("KEE")).collect(toList()); - - assertThat(kees).containsExactlyInAnyOrder(UUID_FACTORY.getRecordedUuids().toArray(new String[] {})); - } - - @Test - public void keys_whose_length_is_lower_than_40_should_not_be_updated() throws SQLException { - // Create 10 permission templates with keys' length lower or equals than 40 - List correctKeys = IntStream.range(0, 10) - .mapToObj(i -> insertTemplate(randomAlphanumeric(RANDOM.nextInt(41)))) - .collect(toList()); - - underTest.execute(); - - assertThat(UUID_FACTORY.getRecordedUuids()).hasSize(0); - List kees = dbTester.select("select kee from permission_templates").stream() - .map(r -> (String) r.get("KEE")).collect(toList()); - - assertThat(kees).containsExactlyInAnyOrder(correctKeys.toArray(new String[] {})); - } - - private String insertTemplate(String kee) { - dbTester.executeInsert( - "PERMISSION_TEMPLATES", - "NAME", randomAlphanumeric(50), - "ORGANIZATION_UUID", "uuid", - "KEE", kee); - return kee; - } - - private static final class RecordingUuidFactory implements UuidFactory { - private final List generatedUuids = new ArrayList<>(); - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - @Override - public String create() { - String uuid = uuidFactory.create(); - generatedUuids.add(uuid); - return uuid; - } - - public void clear() { - generatedUuids.clear(); - } - - public List getRecordedUuids() { - return ImmutableList.copyOf(generatedUuids); - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesDataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesDataTest.java deleted file mode 100644 index 498d386c146..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesDataTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v71; - -import com.google.common.base.Preconditions; -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.sonar.api.utils.KeyValueFormat; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(DataProviderRunner.class) -public class UseRuleIdInQPChangesDataTest { - - public static final String RULE_ID_DATA_FIELD = "ruleId"; - public static final String RULE_KEY_DATA_FIELD = "ruleKey"; - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(UseRuleIdInQPChangesDataTest.class, "rules_and_qprofile_changes.sql"); - - private UseRuleIdInQPChangesData underTest = new UseRuleIdInQPChangesData(dbTester.database()); - - @Test - public void no_effect_if_tables_are_empty() throws SQLException { - underTest.execute(); - } - - @Test - public void qpChange_without_ruleKey_is_unchanged() throws SQLException { - String c1Data = insertQPChange("c1"); - String c2Data = insertQPChange("c2", "random", "data", "for", "value"); - - underTest.execute(); - - assertThat(reaQPChangeData("c1")).isEqualTo(c1Data); - assertThat(reaQPChangeData("c2")).isEqualTo(c2Data); - } - - @Test - public void qpChange_with_ruleKey_of_other_case_is_unchanged() throws SQLException { - int ruleId1 = insertRule("foo", "bar"); - String c1Data = insertQPChange("c1", "RULEKEY", "notARuleKey"); - String c2Data = insertQPChange("c2", "RULeKey", "foo:bar"); - - underTest.execute(); - - assertThat(reaQPChangeData("c1")).isEqualTo(c1Data); - assertThat(reaQPChangeData("c2")).isEqualTo(c2Data); - } - - @Test - @UseDataProvider("nonExistingRuleKey") - public void qpChange_with_ruleKey_of_non_existing_rule_has_ruleKey_removed(String ruleKey) throws SQLException { - insertRule("foo", "bar"); - insertQPChange("c1", RULE_KEY_DATA_FIELD, ruleKey); - insertQPChange("c2", "otherDataKey", "otherDataData", RULE_KEY_DATA_FIELD, ruleKey); - - underTest.execute(); - - assertThat(reaQPChangeData("c1")).isEmpty(); - assertThat(reaQPChangeData("c2")).contains("otherDataKey=otherDataData"); - } - - @DataProvider - public static Object[][] nonExistingRuleKey() { - return new Object[][] { - {"notARuleKey"}, - {"bar:foo"}, - {"foo:bar2"}, - }; - } - - @Test - public void qpChange_with_ruleKey_of_existing_rule_is_replaced_with_ruleId() throws SQLException { - int ruleId1 = insertRule("foo", "bar"); - int ruleId2 = insertRule("foo2", "bar"); - int ruleId3 = insertRule("foo", "bar2"); - insertQPChange("c1", RULE_KEY_DATA_FIELD, "foo:bar"); - insertQPChange("c2", "otherDataKey", "otherDataData", RULE_KEY_DATA_FIELD, "foo2:bar"); - insertQPChange("c3", RULE_KEY_DATA_FIELD, "foo:bar2", "otherDataKey2", "otherDataData2"); - - underTest.execute(); - - assertThat(reaQPChangeData("c1")) - .doesNotContain(RULE_KEY_DATA_FIELD) - .contains("ruleId=" + ruleId1); - assertThat(reaQPChangeData("c2")) - .contains("otherDataKey=otherDataData") - .doesNotContain(RULE_KEY_DATA_FIELD) - .contains("ruleId=" + ruleId2); - assertThat(reaQPChangeData("c3")) - .contains("otherDataKey2=otherDataData2") - .doesNotContain(RULE_KEY_DATA_FIELD) - .contains("ruleId=" + ruleId3); - } - - @Test - public void qpChange_with_ruleId_is_unchanged() throws SQLException { - int ruleId1 = insertRule("foo", "bar"); - String c1Data = insertQPChange("c1", RULE_ID_DATA_FIELD, "notAnIntButIgnored"); - String c2Data = insertQPChange("c2", RULE_ID_DATA_FIELD, String.valueOf(ruleId1)); - - underTest.execute(); - - assertThat(reaQPChangeData("c1")).isEqualTo(c1Data); - assertThat(reaQPChangeData("c2")).isEqualTo(c2Data); - } - - @Test - public void migration_is_reentrant() throws SQLException { - int ruleId1 = insertRule("foo", "bar"); - insertQPChange("c1", RULE_KEY_DATA_FIELD, "foo:bar"); - String c2Data = insertQPChange("c2", "RULEKEY", "notARuleKey"); - insertQPChange("c3", RULE_KEY_DATA_FIELD, "nonExistingRuleKey"); - - underTest.execute(); - - assertThat(reaQPChangeData("c1")) - .doesNotContain(RULE_KEY_DATA_FIELD) - .contains("ruleId=" + ruleId1); - assertThat(reaQPChangeData("c2")).isEqualTo(c2Data); - assertThat(reaQPChangeData("c3")).isEmpty(); - - underTest.execute(); - - assertThat(reaQPChangeData("c1")) - .doesNotContain(RULE_KEY_DATA_FIELD) - .contains("ruleId=" + ruleId1); - assertThat(reaQPChangeData("c2")).isEqualTo(c2Data); - assertThat(reaQPChangeData("c3")).isEmpty(); - } - - private String reaQPChangeData(String qpChangeKey) { - return (String) dbTester.selectFirst("select change_data as \"DATA\"from qprofile_changes where kee='" + qpChangeKey + "'") - .get("DATA"); - } - - private int insertRule(String repo, String key) { - dbTester.executeInsert( - "RULES", - "PLUGIN_RULE_KEY", key, - "PLUGIN_NAME", repo); - - Map row = dbTester.selectFirst("select id as \"ID\" from rules where plugin_rule_key='" + key + "' and plugin_name='" + repo + "'"); - return ((Long) row.get("ID")).intValue(); - } - - private String insertQPChange(String kee, String... keysAndValues) { - String data = keysAndValues.length == 0 ? null : KeyValueFormat.format(toMap(keysAndValues)); - dbTester.executeInsert( - "QPROFILE_CHANGES", - "KEE", kee, - "RULES_PROFILE_UUID", randomAlphanumeric(5), - "CHANGE_TYPE", randomAlphanumeric(6), - "CREATED_AT", new Random().nextInt(10_000), - "CHANGE_DATA", data); - - return data; - } - - private static Map toMap(String[] keysAndValues) { - Preconditions.checkArgument(keysAndValues.length % 2 == 0); - Map res = new HashMap<>(); - for (int i = 0; i < keysAndValues.length; i++) { - res.put(keysAndValues[i++], keysAndValues[i]); - } - return res; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest.java deleted file mode 100644 index f405eb2664b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddExternalIdToUsersTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddExternalIdToUsersTest.class, "users.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddExternalIdToUsers underTest = new AddExternalIdToUsers(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("users", "external_id", VARCHAR, 255, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCountTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCountTest.java deleted file mode 100644 index b22fccedc0a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCountTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.INTEGER; - -public class AddFileSourceLineCountTest { - private static final String TABLE_NAME = "file_sources"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddFileSourceLineCountTest.class, "file_sources.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddFileSourceLineCount underTest = new AddFileSourceLineCount(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition(TABLE_NAME, "line_count", INTEGER, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTableTest.java deleted file mode 100644 index 40b47d2f9ad..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddHashMethodToUsersTableTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddHashMethodToUsersTableTest.class, "users.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddHashMethodToUsersTable underTest = new AddHashMethodToUsersTable(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("users", "hash_method", VARCHAR, 10, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSourcesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSourcesTest.java deleted file mode 100644 index b46b36b473c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSourcesTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.INTEGER; - -public class AddLineHashesVersionToFileSourcesTest { - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddLineHashesVersionToFileSourcesTest.class, "fileSources.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddLineHashesVersionToFileSources underTest = new AddLineHashesVersionToFileSources(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - dbTester.assertColumnDefinition("file_sources", "line_hashes_version", INTEGER, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest.java deleted file mode 100644 index a8d3bc0b6f3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddOrganizationUuidToUsersTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddOrganizationUuidToUsersTest.class, "users.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToUsers underTest = new AddOrganizationUuidToUsers(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("users", "organization_uuid", VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddRuleExternalTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddRuleExternalTest.java deleted file mode 100644 index e4869a778dc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddRuleExternalTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; -import static org.junit.rules.ExpectedException.none; -import static org.sonar.db.CoreDbTester.createForSchema; - -public class AddRuleExternalTest { - @Rule - public final CoreDbTester dbTester = createForSchema(AddRuleExternalTest.class, "rules.sql"); - - @Rule - public ExpectedException expectedException = none(); - - private AddRuleExternal underTest = new AddRuleExternal(dbTester.database()); - - @Test - public void column_are_added_to_table() throws SQLException { - dbTester.assertColumnDoesNotExist("rules", "is_external"); - - underTest.execute(); - - dbTester.assertColumnDefinition("rules", "is_external", BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsersTest.java deleted file mode 100644 index 428336fe1bd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsersTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; -import static org.junit.rules.ExpectedException.none; -import static org.sonar.db.CoreDbTester.createForSchema; - -public class AddUUIDtoUsersTest { - - @Rule - public final CoreDbTester dbTester = createForSchema(AddUUIDtoUsers.class, "users.sql"); - - @Rule - public ExpectedException expectedException = none(); - - private AddUUIDtoUsers underTest = new AddUUIDtoUsers(dbTester.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("users", "uuid", VARCHAR, 255, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParametersTest.java deleted file mode 100644 index cae94698980..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParametersTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddUniqueIndexOnRulesParametersTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexOnRulesParametersTest.class, "rules_parameters.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUniqueIndexOnRulesParameters underTest = new AddUniqueIndexOnRulesParameters(db.database()); - - @Test - public void add_unique_indexes() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_id", "name"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest.java deleted file mode 100644 index 1d80a527ad8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddUniqueIndexesOnUsersTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexesOnUsersTest.class, "users.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUniqueIndexesOnUsers underTest = new AddUniqueIndexesOnUsers(db.database()); - - @Test - public void add_unique_indexes() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("users", "users_uuid", "uuid"); - db.assertUniqueIndex("users", "uniq_external_id", "external_identity_provider", "external_id"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTableTest.java deleted file mode 100644 index 7255bb8d07d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTableTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateAlmAppInstallsTableTest { - - private static final String TABLE = "alm_app_installs"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateAlmAppInstallsTableTest.class, "empty.sql"); - - private CreateAlmAppInstallsTable underTest = new CreateAlmAppInstallsTable(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", VARCHAR, 40, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - db.assertColumnDefinition(TABLE, "alm_id", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "owner_id", VARCHAR, 4000, false); - db.assertColumnDefinition(TABLE, "install_id", VARCHAR, 4000, false); - db.assertColumnDefinition(TABLE, "created_at", BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", BIGINT, null, false); - - db.assertUniqueIndex(TABLE, "alm_app_installs_owner", "alm_id", "owner_id"); - db.assertUniqueIndex(TABLE, "alm_app_installs_install", "alm_id", "install_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTableTest.java deleted file mode 100644 index 794e6d3368c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateProjectMappingsTableTest { - - private static final String TABLE = "project_mappings"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateProjectMappingsTableTest.class, "empty.sql"); - - private CreateProjectMappingsTable underTest = new CreateProjectMappingsTable(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "key_type", VARCHAR, 200, false); - db.assertColumnDefinition(TABLE, "kee", VARCHAR, 4000, false); - db.assertColumnDefinition(TABLE, "project_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, 20, false); - - db.assertUniqueIndex(TABLE, "key_type_kee", "key_type", "kee"); - db.assertIndex(TABLE, "project_uuid", "project_uuid"); - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/DbVersion72Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/DbVersion72Test.java deleted file mode 100644 index b19a7f78e8a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/DbVersion72Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion72Test { - private DbVersion72 underTest = new DbVersion72(); - - @Test - public void migrationNumber_starts_at_2100() { - verifyMinimumMigrationNumber(underTest, 2100); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 30); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizationsTest.java deleted file mode 100644 index 3441fd5cb2d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizationsTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class DropUserIdFromOrganizationsTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(DropUserIdFromOrganizationsTest.class, "organizations.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DropUserIdFromOrganizations underTest = new DropUserIdFromOrganizations(db.database()); - - @Test - public void column_is_removed_from_table() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("organizations", "user_id"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsersTest.java deleted file mode 100644 index 9212a8b2d13..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsersTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class FixDuplicationInExternalLoginOnUsersTest { - - private static final long PAST = 5_000_000_000L; - private static final long NOW = 10_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(FixDuplicationInExternalLoginOnUsersTest.class, "users.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private FixDuplicationInExternalLoginOnUsers underTest = new FixDuplicationInExternalLoginOnUsers(db.database(), system2); - - @Test - public void fix_duplication() throws SQLException { - insertUser("USER_1", "EXT_LOGIN_1", "EXT_LOGIN_1"); - insertUser("USER_2", "EXT_LOGIN_1", "EXT_LOGIN_1"); - insertUser("USER_3", "EXT_LOGIN_2", "EXT_LOGIN_2"); - insertUser("USER_4", "EXT_LOGIN_2", "EXT_LOGIN_2"); - insertUser("USER_5", "user5", "user5"); - - underTest.execute(); - - assertUsers( - tuple("USER_1", "USER_1", "USER_1", NOW), - tuple("USER_2", "USER_2", "USER_2", NOW), - tuple("USER_3", "USER_3", "USER_3", NOW), - tuple("USER_4", "USER_4", "USER_4", NOW), - tuple("USER_5", "user5", "user5", PAST)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertUser("USER_1", "EXT_LOGIN", "EXT_LOGIN"); - insertUser("USER_2", "EXT_LOGIN", "EXT_LOGIN"); - - underTest.execute(); - underTest.execute(); - - assertUsers( - tuple("USER_1", "USER_1", "USER_1", NOW), - tuple("USER_2", "USER_2", "USER_2", NOW)); - } - - private void assertUsers(Tuple... expectedTuples) { - assertThat(db.select("SELECT LOGIN, EXTERNAL_LOGIN, EXTERNAL_ID, UPDATED_AT FROM USERS") - .stream() - .map(map -> new Tuple(map.get("LOGIN"), map.get("EXTERNAL_LOGIN"), map.get("EXTERNAL_ID"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void insertUser(String login, String externalLogin, String externalId) { - db.executeInsert("USERS", - "LOGIN", login, - "EXTERNAL_ID", externalId, - "EXTERNAL_LOGIN", externalLogin, - "CREATED_AT", PAST, - "UPDATED_AT", PAST, - "IS_ROOT", false, - "ONBOARDED", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSizeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSizeTest.java deleted file mode 100644 index ccb124eade6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSizeTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class IncreaseCryptedPasswordSizeTest { - private static final String TABLE_NAME = "users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(IncreaseCryptedPasswordSizeTest.class, "users.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private IncreaseCryptedPasswordSize underTest = new IncreaseCryptedPasswordSize(db.database()); - - @Test - public void cannot_insert_crypted_password() { - expectedException.expect(IllegalStateException.class); - - insertRow(); - } - - @Test - public void can_insert_crypted_password_after_execute() throws SQLException { - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(0); - insertRow(); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(1); - } - - private void insertRow() { - // bcrypt hash is 60 characters - db.executeInsert( - "USERS", - "CRYPTED_PASSWORD", "$2a$10$8tscphgcElKF5vOBer4H.OVfLKpPIH74hK.rxyhOP5HVyZHyfgRGy", - "IS_ROOT", false, - "ONBOARDED", false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullableTest.java deleted file mode 100644 index 93afd2828cd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullableTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.INTEGER; - -public class MakeFileSourceLineCountNotNullableTest { - private static final String TABLE_NAME = "file_sources"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MakeFileSourceLineCountNotNullableTest.class, "file_sources.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeFileSourceLineCountNotNullable underTest = new MakeFileSourceLineCountNotNullable(dbTester.database()); - - @Test - public void column_is_made_not_nullable() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition(TABLE_NAME, "line_count", INTEGER, null, false); - } - - @Test - public void migration_does_not_fix_null_values_in_line_count() throws SQLException { - dbTester.executeInsert( - TABLE_NAME, - "PROJECT_UUID", "foo_prj", - "FILE_UUID", "foo_file", - "CREATED_AT", 123456, - "UPDATED_AT", 987654 - ); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest.java deleted file mode 100644 index 4bdd2bffe8c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class MakeSomeColumnsOfUsersNotNullableTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(MakeSomeColumnsOfUsersNotNullableTest.class, "users.sql"); - - private MakeSomeColumnsOfUsersNotNullable underTest = new MakeSomeColumnsOfUsersNotNullable(db.database()); - - @Test - public void columns_are_set_as_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("users", "uuid", VARCHAR, 255, false); - db.assertColumnDefinition("users", "login", VARCHAR, 255, false); - db.assertColumnDefinition("users", "external_id", VARCHAR, 255, false); - db.assertColumnDefinition("users", "external_login", VARCHAR, 255, false); - db.assertColumnDefinition("users", "external_identity_provider", VARCHAR, 100, false); - db.assertUniqueIndex("users", "users_login", "login"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertColumnDefinition("users", "uuid", VARCHAR, 255, false); - db.assertColumnDefinition("users", "login", VARCHAR, 255, false); - db.assertColumnDefinition("users", "external_id", VARCHAR, 255, false); - db.assertColumnDefinition("users", "external_login", VARCHAR, 255, false); - db.assertColumnDefinition("users", "external_identity_provider", VARCHAR, 100, false); - db.assertUniqueIndex("users", "users_login", "login"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCountTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCountTest.java deleted file mode 100644 index 3eff10de78f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCountTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import java.util.Random; -import java.util.stream.IntStream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateFileSourceLineCountTest { - private static final String TABLE_NAME = "file_sources"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateFileSourceLineCountTest.class, "file_sources.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateFileSourceLineCount underTest = new PopulateFileSourceLineCount(dbTester.database()); - - @Test - public void execute_does_not_fail_on_empty_table() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_set_value_to_minus_1_when_line_count_is_null() throws SQLException { - IntStream.range(0, 5 + new Random().nextInt(10)).forEach(i -> insert("prj_" + i, "file_" + i)); - - underTest.execute(); - - assertThat(dbTester.select("select distinct line_count as \"count\" from " + TABLE_NAME)) - .extracting(t -> t.get("count")) - .containsOnly(-1L); - } - - @Test - public void execute_keeps_value_when_line_count_is_not_null() throws SQLException { - insert("prj_A", "file_1", 12); - insert("prj_A", "file_2", 0); - insert("prj_B", "file_3", -5); - insert("prj_B", "file_4", -5); - insert("prj_C", "file_5", null); - insert("prj_D", "file_6", null); - insert("prj_D", "file_7", 12); - - underTest.execute(); - - assertThat(dbTester.select("select line_count as \"count\" from " + TABLE_NAME)) - .extracting(t -> t.get("count")) - .containsOnly(-1L, 12L, 12L, 0L, -5L, -5L); - } - - public void insert(String projectUuid, String fileUuid) { - insert(projectUuid, fileUuid, null); - } - - public void insert(String projectUuid, String fileUuid, @Nullable Integer lineCount) { - dbTester.executeInsert( - TABLE_NAME, - "PROJECT_UUID", projectUuid, - "FILE_UUID", fileUuid, - "LINE_COUNT", lineCount, - "CREATED_AT", 123456, - "UPDATED_AT", 987654); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsersTest.java deleted file mode 100644 index 21d33f7e27c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsersTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import java.util.stream.IntStream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateHashMethodOnUsersTest { - - private static final long NOW = 10_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateHashMethodOnUsersTest.class, "users.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateHashMethodOnUsers underTest = new PopulateHashMethodOnUsers(db.database(), system2); - - @Test - public void should_update_only_local_users() throws SQLException { - IntStream.range(0, 99).forEach(i -> insertLocalUser(null)); - IntStream.range(0, 100).forEach(i -> insertExternalUser()); - - underTest.execute(); - - assertThat(db.countSql("select count(id) from users where hash_method='SHA1'")).isEqualTo(99); - assertThat(db.countSql("select count(id) from users where hash_method is not null and crypted_password is null")).isEqualTo(0); - } - - @Test - public void should_add_sha1_in_hash_method() throws SQLException { - IntStream.range(0, 99).forEach(i -> insertLocalUser(null)); - - underTest.execute(); - - assertThat(db.countSql("select count(id) from users where hash_method <> 'SHA1'")).isEqualTo(0); - } - - @Test - public void is_reentrant() throws SQLException { - IntStream.range(0, 99).forEach(i -> insertLocalUser(null)); - IntStream.range(0, 100).forEach(i -> insertExternalUser()); - - underTest.execute(); - underTest.execute(); - - assertThat(db.countSql("select count(id) from users where hash_method='SHA1'")).isEqualTo(99); - assertThat(db.countSql("select count(id) from users where hash_method is not null and crypted_password is null")).isEqualTo(0); - } - - private void insertExternalUser() { - insertUser(randomAlphanumeric(10), null, null, null, randomAlphanumeric(20), randomAlphanumeric(20)); - } - - private void insertLocalUser(@Nullable String hashMethod) { - insertUser(randomAlphanumeric(10), randomAlphanumeric(10), randomAlphanumeric(10), hashMethod, null, null); - } - - private void insertUser(String login, String cryptedPassword, String salt, String hashMethod, - @Nullable String externalIdentity, @Nullable String externalIdentityProvider) { - db.executeInsert("USERS", - "LOGIN", login, - "CRYPTED_PASSWORD", cryptedPassword, - "SALT", salt, - "HASH_METHOD", salt, - "EXTERNAL_IDENTITY", externalIdentity, - "EXTERNAL_IDENTITY_PROVIDER", externalIdentityProvider, - "IS_ROOT", false, - "ONBOARDED", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest.java deleted file mode 100644 index a80ce88316c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateOrganizationUuidOnUsersTest { - - private static final long PAST = 5_000_000_000L; - private static final long NOW = 10_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationUuidOnUsersTest.class, "schema.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateOrganizationUuidOnUsers underTest = new PopulateOrganizationUuidOnUsers(db.database(), system2); - - @Test - public void update_users() throws SQLException { - // User not migrated - long userId = insertUser("USER_1", null); - insertOrganization("ORG_1", userId); - // User already migrated - insertOrganization("ORG_2", null); - insertUser("USER_2", "ORG_2"); - - underTest.execute(); - - assertUsers( - tuple("USER_1", "ORG_1", NOW), - tuple("USER_2", "ORG_2", PAST)); - } - - @Test - public void does_nothing_when_no_personal_organization() throws SQLException { - insertUser("USER_1", null); - insertUser("USER_2", null); - - underTest.execute(); - - assertUsers( - tuple("USER_1", null, PAST), - tuple("USER_2", null, PAST)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId = insertUser("USER_1", null); - insertOrganization("ORG_1", userId); - insertOrganization("ORG_2", null); - insertUser("USER_2", "ORG_2"); - - underTest.execute(); - underTest.execute(); - - assertUsers( - tuple("USER_1", "ORG_1", NOW), - tuple("USER_2", "ORG_2", PAST)); - } - - private void assertUsers(Tuple... expectedTuples) { - assertThat(db.select("SELECT LOGIN, ORGANIZATION_UUID, UPDATED_AT FROM USERS") - .stream() - .map(map -> new Tuple(map.get("LOGIN"), map.get("ORGANIZATION_UUID"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private long insertUser(String uuid, @Nullable String organizationUuid) { - db.executeInsert("USERS", - "ORGANIZATION_UUID", organizationUuid, - "UUID", uuid, - "LOGIN", uuid, - "EXTERNAL_ID", uuid, - "EXTERNAL_LOGIN", uuid, - "EXTERNAL_IDENTITY_PROVIDER", uuid, - "IS_ROOT", false, - "ONBOARDED", false, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return (long) db.selectFirst(String.format("SELECT ID FROM USERS WHERE uuid='%s'", uuid)).get("ID"); - } - - private void insertOrganization(String uuid, @Nullable Long userId) { - db.executeInsert("ORGANIZATIONS", - "UUID", uuid, - "USER_ID", userId, - "KEE", uuid, - "NAME", uuid, - "GUARDED", true, - "DEFAULT_QUALITY_GATE_UUID", uuid, - "NEW_PROJECT_PRIVATE", false, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest.java deleted file mode 100644 index fc8f82b864d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import com.google.common.base.Strings; -import java.sql.SQLException; -import java.util.ArrayList; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static java.util.stream.Collectors.toList; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.junit.rules.ExpectedException.none; -import static org.sonar.db.CoreDbTester.createForSchema; - -public class PopulateUUIDOnUsersTest { - - private final static long PAST = 10_000_000_000L; - private static final long NOW = 50_000_000_000L; - private System2 system2 = new TestSystem2().setNow(NOW); - - private final static String NO_LOGIN = null; - private final static String NO_UUID = null; - - @Rule - public ExpectedException expectedException = none(); - - @Rule - public CoreDbTester db = createForSchema(PopulateUUIDOnUsersTest.class, "users.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private PopulateUUIDOnUsers underTest = new PopulateUUIDOnUsers(db.database(), system2, uuidFactory); - - @Test - public void update_uuid_when_login_is_present() throws SQLException { - String login1 = insertUser(NO_UUID, randomAlphanumeric(10)); - String login2 = insertUser(NO_UUID, randomAlphanumeric(10)); - String login3 = insertUser(NO_UUID, randomAlphanumeric(10)); - - underTest.execute(); - - assertUser( - tuple(login1, login1, PAST, NOW), - tuple(login2, login2, PAST, NOW), - tuple(login3, login3, PAST, NOW) - ); - } - - @Test - public void check_max_length() throws Exception { - String login = insertUser(NO_UUID, Strings.repeat("a", 255)); - - underTest.execute(); - - assertUser(tuple(login, login, PAST, NOW)); - } - - @Test - public void generate_random_uuid_when_login_is_null() throws SQLException { - insertUser(NO_UUID, NO_LOGIN); - insertUser(NO_UUID, NO_LOGIN); - insertUser(NO_UUID, NO_LOGIN); - - underTest.execute(); - - assertThat(new ArrayList<>(db.select("SELECT distinct UUID FROM USERS"))).hasSize(3); - } - - @Test - public void do_nothing_when_uuid_is_already_present() throws SQLException { - String login1 = insertUser(NO_UUID, randomAlphanumeric(10)); - String login2 = insertUser("existing-uuid", randomAlphanumeric(10)); - - underTest.execute(); - - assertUser( - tuple(login1, login1, PAST, NOW), - tuple("existing-uuid", login2, PAST, PAST) - ); - } - - @Test - public void is_reentrant() throws SQLException { - String login1 = insertUser(NO_UUID, randomAlphanumeric(10)); - String login2 = insertUser("existing-uuid", randomAlphanumeric(10)); - - underTest.execute(); - underTest.execute(); - - assertUser( - tuple(login1, login1, PAST, NOW), - tuple("existing-uuid", login2, PAST, PAST) - ); - } - - private String insertUser(String uuid, String login) { - db.executeInsert("USERS", "UUID", uuid, "LOGIN", login, "IS_ROOT", false, "ONBOARDED", false, "CREATED_AT", PAST, "UPDATED_AT", PAST); - return login; - } - - private void assertUser(Tuple... expectedTuples) { - assertThat(db.select("SELECT LOGIN, UUID, CREATED_AT, UPDATED_AT FROM USERS") - .stream() - .map(map -> new Tuple(map.get("UUID"), map.get("LOGIN"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParametersTest.java deleted file mode 100644 index 8d61210c355..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParametersTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PurgeDuplicateRulesParametersTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(PurgeDuplicateRulesParametersTest.class, "rules_parameters_etc.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PurgeDuplicateRulesParameters underTest = new PurgeDuplicateRulesParameters(db.database()); - - @Test - public void migration_deletes_duplicates() throws SQLException { - ImmutableMap dup = ImmutableMap.builder() - .put("rule_id", 10) - .put("name", "foo") - .put("param_type", "INTEGER") - .build(); - db.executeInsert("rules_parameters", dup); - Object id1 = lastId(); - - db.executeInsert("rules_parameters", dup); - Object id2 = lastId(); - - db.executeInsert("rules_parameters", ImmutableMap.builder() - .put("rule_id", 20) - .put("name", "bar") - .put("param_type", "INTEGER") - .build()); - Object id3 = lastId(); - - db.executeInsert("active_rule_parameters", ImmutableMap.builder() - .put("active_rule_id", 1) - .put("rules_parameter_id", id1) - .put("rules_parameter_key", "foo") - .build()); - db.executeInsert("active_rule_parameters", ImmutableMap.builder() - .put("active_rule_id", 2) - .put("rules_parameter_id", id2) - .put("rules_parameter_key", "foo") - .build()); - db.executeInsert("active_rule_parameters", ImmutableMap.builder() - .put("active_rule_id", 3) - .put("rules_parameter_id", id3) - .put("rules_parameter_key", "bar") - .build()); - - assertThat(db.countRowsOfTable("rules_parameters")).isEqualTo(3); - assertThat(db.countRowsOfTable("active_rule_parameters")).isEqualTo(3); - - underTest.execute(); - - assertThat(db.countRowsOfTable("rules_parameters")).isEqualTo(2); - assertThat(db.countRowsOfTable("active_rule_parameters")).isEqualTo(2); - assertThat(db.countSql("select count(*) from rules_parameters where id = " + id2)).isEqualTo(0); - assertThat(db.countSql("select count(*) from active_rule_parameters where rules_parameter_id = " + id2)).isEqualTo(0); - } - - private long lastId() { - return (Long) db.selectFirst("select max(id) id from rules_parameters").get("ID"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCETest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCETest.java deleted file mode 100644 index c0840330eb2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCETest.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import com.google.common.collect.ImmutableSet; -import java.sql.SQLException; -import java.util.Random; -import java.util.Set; -import java.util.stream.IntStream; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.db.CoreDbTester.createForSchema; - -public class PurgeOrphansForCETest { - - private static final Set CE_TABLES = ImmutableSet.of("CE_QUEUE", "CE_ACTIVITY"); - private static final Set CE_CHILD_TABLES = ImmutableSet.of( - "CE_TASK_CHARACTERISTICS", "CE_TASK_INPUT", "CE_SCANNER_CONTEXT"); - - @Rule - public CoreDbTester db = createForSchema(PurgeOrphansForCETest.class, "ce.sql"); - - private Random random = new Random(); - private PurgeOrphansForCE underTest = new PurgeOrphansForCE(db.database()); - private String uuid; - - @Test - public void no_effect_on_empty_db() throws SQLException { - underTest.execute(); - } - - @Test - public void delete_rows_from_CE_child_tables_when_ce_tables_are_empty() throws SQLException { - int count = 1 + random.nextInt(5); - IntStream.range(0, count) - .forEach(i -> { - String uuid = i + randomAlphanumeric(10); - insertInChildTables(uuid); - }); - CE_CHILD_TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isEqualTo(count)); - - underTest.execute(); - - assertThat(db.countRowsOfTable("CE_ACTIVITY")).isZero(); - assertThat(db.countRowsOfTable("CE_QUEUE")).isZero(); - CE_CHILD_TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isZero()); - } - - @Test - public void do_not_delete_rows_from_CE_child_tables_if_parent_in_CE_ACTIVITY() throws SQLException { - int count = 1 + random.nextInt(5); - IntStream.range(0, count) - .forEach(i -> { - String uuid = i + randomAlphanumeric(10); - insertCeActivity(uuid); - insertInChildTables(uuid); - }); - CE_CHILD_TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isEqualTo(count)); - - underTest.execute(); - - assertThat(db.countRowsOfTable("CE_ACTIVITY")).isEqualTo(count); - assertThat(db.countRowsOfTable("CE_QUEUE")).isZero(); - CE_CHILD_TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isEqualTo(count)); - } - - @Test - public void do_not_delete_rows_from_CE_child_tables_if_parent_in_CE_QUEUE() throws SQLException { - int count = 1 + random.nextInt(5); - IntStream.range(0, count) - .forEach(i -> { - String uuid = i + randomAlphanumeric(10); - insertCeQueue(uuid); - insertInChildTables(uuid); - }); - CE_CHILD_TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isEqualTo(count)); - - underTest.execute(); - - assertThat(db.countRowsOfTable("CE_ACTIVITY")).isZero(); - assertThat(db.countRowsOfTable("CE_QUEUE")).isEqualTo(count); - CE_CHILD_TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isEqualTo(count)); - } - - @Test - public void delete_only_orphan_rows_from_ce_child_tables() throws SQLException { - int withCeActivityParent = 1 + new Random().nextInt(10); - int withCeQueueParent = 1 + new Random().nextInt(10); - int orphans = 1 + new Random().nextInt(10); - IntStream.range(0, withCeActivityParent) - .forEach(i -> { - String uuid = "ca_" + i; - insertCeActivity(uuid); - insertInChildTables(uuid); - }); - IntStream.range(0, withCeQueueParent) - .forEach(i -> { - String uuid = "cq_" + i; - insertCeQueue(uuid); - insertInChildTables(uuid); - }); - IntStream.range(0, orphans) - .forEach(i -> { - String uuid = "orph_" + i; - insertInChildTables(uuid); - }); - - underTest.execute(); - - assertThat(db.countRowsOfTable("CE_ACTIVITY")).isEqualTo(withCeActivityParent); - assertThat(db.countRowsOfTable("CE_QUEUE")).isEqualTo(withCeQueueParent); - CE_CHILD_TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isEqualTo(withCeActivityParent + withCeQueueParent)); - CE_CHILD_TABLES.forEach(tableName -> assertThat(db.select("select task_uuid as \"TASK_UUID\" from " + tableName)) - .extracting(t -> (String) t.get("TASK_UUID")) - .allMatch(t -> t.startsWith("ca_") || t.startsWith("cq_"))); - } - - @Test - public void reentrant_on_empty_db() throws SQLException { - underTest.execute(); - - underTest.execute(); - } - - @Test - public void reentrant_on_non_empty_db() throws SQLException { - delete_only_orphan_rows_from_ce_child_tables(); - - underTest.execute(); - } - - private void insertCeActivity(String uuid) { - long now = System.currentTimeMillis(); - - db.executeInsert("CE_ACTIVITY", - "UUID", uuid, - "TASK_TYPE", randomAlphanumeric(15), - "COMPONENT_UUID", randomAlphanumeric(15), - "ANALYSIS_UUID", randomAlphanumeric(15), - "STATUS", randomAlphanumeric(15), - "IS_LAST", false, - "IS_LAST_KEY", randomAlphanumeric(15), - "SUBMITTER_UUID", randomAlphanumeric(15), - "EXECUTION_COUNT", 0, - "SUBMITTED_AT", now, - "CREATED_AT", now, - "UPDATED_AT", now); - } - - private void insertCeQueue(String uuid) { - long now = System.currentTimeMillis(); - - db.executeInsert("CE_QUEUE", - "UUID", uuid, - "TASK_TYPE", randomAlphanumeric(15), - "STATUS", randomAlphanumeric(15), - "EXECUTION_COUNT", 0, - "CREATED_AT", now, - "UPDATED_AT", now); - } - - private void insertInChildTables(String uuid) { - insertCeCharacteristics(uuid); - insertCeTaskInput(uuid); - insertCeScannerContext(uuid); - } - - private void insertCeCharacteristics(String uuid) { - db.executeInsert("CE_TASK_CHARACTERISTICS", - "UUID", randomAlphanumeric(15), - "TASK_UUID", uuid, - "KEE", randomAlphanumeric(15)); - } - - private void insertCeTaskInput(String uuid) { - long now = System.currentTimeMillis(); - - db.executeInsert("CE_TASK_INPUT", - "TASK_UUID", uuid, - "INPUT_DATA", randomAlphanumeric(15).getBytes(), - "CREATED_AT", now, - "UPDATED_AT", now); - } - - private void insertCeScannerContext(String uuid) { - long now = System.currentTimeMillis(); - - db.executeInsert("CE_SCANNER_CONTEXT", - "TASK_UUID", uuid, - "CONTEXT_DATA", randomAlphanumeric(15).getBytes(), - "CREATED_AT", now, - "UPDATED_AT", now); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest.java deleted file mode 100644 index 9670c3b0362..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class RenameExternalIdentityToExternalLoginOnUsersTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(RenameExternalIdentityToExternalLoginOnUsersTest.class, "users.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameExternalIdentityToExternalLoginOnUsers underTest = new RenameExternalIdentityToExternalLoginOnUsers(db.database()); - - @Test - public void column_is_renamed() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("users", "external_login", VARCHAR, 255, true); - db.assertColumnDoesNotExist("users", "external_identity"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokensTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokensTest.java deleted file mode 100644 index cfc03c6e636..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokensTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class RenameLoginToUserUuidOnTableUserTokensTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(RenameLoginToUserUuidOnTableUserTokensTest.class, "user_tokens.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameLoginToUserUuidOnTableUserTokens underTest = new RenameLoginToUserUuidOnTableUserTokens(db.database()); - - @Test - public void rename_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("user_tokens", "user_uuid", VARCHAR, 255, false); - db.assertColumnDoesNotExist("user_tokens", "login"); - db.assertUniqueIndex("user_tokens", "user_tokens_user_uuid_name", "user_uuid", "name"); - db.assertIndexDoesNotExist("user_tokens", "user_tokens_login_name"); - } - - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest.java deleted file mode 100644 index c16509c85c9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest.class, "rules_metadata.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata underTest = new RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadata(db.database()); - - @Test - public void rename_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_metadata", "note_user_uuid", VARCHAR, 255, true); - db.assertColumnDoesNotExist("rules_metadata", "note_user_login"); - } - - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest.java deleted file mode 100644 index a7824a1a3fb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -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.es.MigrationEsClient; - -import static java.sql.Types.VARCHAR; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest.class, "ce_activity.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrationEsClient esClient = mock(MigrationEsClient.class); - private RenameSubmitterLoginToSubmitterUuidOnTableCeActivity underTest = new RenameSubmitterLoginToSubmitterUuidOnTableCeActivity(db.database(), esClient); - - @Test - public void rename_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_activity", "submitter_uuid", VARCHAR, 255, true); - db.assertColumnDoesNotExist("ce_activity", "submitter_login"); - - verify(esClient).deleteIndexes("users"); - } - - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest.java deleted file mode 100644 index 4d058f9c9bb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest.class, "ce_queue.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameSubmitterLoginToSubmitterUuidOnTableCeQueue underTest = new RenameSubmitterLoginToSubmitterUuidOnTableCeQueue(db.database()); - - @Test - public void rename_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_queue", "submitter_uuid", VARCHAR, 255, true); - db.assertColumnDoesNotExist("ce_queue", "submitter_login"); - } - - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasuresTest.java deleted file mode 100644 index 631e9650c06..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasuresTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class RenameUserLoginToUserUuidOnTableManualMeasuresTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(RenameUserLoginToUserUuidOnTableManualMeasuresTest.class, "manual_measures.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameUserLoginToUserUuidOnTableManualMeasures underTest = new RenameUserLoginToUserUuidOnTableManualMeasures(db.database()); - - @Test - public void rename_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "user_uuid", VARCHAR, 255, true); - db.assertColumnDoesNotExist("manual_measures", "user_login"); - } - - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChangesTest.java deleted file mode 100644 index 3de372c1656..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChangesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class RenameUserLoginToUserUuidOnTableQProfileChangesTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(RenameUserLoginToUserUuidOnTableQProfileChangesTest.class, "qprofile_changes.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameUserLoginToUserUuidOnTableQProfileChanges underTest = new RenameUserLoginToUserUuidOnTableQProfileChanges(db.database()); - - @Test - public void rename_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("qprofile_changes", "user_uuid", VARCHAR, 255, true); - db.assertColumnDoesNotExist("qprofile_changes", "user_login"); - } - - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest.java deleted file mode 100644 index 313ad1b2dbb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v72; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.log.LogTester; -import org.sonar.api.utils.log.LoggerLevel; -import org.sonar.core.util.SequenceUuidFactory; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest { - - private static final long PAST = 5_000_000_000L; - private static final long NOW = 10_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest.class, "users.sql"); - - @Rule - public LogTester logTester = new LogTester(); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private UpdateNullValuesFromExternalColumnsAndLoginOfUsers underTest = new UpdateNullValuesFromExternalColumnsAndLoginOfUsers(db.database(), system2, new SequenceUuidFactory()); - - @Test - public void update_users() throws SQLException { - insertUser("USER_1", "user1", "user1", "github"); - insertUser("USER_2", null, null, null); - insertUser("USER_3", "user", null, null); - insertUser("USER_4", null, "user", null); - insertUser("USER_5", null, null, "github"); - insertUser(null, "user", "user", "bitbucket"); - insertUser(null, null, null, null); - - underTest.execute(); - - assertUsers( - tuple("USER_1", "user1", "user1", "github", PAST), - tuple("USER_2", "USER_2", "USER_2", "sonarqube", NOW), - tuple("USER_3", "user", "user", "sonarqube", NOW), - tuple("USER_4", "USER_4", "USER_4", "sonarqube", NOW), - tuple("USER_5", "USER_5", "USER_5", "github", NOW), - tuple("1", "user", "user", "bitbucket", NOW), - tuple("2", "2", "2", "sonarqube", NOW)); - } - - @Test - public void log_warning_when_login_is_null() throws SQLException { - insertUser(null, "user", "user", "bitbucket"); - long id = (long) db.selectFirst("SELECT ID FROM USERS").get("ID"); - - underTest.execute(); - - assertThat(logTester.logs(LoggerLevel.WARN)) - .containsExactlyInAnyOrder(format("No login has been found for user id '%s'. A UUID has been generated to not have null value.", id)); - } - - @Test - public void is_reentrant() throws SQLException { - insertUser("USER_1", null, null, null); - - underTest.execute(); - underTest.execute(); - - assertUsers(tuple("USER_1", "USER_1", "USER_1", "sonarqube", NOW)); - } - - private void assertUsers(Tuple... expectedTuples) { - assertThat(db.select("SELECT LOGIN, EXTERNAL_LOGIN, EXTERNAL_ID, EXTERNAL_IDENTITY_PROVIDER, UPDATED_AT FROM USERS") - .stream() - .map(map -> new Tuple(map.get("LOGIN"), map.get("EXTERNAL_LOGIN"), map.get("EXTERNAL_ID"), map.get("EXTERNAL_IDENTITY_PROVIDER"), map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void insertUser(@Nullable String login, @Nullable String externalLogin, @Nullable String externalId, @Nullable String externalIdentityProvider) { - db.executeInsert("USERS", - "LOGIN", login, - "EXTERNAL_LOGIN", externalLogin, - "EXTERNAL_ID", externalLogin, - "EXTERNAL_IDENTITY_PROVIDER", externalIdentityProvider, - "CREATED_AT", PAST, - "UPDATED_AT", PAST, - "IS_ROOT", false, - "ONBOARDED", false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssuesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssuesTest.java deleted file mode 100644 index 37b483fb2a8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssuesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; - -public class AddFromHotspotFlagToIssuesTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddFromHotspotFlagToIssuesTest.class, "issues.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddFromHotspotFlagToIssues underTest = new AddFromHotspotFlagToIssues(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("issues", "from_hotspot", BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembersTest.java deleted file mode 100644 index be64b5d963b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembersTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddIndexOnOrganizationMembersTest { - private static final String TABLE_LOADED_TEMPLATES = "organization_members"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnOrganizationMembersTest.class, "organization_members.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIndexOnOrganizationMembers underTest = new AddIndexOnOrganizationMembers(db.database()); - - @Test - public void execute_adds_index_ix_loaded_templates_type() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_LOADED_TEMPLATES, "ix_org_members_on_user_id", "user_id"); - } - - @Test - public void execute_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRulesTest.java deleted file mode 100644 index d04dc121fca..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRulesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -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.v72.AddOrganizationUuidToUsers; - -import static java.sql.Types.VARCHAR; - -public class AddSecurityStandardsToRulesTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddSecurityStandardsToRulesTest.class, "rules.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddSecurityStandardsToRules underTest = new AddSecurityStandardsToRules(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules", "security_standards", VARCHAR, 4000, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizationsTest.java deleted file mode 100644 index a7c54c32464..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizationsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddSubscriptionToOrganizationsTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddSubscriptionToOrganizationsTest.class, "organizations.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddSubscriptionToOrganizations underTest = new AddSubscriptionToOrganizations(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("organizations", "subscription", VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTableTest.java deleted file mode 100644 index c99fd06ca4d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTableTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateProjectAlmBindingsTableTest { - - private static final String TABLE = "project_alm_bindings"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateProjectAlmBindingsTableTest.class, "empty.sql"); - - private CreateProjectAlmBindingsTable underTest = new CreateProjectAlmBindingsTable(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", VARCHAR, 40, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - db.assertColumnDefinition(TABLE, "alm_id", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "repo_id", VARCHAR, 256, false); - db.assertColumnDefinition(TABLE, "project_uuid", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "github_slug", VARCHAR, 256, true); - db.assertColumnDefinition(TABLE, "url", VARCHAR, 2000, false); - db.assertColumnDefinition(TABLE, "created_at", BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", BIGINT, null, false); - - db.assertUniqueIndex(TABLE, TABLE + "_alm_repo", "alm_id", "repo_id"); - db.assertUniqueIndex(TABLE, TABLE + "_project", "project_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/DbVersion73Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/DbVersion73Test.java deleted file mode 100644 index 5c22c213fbf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/DbVersion73Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion73Test { - - private DbVersion73 underTest = new DbVersion73(); - - @Test - public void migrationNumber_starts_at_2200() { - verifyMinimumMigrationNumber(underTest, 2200); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 14); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizationsTest.java deleted file mode 100644 index fb2bb458e95..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizationsTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.config.internal.MapSettings; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class FixMissingQualityProfilesOnOrganizationsTest { - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(FixMissingQualityProfilesOnOrganizationsTest.class, "schema.sql"); - - private MapSettings settings = new MapSettings(); - private System2 system2 = new TestSystem2().setNow(NOW); - private FixMissingQualityProfilesOnOrganizations underTest = new FixMissingQualityProfilesOnOrganizations(db.database(), system2, - UuidFactoryFast.getInstance(), settings.asConfig()); - - @Test - public void migration_is_reentrant_on_sonarqube() throws SQLException { - underTest.execute(); - underTest.execute(); - } - - @Test - public void create_missing_links_with_builtin() throws SQLException { - setSonarCloud(); - String orgUuid = insertOrganization(); - String qProfileUuid = insertRulesProfiles("xoo profile", "xoo", true); - - underTest.execute(); - - assertDefaultQProfiles(tuple(orgUuid, "xoo", retrieveOrgQProfile(orgUuid, qProfileUuid))); - assertOrgQProfiles(tuple(orgUuid, qProfileUuid)); - } - - @Test - public void does_nothing_when_no_missing_built_in_profile() throws SQLException { - setSonarCloud(); - insertOrganization(); - insertRulesProfiles("xoo profile", "xoo", false); - - underTest.execute(); - - assertDefaultQProfiles(); - assertOrgQProfiles(); - } - - @Test - public void prefer_SonarWay_BuiltIn_quality_profile_as_default() throws SQLException { - setSonarCloud(); - String orgUuid = insertOrganization(); - String anotherRuleProfileUuid = insertRulesProfiles("xoo profile", "xoo", true); - String sonarWayQProfileUuid = insertRulesProfiles("Sonar way", "xoo", true); - - underTest.execute(); - assertOrgQProfiles( - tuple(orgUuid, anotherRuleProfileUuid), - tuple(orgUuid, sonarWayQProfileUuid) - ); - assertDefaultQProfiles(tuple(orgUuid, "xoo", retrieveOrgQProfile(orgUuid, sonarWayQProfileUuid))); - } - - @Test - public void dont_create_duplicates_when_records_exist() throws SQLException { - setSonarCloud(); - String orgUuid = insertOrganization(); - String qProfileUuid = insertRulesProfiles("xoo profile","xoo", true); - insertDefaultQProfiles(orgUuid, "xoo", qProfileUuid); - insertOrgQProfiles(orgUuid, qProfileUuid); - - underTest.execute(); - - assertDefaultQProfiles(tuple(orgUuid, "xoo", qProfileUuid)); - assertOrgQProfiles(tuple(orgUuid, qProfileUuid)); - } - - @Test - public void create_missing_default_qprofiles() throws SQLException { - setSonarCloud(); - String orgUuid = insertOrganization(); - String qProfileUuid = insertRulesProfiles("xoo profile","xoo", true); - String orgQProfileUuid = insertOrgQProfiles(orgUuid, qProfileUuid); - - underTest.execute(); - - assertDefaultQProfiles(tuple(orgUuid, "xoo", orgQProfileUuid)); - assertOrgQProfiles(tuple(orgUuid, qProfileUuid)); - } - - @Test - public void migration_is_reentrant_on_sonarcloud() throws SQLException { - setSonarCloud(); - - underTest.execute(); - underTest.execute(); - } - - private String insertOrganization() { - String uuid = Uuids.createFast(); - db.executeInsert("ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "SUBSCRIPTION", "PAID", - "GUARDED", false, - "DEFAULT_QUALITY_GATE_UUID", "QGATE_UUID", - "NEW_PROJECT_PRIVATE", false, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return uuid; - } - - private String insertRulesProfiles(String name, String language, Boolean isBuiltIn) { - String uuid = Uuids.createFast(); - db.executeInsert("RULES_PROFILES", - "NAME", name, - "LANGUAGE", language, - "KEE", uuid, - "CREATED_AT", new Timestamp(PAST), - "UPDATED_AT", new Timestamp(PAST), - "IS_BUILT_IN", isBuiltIn); - return uuid; - } - - private String insertOrgQProfiles(String organizationUuid, String rulesProfileUuid) { - String uuid = Uuids.createFast(); - db.executeInsert("ORG_QPROFILES", - "UUID", uuid, - "ORGANIZATION_UUID", organizationUuid, - "RULES_PROFILE_UUID", rulesProfileUuid, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return uuid; - } - - private void insertDefaultQProfiles(String organizationUuid, String language, String qProfileUuid) { - db.executeInsert("DEFAULT_QPROFILES", - "ORGANIZATION_UUID", organizationUuid, - "LANGUAGE", language, - "QPROFILE_UUID", qProfileUuid, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private String retrieveOrgQProfile(String organizationUuid, String qProfileUuid) { - return (String) db.select("SELECT UUID FROM ORG_QPROFILES " + - "WHERE ORGANIZATION_UUID='" + organizationUuid + "' AND RULES_PROFILE_UUID='" + qProfileUuid + "'") - .iterator() - .next() - .get("UUID"); - } - - private void assertOrgQProfiles(Tuple... expectedTuples) { - assertThat(db.select("SELECT ORGANIZATION_UUID, RULES_PROFILE_UUID FROM ORG_QPROFILES") - .stream() - .map(row -> new Tuple(row.get("ORGANIZATION_UUID"), row.get("RULES_PROFILE_UUID"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertDefaultQProfiles(Tuple... expectedTuples) { - assertThat(db.select("SELECT ORGANIZATION_UUID, LANGUAGE, QPROFILE_UUID FROM DEFAULT_QPROFILES") - .stream() - .map(row -> new Tuple(row.get("ORGANIZATION_UUID"), row.get("LANGUAGE"), row.get("QPROFILE_UUID"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void setSonarCloud() { - settings.setProperty("sonar.sonarcloud.enabled", true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroupsTest.java deleted file mode 100644 index 72cef1295fa..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroupsTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; - -public class PopulateHotspotAdminPermissionOnGroupsTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateHotspotAdminPermissionOnGroupsTest.class, "group_roles.sql"); - - private PopulateHotspotAdminPermissionOnGroups underTest = new PopulateHotspotAdminPermissionOnGroups(db.database()); - - @Test - public void insert_missing_permission() throws SQLException { - insertGroupRole("uuid", 1, 2, "noissueadmin"); - insertGroupRole("uuid", 3, 4, "issueadmin"); - insertGroupRole("uuid", 3, 4, "another"); - insertGroupRole("uuid2", 5, 6, "securityhotspotadmin"); - - underTest.execute(); - - assertGroupRoles( - tuple("uuid", 1L, 2L, "noissueadmin"), - tuple("uuid", 3L, 4L, "issueadmin"), - tuple("uuid", 3L, 4L, "another"), - tuple("uuid", 3L, 4L, "securityhotspotadmin"), - tuple("uuid2", 5L, 6L, "securityhotspotadmin")); - } - - private void insertGroupRole(String orgaUuid, int groupId, int resourceId, String role) { - db.executeInsert( - "GROUP_ROLES", - "ORGANIZATION_UUID", orgaUuid, - "GROUP_ID", groupId, - "RESOURCE_ID", resourceId, - "ROLE", role); - } - - private void assertGroupRoles(Tuple... expectedTuples) { - assertThat(db.select("SELECT ORGANIZATION_UUID, GROUP_ID, RESOURCE_ID, ROLE FROM GROUP_ROLES") - .stream() - .map(map -> new Tuple(map.get("ORGANIZATION_UUID"), map.get("GROUP_ID"), map.get("RESOURCE_ID"), map.get("ROLE"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest.java deleted file mode 100644 index aaf0898738b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest { - - private static final long PAST = 100_000_000_000L; - private static final long NOW = 500_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest.class, "perm_tpl_characteristics.sql"); - - private System2 system2 = mock(System2.class); - - private PopulateHotspotAdminPermissionOnTemplatesCharacteristics underTest = new PopulateHotspotAdminPermissionOnTemplatesCharacteristics(db.database(), system2); - - @Test - public void insert_missing_permission() throws SQLException { - when(system2.now()).thenReturn(NOW); - insertPermTemplateCharacteristic(1, "noissueadmin", true); - insertPermTemplateCharacteristic(3, "issueadmin", true); - insertPermTemplateCharacteristic(3, "another", true); - insertPermTemplateCharacteristic(5, "securityhotspotadmin", true); - insertPermTemplateCharacteristic(11, "noissueadmin", false); - insertPermTemplateCharacteristic(13, "issueadmin", false); - insertPermTemplateCharacteristic(13, "another", false); - insertPermTemplateCharacteristic(15, "securityhotspotadmin", false); - - underTest.execute(); - - assertPermTemplateCharacteristics( - tuple(1L, "noissueadmin", true, PAST, PAST), - tuple(3L, "issueadmin", true, PAST, PAST), - tuple(3L, "another", true, PAST, PAST), - tuple(3L, "securityhotspotadmin", true, NOW, NOW), - tuple(5L, "securityhotspotadmin", true, PAST, PAST), - tuple(11L, "noissueadmin", false, PAST, PAST), - tuple(13L, "issueadmin", false, PAST, PAST), - tuple(13L, "another", false, PAST, PAST), - tuple(15L, "securityhotspotadmin", false, PAST, PAST)); - } - - private void insertPermTemplateCharacteristic(int templateId, String perm, boolean withProjectCreator) { - db.executeInsert( - "PERM_TPL_CHARACTERISTICS", - "TEMPLATE_ID", templateId, - "PERMISSION_KEY", perm, - "WITH_PROJECT_CREATOR", withProjectCreator, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private void assertPermTemplateCharacteristics(Tuple... expectedTuples) { - assertThat(db.select("SELECT TEMPLATE_ID, PERMISSION_KEY, WITH_PROJECT_CREATOR, CREATED_AT, UPDATED_AT FROM PERM_TPL_CHARACTERISTICS") - .stream() - .map(map -> new Tuple(map.get("TEMPLATE_ID"), map.get("PERMISSION_KEY"), map.get("WITH_PROJECT_CREATOR"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroupsTest.java deleted file mode 100644 index c385efc1df9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroupsTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.Date; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateHotspotAdminPermissionOnTemplatesGroupsTest { - - private static final Date PAST = new Date(100_000_000_000L); - private static final Date NOW = new Date(500_000_000_000L); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateHotspotAdminPermissionOnTemplatesGroupsTest.class, "perm_templates_groups.sql"); - - private System2 system2 = mock(System2.class); - - private PopulateHotspotAdminPermissionOnTemplatesGroups underTest = new PopulateHotspotAdminPermissionOnTemplatesGroups(db.database(), system2); - - @Test - public void insert_missing_permission() throws SQLException { - when(system2.now()).thenReturn(NOW.getTime()); - insertPermTemplateGroupRole(1, 2, "noissueadmin"); - insertPermTemplateGroupRole(3, 4, "issueadmin"); - insertPermTemplateGroupRole(3, 4, "another"); - insertPermTemplateGroupRole(5, 6, "securityhotspotadmin"); - - underTest.execute(); - - assertPermTemplateGroupRoles( - tuple(1L, 2L, "noissueadmin", PAST, PAST), - tuple(3L, 4L, "issueadmin", PAST, PAST), - tuple(3L, 4L, "another", PAST, PAST), - tuple(3L, 4L, "securityhotspotadmin", NOW, NOW), - tuple(5L, 6L, "securityhotspotadmin", PAST, PAST)); - } - - private void insertPermTemplateGroupRole(int templateId, int groupId, String role) { - db.executeInsert( - "PERM_TEMPLATES_GROUPS", - "TEMPLATE_ID", templateId, - "GROUP_ID", groupId, - "PERMISSION_REFERENCE", role, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private void assertPermTemplateGroupRoles(Tuple... expectedTuples) { - assertThat(db.select("SELECT TEMPLATE_ID, GROUP_ID, PERMISSION_REFERENCE, CREATED_AT, UPDATED_AT FROM PERM_TEMPLATES_GROUPS") - .stream() - .map(map -> new Tuple(map.get("TEMPLATE_ID"), map.get("GROUP_ID"), map.get("PERMISSION_REFERENCE"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsersTest.java deleted file mode 100644 index 8528d0a1865..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsersTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.Date; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateHotspotAdminPermissionOnTemplatesUsersTest { - - private static final Date PAST = new Date(100_000_000_000L); - private static final Date NOW = new Date(500_000_000_000L); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateHotspotAdminPermissionOnTemplatesUsersTest.class, "perm_templates_users.sql"); - - private System2 system2 = mock(System2.class); - - private PopulateHotspotAdminPermissionOnTemplatesUsers underTest = new PopulateHotspotAdminPermissionOnTemplatesUsers(db.database(), system2); - - @Test - public void insert_missing_permission() throws SQLException { - when(system2.now()).thenReturn(NOW.getTime()); - insertPermTemplateUserRole(1, 2, "noissueadmin"); - insertPermTemplateUserRole(3, 4, "issueadmin"); - insertPermTemplateUserRole(3, 4, "another"); - insertPermTemplateUserRole(5, 6, "securityhotspotadmin"); - - underTest.execute(); - - assertPermTemplateUserRoles( - tuple(1L, 2L, "noissueadmin", PAST, PAST), - tuple(3L, 4L, "issueadmin", PAST, PAST), - tuple(3L, 4L, "another", PAST, PAST), - tuple(3L, 4L, "securityhotspotadmin", NOW, NOW), - tuple(5L, 6L, "securityhotspotadmin", PAST, PAST)); - } - - private void insertPermTemplateUserRole(int templateId, int userId, String role) { - db.executeInsert( - "PERM_TEMPLATES_USERS", - "TEMPLATE_ID", templateId, - "USER_ID", userId, - "PERMISSION_REFERENCE", role, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private void assertPermTemplateUserRoles(Tuple... expectedTuples) { - assertThat(db.select("SELECT TEMPLATE_ID, USER_ID, PERMISSION_REFERENCE, CREATED_AT, UPDATED_AT FROM PERM_TEMPLATES_USERS") - .stream() - .map(map -> new Tuple(map.get("TEMPLATE_ID"), map.get("USER_ID"), map.get("PERMISSION_REFERENCE"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsersTest.java deleted file mode 100644 index 2d0d6ece189..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsersTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; - -public class PopulateHotspotAdminPermissionOnUsersTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateHotspotAdminPermissionOnUsersTest.class, "user_roles.sql"); - - private PopulateHotspotAdminPermissionOnUsers underTest = new PopulateHotspotAdminPermissionOnUsers(db.database()); - - @Test - public void insert_missing_permission() throws SQLException { - insertUserRole("uuid", 1, 2, "noissueadmin"); - insertUserRole("uuid", 3, 4, "issueadmin"); - insertUserRole("uuid", 3, 4, "another"); - insertUserRole("uuid2", 5, 6, "securityhotspotadmin"); - - underTest.execute(); - - assertUserRoles( - tuple("uuid", 1L, 2L, "noissueadmin"), - tuple("uuid", 3L, 4L, "issueadmin"), - tuple("uuid", 3L, 4L, "another"), - tuple("uuid", 3L, 4L, "securityhotspotadmin"), - tuple("uuid2", 5L, 6L, "securityhotspotadmin")); - } - - private void insertUserRole(String orgaUuid, int userId, int resourceId, String role) { - db.executeInsert( - "USER_ROLES", - "ORGANIZATION_UUID", orgaUuid, - "USER_ID", userId, - "RESOURCE_ID", resourceId, - "ROLE", role); - } - - private void assertUserRoles(Tuple... expectedTuples) { - assertThat(db.select("SELECT ORGANIZATION_UUID, USER_ID, RESOURCE_ID, ROLE FROM USER_ROLES") - .stream() - .map(map -> new Tuple(map.get("ORGANIZATION_UUID"), map.get("USER_ID"), map.get("RESOURCE_ID"), map.get("ROLE"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranchesTest.java deleted file mode 100644 index 83a78d80beb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranchesTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateMainApplicationBranchesTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateMainApplicationBranchesTest.class, "schema.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateMainApplicationBranches underTest = new PopulateMainApplicationBranches(db.database(), system2); - - @Test - public void migrate() throws SQLException { - String project = insertApplication(); - - underTest.execute(); - - assertProjectBranches(tuple("master", project, project, "LONG", NOW, NOW)); - } - - @Test - public void does_nothing_on_non_applications() throws SQLException { - insertComponent(null, "BRC"); - insertComponent(null, "VW"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("project_branches")).isZero(); - } - - @Test - public void does_nothing_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("project_branches")).isZero(); - } - - @Test - public void does_nothing_if_already_migrated() throws SQLException { - String application = insertApplication(); - insertMainBranch(application); - - underTest.execute(); - - assertProjectBranches(tuple("master", application, application, "LONG", PAST, PAST)); - } - - private void assertProjectBranches(Tuple... expectedTuples) { - assertThat(db.select("SELECT KEE, UUID, PROJECT_UUID, BRANCH_TYPE, CREATED_AT, UPDATED_AT FROM PROJECT_BRANCHES") - .stream() - .map(row -> new Tuple(row.get("KEE"), row.get("UUID"), row.get("PROJECT_UUID"), row.get("BRANCH_TYPE"), row.get("CREATED_AT"), row.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private String insertApplication() { - return insertComponent(null, "APP"); - } - - private String insertComponent(@Nullable String mainBranchUuid, String qualifier) { - String uuid = Uuids.createFast(); - db.executeInsert("PROJECTS", - "ORGANIZATION_UUID", "default-org", - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", mainBranchUuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", "true", - "SCOPE", "PRJ", - "QUALIFIER", qualifier); - return uuid; - } - - private void insertMainBranch(String uuid) { - db.executeInsert("PROJECT_BRANCHES", - "UUID", uuid, - "PROJECT_UUID", uuid, - "KEE", "master", - "KEY_TYPE", "BRANCH", - "BRANCH_TYPE", "LONG", - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizationsTest.java deleted file mode 100644 index f86ee0f6811..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizationsTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.config.internal.MapSettings; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateSubscriptionOnOrganizationsTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateSubscriptionOnOrganizationsTest.class, "schema.sql"); - - private MapSettings settings = new MapSettings(); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateSubscriptionOnOrganizations underTest = new PopulateSubscriptionOnOrganizations(db.database(), system2, settings.asConfig()); - - @Test - public void set_organization_as_paid_when_containing_only_private_projects_on_sonarcloud() throws SQLException { - setSonarCloud(); - String organization1 = insertOrganization(Uuids.createFast(), null); - insertProject(organization1, true); - insertProject(organization1, true); - String organization2 = insertOrganization(Uuids.createFast(), null); - insertProject(organization2, true); - - underTest.execute(); - - assertOrganizations( - tuple(organization1, "PAID", NOW), - tuple(organization2, "PAID", NOW)); - } - - @Test - public void set_organization_as_free_when_containing_no_private_projects_on_sonarcloud() throws SQLException { - setSonarCloud(); - String organization1 = insertOrganization(Uuids.createFast(), null); - insertProject(organization1, false); - insertProject(organization1, false); - String organization2 = insertOrganization(Uuids.createFast(), null); - - underTest.execute(); - - assertOrganizations( - tuple(organization1, "FREE", NOW), - tuple(organization2, "FREE", NOW)); - } - - @Test - public void does_nothing_when_subscription_is_already_set_on_sonarcloud() throws SQLException { - setSonarCloud(); - String organization1 = insertOrganization(Uuids.createFast(), "PAID"); - insertProject(organization1, true); - insertProject(organization1, true); - String organization2 = insertOrganization(Uuids.createFast(), "FREE"); - insertProject(organization2, false); - - underTest.execute(); - - assertOrganizations( - tuple(organization1, "PAID", PAST), - tuple(organization2, "FREE", PAST)); - } - - @Test - public void migration_is_reentrant_on_sonarcloud() throws SQLException { - setSonarCloud(); - String organization1 = insertOrganization(Uuids.createFast(), null); - insertProject(organization1, true); - insertProject(organization1, true); - String organization2 = insertOrganization(Uuids.createFast(), null); - insertProject(organization2, false); - - underTest.execute(); - underTest.execute(); - - assertOrganizations( - tuple(organization1, "PAID", NOW), - tuple(organization2, "FREE", NOW)); - } - - @Test - public void set_organization_as_sonarqube() throws SQLException { - String defaultOrganization = insertOrganization(Uuids.createFast(), null); - - underTest.execute(); - - assertOrganizations(tuple(defaultOrganization, "SONARQUBE", NOW)); - } - - @Test - public void does_nothing_when_subscription_is_already_set_on_sonarqube() throws SQLException { - String defaultOrganization = insertOrganization(Uuids.createFast(), "SONARQUBE"); - - underTest.execute(); - - assertOrganizations(tuple(defaultOrganization, "SONARQUBE", PAST)); - } - - @Test - public void migration_is_reentrant_on_sonarqube() throws SQLException { - String defaultOrganization = insertOrganization(Uuids.createFast(), null); - - underTest.execute(); - underTest.execute(); - - assertOrganizations(tuple(defaultOrganization, "SONARQUBE", NOW)); - } - - private void assertOrganizations(Tuple... expectedTuples) { - assertThat(db.select("SELECT UUID, SUBSCRIPTION, UPDATED_AT FROM ORGANIZATIONS") - .stream() - .map(row -> new Tuple(row.get("UUID"), row.get("SUBSCRIPTION"), row.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private String insertOrganization(String uuid, @Nullable String subscription) { - db.executeInsert("ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "SUBSCRIPTION", subscription, - "GUARDED", false, - "DEFAULT_QUALITY_GATE_UUID", "QGATE_UUID", - "NEW_PROJECT_PRIVATE", false, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return uuid; - } - - private void insertProject(String organizationUuid, boolean isPrivate) { - String uuid = Uuids.createFast(); - db.executeInsert("PROJECTS", - "ORGANIZATION_UUID", organizationUuid, - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", uuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(isPrivate), - "SCOPE", "PRJ", - "QUALIFIER", "PRJ"); - } - - private void setSonarCloud() { - settings.setProperty("sonar.sonarcloud.enabled", true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullableTest.java deleted file mode 100644 index 94c61f95777..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v73; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class SetSubscriptionOnOrganizationsNotNullableTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(SetSubscriptionOnOrganizationsNotNullableTest.class, "organizations.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private SetSubscriptionOnOrganizationsNotNullable underTest = new SetSubscriptionOnOrganizationsNotNullable(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("organizations", "subscription", VARCHAR, 40, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadataTest.java deleted file mode 100644 index 09e7dee163d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadataTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.CLOB; -import static java.sql.Types.TINYINT; -import static java.sql.Types.VARCHAR; - -public class AddAdHocColumnsInInRulesMetadataTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddAdHocColumnsInInRulesMetadataTest.class, "rules_metadata.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddAdHocColumnsInInRulesMetadata underTest = new AddAdHocColumnsInInRulesMetadata(db.database()); - - @Test - public void columns_are_updated() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_metadata", "ad_hoc_name", VARCHAR, 200, true); - db.assertColumnDefinition("rules_metadata", "ad_hoc_description", CLOB, null, true); - db.assertColumnDefinition("rules_metadata", "ad_hoc_severity", VARCHAR, 10, true); - db.assertColumnDefinition("rules_metadata", "ad_hoc_type", TINYINT, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest.java deleted file mode 100644 index f50108a334d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import java.util.Date; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.config.internal.MapSettings; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProvider; -import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest.class, - "group_roles_and_internal_properties.sql"); - - private UuidFactoryFast uuidFactoryFast = UuidFactoryFast.getInstance(); - private MapSettings settings = new MapSettings(); - private DefaultOrganizationUuidProvider defaultOrganizationUuidProvider = new DefaultOrganizationUuidProviderImpl(); - private AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator underTest = new AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator(db.database(), settings.asConfig(), - defaultOrganizationUuidProvider); - - @Test - public void is_reentrant() throws SQLException { - String orgUuid = uuidFactoryFast.create(); - insertDefaultOrganizationUuid(orgUuid); - insertGroup(orgUuid, "sonar-administrators"); - Long adminGroupId = getGroupId("sonar-administrators"); - - underTest.execute(); - underTest.execute(); - - assertGroupRoles( - tuple(orgUuid, adminGroupId, null, "applicationcreator"), - tuple(orgUuid, adminGroupId, null, "portfoliocreator")); - } - - @Test - public void create_missing_permissions() throws SQLException { - String orgUuid = uuidFactoryFast.create(); - insertDefaultOrganizationUuid(orgUuid); - insertGroup(orgUuid, "sonar-administrators"); - Long adminGroupId = getGroupId("sonar-administrators"); - - underTest.execute(); - - assertGroupRoles( - tuple(orgUuid, adminGroupId, null, "applicationcreator"), - tuple(orgUuid, adminGroupId, null, "portfoliocreator")); - } - - @Test - public void has_no_effect_if_group_does_not_exist() throws SQLException { - String orgUuid = uuidFactoryFast.create(); - insertDefaultOrganizationUuid(orgUuid); - insertGroup(orgUuid, "sonar"); - - underTest.execute(); - - assertGroupRoles(); - } - - @Test - public void has_no_effect_if_roles_are_already_present() throws SQLException { - String orgUuid = uuidFactoryFast.create(); - insertDefaultOrganizationUuid(orgUuid); - insertGroup(orgUuid, "sonar-administrators"); - Long adminGroupId = getGroupId("sonar-administrators"); - insertGroupRole(orgUuid, adminGroupId, null, "applicationcreator"); - insertGroupRole(orgUuid, adminGroupId, null, "portfoliocreator"); - - underTest.execute(); - - assertGroupRoles( - tuple(orgUuid, adminGroupId, null, "applicationcreator"), - tuple(orgUuid, adminGroupId, null, "portfoliocreator")); - } - - @Test - public void has_no_effect_on_SonarCloud() throws SQLException { - settings.setProperty("sonar.sonarcloud.enabled", true); - underTest.execute(); - assertGroupRoles(); - } - - private void insertDefaultOrganizationUuid(String uuid) { - db.executeInsert("INTERNAL_PROPERTIES", - "KEE", "organization.default", - "IS_EMPTY", false, - "TEXT_VALUE", uuid, - "CREATED_AT", System.currentTimeMillis()); - } - - private void insertGroup(String organizationUuid, String name) { - db.executeInsert("GROUPS", - "ORGANIZATION_UUID", organizationUuid, - "NAME", name, - "CREATED_AT", new Date(), - "UPDATED_AT", new Date()); - } - - private void insertGroupRole(String organizationUuid, @Nullable Long groupId, @Nullable Integer resourceId, String role) { - db.executeInsert("GROUP_ROLES", - "ORGANIZATION_UUID", organizationUuid, - "GROUP_ID", groupId, - "RESOURCE_ID", resourceId, - "ROLE", role); - } - - private Long getGroupId(String groupName) { - return (Long) db.selectFirst("SELECT id FROM groups WHERE name = '" + groupName + "'").get("ID"); - } - - private void assertGroupRoles(Tuple... expectedTuples) { - assertThat(db.select("SELECT organization_uuid, group_id, resource_id, role FROM group_roles") - .stream() - .map(row -> new Tuple(row.get("ORGANIZATION_UUID"), row.get("GROUP_ID"), row.get("RESOURCE_ID"), row.get("ROLE"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizationsTest.java deleted file mode 100644 index 6dfb8748a84..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizationsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddDefaultPermTemplateColumnsToOrganizationsTest { - - @Rule - public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddDefaultPermTemplateColumnsToOrganizationsTest.class, "previous-organizations.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddDefaultPermTemplateColumnsToOrganizations underTest = new AddDefaultPermTemplateColumnsToOrganizations(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("organizations", "default_perm_template_app", Types.VARCHAR, 40, true); - dbTester.assertColumnDefinition("organizations", "default_perm_template_port", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRulesTest.java deleted file mode 100644 index f9e4931b8ef..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRulesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; - -public class AddIsAdHocToRulesTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddIsAdHocToRulesTest.class, "rules.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIsAdHocToRules underTest = new AddIsAdHocToRules(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules", "is_ad_hoc", BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivityTest.java deleted file mode 100644 index 0e0450b724c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivityTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddTmpColumnsToCeActivityTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddTmpColumnsToCeActivityTest.class, "ce_activity.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddTmpColumnsToCeActivity underTest = new AddTmpColumnsToCeActivity(db.database()); - - @Test - public void columns_and_indexes_are_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_activity", "tmp_component_uuid", VARCHAR, 40, true); - db.assertColumnDefinition("ce_activity", "tmp_main_component_uuid", VARCHAR, 40, true); - db.assertIndex("ce_activity", "ce_activity_tmp_cpnt_uuid", "tmp_component_uuid"); - db.assertIndex("ce_activity", "ce_activity_tmp_main_cpnt_uuid", "tmp_main_component_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueueTest.java deleted file mode 100644 index 4a1d56992f6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueueTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddTmpColumnsToCeQueueTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddTmpColumnsToCeQueueTest.class, "ce_queue.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddTmpColumnsToCeQueue underTest = new AddTmpColumnsToCeQueue(db.database()); - - @Test - public void columns_and_indexes_are_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_queue", "tmp_component_uuid", VARCHAR, 40, true); - db.assertColumnDefinition("ce_queue", "tmp_main_component_uuid", VARCHAR, 40, true); - db.assertIndex("ce_queue", "ce_queue_tmp_cpnt_uuid", "tmp_component_uuid"); - db.assertIndex("ce_queue", "ce_queue_tmp_main_cpnt_uuid", "tmp_main_component_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivityTest.java deleted file mode 100644 index a5e9f77d0b4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivityTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; -import static java.sql.Types.VARCHAR; - -public class AddTmpLastKeyColumnsToCeActivityTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddTmpLastKeyColumnsToCeActivityTest.class, "ce_activity.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddTmpLastKeyColumnsToCeActivity underTest = new AddTmpLastKeyColumnsToCeActivity(db.database()); - - @Test - public void columns_and_indexes_are_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_activity", "tmp_is_last", BOOLEAN, null, true); - db.assertColumnDefinition("ce_activity", "tmp_is_last_key", VARCHAR, 55, true); - db.assertColumnDefinition("ce_activity", "tmp_main_is_last", BOOLEAN, null, true); - db.assertColumnDefinition("ce_activity", "tmp_main_is_last_key", VARCHAR, 55, true); - db.assertIndex("ce_activity", "ce_activity_t_islast_key", "tmp_is_last_key"); - db.assertIndex("ce_activity", "ce_activity_t_main_islast", "tmp_main_is_last", "status"); - db.assertIndex("ce_activity", "ce_activity_t_main_islast_key", "tmp_main_is_last_key"); - db.assertIndex("ce_activity", "ce_activity_t_main_islast", "tmp_main_is_last", "status"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTablesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTablesTest.java deleted file mode 100644 index 51361b81e2b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTablesTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import java.util.Random; -import java.util.stream.IntStream; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.config.internal.MapSettings; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; - -public class CleanOrphanRowsInCeTablesTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInCeTablesTest.class, "ce_tables.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private Random random = new Random(); - private MapSettings settings = new MapSettings(); - private CleanOrphanRowsInCeTables underTest = new CleanOrphanRowsInCeTables(db.database(), settings.asConfig()); - - @Test - public void execute_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - } - - @Test - public void execute_deletes_rows_of_ce_activity_and_child_tables_which_have_main_component_equals_component_and_at_least_one_characteristic() throws SQLException { - String projectUuid = randomAlphabetic(10); - String branchUuid = randomAlphanumeric(11); - String mainBranchTask = insertCeActivity(projectUuid, projectUuid, 0); - String existingBranchTask = insertCeActivity(projectUuid, branchUuid, 1 + new Random().nextInt(10)); - String nonExistingBranchTask = insertCeActivity(projectUuid, projectUuid, 1 + new Random().nextInt(10)); - String missingTask = "missing_task"; - Stream.of(mainBranchTask, existingBranchTask, nonExistingBranchTask, missingTask) - .forEach(taskUuid -> { - insertCeTaskInput(taskUuid); - insertCeScannerContext(taskUuid); - }); - insertCeTaskCharacteristics(missingTask); - - underTest.execute(); - - assertThat(uuidsOf("ce_activity")).containsOnly(mainBranchTask, existingBranchTask); - assertThat(taskUuidsOf("ce_task_input")).containsOnly(mainBranchTask, existingBranchTask, missingTask); - assertThat(taskUuidsOf("ce_scanner_context")).containsOnly(mainBranchTask, existingBranchTask, missingTask); - assertThat(taskUuidsOf("ce_task_characteristics")).containsOnly(existingBranchTask, missingTask); - } - - @Test - public void execute_has_no_effect_on_SonarCloud() throws SQLException { - String projectUuid = randomAlphabetic(10); - String branchUuid = randomAlphanumeric(11); - String mainBranchTask = insertCeActivity(projectUuid, projectUuid, 0); - String existingBranchTask = insertCeActivity(projectUuid, branchUuid, 1 + new Random().nextInt(10)); - String nonExistingBranchTask = insertCeActivity(projectUuid, projectUuid, 1 + new Random().nextInt(10)); - String missingTask = "missing_task"; - Stream.of(mainBranchTask, existingBranchTask, nonExistingBranchTask, missingTask) - .forEach(taskUuid -> { - insertCeTaskInput(taskUuid); - insertCeScannerContext(taskUuid); - }); - insertCeTaskCharacteristics(missingTask); - settings.setProperty("sonar.sonarcloud.enabled", true); - - underTest.execute(); - - assertThat(uuidsOf("ce_activity")).containsOnly(mainBranchTask, existingBranchTask, nonExistingBranchTask); - assertThat(taskUuidsOf("ce_task_input")).containsOnly(mainBranchTask, existingBranchTask, nonExistingBranchTask, missingTask); - assertThat(taskUuidsOf("ce_scanner_context")).containsOnly(mainBranchTask, existingBranchTask, nonExistingBranchTask, missingTask); - assertThat(taskUuidsOf("ce_task_characteristics")).containsOnly(existingBranchTask, nonExistingBranchTask, missingTask); - } - - @Test - public void execute_is_reentrant() throws SQLException { - String projectUuid = randomAlphabetic(10); - String branchUuid = randomAlphanumeric(11); - String mainBranchTask = insertCeActivity(projectUuid, projectUuid, 0); - String existingBranchTask = insertCeActivity(projectUuid, branchUuid, 1 + new Random().nextInt(10)); - String nonExistingBranchTask = insertCeActivity(projectUuid, projectUuid, 1 + new Random().nextInt(10)); - Stream.of(mainBranchTask, existingBranchTask, nonExistingBranchTask) - .forEach(taskUuid -> { - insertCeTaskInput(taskUuid); - insertCeScannerContext(taskUuid); - }); - underTest.execute(); - - underTest.execute(); - } - - private Stream taskUuidsOf(String tableName) { - return db.select("select distinct task_uuid as \"TASK_UUID\" from " + tableName) - .stream() - .map(r -> (String) r.get("TASK_UUID")); - } - - private Stream uuidsOf(String tableName) { - return db.select("select uuid as \"UUID\" from " + tableName) - .stream() - .map(r -> (String) r.get("UUID")); - } - - private String insertCeActivity(@Nullable String componentUuid, @Nullable String mainComponentUuid, int numberOfCharacteristics) { - String uuid = UuidFactoryFast.getInstance().create(); - db.executeInsert( - "ce_activity", - "UUID", uuid, - "COMPONENT_UUID", componentUuid, - "MAIN_COMPONENT_UUID", mainComponentUuid, - "TASK_TYPE", randomAlphanumeric(10), - "STATUS", randomAlphanumeric(10), - "IS_LAST", random.nextBoolean(), - "IS_LAST_KEY", randomAlphanumeric(15), - "EXECUTION_COUNT", random.nextInt(99), - "SUBMITTED_AT", random.nextInt(95654354), - "CREATED_AT", random.nextInt(95654354), - "UPDATED_AT", random.nextInt(95654354)); - - IntStream.range(0, numberOfCharacteristics) - .forEach(i -> insertCeTaskCharacteristic(uuid, i)); - - return uuid; - } - - private void insertCeTaskInput(String taskUuid) { - db.executeInsert( - "ce_task_input", - "TASK_UUID", taskUuid, - "INPUT_DATA", randomAlphanumeric(123).getBytes(), - "CREATED_AT", random.nextInt(95654354), - "UPDATED_AT", random.nextInt(95654354)); - } - - private void insertCeScannerContext(String taskUuid) { - db.executeInsert( - "ce_scanner_context", - "TASK_UUID", taskUuid, - "CONTEXT_DATA", randomAlphanumeric(123).getBytes(), - "CREATED_AT", random.nextInt(95654354), - "UPDATED_AT", random.nextInt(95654354)); - } - - private void insertCeTaskCharacteristics(String taskUuid) { - for (int i = 0; i < 1 + random.nextInt(3); i++) { - insertCeTaskCharacteristic(taskUuid, i); - } - } - - private void insertCeTaskCharacteristic(String taskUuid, int i) { - String uuid = UuidFactoryFast.getInstance().create(); - db.executeInsert( - "ce_task_characteristics", - "UUID", uuid, - "TASK_UUID", taskUuid, - "KEE", "kee_" + uuid + i, - "TEXT_VALUE", randomAlphanumeric(18)); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - // FIXME - underTest.execute(); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissionsTest.java deleted file mode 100644 index b3bcf169aba..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissionsTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import java.util.Date; -import java.util.stream.Collectors; -import org.assertj.core.groups.Tuple; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.api.web.UserRole; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class CreateApplicationsAndPortfoliosCreatorPermissionsTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CreateApplicationsAndPortfoliosCreatorPermissionsTest.class, "perm_templates_groups.sql"); - - private static final Date PAST = new Date(100_000_000_000L); - private static final Date NOW = new Date(500_000_000_000L); - private static final String DEFAULT_ORGANIZATION_UUID = UuidFactoryFast.getInstance().create(); - private static final String DEFAULT_PERM_TEMPLATE_VIEW = "default_view_template"; - private static final String ANOTHER_PERM_TEMPLATE_VIEW = "another_template"; - - private System2 system2 = mock(System2.class); - private CreateApplicationsAndPortfoliosCreatorPermissions underTest = new CreateApplicationsAndPortfoliosCreatorPermissions(db.database(), system2); - - @Before - public void setupDatabase() { - insertDefaultOrganization(); - insertDefaultGroups(); - insertPermissionTemplate(); - } - - - @Test - public void migration_is_reentrant() throws SQLException { - when(system2.now()).thenReturn(NOW.getTime()); - - underTest.execute(); - underTest.execute(); - - Long idOfDefaultPermissionTemplate = getIdOfPermissionTemplate(DEFAULT_PERM_TEMPLATE_VIEW); - Long idOfAdministratorGroup = getIdOfGroup("sonar-administrators"); - - assertPermTemplateGroupRoles( - tuple(idOfDefaultPermissionTemplate, idOfAdministratorGroup, "applicationcreator", NOW, NOW), - tuple(idOfDefaultPermissionTemplate, idOfAdministratorGroup, "portfoliocreator", NOW, NOW)); - } - - @Test - public void insert_missing_permissions() throws SQLException { - when(system2.now()).thenReturn(NOW.getTime()); - - underTest.execute(); - - Long idOfDefaultPermissionTemplate = getIdOfPermissionTemplate(DEFAULT_PERM_TEMPLATE_VIEW); - Long idOfAdministratorGroup = getIdOfGroup("sonar-administrators"); - - assertPermTemplateGroupRoles( - tuple(idOfDefaultPermissionTemplate, idOfAdministratorGroup, "applicationcreator", NOW, NOW), - tuple(idOfDefaultPermissionTemplate, idOfAdministratorGroup, "portfoliocreator", NOW, NOW)); - } - - @Test - public void does_nothing_if_template_group_has_the_permissions_already() throws SQLException { - Long idOfDefaultPermissionTemplate = getIdOfPermissionTemplate(DEFAULT_PERM_TEMPLATE_VIEW); - Long idOfAdministratorGroup = getIdOfGroup("sonar-administrators"); - - insertPermTemplateGroupRole(1, 2, "noissueadmin"); - insertPermTemplateGroupRole(3, 4, "issueadmin"); - insertPermTemplateGroupRole(3, 4, "another"); - insertPermTemplateGroupRole(5, 6, "securityhotspotadmin"); - insertPermTemplateGroupRole(idOfDefaultPermissionTemplate.intValue(), idOfAdministratorGroup.intValue(), "applicationcreator"); - insertPermTemplateGroupRole(idOfDefaultPermissionTemplate.intValue(), idOfAdministratorGroup.intValue(), "portfoliocreator"); - - when(system2.now()).thenReturn(NOW.getTime()); - underTest.execute(); - - assertPermTemplateGroupRoles( - tuple(1L, 2L, "noissueadmin", PAST, PAST), - tuple(3L, 4L, "issueadmin", PAST, PAST), - tuple(3L, 4L, "another", PAST, PAST), - tuple(5L, 6L, "securityhotspotadmin", PAST, PAST), - tuple(idOfDefaultPermissionTemplate, idOfAdministratorGroup, "applicationcreator", PAST, PAST), - tuple(idOfDefaultPermissionTemplate, idOfAdministratorGroup, "portfoliocreator", PAST, PAST)); - } - - @Test - public void insert_missing_permission_keeping_other_template_group_permissions() throws SQLException { - when(system2.now()).thenReturn(NOW.getTime()); - insertPermTemplateGroupRole(1, 2, "noissueadmin"); - insertPermTemplateGroupRole(3, 4, "issueadmin"); - insertPermTemplateGroupRole(3, 4, "another"); - insertPermTemplateGroupRole(5, 6, "securityhotspotadmin"); - - underTest.execute(); - - Long idOfDefaultPermissionTemplate = getIdOfPermissionTemplate(DEFAULT_PERM_TEMPLATE_VIEW); - Long idOfAdministratorGroup = getIdOfGroup("sonar-administrators"); - - assertPermTemplateGroupRoles( - tuple(1L, 2L, "noissueadmin", PAST, PAST), - tuple(3L, 4L, "issueadmin", PAST, PAST), - tuple(3L, 4L, "another", PAST, PAST), - tuple(5L, 6L, "securityhotspotadmin", PAST, PAST), - tuple(idOfDefaultPermissionTemplate, idOfAdministratorGroup, "applicationcreator", NOW, NOW), - tuple(idOfDefaultPermissionTemplate, idOfAdministratorGroup, "portfoliocreator", NOW, NOW)); - } - - private void insertPermTemplateGroupRole(int templateId, int groupId, String role) { - db.executeInsert( - "PERM_TEMPLATES_GROUPS", - "TEMPLATE_ID", templateId, - "GROUP_ID", groupId, - "PERMISSION_REFERENCE", role, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private void insertDefaultGroups() { - db.executeInsert( - "GROUPS", - "NAME", "sonar-administrators", - "CREATED_AT", PAST, - "UPDATED_AT", PAST, - "ORGANIZATION_UUID", DEFAULT_ORGANIZATION_UUID); - db.executeInsert( - "GROUPS", - "NAME", "sonar-users", - "CREATED_AT", PAST, - "UPDATED_AT", PAST, - "ORGANIZATION_UUID", DEFAULT_ORGANIZATION_UUID); - } - - private void insertDefaultOrganization() { - db.executeInsert( - "ORGANIZATIONS", - "UUID", DEFAULT_ORGANIZATION_UUID, - "KEE", "default-organization", - "NAME", "Default Organization", - "GUARDED", true, - "DEFAULT_PERM_TEMPLATE_VIEW", DEFAULT_PERM_TEMPLATE_VIEW, - "DEFAULT_QUALITY_GATE_UUID", UuidFactoryFast.getInstance().create(), - "NEW_PROJECT_PRIVATE", false, - "SUBSCRIPTION", "SONARQUBE", - "CREATED_AT", PAST.getTime(), - "UPDATED_AT", PAST.getTime()); - } - - private void insertPermissionTemplate() { - db.executeInsert( - "PERMISSION_TEMPLATES", - "ORGANIZATION_UUID", DEFAULT_ORGANIZATION_UUID, - "NAME", "Default template for views", - "KEE", DEFAULT_PERM_TEMPLATE_VIEW, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - db.executeInsert( - "PERMISSION_TEMPLATES", - "ORGANIZATION_UUID", DEFAULT_ORGANIZATION_UUID, - "NAME", ANOTHER_PERM_TEMPLATE_VIEW, - "KEE", ANOTHER_PERM_TEMPLATE_VIEW, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - - private Long getIdOfPermissionTemplate(String key) { - return (Long) db.selectFirst("SELECT id FROM permission_templates WHERE kee='" + key + "'") - .get("ID"); - } - - private Long getIdOfGroup(String key) { - return (Long) db.selectFirst("SELECT id FROM groups WHERE name='" + key + "'") - .get("ID"); - } - - private void assertPermTemplateGroupRoles(Tuple... expectedTuples) { - assertThat(db.select("SELECT TEMPLATE_ID, GROUP_ID, PERMISSION_REFERENCE, CREATED_AT, UPDATED_AT FROM PERM_TEMPLATES_GROUPS") - .stream() - .map(map -> new Tuple(map.get("TEMPLATE_ID"), map.get("GROUP_ID"), map.get("PERMISSION_REFERENCE"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessageTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessageTest.java deleted file mode 100644 index ed91f22c194..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessageTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateCeTaskMessageTest { - - private static final String TABLE = "ce_task_message"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateCeTaskMessageTest.class, "empty.sql"); - - private CreateCeTaskMessage underTest = new CreateCeTaskMessage(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", VARCHAR, 40, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - db.assertColumnDefinition(TABLE, "task_uuid", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "message", VARCHAR, 4000, false); - db.assertColumnDefinition(TABLE, "created_at", BIGINT, null, false); - - db.assertIndex(TABLE, TABLE + "_task", "task_uuid"); - } - - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74Test.java deleted file mode 100644 index 01653f4422a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion74Test { - - private DbVersion74 underTest = new DbVersion74(); - - @Test - public void migrationNumber_starts_at_2300() { - verifyMinimumMigrationNumber(underTest, 2300); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 23); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest.java deleted file mode 100644 index 13349dea531..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class DropDefaultPermTemplateViewFromOrganizationsTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(DropDefaultPermTemplateViewFromOrganizationsTest.class, "organizations.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DropDefaultPermTemplateViewFromOrganizations underTest = new DropDefaultPermTemplateViewFromOrganizations(db.database()); - - @Test - public void column_is_removed_from_table() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("organizations", "default_perm_template_view"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest.java deleted file mode 100644 index 8d99b5877ea..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class FinalizeMainComponentUuidColumnsToCeActivityTest { - private static final String TABLE_NAME = "ce_activity"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(FinalizeMainComponentUuidColumnsToCeActivityTest.class, "ce_activity.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private FinalizeMainComponentUuidColumnsToCeActivity underTest = new FinalizeMainComponentUuidColumnsToCeActivity(db.database()); - - @Test - public void columns_and_indexes_are_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist(TABLE_NAME, "tmp_component_uuid"); - db.assertColumnDoesNotExist(TABLE_NAME, "tmp_main_component_uuid"); - db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_tmp_cmpt_uuid"); - db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_tmp_main_cmpt_uuid"); - db.assertColumnDefinition(TABLE_NAME, "component_uuid", VARCHAR, 40, true); - db.assertColumnDefinition(TABLE_NAME, "main_component_uuid", VARCHAR, 40, true); - db.assertIndex(TABLE_NAME, "ce_activity_component", "component_uuid"); - db.assertIndex(TABLE_NAME, "ce_activity_main_component", "main_component_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest.java deleted file mode 100644 index b745e454fa3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class FinalizeMainComponentUuidColumnsToCeQueueTest { - private static final String TABLE_NAME = "ce_queue"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(FinalizeMainComponentUuidColumnsToCeQueueTest.class, "ce_queue.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private FinalizeMainComponentUuidColumnsToCeQueue underTest = new FinalizeMainComponentUuidColumnsToCeQueue(db.database()); - - @Test - public void columns_and_indexes_are_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist(TABLE_NAME, "tmp_component_uuid"); - db.assertColumnDoesNotExist(TABLE_NAME, "tmp_main_component_uuid"); - db.assertIndexDoesNotExist(TABLE_NAME, "ce_queue_tmp_cmpt_uuid"); - db.assertIndexDoesNotExist(TABLE_NAME, "ce_queue_tmp_main_cmpt_uuid"); - db.assertColumnDefinition(TABLE_NAME, "component_uuid", VARCHAR, 40, true); - db.assertColumnDefinition(TABLE_NAME, "main_component_uuid", VARCHAR, 40, true); - db.assertIndex(TABLE_NAME, "ce_queue_component", "component_uuid"); - db.assertIndex(TABLE_NAME, "ce_queue_main_component", "main_component_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest.java deleted file mode 100644 index eaf2a542aea..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; -import static java.sql.Types.VARCHAR; - -public class FinalizeMainLastKeyColumnsToCeActivityTest { - private static final String TABLE_NAME = "ce_activity"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(FinalizeMainLastKeyColumnsToCeActivityTest.class, "ce_activity.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private FinalizeMainLastKeyColumnsToCeActivity underTest = new FinalizeMainLastKeyColumnsToCeActivity(db.database()); - - @Test - public void columns_and_indexes_are_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist(TABLE_NAME, "tmp_is_last"); - db.assertColumnDoesNotExist(TABLE_NAME, "tmp_is_last_key"); - db.assertColumnDoesNotExist(TABLE_NAME, "tmp_main_is_last"); - db.assertColumnDoesNotExist(TABLE_NAME, "tmp_main_is_last_key"); - db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_t_islast_key"); - db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_t_islast"); - db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_t_main_islast_key"); - db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_t_main_islast"); - db.assertColumnDefinition(TABLE_NAME, "is_last", BOOLEAN, null, false); - db.assertColumnDefinition(TABLE_NAME, "is_last_key", VARCHAR, 55, false); - db.assertColumnDefinition(TABLE_NAME, "main_is_last", BOOLEAN, null, false); - db.assertColumnDefinition(TABLE_NAME, "main_is_last_key", VARCHAR, 55, false); - db.assertIndex(TABLE_NAME, "ce_activity_islast_key", "is_last_key"); - db.assertIndex(TABLE_NAME, "ce_activity_islast", "is_last", "status"); - db.assertIndex(TABLE_NAME, "ce_activity_main_islast_key", "main_is_last_key"); - db.assertIndex(TABLE_NAME, "ce_activity_main_islast", "main_is_last", "status"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLengthTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLengthTest.java deleted file mode 100644 index c3314b1df59..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLengthTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class IncreaseOrganizationsKeeAndNameLengthTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(IncreaseOrganizationsKeeAndNameLengthTest.class, "organizations.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private IncreaseOrganizationsKeeAndNameLength underTest = new IncreaseOrganizationsKeeAndNameLength(db.database()); - - @Test - public void column_is_updated() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("organizations", "kee", VARCHAR, 255, false); - db.assertColumnDefinition("organizations", "name", VARCHAR, 255, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizationsTest.java deleted file mode 100644 index 70f4b3844d7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizationsTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateDefaultPermTemplateOnOrganizationsTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateDefaultPermTemplateOnOrganizationsTest.class, "organizations.sql"); - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateDefaultPermTemplateOnOrganizations underTest = new PopulateDefaultPermTemplateOnOrganizations(db.database(), system2); - - @Test - public void test_is_reentrant() throws SQLException { - insertOrganization("aa", "aa-1"); - insertOrganization("bb", null); - underTest.execute(); - underTest.execute(); - - assertOrganizations( - tuple("aa", "aa-1", "aa-1", "aa-1", NOW), - tuple("bb", null, null, null, PAST) - ); - } - - @Test - public void test_with_organizations() throws SQLException { - insertOrganization("aa", "aa-1"); - insertOrganization("bb", "bb-1"); - insertOrganization("cc", null); - - underTest.execute(); - - assertOrganizations( - tuple("aa", "aa-1", "aa-1", "aa-1", NOW), - tuple("bb", "bb-1", "bb-1", "bb-1", NOW), - tuple("cc", null, null, null, PAST) - ); - } - - @Test - public void without_governance_no_modifications() throws SQLException { - insertOrganization("default-organization", null); - - underTest.execute(); - - assertOrganizations( - tuple("default-organization", null, null, null, PAST) - ); - } - - private void assertOrganizations(Tuple... expectedTuples) { - assertThat(db.select("SELECT uuid, default_perm_template_view, default_perm_template_app, default_perm_template_port, updated_at FROM organizations") - .stream() - .map(row -> new Tuple(row.get("UUID"), row.get("DEFAULT_PERM_TEMPLATE_VIEW"), row.get("DEFAULT_PERM_TEMPLATE_APP"), row.get("DEFAULT_PERM_TEMPLATE_PORT"), row.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void insertOrganization(String uuid, @Nullable String defaultPermTemplateView) { - db.executeInsert("ORGANIZATIONS", - "UUID", uuid, - "KEE", uuid, - "NAME", uuid, - "GUARDED", false, - "DEFAULT_PERM_TEMPLATE_VIEW", defaultPermTemplateView, - "DEFAULT_QUALITY_GATE_UUID", "111", - "NEW_PROJECT_PRIVATE", false, - "SUBSCRIPTION", "sonarqube", - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRulesTest.java deleted file mode 100644 index 17282511c53..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRulesTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateIsAdHocOnRulesTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateIsAdHocOnRulesTest.class, "rules.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateIsAdHocOnRules underTest = new PopulateIsAdHocOnRules(db.database(), system2); - - @Test - public void set_is_ad_hoc_to_true_on_external_rules() throws SQLException { - insertRule(1, true, null); - insertRule(2, true, null); - - underTest.execute(); - - assertRules( - tuple(1L, true, true, NOW), - tuple(2L, true, true, NOW)); - } - - @Test - public void set_is_ad_hoc_to_false_on_none_external_rules() throws SQLException { - insertRule(1, false, null); - insertRule(2, false, null); - - underTest.execute(); - - assertRules( - tuple(1L, false, false, NOW), - tuple(2L, false, false, NOW)); - } - - @Test - public void does_nothing_when_is_ad_hoc_is_already_set() throws SQLException { - insertRule(1, true, true); - insertRule(2, false, false); - - underTest.execute(); - - assertRules( - tuple(1L, true, true, PAST), - tuple(2L, false, false, PAST)); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - insertRule(1, true, null); - insertRule(2, false, null); - - underTest.execute(); - underTest.execute(); - - assertRules( - tuple(1L, true, true, NOW), - tuple(2L, false, false, NOW)); - } - - private void assertRules(Tuple... expectedTuples) { - assertThat(db.select("SELECT ID, IS_EXTERNAL, IS_AD_HOC, UPDATED_AT FROM RULES") - .stream() - .map(row -> new Tuple(row.get("ID"), row.get("IS_EXTERNAL"), row.get("IS_AD_HOC"), row.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void insertRule(int id, boolean isEternal, @Nullable Boolean isAdHoc) { - db.executeInsert("RULES", - "ID", id, - "IS_EXTERNAL", isEternal, - "IS_AD_HOC", isAdHoc, - "PLUGIN_RULE_KEY", randomAlphanumeric(3), - "PLUGIN_NAME", randomAlphanumeric(3), - "SCOPE", "MAIN", - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRulesTest.java deleted file mode 100644 index 72104c6da71..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRulesTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateNullValuesOfIsExternalOnRulesTest { - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateNullValuesOfIsExternalOnRulesTest.class, "rules.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private PopulateNullValuesOfIsExternalOnRules underTest = new PopulateNullValuesOfIsExternalOnRules(db.database(), system2); - - @Test - public void set_is_external_to_false() throws SQLException { - insertRule(1, null); - insertRule(2, null); - - underTest.execute(); - - assertRules( - tuple(1L, false, NOW), - tuple(2L, false, NOW)); - } - - @Test - public void does_nothing_when_is_external_is_already_set() throws SQLException { - insertRule(1, true); - insertRule(2, false); - - underTest.execute(); - - assertRules( - tuple(1L, true, PAST), - tuple(2L, false, PAST)); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - insertRule(1, null); - - underTest.execute(); - underTest.execute(); - - assertRules( - tuple(1L, false, NOW)); - } - - private void assertRules(Tuple... expectedTuples) { - assertThat(db.select("SELECT ID, IS_EXTERNAL, UPDATED_AT FROM RULES") - .stream() - .map(row -> new Tuple(row.get("ID"), row.get("IS_EXTERNAL"), row.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void insertRule(int id, @Nullable Boolean isEternal) { - db.executeInsert("RULES", - "ID", id, - "IS_EXTERNAL", isEternal, - "PLUGIN_RULE_KEY", randomAlphanumeric(3), - "PLUGIN_NAME", randomAlphanumeric(3), - "SCOPE", "MAIN", - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivityTest.java deleted file mode 100644 index 74de07f1477..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivityTest.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import com.google.common.collect.ImmutableMap; -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.Collections; -import java.util.Map; -import java.util.Random; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.sonar.db.CoreDbTester; - -import static java.util.Arrays.stream; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(DataProviderRunner.class) -public class PopulateTmpColumnsToCeActivityTest { - private static final Map NO_CHARACTERISTICS = Collections.emptyMap(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateTmpColumnsToCeActivityTest.class, "ce_activity.sql"); - - private PopulateTmpColumnsToCeActivity underTest = new PopulateTmpColumnsToCeActivity(db.database()); - - @Test - public void execute_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(rowsInCeActivity()).isEmpty(); - } - - @Test - @UseDataProvider("characteriticsOfMainBranchesAndPr") - public void execute_populates_tmp_columns_with_component_uuid_if_task_has_no_row_in_PROJECTS(Map characteristics) throws SQLException { - Row[] notUpdatedRows = Stream.of( - // not updated because no component_uuid - new Row(newUuid(), null, null, null), - new Row(newUuid(), null, randomAlphabetic(2), null), - new Row(newUuid(), null, randomAlphabetic(3), randomAlphabetic(4)), - new Row(newUuid(), null, null, randomAlphabetic(5)), - // not updated because both target fields are already set (re-entrance) - new Row(newUuid(), randomAlphabetic(14), randomAlphabetic(6), randomAlphabetic(7))) - .toArray(Row[]::new); - Row[] updatedRows = { - new Row(newUuid(), randomAlphabetic(12), null, null), - new Row(newUuid(), randomAlphabetic(13), randomAlphabetic(5), null), - new Row(newUuid(), randomAlphabetic(14), null, randomAlphabetic(6)), - }; - stream(notUpdatedRows).forEach(row -> insertCeActivity(row, characteristics)); - stream(updatedRows).forEach(row -> insertCeActivity(row, characteristics)); - - underTest.execute(); - - assertThat(rowsInCeActivity()) - .hasSize(notUpdatedRows.length + updatedRows.length) - .contains(notUpdatedRows) - .contains(stream(updatedRows) - .map(row -> new Row(row.taskUuid, row.componentUuid, row.componentUuid, row.componentUuid)) - .toArray(Row[]::new)); - } - - @DataProvider - public static Object[][] characteriticsOfMainBranchesAndPr() { - return new Object[][] { - {NO_CHARACTERISTICS}, - {branchCharacteristics("LONG", randomAlphabetic(15))}, - {branchCharacteristics("SHORT", randomAlphabetic(16))}, - {branchCharacteristics(randomAlphabetic(17), randomAlphabetic(18))}, - {prCharacteristics(randomAlphabetic(19))}, - }; - } - - @Test - public void execute_populates_tmp_columns_with_component_uuid_for_existing_main_branch() throws SQLException { - String mainComponentUuid = randomAlphabetic(2); - insertProjects(mainComponentUuid, randomAlphabetic(3)); - String taskUuid = insertCeActivity(new Row(newUuid(), mainComponentUuid, null, null), NO_CHARACTERISTICS); - - underTest.execute(); - - assertThat(rowsInCeActivity()) - .containsOnly(new Row(taskUuid, mainComponentUuid, mainComponentUuid, mainComponentUuid)); - } - - @Test - public void execute_deletes_populates_branches_of_task_without_row_in_PROJECTS_with_COMPONENT_UUID_and_those_with_row_in_PROJECTS_by_KEE() throws SQLException { - String mainComponentUuid = randomAlphabetic(2); - String mainComponentKey = randomAlphabetic(3); - String branchUuid = randomAlphabetic(4); - String branchType1 = randomAlphabetic(5); - String branchName1 = randomAlphabetic(6); - String branchType2 = randomAlphabetic(7); - String branchName2 = randomAlphabetic(8); - insertProjects(mainComponentUuid, mainComponentKey); - insertProjects(branchUuid, mainComponentKey + ":BRANCH:" + branchName2); - String orphanTaskUuid = insertCeActivity(new Row(newUuid(), mainComponentUuid, null, null), branchCharacteristics(branchType1, branchName1)); - String regularTaskUuid = insertCeActivity(new Row(newUuid(), mainComponentUuid, null, null), branchCharacteristics(branchType2, branchName2)); - - underTest.execute(); - - assertThat(rowsInCeActivity()) - .containsOnly( - new Row(orphanTaskUuid, mainComponentUuid, mainComponentUuid, mainComponentUuid), - new Row(regularTaskUuid, mainComponentUuid, branchUuid, mainComponentUuid)); - } - - @Test - public void execute_deletes_populates_prs_of_task_without_row_in_PROJECTS_with_COMPONENT_UUID_and_those_with_row_in_PROJECTS_by_KEE() throws SQLException { - String mainComponentUuid = randomAlphabetic(2); - String mainComponentKey = randomAlphabetic(3); - String prUuid = randomAlphabetic(4); - String prName1 = randomAlphabetic(6); - String prName2 = randomAlphabetic(8); - insertProjects(mainComponentUuid, mainComponentKey); - insertProjects(prUuid, mainComponentKey + ":PULL_REQUEST:" + prName2); - String orphanTaskUuid = insertCeActivity(new Row(newUuid(), mainComponentUuid, null, null), prCharacteristics(prName1)); - String regularTaskUuid = insertCeActivity(new Row(newUuid(), mainComponentUuid, null, null), prCharacteristics(prName2)); - - underTest.execute(); - - assertThat(rowsInCeActivity()) - .containsOnly( - new Row(orphanTaskUuid, mainComponentUuid, mainComponentUuid, mainComponentUuid), - new Row(regularTaskUuid, mainComponentUuid, prUuid, mainComponentUuid)); - } - - private Stream rowsInCeActivity() { - return db.select("select" + - " uuid as \"UUID\", component_uuid as \"COMPONENT_UUID\", tmp_component_uuid as \"TMP_COMPONENT_UUID\", tmp_main_component_UUID as \"TMP_MAIN_COMPONENT_UUID\"" + - " from ce_activity") - .stream() - .map(row -> new Row( - (String) row.get("UUID"), - (String) row.get("COMPONENT_UUID"), - (String) row.get("TMP_COMPONENT_UUID"), - (String) row.get("TMP_MAIN_COMPONENT_UUID"))); - } - - private String insertCeActivity(Row row, Map characteristics) { - String uuid = insertCeActivity(row.taskUuid, row.componentUuid, row.tmpComponentUuid, row.tmpMainComponentUuid); - characteristics.forEach((key, value) -> insertCeCharacteristic(uuid, key, value)); - return uuid; - } - - private String insertCeActivity(String uuid, @Nullable String componentUuid, @Nullable String tmpComponentUuid, @Nullable String tmpMainComponentUuid) { - Random random = new Random(); - db.executeInsert("ce_activity", - "UUID", uuid, - "TASK_TYPE", randomAlphabetic(6), - "COMPONENT_UUID", componentUuid, - "TMP_COMPONENT_UUID", tmpComponentUuid, - "TMP_MAIN_COMPONENT_UUID", tmpMainComponentUuid, - "STATUS", randomAlphabetic(7), - "IS_LAST", random.nextBoolean(), - "IS_LAST_KEY", random.nextBoolean(), - "EXECUTION_COUNT", random.nextInt(500), - "SUBMITTED_AT", (long) random.nextInt(500), - "CREATED_AT", (long) random.nextInt(500), - "UPDATED_AT", (long) random.nextInt(500)); - return uuid; - } - - private void insertCeCharacteristic(String taskUuid, String key, String value) { - db.executeInsert( - "ce_task_characteristics", - "UUID", newUuid(), - "TASK_UUID", taskUuid, - "KEE", key, - "TEXT_VALUE", value); - } - - private void insertProjects(String uuid, String key) { - db.executeInsert( - "PROJECTS", - "UUID", uuid, - "KEE", key, - "ORGANIZATION_UUID", "org_" + uuid, - "ROOT_UUID", uuid + "_root", - "UUID_PATH", uuid + "_path", - "PROJECT_UUID", uuid + "_project", - "PRIVATE", new Random().nextBoolean()); - } - - private int uuidGenerator = new Random().nextInt(9000); - - private String newUuid() { - return "uuid_" + uuidGenerator++; - } - - private static Map branchCharacteristics(String branchType, String branchName) { - return ImmutableMap.of("branchType", branchType, "branch", branchName); - } - - private static Map prCharacteristics(String prName) { - return ImmutableMap.of("pullRequest", prName); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueueTest.java deleted file mode 100644 index b475392be54..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueueTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import com.google.common.collect.ImmutableMap; -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.Collections; -import java.util.Map; -import java.util.Random; -import java.util.stream.Stream; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.sonar.db.CoreDbTester; - -import static java.util.Arrays.stream; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(DataProviderRunner.class) -public class PopulateTmpColumnsToCeQueueTest { - private static final Map NO_CHARACTERISTICS = Collections.emptyMap(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateTmpColumnsToCeQueueTest.class, "ce_queue.sql"); - - private PopulateTmpColumnsToCeQueue underTest = new PopulateTmpColumnsToCeQueue(db.database()); - - @Test - public void no_action_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("ce_queue")).isZero(); - } - - @Test - @UseDataProvider("characteriticsOfMainBranchesAndPr") - public void execute_populates_tmp_columns_with_component_uuid_if_task_has_no_row_in_PROJECTS(Map characteristics) throws SQLException { - Row[] notUpdatedRows = Stream.of( - // not updated because no component_uuid - new Row(newUuid(), null, null, null), - new Row(newUuid(), null, randomAlphabetic(2), null), - new Row(newUuid(), null, randomAlphabetic(3), randomAlphabetic(4)), - new Row(newUuid(), null, null, randomAlphabetic(5)), - // not updated because both target fields are already set (re-entrance) - new Row(newUuid(), randomAlphabetic(14), randomAlphabetic(6), randomAlphabetic(7))) - .toArray(Row[]::new); - Row[] updatedRows = { - new Row(newUuid(), randomAlphabetic(12), null, null), - new Row(newUuid(), randomAlphabetic(13), randomAlphabetic(5), null), - new Row(newUuid(), randomAlphabetic(14), null, randomAlphabetic(6)), - }; - stream(notUpdatedRows).forEach(row -> insertCeQueue(row, characteristics)); - stream(updatedRows).forEach(row -> insertCeQueue(row, characteristics)); - - underTest.execute(); - - assertThat(rowsInCeQueue()) - .hasSize(notUpdatedRows.length + updatedRows.length) - .contains(notUpdatedRows) - .contains(stream(updatedRows) - .map(row -> new Row(row.taskUuid, row.componentUuid, row.componentUuid, row.componentUuid)) - .toArray(Row[]::new)); - } - - @DataProvider - public static Object[][] characteriticsOfMainBranchesAndPr() { - return new Object[][] { - {NO_CHARACTERISTICS}, - {branchCharacteristics("LONG", randomAlphabetic(15))}, - {branchCharacteristics("SHORT", randomAlphabetic(16))}, - {branchCharacteristics(randomAlphabetic(17), randomAlphabetic(18))}, - {prCharacteristics(randomAlphabetic(19))}, - }; - } - - @Test - public void execute_populates_tmp_columns_with_component_uuid_for_existing_main_branch() throws SQLException { - String mainComponentUuid = randomAlphabetic(2); - insertProjects(mainComponentUuid, randomAlphabetic(3)); - String taskUuid = insertCeQueue(new Row(newUuid(), mainComponentUuid, null, null), NO_CHARACTERISTICS); - - underTest.execute(); - - assertThat(rowsInCeQueue()) - .containsOnly(new Row(taskUuid, mainComponentUuid, mainComponentUuid, mainComponentUuid)); - } - - @Test - public void execute_deletes_tasks_of_branches_without_row_in_PROJECTS_and_populates_others_matching_row_in_PROJECTS_by_KEE() throws SQLException { - String mainComponentUuid = randomAlphabetic(2); - String mainComponentKey = randomAlphabetic(3); - String branchUuid = randomAlphabetic(4); - String branchType1 = randomAlphabetic(5); - String branchName1 = randomAlphabetic(6); - String branchType2 = randomAlphabetic(7); - String branchName2 = randomAlphabetic(8); - insertProjects(mainComponentUuid, mainComponentKey); - insertProjects(branchUuid, mainComponentKey + ":BRANCH:" + branchName2); - String deletedTaskUuid = insertCeQueue(new Row(newUuid(), mainComponentUuid, null, null), branchCharacteristics(branchType1, branchName1)); - String updatedTaskUuid = insertCeQueue(new Row(newUuid(), mainComponentUuid, null, null), branchCharacteristics(branchType2, branchName2)); - - underTest.execute(); - - assertThat(rowsInCeQueue()) - .containsOnly(new Row(updatedTaskUuid, mainComponentUuid, branchUuid, mainComponentUuid)); - } - - @Test - public void execute_deletes_tasks_of_prs_without_row_in_PROJECTS_and_populates_others_matching_row_in_PROJECTS_by_KEE() throws SQLException { - String mainComponentUuid = randomAlphabetic(2); - String mainComponentKey = randomAlphabetic(3); - String prUuid = randomAlphabetic(4); - String prName1 = randomAlphabetic(6); - String prName2 = randomAlphabetic(8); - insertProjects(mainComponentUuid, mainComponentKey); - insertProjects(prUuid, mainComponentKey + ":PULL_REQUEST:" + prName2); - String deletedTaskUuid = insertCeQueue(new Row(newUuid(), mainComponentUuid, null, null), prCharacteristics(prName1)); - String updatedTaskUuid = insertCeQueue(new Row(newUuid(), mainComponentUuid, null, null), prCharacteristics(prName2)); - - underTest.execute(); - - assertThat(rowsInCeQueue()) - .containsOnly(new Row(updatedTaskUuid, mainComponentUuid, prUuid, mainComponentUuid)); - } - - private Stream rowsInCeQueue() { - return db.select("select" + - " uuid as \"UUID\", component_uuid as \"COMPONENT_UUID\", tmp_component_uuid as \"TMP_COMPONENT_UUID\", tmp_main_component_UUID as \"TMP_MAIN_COMPONENT_UUID\"" + - " from ce_queue") - .stream() - .map(row -> new Row( - (String) row.get("UUID"), - (String) row.get("COMPONENT_UUID"), - (String) row.get("TMP_COMPONENT_UUID"), - (String) row.get("TMP_MAIN_COMPONENT_UUID"))); - } - - private String insertCeQueue(Row row, Map characteristics) { - String uuid = insertCeQueue(row.taskUuid, row.componentUuid, row.tmpComponentUuid, row.tmpMainComponentUuid); - characteristics.forEach((key, value) -> insertCeCharacteristic(uuid, key, value)); - return uuid; - } - - private String insertCeQueue(String uuid, @Nullable String componentUuid, @Nullable String tmpComponentUuid, @Nullable String tmpMainComponentUuid) { - Random random = new Random(); - db.executeInsert("ce_queue", - "UUID", uuid, - "TASK_TYPE", randomAlphabetic(6), - "COMPONENT_UUID", componentUuid, - "TMP_COMPONENT_UUID", tmpComponentUuid, - "TMP_MAIN_COMPONENT_UUID", tmpMainComponentUuid, - "STATUS", randomAlphabetic(7), - "EXECUTION_COUNT", random.nextInt(500), - "CREATED_AT", (long) random.nextInt(500), - "UPDATED_AT", (long) random.nextInt(500)); - return uuid; - } - - private void insertCeCharacteristic(String taskUuid, String key, String value) { - db.executeInsert( - "ce_task_characteristics", - "UUID", newUuid(), - "TASK_UUID", taskUuid, - "KEE", key, - "TEXT_VALUE", value); - } - - private void insertProjects(String uuid, String key) { - db.executeInsert( - "PROJECTS", - "UUID", uuid, - "KEE", key, - "ORGANIZATION_UUID", "org_" + uuid, - "ROOT_UUID", uuid + "_root", - "UUID_PATH", uuid + "_path", - "PROJECT_UUID", uuid + "_project", - "PRIVATE", new Random().nextBoolean()); - } - - private int uuidGenerator = new Random().nextInt(9000); - - private String newUuid() { - return "uuid_" + uuidGenerator++; - } - - private static Map branchCharacteristics(String branchType, String branchName) { - return ImmutableMap.of("branchType", branchType, "branch", branchName); - } - - private static Map prCharacteristics(String prName) { - return ImmutableMap.of("pullRequest", prName); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivityTest.java deleted file mode 100644 index 8401ebb1b84..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivityTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import java.util.List; -import java.util.Random; -import javax.annotation.Nullable; -import org.assertj.core.api.AbstractIterableAssert; -import org.assertj.core.api.ObjectAssert; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; - -import static com.google.common.base.Preconditions.checkArgument; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateTmpLastKeyColumnsToCeActivityTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateTmpLastKeyColumnsToCeActivityTest.class, "ce_activity.sql"); - - private PopulateTmpLastKeyColumnsToCeActivity underTest = new PopulateTmpLastKeyColumnsToCeActivity(db.database()); - - @Test - public void execute_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("ce_activity")).isZero(); - } - - @Test - public void execute_populate_tmp_last_key_columns_from_type_and_component_uuid_columns() throws SQLException { - String type = randomAlphabetic(6); - String oldComponentUuid = randomAlphabetic(7); - String tmpComponentUuid = randomAlphabetic(8); - String tmpMainComponentUuid = randomAlphabetic(9); - - String taskWithComponentUuid = insertCeActivity(type, oldComponentUuid, tmpComponentUuid, tmpMainComponentUuid); - String taskWithInconsistentComponentUuid = insertCeActivity(type, null, tmpComponentUuid, tmpMainComponentUuid); - String taskNoComponentUuid = insertCeActivity(type, null, null, null); - - underTest.execute(); - - assertThatTmpLastKeyAndMainLastKeyOf(taskWithComponentUuid).containsOnly(tuple(type + tmpComponentUuid, type + tmpMainComponentUuid)); - assertThatTmpLastKeyAndMainLastKeyOf(taskWithInconsistentComponentUuid).containsOnly(tuple(type, type)); - assertThatTmpLastKeyAndMainLastKeyOf(taskNoComponentUuid).containsOnly(tuple(type, type)); - - assertThatTmpIsLastAndMainIsLastOf(taskWithComponentUuid).containsOnly(tuple(false, false)); - assertThatTmpIsLastAndMainIsLastOf(taskWithInconsistentComponentUuid).containsOnly(tuple(false, false)); - assertThatTmpIsLastAndMainIsLastOf(taskNoComponentUuid).containsOnly(tuple(false, false)); - } - @Test - public void execute_is_reentrant() throws SQLException { - execute_populate_tmp_last_key_columns_from_type_and_component_uuid_columns(); - - underTest.execute(); - } - - private String insertCeActivity(String type, - @Nullable String oldComponentUuid, - @Nullable String tmpComponentUuid, @Nullable String tmpMainComponentUuid) { - checkArgument((tmpComponentUuid == null) == (tmpMainComponentUuid == null)); - - String uuid = UuidFactoryFast.getInstance().create(); - - Random random = new Random(); - db.executeInsert( - "ce_activity", - "UUID", uuid, - "TASK_TYPE", type, - "COMPONENT_UUID", oldComponentUuid, - "TMP_COMPONENT_UUID", tmpComponentUuid, - "TMP_MAIN_COMPONENT_UUID", tmpMainComponentUuid, - "STATUS", randomAlphabetic(5), - "IS_LAST", random.nextBoolean(), - "IS_LAST_KEY", randomAlphabetic(12), - "EXECUTION_COUNT", random.nextInt(10), - "SUBMITTED_AT", (long) random.nextInt(5_999), - "CREATED_AT", (long) random.nextInt(5_999), - "UPDATED_AT", (long) random.nextInt(5_999)); - - return uuid; - } - - private AbstractIterableAssert, Tuple, ObjectAssert> assertThatTmpLastKeyAndMainLastKeyOf(String uuid) { - return assertThat(db.select("select tmp_is_last_key as \"LAST_KEY\", tmp_main_is_last_key as \"MAIN_LAST_KEY\" from ce_activity where uuid='" + uuid + "'")) - .extracting(t -> (String) t.get("LAST_KEY"), t -> (String) t.get("MAIN_LAST_KEY")); - } - - private AbstractIterableAssert, Tuple, ObjectAssert> assertThatTmpIsLastAndMainIsLastOf(String uuid) { - return assertThat(db.select("select tmp_is_last as \"LAST\", tmp_main_is_last as \"MAIN_LAST\" from ce_activity where uuid='" + uuid + "'")) - .extracting(t -> (Boolean) t.get("LAST"), t -> (Boolean) t.get("MAIN_LAST")); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/Row.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/Row.java deleted file mode 100644 index 0b2a8fadc8b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/Row.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.util.Objects; -import javax.annotation.Nullable; - -final class Row { - final String taskUuid; - final String componentUuid; - final String tmpComponentUuid; - final String tmpMainComponentUuid; - - Row(String taskUuid, @Nullable String componentUuid, @Nullable String tmpComponentUuid, @Nullable String tmpMainComponentUuid) { - this.taskUuid = taskUuid; - this.componentUuid = componentUuid; - this.tmpComponentUuid = tmpComponentUuid; - this.tmpMainComponentUuid = tmpMainComponentUuid; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Row row = (Row) o; - return Objects.equals(taskUuid, row.taskUuid) && - Objects.equals(componentUuid, row.componentUuid) && - Objects.equals(tmpComponentUuid, row.tmpComponentUuid) && - Objects.equals(tmpMainComponentUuid, row.tmpMainComponentUuid); - } - - @Override - public int hashCode() { - return Objects.hash(taskUuid, componentUuid, tmpComponentUuid, tmpMainComponentUuid); - } - - @Override - public String toString() { - return "Row{" + - "uuid='" + taskUuid + '\'' + - ", componentUuid='" + componentUuid + '\'' + - ", tmpComponentUuid='" + tmpComponentUuid + '\'' + - ", tmpMainComponentUuid='" + tmpMainComponentUuid + '\'' + - '}'; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRulesTest.java deleted file mode 100644 index 0e089c47942..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRulesTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v74; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; - -public class SetIsExternalAndIsAdHocNotNullableInRulesTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(SetIsExternalAndIsAdHocNotNullableInRulesTest.class, "rules.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private SetIsExternalAndIsAdHocNotNullableInRules underTest = new SetIsExternalAndIsAdHocNotNullableInRules(db.database()); - - @Test - public void columns_are_updated() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules", "is_external", BOOLEAN, null, false); - db.assertColumnDefinition("rules", "is_ad_hoc", BOOLEAN, null, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChangesTest.java deleted file mode 100644 index 118e288889a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChangesTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; -import static org.assertj.core.api.Assertions.assertThat; - -public class AddEventComponentChangesTest { - - private static final String TABLE = "event_component_changes"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddEventComponentChangesTest.class, "empty.sql"); - - private AddEventComponentChanges underTest = new AddEventComponentChanges(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); - - db.assertColumnDefinition(TABLE, "uuid", VARCHAR, 40, false); - db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - db.assertColumnDefinition(TABLE, "event_uuid", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "event_component_uuid", VARCHAR, 50, false); - db.assertColumnDefinition(TABLE, "event_analysis_uuid", VARCHAR, 50, false); - db.assertColumnDefinition(TABLE, "change_category", VARCHAR, 12, false); - db.assertColumnDefinition(TABLE, "component_uuid", VARCHAR, 50, false); - db.assertColumnDefinition(TABLE, "component_key", VARCHAR, 400, false); - db.assertColumnDefinition(TABLE, "component_name", VARCHAR, 2000, false); - db.assertColumnDefinition(TABLE, "component_branch_key", VARCHAR, 255, true); - db.assertColumnDefinition(TABLE, "created_at", BIGINT, null, false); - - db.assertUniqueIndex(TABLE, TABLE + "_unique", "event_uuid", "change_category", "component_uuid"); - db.assertIndex(TABLE, "event_cpnt_changes_cpnt", "event_component_uuid"); - db.assertIndex(TABLE, "event_cpnt_changes_analysis", "event_analysis_uuid"); - } - -} \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstallTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstallTest.java deleted file mode 100644 index 3abe5843e97..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstallTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; - -public class AddIsOwnerUserColumnInAlmAppInstallTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddIsOwnerUserColumnInAlmAppInstallTest.class, "almAppInstalls.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIsOwnerUserColumnInAlmAppInstall underTest = new AddIsOwnerUserColumnInAlmAppInstall(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("alm_app_installs", "is_owner_user", BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstallTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstallTest.java deleted file mode 100644 index 9d17e4efff6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstallTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddUserExternalIdColumnInAlmAppInstallTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddUserExternalIdColumnInAlmAppInstallTest.class, "almAppInstalls.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUserExternalIdColumnInAlmAppInstall underTest = new AddUserExternalIdColumnInAlmAppInstall(db.database()); - - @Test - public void column_is_added_to_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("alm_app_installs", "user_external_id", VARCHAR, 255, true); - db.assertIndex("alm_app_installs", "alm_app_installs_external_id", "user_external_id"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/CreateOrganizationsAlmBindingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/CreateOrganizationsAlmBindingsTableTest.java deleted file mode 100644 index ac747b43643..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/CreateOrganizationsAlmBindingsTableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class CreateOrganizationsAlmBindingsTableTest { - - private static final String TABLE = "organization_alm_bindings"; - - @Rule - public final CoreDbTester db = CoreDbTester.createEmpty(); - - private CreateOrganizationsAlmBindingsTable underTest = new CreateOrganizationsAlmBindingsTable(db.database()); - - @Test - public void creates_table() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "organization_uuid", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "alm_app_install_uuid", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "alm_id", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "url", Types.VARCHAR, 2000, false); - db.assertColumnDefinition(TABLE, "user_uuid", Types.VARCHAR, 255, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - - db.assertUniqueIndex(TABLE, "org_alm_bindings_org", "organization_uuid"); - db.assertUniqueIndex(TABLE, "org_alm_bindings_install", "alm_app_install_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/DbVersion75Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/DbVersion75Test.java deleted file mode 100644 index 6a0eee289e2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/DbVersion75Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion75Test { - - private DbVersion75 underTest = new DbVersion75(); - - @Test - public void migrationNumber_starts_at_2400() { - verifyMinimumMigrationNumber(underTest, 2400); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 5); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest.java deleted file mode 100644 index 1fe1a3c7644..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v75; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BOOLEAN; - -public class SetIsOwnerUserNotNullableInAlmAppInstallsTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(SetIsOwnerUserNotNullableInAlmAppInstallsTest.class, "almAppInstalls.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private SetIsOwnerUserNotNullableInAlmAppInstalls underTest = new SetIsOwnerUserNotNullableInAlmAppInstalls(db.database()); - - @Test - public void columns_are_updated() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("alm_app_installs", "is_owner_user", BOOLEAN, null, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTableTest.java deleted file mode 100644 index 3f5a5864957..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddUniqueIndexInUserPropertiesTableTest { - - private static final String TABLE = "user_properties"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexInUserPropertiesTableTest.class, "user_properties.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUniqueIndexInUserPropertiesTable underTest = new AddUniqueIndexInUserPropertiesTable(db.database()); - - @Test - public void creates_index() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex(TABLE, "user_properties_user_uuid_kee", "user_uuid", "kee"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTableTest.java deleted file mode 100644 index c1051f1073f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddUniqueIndexOnExternalLoginInUsersTableTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexOnExternalLoginInUsersTableTest.class, "users.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddUniqueIndexOnExternalLoginInUsersTable underTest = new AddUniqueIndexOnExternalLoginInUsersTable(db.database()); - - @Test - public void add_unique_indexes() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("users", "uniq_external_login", "external_identity_provider", "external_login"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/CreateUserPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/CreateUserPropertiesTableTest.java deleted file mode 100644 index 76c1c7407d5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/CreateUserPropertiesTableTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; - -public class CreateUserPropertiesTableTest { - - private static final String TABLE = "user_properties"; - - @Rule - public final CoreDbTester db = CoreDbTester.createEmpty(); - - private CreateUserPropertiesTable underTest = new CreateUserPropertiesTable(db.database()); - - @Test - public void creates_table() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - db.assertPrimaryKey(TABLE, "pk_user_properties", "uuid"); - db.assertColumnDefinition(TABLE, "uuid", VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "user_uuid", VARCHAR, 255, false); - db.assertColumnDefinition(TABLE, "kee", VARCHAR, 100, false); - db.assertColumnDefinition(TABLE, "text_value", VARCHAR, 4000, false); - db.assertColumnDefinition(TABLE, "created_at", BIGINT, null, false); - db.assertColumnDefinition(TABLE, "updated_at", BIGINT, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76Test.java deleted file mode 100644 index 220173c84dd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion76Test { - - private DbVersion76 underTest = new DbVersion76(); - - @Test - public void migrationNumber_starts_at_2500() { - verifyMinimumMigrationNumber(underTest, 2500); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 9); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasuresTest.java deleted file mode 100644 index 5c69599cd7a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasuresTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.config.internal.MapSettings; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteModuleAndFolderMeasuresTest { - - private static final String TABLE_MEASURES = "project_measures"; - private static final int COMPONENT_ID_1 = 125; - private static final int COMPONENT_ID_2 = 604; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteModuleAndFolderMeasuresTest.class, "project_measures.sql"); - - private MapSettings settings = new MapSettings(); - private DeleteModuleAndFolderMeasures underTest = new DeleteModuleAndFolderMeasures(db.database(), settings.asConfig()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isZero(); - } - - @Test - public void execute_has_no_effect_on_SonarCloud() throws SQLException { - String moduleUuid = insertComponent(1, "BRC"); - insertMeasure(1, moduleUuid); - - settings.setProperty("sonar.sonarcloud.enabled", true); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(1); - } - - @Test - public void migration_removes_module_level_measures() throws SQLException { - String moduleUuid = insertComponent(1, "BRC"); - insertMeasure(1, moduleUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isZero(); - } - - @Test - public void migration_removes_folder_level_measures() throws SQLException { - String dirUuid = insertComponent(1, "DIR"); - insertMeasure(1, dirUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isZero(); - } - - @Test - public void migration_ignores_not_relevant_measures() throws SQLException { - String projectUuid = insertComponent(1, "TRK"); - insertMeasure(1, projectUuid); - String moduleUuid = insertComponent(2, "BRC"); - insertMeasure(2, moduleUuid); - insertMeasure(3, moduleUuid); - String dirUuid = insertComponent(3, "DIR"); - insertMeasure(4, dirUuid); - insertMeasure(5, dirUuid); - String fileUuid = insertComponent(4, "FIL"); - insertMeasure(6, fileUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(2); - } - - @Test - public void migration_is_reentrant() throws SQLException { - String dirUuid = insertComponent(3, "DIR"); - insertMeasure(1, dirUuid); - String fileUuid = insertComponent(4, "FIL"); - insertMeasure(2, fileUuid); - - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(1); - - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(1); - } - - private String insertComponent(long id, String qualifier) { - String uuid = "uuid_" + id; - db.executeInsert( - "projects", - "ID", valueOf(id), - "QUALIFIER", qualifier, - "ORGANIZATION_UUID", "org_" + id, - "UUID_PATH", "path_" + id, - "ROOT_UUID", "root_" + id, - "PROJECT_UUID", "project_" + id, - "PRIVATE", false, - "UUID", uuid); - return uuid; - } - - private void insertMeasure(long id, String componentUuid) { - db.executeInsert( - "project_measures", - "ID", valueOf(id), - "COMPONENT_UUID", componentUuid, - "METRIC_ID", valueOf(id + 10), - "ANALYSIS_UUID", valueOf(id + 100), - "VALUE", valueOf(id + 1000)); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSettingTest.java deleted file mode 100644 index b4cc72abb59..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSettingTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import com.google.common.collect.ImmutableMap; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteUselessOnboardingSettingTest { - - private static final String TABLE_PROPERTIES = "properties"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteUselessOnboardingSettingTest.class, "properties.sql"); - - private DeleteUselessOnboardingSetting underTest = new DeleteUselessOnboardingSetting(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_removes_onboarding_setting() throws SQLException { - insertProperty("sonar.onboardingTutorial.showToNewUsers"); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - private void insertProperty(String key) { - Map values = new HashMap<>(ImmutableMap.of( - "PROP_KEY", key, - "IS_EMPTY", false, - "CREATED_AT", 456789)); - db.executeInsert(TABLE_PROPERTIES, values); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessPropertyTest.java deleted file mode 100644 index f12d19d2412..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/DeleteUselessPropertyTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteUselessPropertyTest { - - private static final String TABLE_PROPERTIES = "properties"; - private static final int COMPONENT_ID_1 = 125; - private static final int COMPONENT_ID_2 = 604; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteUselessPropertyTest.class, "properties.sql"); - - private DeleteUselessProperty underTest = new DeleteUselessProperty(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_removes_cleanDirectory_settings_related_to_component() throws SQLException { - insertProperty("sonar.dbcleaner.cleanDirectory", COMPONENT_ID_1); - insertProperty("sonar.dbcleaner.cleanDirectory", COMPONENT_ID_1); - insertProperty("sonar.dbcleaner.cleanDirectory", COMPONENT_ID_2); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isZero(); - } - - @Test - public void migration_ignores_not_relevant_settings() throws SQLException { - insertProperty("sonar.core.serverBaseURL", null); - // Only this setting should be removed - insertProperty("sonar.dbcleaner.cleanDirectory", null); - - underTest.execute(); - - verifyPropertyKeys("sonar.core.serverBaseURL"); - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProperty("sonar.core.serverBaseURL", null); - // Only this setting should be removed - insertProperty("sonar.dbcleaner.cleanDirectory", null); - - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(1); - - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(1); - } - - private void insertProperty(String key, @Nullable Integer componentId) { - Map values = new HashMap<>(ImmutableMap.of( - "PROP_KEY", key, - "IS_EMPTY", false, - "CREATED_AT", 456789)); - if (componentId != null) { - values.put("RESOURCE_ID", valueOf(componentId)); - } - db.executeInsert(TABLE_PROPERTIES, values); - } - - private void verifyPropertyKeys(String... propertyKeys) { - List> rows = db.select("select prop_key from " + TABLE_PROPERTIES); - Set result = rows.stream().map(cols -> (String)cols.get("PROP_KEY")).collect(Collectors.toSet()); - assertThat(result).containsOnly(propertyKeys); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetricsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetricsTest.java deleted file mode 100644 index 5e8d1898db7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetricsTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import com.google.common.collect.ImmutableMap; -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(DataProviderRunner.class) -public class FixDirectionOfMetricsTest { - - private static final String TESTS_METRIC_NAME = "tests"; - private static final String CONDITIONS_TO_COVER_METRIC_NAME = "conditions_to_cover"; - private static final String NEW_CONDITIONS_TO_COVER_METRIC_NAME = "new_conditions_to_cover"; - private static final String UNRELATED_METRIC_NAME = "unrelated"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(FixDirectionOfMetricsTest.class, "metrics.sql"); - - private static long idCounter = 1; - - private FixDirectionOfMetrics underTest = new FixDirectionOfMetrics(db.database()); - - @Test - @UseDataProvider("interestingCombinationsOfInitialMetricsAndValues") - public void fixes_direction_of_relevant_metrics(Map initialMetricsAndValues) throws SQLException { - insertMetric(TESTS_METRIC_NAME, initialMetricsAndValues.get(TESTS_METRIC_NAME)); - insertMetric(CONDITIONS_TO_COVER_METRIC_NAME, initialMetricsAndValues.get(CONDITIONS_TO_COVER_METRIC_NAME)); - insertMetric(NEW_CONDITIONS_TO_COVER_METRIC_NAME, initialMetricsAndValues.get(NEW_CONDITIONS_TO_COVER_METRIC_NAME)); - insertMetric(UNRELATED_METRIC_NAME, initialMetricsAndValues.get(UNRELATED_METRIC_NAME)); - - underTest.execute(); - - assertThat(selectMetricDirection(TESTS_METRIC_NAME)).isEqualTo(1L); - assertThat(selectMetricDirection(CONDITIONS_TO_COVER_METRIC_NAME)).isEqualTo(-1L); - assertThat(selectMetricDirection(NEW_CONDITIONS_TO_COVER_METRIC_NAME)).isEqualTo(-1L); - assertThat(selectMetricDirection(UNRELATED_METRIC_NAME)).isEqualTo((long) initialMetricsAndValues.get(UNRELATED_METRIC_NAME)); - } - - @DataProvider - public static Object[][] interestingCombinationsOfInitialMetricsAndValues() { - List> mappings = new ArrayList<>(); - int[] directions = {-1, 0, 1}; - for (int unrelatedDirection : directions) { - // the target metrics with old (wrong) direction, and an unrelated metric with any direction - mappings.add(ImmutableMap.of( - TESTS_METRIC_NAME, -1, - CONDITIONS_TO_COVER_METRIC_NAME, 0, - NEW_CONDITIONS_TO_COVER_METRIC_NAME, 0, - UNRELATED_METRIC_NAME, unrelatedDirection)); - - // the target metrics with correct direction, and an unrelated metric with any direction - mappings.add(ImmutableMap.of( - TESTS_METRIC_NAME, 1, - CONDITIONS_TO_COVER_METRIC_NAME, -1, - NEW_CONDITIONS_TO_COVER_METRIC_NAME, -1, - UNRELATED_METRIC_NAME, unrelatedDirection)); - } - return mappings.stream().map(m -> new Object[] {m}).toArray(Object[][]::new); - } - - private void insertMetric(String name, int direction) { - long id = idCounter++; - db.executeInsert("METRICS", - "ID", id, - "NAME", name, - "DIRECTION", direction); - } - - private long selectMetricDirection(String metricName) { - return (long) db.selectFirst("SELECT direction FROM metrics WHERE name = '" + metricName + "'").get("DIRECTION"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest.java deleted file mode 100644 index 155663653e8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; -import org.sonar.api.utils.System2; -import org.sonar.core.util.SequenceUuidFactory; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.valueOf; -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.server.platform.db.migration.version.v76.MigrateModuleProperties.NEW_PROPERTY_NAME; - -public class MigrateModulePropertiesTest { - private static final long NOW = 50_000_000_000L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateModulePropertiesTest.class, "schema.sql"); - private System2 system2 = new TestSystem2().setNow(NOW); - private UuidFactory uuidFactory = new SequenceUuidFactory(); - private MigrateModuleProperties underTest = new MigrateModuleProperties(db.database(), system2); - - @Test - public void multi_module_project_migration() throws SQLException { - setupMultiModuleProject(); - - underTest.execute(); - - verifyMultiModuleProjectMigration(); - assertThat(getRemainingProperties()).hasSize(3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - setupMultiModuleProject(); - - underTest.execute(); - underTest.execute(); - - verifyMultiModuleProjectMigration(); - assertThat(getRemainingProperties()).hasSize(3); - } - - @Test - public void single_module_project_migration() throws SQLException { - String project2Uuid = uuidFactory.create(); - insertComponent(5, project2Uuid, null, project2Uuid, Qualifiers.PROJECT, "Single module project"); - insertProperty(9, 5, "sonar.coverage.exclusions", "SingleModuleA.java", null); - insertProperty(10, 5, "sonar.cp.exclusions", "SingleModuleB.java", null); - - underTest.execute(); - - List> properties = db.select(String.format("select ID, TEXT_VALUE, CLOB_VALUE " + - "from properties " + - "where PROP_KEY='%s' and RESOURCE_ID = 5", NEW_PROPERTY_NAME)); - assertThat(properties).hasSize(0); - List> remainingProperties = db.select("select ID from properties"); - assertThat(remainingProperties).hasSize(2); - } - - @Test - public void properties_do_not_leak_between_projects() throws SQLException { - setupMultiModuleProject(); - setupSecondMultiModuleProject(); - - underTest.execute(); - - verifyMultiModuleProjectMigration(); - verifySecondMultiModuleProjectMigration(); - assertThat(getRemainingProperties()).hasSize(5); - } - - private List> getRemainingProperties() { - return db.select("select ID from properties"); - } - - private void insertComponent(long id, String uuid, @Nullable String rootUuid, String projectUuid, String qualifier, String name) { - db.executeInsert( - "projects", - "ID", valueOf(id), - "UUID", uuid, - "ROOT_UUID", rootUuid, - "PROJECT_UUID", projectUuid, - "SCOPE", Scopes.PROJECT, - "QUALIFIER", qualifier, - "NAME", name); - } - - private void insertProperty(long id, long componentId, String key, String value, Long userId) { - db.executeInsert( - "properties", - "ID", valueOf(id), - "RESOURCE_ID", componentId, - "PROP_KEY", key, - "TEXT_VALUE", value, - "IS_EMPTY", false, - "USER_ID", userId); - } - - private void setupMultiModuleProject() { - String projectUuid = uuidFactory.create(); - String moduleUuid = uuidFactory.create(); - String subModule1Uuid = uuidFactory.create(); - String subModule2Uuid = uuidFactory.create(); - String subModule3Uuid = uuidFactory.create(); - String subModule4Uuid = uuidFactory.create(); - String subModule5Uuid = uuidFactory.create(); - insertComponent(1, projectUuid, null, projectUuid, Qualifiers.PROJECT, "Multi-module project"); - insertComponent(2, moduleUuid, projectUuid, projectUuid, Qualifiers.MODULE, "Module"); - insertComponent(3, subModule1Uuid, moduleUuid, projectUuid, Qualifiers.MODULE, "Submodule 1"); - insertComponent(4, subModule2Uuid, moduleUuid, projectUuid, Qualifiers.MODULE, "Submodule 2"); - insertComponent(5, subModule3Uuid, moduleUuid, projectUuid, Qualifiers.MODULE, "Submodule with reset property"); - insertComponent(6, subModule4Uuid, moduleUuid, projectUuid, Qualifiers.MODULE, "Submodule without properties"); - insertComponent(7, subModule5Uuid, moduleUuid, projectUuid, Qualifiers.MODULE, "Submodule with user property"); - insertProperty(1, 1, "sonar.coverage.exclusions", "Proj1.java", null); - insertProperty(2, 1, "sonar.cpd.exclusions", "Proj2.java", null); - insertProperty(3, 2, "sonar.coverage.exclusions", "ModuleA.java", null); - insertProperty(4, 2, "sonar.cpd.exclusions", "ModuleB.java", null); - insertProperty(5, 3, "sonar.coverage.exclusions", "Module1A.java", null); - insertProperty(6, 3, "sonar.cpd.exclusions", "Moddule1B.java", null); - insertProperty(7, 4, "sonar.coverage.exclusions", "Module2A.java", null); - insertProperty(8, 4, "sonar.cpd.exclusions", "Module2B.java", null); - insertProperty(9, 5, "sonar.coverage.exclusions", null, null); - insertProperty(10, 7, "favourite", null, 5L); - } - - private void verifyMultiModuleProjectMigration() { - final String expectedResult = "# Settings from 'Multi-module project::Module'\n" + - "sonar.coverage.exclusions=ModuleA.java\n" + - "sonar.cpd.exclusions=ModuleB.java\n" + - "\n" + - "# Settings from 'Multi-module project::Submodule 1'\n" + - "sonar.coverage.exclusions=Module1A.java\n" + - "sonar.cpd.exclusions=Moddule1B.java\n" + - "\n" + - "# Settings from 'Multi-module project::Submodule 2'\n" + - "sonar.coverage.exclusions=Module2A.java\n" + - "sonar.cpd.exclusions=Module2B.java\n" + - "\n" + - "# Settings from 'Multi-module project::Submodule with reset property'\n" + - "sonar.coverage.exclusions=\n"; - - List> properties = db - .select(String.format("select ID, TEXT_VALUE, CLOB_VALUE from properties where PROP_KEY='%s' and RESOURCE_ID = 1", - NEW_PROPERTY_NAME)); - - assertThat(properties).hasSize(1); - Map project1Property = properties.get(0); - assertThat(project1Property.get("TEXT_VALUE")).isNull(); - assertThat(project1Property.get("CLOB_VALUE")).isEqualTo(expectedResult); - } - - private void setupSecondMultiModuleProject() { - String project3Uuid = uuidFactory.create(); - String singleModuleUuid = uuidFactory.create(); - insertComponent(8, project3Uuid, null, project3Uuid, Qualifiers.PROJECT, "Another multi-module project"); - insertComponent(9, singleModuleUuid, project3Uuid, project3Uuid, Qualifiers.MODULE, "Module X"); - insertProperty(11, 8, "sonar.coverage.exclusions", "InRoot.java", null); - insertProperty(12, 9, "sonar.coverage.exclusions", "InModule.java", null); - } - - private void verifySecondMultiModuleProjectMigration() { - final String expectedResult = "# Settings from 'Another multi-module project::Module X'\n" + - "sonar.coverage.exclusions=InModule.java\n"; - - List> properties = db.select(String.format("select ID, TEXT_VALUE, CLOB_VALUE " + - "from properties " + - "where PROP_KEY='%s' and RESOURCE_ID = 8", NEW_PROPERTY_NAME)); - - assertThat(properties).hasSize(1); - Map project2Property = properties.get(0); - assertThat(project2Property.get("TEXT_VALUE")).isNull(); - assertThat(project2Property.get("CLOB_VALUE")).isEqualTo(expectedResult); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditionsTest.java deleted file mode 100644 index 06b384ce19c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditionsTest.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v76; - -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.Date; -import java.util.Random; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; - -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -@RunWith(DataProviderRunner.class) -public class MigrateNoMoreUsedQualityGateConditionsTest { - - private static final int DIRECTION_WORST = -1; - private static final int DIRECTION_BETTER = 1; - private static final int DIRECTION_NONE = 0; - - private final static long PAST = 10_000_000_000L; - private final static long NOW = 50_000_000_000L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateNoMoreUsedQualityGateConditionsTest.class, "qg-schema.sql"); - - private System2 system2 = new TestSystem2().setNow(NOW); - - private Random random = new Random(); - - private MigrateNoMoreUsedQualityGateConditions underTest = new MigrateNoMoreUsedQualityGateConditions(db.database(), system2); - - @Test - public void remove_conditions_using_only_warning() throws SQLException { - long qualityGate = insertQualityGate(false); - long ncloc = insertMetric("ncloc", DIRECTION_WORST, "INT"); - long lines = insertMetric("lines", DIRECTION_WORST, "INT"); - long issues = insertMetric("violations", DIRECTION_WORST, "INT"); - long coverage = insertMetric("coverage", DIRECTION_BETTER, "PERCENT"); - long conditionWithWarning1 = insertCondition(qualityGate, ncloc, "GT", null, "10", null); - long conditionWithWarning2 = insertCondition(qualityGate, lines, "GT", null, "15", null); - long conditionWithError = insertCondition(qualityGate, issues, "GT", "5", null, null); - - underTest.execute(); - - assertConditions( - tuple(conditionWithError, issues, "5", null, null)); - } - - @Test - public void update_conditions_using_error_and_warning() throws SQLException { - long qualityGate = insertQualityGate(false); - long issues = insertMetric("violations", DIRECTION_WORST, "INT"); - long coverage = insertMetric("coverage", DIRECTION_BETTER, "PERCENT"); - long newLines = insertMetric("new_lines", DIRECTION_WORST, "INT"); - long conditionWithError = insertCondition(qualityGate, issues, "GT", "5", null, null); - long conditionWithErrorAndWarning1 = insertCondition(qualityGate, coverage, "LT", "5", "10", null); - long conditionWithErrorAndWarning2 = insertCondition(qualityGate, newLines, "GT", "7", "13", 1); - - underTest.execute(); - - assertConditions( - tuple(conditionWithError, issues, "5", null, null), - tuple(conditionWithErrorAndWarning1, coverage, "5", null, null), - tuple(conditionWithErrorAndWarning2, newLines, "7", null, 1L) - ); - } - - @Test - @UseDataProvider("metricsHavingNoLinkedLeakMetrics") - public void delete_condition_on_not_supported_leak_period_metric(String metricKey) throws SQLException { - long qualityGate = insertQualityGate(false); - long metric = insertMetric(metricKey, DIRECTION_BETTER, "INT"); - insertCondition(qualityGate, metric, "LT", "5", null, 1); - - underTest.execute(); - - assertThat(db.countRowsOfTable("quality_gate_conditions")).isZero(); - } - - @DataProvider - public static Object[][] metricsHavingNoLinkedLeakMetrics() { - return new Object[][] { - {"statements"}, - {"functions"} - }; - } - - @Test - @UseDataProvider("supportedLeakPeriodMetrics") - public void update_condition_on_supported_leak_period_metric(String metricKey, String relatedMetricKeyOnLeakPeriod) throws SQLException { - long qualityGate = insertQualityGate(false); - long metric = insertMetric(metricKey, DIRECTION_BETTER, "INT"); - long relatedMetricOnLeakPeriod = insertMetric(relatedMetricKeyOnLeakPeriod, DIRECTION_BETTER, "INT"); - long condition = insertCondition(qualityGate, metric, "LT", "5", null, 1); - - underTest.execute(); - - assertConditions(tuple(condition, relatedMetricOnLeakPeriod, "5", null, 1L)); - } - - @Test - @UseDataProvider("supportedLeakPeriodMetrics") - public void remove_condition_on_supported_leak_period_metric_when_condition_already_exists(String metricKey, String relatedMetricKeyOnLeakPeriod) throws SQLException { - long qualityGate = insertQualityGate(false); - long metric = insertMetric(metricKey, DIRECTION_BETTER, "INT"); - long condition = insertCondition(qualityGate, metric, "LT", "10", null, 1); - long relatedMetricOnLeakPeriod = insertMetric(relatedMetricKeyOnLeakPeriod, DIRECTION_BETTER, "INT"); - long leakCondition = insertCondition(qualityGate, relatedMetricOnLeakPeriod, "LT", "5", null, 1); - - underTest.execute(); - - assertConditions(tuple(leakCondition, relatedMetricOnLeakPeriod, "5", null, 1L)); - } - - @DataProvider - public static Object[][] supportedLeakPeriodMetrics() { - return new Object[][] { - {"branch_coverage", "new_branch_coverage"}, - {"conditions_to_cover", "new_conditions_to_cover"}, - {"coverage", "new_coverage"}, - {"line_coverage", "new_line_coverage"}, - {"lines_to_cover", "new_lines_to_cover"}, - {"uncovered_conditions", "new_uncovered_conditions"}, - {"uncovered_lines", "new_uncovered_lines"}, - {"duplicated_blocks", "new_duplicated_blocks"}, - {"duplicated_lines", "new_duplicated_lines"}, - {"duplicated_lines_density", "new_duplicated_lines_density"}, - {"blocker_violations", "new_blocker_violations"}, - {"critical_violations", "new_critical_violations"}, - {"info_violations", "new_info_violations"}, - {"violations", "new_violations"}, - {"major_violations", "new_major_violations"}, - {"minor_violations", "new_minor_violations"}, - {"sqale_index", "new_technical_debt"}, - {"code_smells", "new_code_smells"}, - {"sqale_rating", "new_maintainability_rating"}, - {"sqale_debt_ratio", "new_sqale_debt_ratio"}, - {"bugs", "new_bugs"}, - {"reliability_rating", "new_reliability_rating"}, - {"reliability_remediation_effort", "new_reliability_remediation_effort"}, - {"vulnerabilities", "new_vulnerabilities"}, - {"security_rating", "new_security_rating"}, - {"security_remediation_effort", "new_security_remediation_effort"}, - {"lines", "new_lines"}, - }; - } - - @Test - public void update_condition_using_leak_period_metric_when_condition_on_new_metric_exists_but_using_bad_operator() throws SQLException { - long qualityGate = insertQualityGate(false); - long linesToCover = insertMetric("lines_to_cover", DIRECTION_WORST, "INT"); - long newLinesToCover = insertMetric("new_lines_to_cover", DIRECTION_WORST, "INT"); - // This condition should be migrated to use new_lines_to_cover metric - long conditionOnLinesToCover = insertCondition(qualityGate, linesToCover, "GT", "10", null, 1); - // This condition should be removed as using a no more supported operator - long conditionOnNewLinesToCover = insertCondition(qualityGate, newLinesToCover, "EQ", "5", null, 1); - - underTest.execute(); - - assertConditions( - tuple(conditionOnLinesToCover, newLinesToCover, "10", null, 1L)); - } - - @Test - @UseDataProvider("noMoreSupportedMetricTypes") - public void delete_condition_on_no_more_supported_metric_types(String metricKey, String metricType) throws SQLException { - long qualityGate = insertQualityGate(false); - long metric = insertMetric(metricKey, DIRECTION_BETTER, metricType); - long condition = insertCondition(qualityGate, metric, "LT", "5", null, null); - - underTest.execute(); - - assertThat(db.countRowsOfTable("quality_gate_conditions")).isZero(); - } - - @DataProvider - public static Object[][] noMoreSupportedMetricTypes() { - return new Object[][] { - {"bool_type", "BOOL"}, - {"development_cost", "STRING"}, - {"last_change_on_maintainability_rating", "DATA"}, - {"class_complexity_distribution", "DISTRIB"} - }; - } - - @Test - @UseDataProvider("conditionsOnNoMoreSupportedOperators") - public void delete_condition_on_no_more_supported_operators(String metricKey, int direction, String operator) throws SQLException { - long qualityGate = insertQualityGate(false); - long metric = insertMetric(metricKey, direction, "INT"); - long condition = insertCondition(qualityGate, metric, operator, "5", null, null); - - underTest.execute(); - - assertThat(db.countRowsOfTable("quality_gate_conditions")).isZero(); - } - - @DataProvider - public static Object[][] conditionsOnNoMoreSupportedOperators() { - return new Object[][] { - {"function_complexity_distribution", DIRECTION_NONE, "EQ"}, - {"file_complexity_distribution", DIRECTION_NONE, "NE"}, - {"blockers", DIRECTION_WORST, "LT"}, - {"coverage", DIRECTION_BETTER, "GT"} - }; - } - - @Test - @UseDataProvider("conditionsOnSupportedOperators") - public void do_not_delete_condition_on_supported_operators(String metricKey, int direction, String operator) throws SQLException { - long qualityGate = insertQualityGate(false); - long metric = insertMetric(metricKey, direction, "INT"); - long condition = insertCondition(qualityGate, metric, operator, "5", null, null); - - underTest.execute(); - - assertConditions(condition); - } - - @DataProvider - public static Object[][] conditionsOnSupportedOperators() { - return new Object[][] { - {"function_complexity_distribution", DIRECTION_NONE, "LT"}, - {"file_complexity_distribution", DIRECTION_NONE, "GT"}, - {"blockers", DIRECTION_BETTER, "LT"}, - {"coverage", DIRECTION_WORST, "GT"} - }; - } - - private void assertConditions(Long... expectedIds) { - assertThat(db.select("SELECT id FROM quality_gate_conditions") - .stream() - .map(row -> (long) row.get("ID")) - .collect(toList())) - .containsExactlyInAnyOrder(expectedIds); - } - - private void assertConditions(Tuple... expectedTuples) { - assertThat(db.select("SELECT id, metric_id, value_error, value_warning, period FROM quality_gate_conditions") - .stream() - .map(row -> new Tuple(row.get("ID"), row.get("METRIC_ID"), row.get("VALUE_ERROR"), row.get("VALUE_WARNING"), row.get("PERIOD"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private long insertQualityGate(boolean isBuiltIn) { - long id = random.nextInt(1_000_000); - db.executeInsert("QUALITY_GATES", - "UUID", id, - "ID", id, - "NAME", "name " + id, - "IS_BUILT_IN", isBuiltIn, - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - return id; - } - - private long insertMetric(String name, int direction, String metricType) { - long id = random.nextInt(1_000_000); - db.executeInsert("METRICS", - "ID", id, - "NAME", name, - "VAL_TYPE", metricType, - "DIRECTION", direction); - return id; - } - - private long insertCondition(long qualityGateId, long metricId, String operator, @Nullable String error, @Nullable String warning, @Nullable Integer period) { - long id = random.nextInt(1_000_000); - db.executeInsert("QUALITY_GATE_CONDITIONS", - "ID", id, - "QGATE_ID", qualityGateId, - "METRIC_ID", metricId, - "OPERATOR", operator, - "VALUE_ERROR", error, - "VALUE_WARNING", warning, - "PERIOD", period, - "CREATED_AT", new Date(PAST), - "UPDATED_AT", new Date(PAST)); - return id; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshotTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshotTest.java deleted file mode 100644 index 4d2ad7e9e99..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshotTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -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.step.DdlChange; - -import static java.sql.Types.VARCHAR; - -public class AddBuildStringToSnapshotTest { - - private static final String TABLE = "snapshots"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddBuildStringToSnapshotTest.class, "snapshots.sql"); - - private DdlChange underTest = new AddBuildStringToSnapshot(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE, "project_version", VARCHAR, 100, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokensTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokensTest.java deleted file mode 100644 index 95a90ffff0b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokensTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import java.sql.Types; -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.step.DdlChange; - -public class AddLastConnectionDateToUserTokensTest { - - private static final String TABLE = "user_tokens"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddLastConnectionDateToUserTokensTest.class, "user_tokens.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DdlChange underTest = new AddLastConnectionDateToUserTokens(db.database()); - - @Test - public void add_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE, "last_connection_date", Types.BIGINT, null); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsersTest.java deleted file mode 100644 index 1c807994abc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsersTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import java.sql.Types; -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.step.DdlChange; - -public class AddLastConnectionDateToUsersTest { - - private static final String TABLE = "users"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddLastConnectionDateToUsersTest.class, "users.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DdlChange underTest = new AddLastConnectionDateToUsers(db.database()); - - @Test - public void add_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE, "last_connection_date", Types.BIGINT, null); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranchesTest.java deleted file mode 100644 index 3b27dc0a0ae..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranchesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -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.step.DdlChange; - -import static java.sql.Types.VARCHAR; -import static org.sonar.server.platform.db.migration.version.v77.AddManualBaselineToProjectBranches.TABLE_NAME; - -public class AddManualBaselineToProjectBranchesTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddManualBaselineToProjectBranchesTest.class, "initial.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DdlChange underTest = new AddManualBaselineToProjectBranches(db.database()); - - @Test - public void adds_nullable_columns_to_existing_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "manual_baseline_analysis_uuid", VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute "); - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBindingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBindingTest.java deleted file mode 100644 index e4d49d8f6b0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBindingTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import java.sql.Types; -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.step.DdlChange; - -public class AddMembersSyncFlagToOrgAlmBindingTest { - - private static final String TABLE = "organization_alm_bindings"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddMembersSyncFlagToOrgAlmBindingTest.class, "org_alm_binding.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DdlChange underTest = new AddMembersSyncFlagToOrgAlmBinding(db.database()); - - @Test - public void add_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE, "members_sync_enabled", Types.BOOLEAN, null); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java deleted file mode 100644 index 001eef0e521..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v77; - -import org.junit.Test; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion77Test { - - private DbVersion77 underTest = new DbVersion77(); - - @Test - public void migrationNumber_starts_at_2600() { - verifyMinimumMigrationNumber(underTest, 2600); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 11); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundredTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundredTest.java deleted file mode 100644 index a0f5c21d2cc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundredTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import 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 java.util.stream.IntStream.rangeClosed; -import static org.apache.commons.lang.math.RandomUtils.nextInt; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteFavoritesExceedingOneHundredTest { - - private static final String TABLE = "properties"; - private static final String FAVOURITE_PROPERTY = "favourite"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteFavoritesExceedingOneHundredTest.class, "schema.sql"); - - private DataChange underTest = new DeleteFavoritesExceedingOneHundred(db.database()); - - @Test - public void delete_favorites_when_user_has_more_than_100() throws SQLException { - int user1Id = nextInt(); - insertProperties(user1Id, "TRK", 110); - int user2Id = nextInt(); - insertProperties(user2Id, "TRK", 130); - int user3Id = nextInt(); - insertProperties(user3Id, "TRK", 90); - - underTest.execute(); - - assertFavorites(user1Id, 100); - assertFavorites(user2Id, 100); - assertFavorites(user3Id, 90); - } - - @Test - public void keep_in_priority_projects_over_files() throws SQLException { - int userId = nextInt(); - insertProperties(userId, "TRK", 90); - insertProperties(userId, "FIL", 20); - underTest.execute(); - - assertFavorites(userId, "TRK", 90); - assertFavorites(userId, "FIL", 10); - } - - @Test - public void keep_in_priority_views_over_sub_views() throws SQLException { - int userId = nextInt(); - insertProperties(userId, "VW", 90); - insertProperties(userId, "SVW", 20); - underTest.execute(); - - assertFavorites(userId, "VW", 90); - assertFavorites(userId, "SVW", 10); - } - - @Test - public void keep_in_priority_apps_over_sub_views() throws SQLException { - int userId = nextInt(); - insertProperties(userId, "APP", 90); - insertProperties(userId, "SVW", 20); - underTest.execute(); - - assertFavorites(userId, "APP", 90); - assertFavorites(userId, "SVW", 10); - } - - @Test - public void keep_in_priority_enabled_projects() throws SQLException { - int userId = nextInt(); - insertProperties(userId, "TRK", 90); - rangeClosed(1, 20).forEach(i -> { - int componentId = insertDisabledComponent("TRK"); - insertProperty(FAVOURITE_PROPERTY, userId, componentId); - }); - - underTest.execute(); - - assertFavorites(userId, "TRK", true, 90); - assertFavorites(userId, "TRK", false, 10); - } - - @Test - public void ignore_non_favorite_properties() throws SQLException { - int userId = nextInt(); - rangeClosed(1, 130).forEach(i -> { - int componentId = insertComponent("TRK"); - insertProperty("other", userId, componentId); - }); - - underTest.execute(); - - assertProperties("other", userId, 130); - } - - private void assertFavorites(int userId, int expectedSize) { - assertProperties(FAVOURITE_PROPERTY, userId, expectedSize); - } - - private void assertFavorites(int userId, String qualifier, int expectedSize) { - assertThat(db.countSql("SELECT count(prop.id) FROM properties prop " + - "INNER JOIN projects p ON p.id=prop.resource_id AND p.qualifier='" + qualifier + "'" + - "WHERE prop.user_id=" + userId + " AND prop.prop_key='" + FAVOURITE_PROPERTY + "'")) - .isEqualTo(expectedSize); - } - - private void assertFavorites(int userId, String qualifier, boolean enabled, int expectedSize) { - assertThat(db.countSql("SELECT count(prop.id) FROM properties prop " + - "INNER JOIN projects p ON p.id=prop.resource_id AND p.qualifier='" + qualifier + "' AND p.enabled='" + enabled + "'" + - "WHERE prop.user_id=" + userId + " AND prop.prop_key='" + FAVOURITE_PROPERTY + "'")) - .isEqualTo(expectedSize); - } - - private void assertProperties(String propertyKey, int userId, int expectedSize) { - assertThat(db.countSql("SELECT count(ID) FROM properties WHERE user_id=" + userId + " AND prop_key='" + propertyKey + "'")).isEqualTo(expectedSize); - } - - private void insertProperties(int userId, String qualifier, int nbProperties) { - rangeClosed(1, nbProperties).forEach(i -> { - int componentId = insertComponent(qualifier); - insertProperty(FAVOURITE_PROPERTY, userId, componentId); - }); - } - - private void insertProperty(String key, int userId, int componentId) { - db.executeInsert( - TABLE, - "PROP_KEY", key, - "USER_ID", userId, - "RESOURCE_ID", componentId, - "IS_EMPTY", true, - "CREATED_AT", 123456); - } - - private int insertComponent(String qualifier) { - return insertCommonComponent(qualifier, true); - } - - private int insertDisabledComponent(String qualifier) { - return insertCommonComponent(qualifier, false); - } - - private int insertCommonComponent(String qualifier, boolean enabled) { - int id = nextInt(); - String uuid = "uuid_" + id; - db.executeInsert( - "projects", - "ID", id, - "UUID", uuid, - "ORGANIZATION_UUID", "org_" + id, - "UUID_PATH", "path_" + id, - "ROOT_UUID", "root_" + id, - "PROJECT_UUID", "project_" + id, - "QUALIFIER", qualifier, - "ENABLED", enabled, - "PRIVATE", false); - return id; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiersTest.java deleted file mode 100644 index 82110265a9e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiersTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import 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 java.util.stream.Collectors.toList; -import static org.apache.commons.lang.math.RandomUtils.nextInt; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteFavouritesOnNotSupportedComponentQualifiersTest { - - private static final String TABLE = "properties"; - private static final String FAVOURITE_PROPERTY = "favourite"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteFavouritesOnNotSupportedComponentQualifiersTest.class, "schema.sql"); - - private DataChange underTest = new DeleteFavouritesOnNotSupportedComponentQualifiers(db.database()); - - @Test - public void delete_favorites_on_none_supported_component_qualifiers() throws SQLException { - int moduleId = insertComponent("BRC"); - insertProperty(FAVOURITE_PROPERTY, moduleId); - insertProperty(FAVOURITE_PROPERTY, moduleId); - insertProperty(FAVOURITE_PROPERTY, moduleId); - int libId = insertComponent("LIB"); - insertProperty(FAVOURITE_PROPERTY, libId); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE)).isZero(); - } - - @Test - public void ignore_favorites_on_supported_component_qualifiers() throws SQLException { - int projectId = insertComponent("TRK"); - int prop1 = insertProperty(FAVOURITE_PROPERTY, projectId); - int fileId = insertComponent("FIL"); - int prop2 = insertProperty(FAVOURITE_PROPERTY, fileId); - int portfolioId = insertComponent("VW"); - int prop3 = insertProperty(FAVOURITE_PROPERTY, portfolioId); - int subPortfolioId = insertComponent("SVW"); - int prop4 = insertProperty(FAVOURITE_PROPERTY, subPortfolioId); - int applicationId = insertComponent("APP"); - int prop5 = insertProperty(FAVOURITE_PROPERTY, applicationId); - int unitTestId = insertComponent("UTS"); - int prop6 = insertProperty(FAVOURITE_PROPERTY, unitTestId); - - underTest.execute(); - - assertProperties(prop1, prop2, prop3, prop4, prop5, prop6); - } - - @Test - public void ignore_other_properties() throws SQLException { - int moduleId = insertComponent("BRC"); - int prop1 = insertProperty("other", moduleId); - int prop2 = insertProperty("other", moduleId); - int libId = insertComponent("LIB"); - int prop3 = insertProperty("other", libId); - - underTest.execute(); - - assertProperties(prop1, prop2, prop3); - } - - private void assertProperties(Integer... expectedIds) { - assertThat(db.select("SELECT id FROM properties") - .stream() - .map(map -> ((Long) map.get("ID")).intValue()) - .collect(toList())) - .containsExactlyInAnyOrder(expectedIds); - } - - private int insertProperty(String key, int componentId) { - int id = nextInt(); - db.executeInsert( - TABLE, - "ID", id, - "PROP_KEY", key, - "USER_ID", nextInt(), - "RESOURCE_ID", componentId, - "IS_EMPTY", true, - "CREATED_AT", 123456); - return id; - } - - private int insertComponent(String qualifier) { - int id = nextInt(); - String uuid = "uuid_" + id; - db.executeInsert( - "projects", - "ID", id, - "UUID", uuid, - "ORGANIZATION_UUID", "org_" + id, - "UUID_PATH", "path_" + id, - "ROOT_UUID", "root_" + id, - "PROJECT_UUID", "project_" + id, - "QUALIFIER", qualifier, - "ENABLED", true, - "PRIVATE", false); - return id; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSourcesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSourcesTest.java deleted file mode 100644 index f9fe8a1b8dd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSourcesTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -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 java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class DeleteTestDataTypeFromFileSourcesTest { - - private static final String TABLE = "file_sources"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteTestDataTypeFromFileSourcesTest.class, "file_sources.sql"); - - private DataChange underTest = new DeleteTestDataTypeFromFileSources(db.database()); - - @Test - public void remove_test_data_type() throws SQLException { - insert("FILE1", "PROJECT1", "TEST"); - insert("FILE1", "PROJECT1", "SOURCE"); - insert("FILE2", "PROJECT2", "TEST"); - - underTest.execute(); - - assertFileSources(tuple("FILE1", "SOURCE")); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insert("FILE1", "PROJECT1", "SOURCE"); - insert("FILE1", "PROJECT1", "TEST"); - underTest.execute(); - - underTest.execute(); - - assertFileSources(tuple("FILE1", "SOURCE")); - } - - private void assertFileSources(Tuple... expectedTuples) { - assertThat(db.select("SELECT FILE_UUID, DATA_TYPE FROM FILE_SOURCES") - .stream() - .map(map -> new Tuple(map.get("FILE_UUID"), map.get("DATA_TYPE"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - public void insert(String fileUuid, String projectUuid, String dataType) { - db.executeInsert( - TABLE, - "PROJECT_UUID", projectUuid, - "DATA_TYPE", dataType, - "FILE_UUID", fileUuid, - "LINE_COUNT", 10, - "CREATED_AT", 123456, - "UPDATED_AT", 987654); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSourcesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSourcesTest.java deleted file mode 100644 index a55f76f0913..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSourcesTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -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.step.DdlChange; - -public class DropDataTypeFromFileSourcesTest { - - private static final String TABLE = "file_sources"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(DropDataTypeFromFileSourcesTest.class, "file_sources.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DdlChange underTest = new DropDataTypeFromFileSources(db.database()); - - @Test - public void drop_column_and_recreate_index() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist(TABLE, "data_type"); - db.assertUniqueIndex(TABLE, "file_sources_file_uuid", "file_uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropElasticsearchIndexTestsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropElasticsearchIndexTestsTest.java deleted file mode 100644 index 0bfa6fcdc43..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropElasticsearchIndexTestsTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -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.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class DropElasticsearchIndexTestsTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrationEsClient esClient = mock(MigrationEsClient.class); - private DdlChange underTest = new DropElasticsearchIndexTests(db.database(), esClient); - - @Test - public void rename_column() throws SQLException { - underTest.execute(); - - verify(esClient).deleteIndexes("tests"); - } - - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - - verify(esClient).deleteIndexes("tests"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueueTest.java deleted file mode 100644 index e24a23a8f40..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueueTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v77; - -import java.sql.SQLException; -import java.util.Random; -import java.util.stream.IntStream; -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.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TruncateEsQueueTest { - private static final String ES_QUEUE_TABLE = "es_queue"; - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(TruncateEsQueueTest.class, "es_queue.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DataChange underTest = new TruncateEsQueue(db.database()); - - @Test - public void migration_does_not_fail_on_empty_table() throws SQLException { - assertThat(db.countRowsOfTable(ES_QUEUE_TABLE)).isZero(); - - underTest.execute(); - - assertThat(db.countRowsOfTable(ES_QUEUE_TABLE)).isZero(); - } - - @Test - public void migration_truncates_content_of_table_es_queue() throws SQLException { - int count = insertData(); - assertThat(db.countRowsOfTable(ES_QUEUE_TABLE)).isEqualTo(count); - - underTest.execute(); - - assertThat(db.countRowsOfTable(ES_QUEUE_TABLE)).isZero(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - int count = insertData(); - assertThat(db.countRowsOfTable(ES_QUEUE_TABLE)).isEqualTo(count); - - underTest.execute(); - assertThat(db.countRowsOfTable(ES_QUEUE_TABLE)).isZero(); - - underTest.execute(); - assertThat(db.countRowsOfTable(ES_QUEUE_TABLE)).isZero(); - } - - private int insertData() { - int count = 5 + new Random().nextInt(200); - IntStream.range(0, count) - .forEach(i -> db.executeInsert( - ES_QUEUE_TABLE, - "UUID", "uuid_" + i, - "DOC_TYPE", "doc_type_" + i, - "DOC_ID", "doc_id_" + i, - "CREATED_AT", String.valueOf(i))); - return count; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuidTest.java deleted file mode 100644 index be1d90c1f70..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuidTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -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.step.DdlChange; - -public class AddIndexToOrgQProfileParentUuidTest { - - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddIndexToOrgQProfileParentUuidTest.class, "org_qprofiles.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DdlChange underTest = new AddIndexToOrgQProfileParentUuid(db.database()); - - @Test - public void creates_index() throws SQLException { - underTest.execute(); - - db.assertIndex("org_qprofiles", "org_qprofiles_parent_uuid", "parent_uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddSecurityFieldsToElasticsearchIndicesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddSecurityFieldsToElasticsearchIndicesTest.java deleted file mode 100644 index 4316932556a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddSecurityFieldsToElasticsearchIndicesTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v78; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; - -public class AddSecurityFieldsToElasticsearchIndicesTest { - - private MigrationEsClient esClient = mock(MigrationEsClient.class); - private Database database = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange underTest = new AddSecurityFieldsToElasticsearchIndices(database, esClient); - - @Test - public void migration_adds_new_issues_mapping() throws SQLException { - underTest.execute(); - - verify(esClient).addMappingToExistingIndex("issues", "auth", "sonarsourceSecurity", "keyword", - ImmutableMap.of("norms", "false")); - verify(esClient).addMappingToExistingIndex("rules", "rule", "cwe", "keyword", - ImmutableMap.of("norms", "false")); - verify(esClient).addMappingToExistingIndex("rules", "rule", "owaspTop10", "keyword", - ImmutableMap.of("norms", "false")); - verify(esClient).addMappingToExistingIndex("rules", "rule", "sansTop25", "keyword", - ImmutableMap.of("norms", "false")); - verify(esClient).addMappingToExistingIndex("rules", "rule", "sonarsourceSecurity", "keyword", - ImmutableMap.of("norms", "false")); - verifyNoMoreInteractions(esClient); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevisionTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevisionTest.java deleted file mode 100644 index f44bebb7b58..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevisionTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -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.step.DdlChange; - -import static java.sql.Types.VARCHAR; - -public class AddSnapshotRevisionTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddSnapshotRevisionTest.class, "snapshots.sql"); - - private DdlChange underTest = new AddSnapshotRevision(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("snapshots", "revision", VARCHAR, 100, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecretTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecretTest.java deleted file mode 100644 index 0e2e6f7081c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecretTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -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.step.DdlChange; - -import static java.sql.Types.VARCHAR; - -public class AddWebhooksSecretTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(AddWebhooksSecretTest.class, "webhooks.sql"); - - private DdlChange underTest = new AddWebhooksSecret(db.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("webhooks", "secret", VARCHAR, 200, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/CreateInternalComponentPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/CreateInternalComponentPropertiesTableTest.java deleted file mode 100644 index d42fbb28d19..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/CreateInternalComponentPropertiesTableTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class CreateInternalComponentPropertiesTableTest { - - private static final String TABLE = "internal_component_props"; - - @Rule - public final CoreDbTester db = CoreDbTester.createEmpty(); - - private CreateInternalComponentPropertiesTable underTest = new CreateInternalComponentPropertiesTable(db.database()); - - @Test - public void creates_table() throws SQLException { - underTest.execute(); - - checkTable(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - checkTable(); - } - - private void checkTable() { - db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 50, false); - db.assertColumnDefinition(TABLE, "kee", Types.VARCHAR, 512, false); - db.assertColumnDefinition(TABLE, "value", Types.VARCHAR, 4000, true); - db.assertColumnDefinition(TABLE, "updated_at", Types.BIGINT, null, false); - db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - - db.assertUniqueIndex(TABLE, "unique_component_uuid_kee", "component_uuid", "kee"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/DbVersion78Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/DbVersion78Test.java deleted file mode 100644 index 524248a37df..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/DbVersion78Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion78Test { - private DbVersion underTest = new DbVersion78(); - - @Test - public void migrationNumber_starts_at_2700() { - verifyMinimumMigrationNumber(underTest, 2700); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 9); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest.java deleted file mode 100644 index 24e1380a37e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.util.stream.Collectors.toList; -import static org.apache.commons.lang.math.RandomUtils.nextInt; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest.class, "schema.sql"); - - private DataChange underTest = new DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications(db.database()); - - @Test - public void delete_overall_subscriptions() throws SQLException { - // properties that do not relate to subscriptions - insertProperty(1, "foo", null); - insertProperty(2, "bar", nextInt()); - - // global subscriptions to be deleted - insertProperty(3, "notification.NewFalsePositiveIssue.EmailNotificationChannel", null); - insertProperty(4, "notification.NewFalsePositiveIssue.OtherChannel", null); - insertProperty(5, "notification.NewIssues.EmailNotificationChannel", null); - insertProperty(6, "notification.NewIssues.OtherChannel", null); - - // global subscriptions on other notifications, to be kept - insertProperty(7, "notification.ChangesOnMyIssue.EmailNotificationChannel", null); - insertProperty(8, "notification.NewAlerts.EmailNotificationChannel", null); - insertProperty(9, "notification.CeReportTaskFailure.EmailNotificationChannel", null); - insertProperty(10, "notification.SQ-MyNewIssues.EmailNotificationChannel", null); - - // project subscriptions, to be kept - insertProperty(11, "notification.NewFalsePositiveIssue.EmailNotificationChannel", nextInt()); - insertProperty(12, "notification.NewIssues.EmailNotificationChannel", nextInt()); - insertProperty(13, "notification.ChangesOnMyIssue.EmailNotificationChannel", nextInt()); - insertProperty(14, "notification.NewAlerts.EmailNotificationChannel", nextInt()); - insertProperty(15, "notification.CeReportTaskFailure.EmailNotificationChannel", nextInt()); - insertProperty(16, "notification.SQ-MyNewIssues.EmailNotificationChannel", nextInt()); - - underTest.execute(); - - assertProperties(1, 2, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); - } - - private void assertProperties(Integer... expectedIds) { - assertThat(db.select("SELECT id FROM properties") - .stream() - .map(map -> ((Long) map.get("ID")).intValue()) - .collect(toList())) - .containsExactlyInAnyOrder(expectedIds); - } - - private void insertProperty(int id, String key, @Nullable Integer componentId) { - db.executeInsert( - "PROPERTIES", - "ID", id, - "PROP_KEY", key, - "USER_ID", nextInt(), - "RESOURCE_ID", componentId, - "IS_EMPTY", true, - "CREATED_AT", 123456); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/MigrateRevisionTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/MigrateRevisionTest.java deleted file mode 100644 index 9cef01de6b9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/MigrateRevisionTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrateRevisionTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateRevisionTest.class, "snapshots.sql"); - - private MigrateRevision underTest = new MigrateRevision(db.database()); - - @Test - public void copies_revision_from_analysis_properties_to_snapshots() throws SQLException { - insertSnapshot(1, "uuid1", "cuuid1"); - insertAnalysisProperty("uuid1", "sonar.analysis.scm_revision_id", "000b17c1db52814d41e4f1425292435b4261ef22"); - insertAnalysisProperty("uuid1", "sonar.pullrequest.base", "master"); - insertSnapshot(2, "uuid2", "cuuid2"); - insertSnapshot(3, "uuid3", "cuuid3"); - insertAnalysisProperty("uuid3", "sonar.analysis.scm_revision_id", "7e1071e0606e8c7c8181602f8263bc6f56509ac4"); - - underTest.execute(); - - Map result = db.select("select ID, REVISION from SNAPSHOTS") - .stream() - .collect(HashMap::new, (m, v) -> m.put((Long) v.get("ID"), (String) v.get("REVISION")), HashMap::putAll); - assertThat(result.get(1L)).isEqualTo("000b17c1db52814d41e4f1425292435b4261ef22"); - assertThat(result.get(2L)).isNull(); - assertThat(result.get(3L)).isEqualTo("7e1071e0606e8c7c8181602f8263bc6f56509ac4"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertSnapshot(1, "uuid1", "cuuid1"); - insertAnalysisProperty("uuid1", "sonar.analysis.scm_revision_id", "7e1071e0606e8c7c8181602f8263bc6f56509ac4"); - - underTest.execute(); - underTest.execute(); - - Map result = db.select("select ID, REVISION from SNAPSHOTS") - .stream() - .collect(HashMap::new, (m, v) -> m.put((Long) v.get("ID"), (String) v.get("REVISION")), HashMap::putAll); - assertThat(result.get(1L)).isEqualTo("7e1071e0606e8c7c8181602f8263bc6f56509ac4"); - } - - private void insertSnapshot(long id, String uuid, String componentUuid) { - db.executeInsert( - "snapshots", - "id", id, - "uuid", uuid, - "component_uuid", componentUuid); - } - - private void insertAnalysisProperty(String snapshotUuid, String name, String value) { - db.executeInsert( - "analysis_properties", - "UUID", UUID.randomUUID(), - "SNAPSHOT_UUID", snapshotUuid, - "KEE", name, - "TEXT_VALUE", value, - "IS_EMPTY", false, - "CREATED_AT", new Date().getTime()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranchesTest.java deleted file mode 100644 index da0cd4d69ab..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranchesTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import java.util.Random; -import java.util.stream.IntStream; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RemoveOrphansFromProjectBranchesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RemoveOrphansFromProjectBranchesTest.class, "project_and_project_branches.sql"); - - private RemoveOrphansFromProjectBranches underTest = new RemoveOrphansFromProjectBranches(db.database()); - - @Test - public void migration_has_no_effect_on_empty_tables() throws SQLException { - String[] keeps = IntStream.range(0, 1 + new Random().nextInt(30)).mapToObj(i -> { - String uuid = "Keep_" + i; - insertIntoProjectBranches(uuid); - insertIntoProjects(uuid); - return uuid; - }) - .toArray(String[]::new); - String[] deletes = IntStream.range(0, 1 + new Random().nextInt(30)).mapToObj(i -> { - String uuid = "Dl_" + i; - insertIntoProjectBranches(uuid); - return uuid; - }) - .toArray(String[]::new); - - underTest.execute(); - - assertThat(db.select("select uuid as \"UUID\" from project_branches").stream().map(t -> (String) t.get("UUID"))) - .containsOnly(keeps) - .doesNotContain(deletes); - } - - private void insertIntoProjects(String uuid) { - db.executeInsert("PROJECTS", - "ORGANIZATION_UUID", "org_" + uuid, - "PROJECT_UUID", "PU_" + uuid, - "UUID", uuid, - "UUID_PATH", "UP_" + uuid, - "ROOT_UUID", "R_" + uuid, - "PRIVATE", new Random().nextBoolean()); - } - - @Test - public void migration_deletes_all_rows_in_project_branches_table_if_projects_table_is_empty() throws SQLException { - IntStream.range(0, 1 + new Random().nextInt(30)).forEach(this::insertIntoProjectBranches); - - underTest.execute(); - - assertThat(db.countRowsOfTable("PROJECT_BRANCHES")).isZero(); - } - - @Test - public void db_migration_is_reentrant() throws SQLException { - migration_deletes_all_rows_in_project_branches_table_if_projects_table_is_empty(); - - underTest.execute(); - - assertThat(db.countRowsOfTable("PROJECT_BRANCHES")).isZero(); - } - - private void insertIntoProjectBranches(int i) { - String uuid = "UUID_" + i; - insertIntoProjectBranches(uuid); - } - - private void insertIntoProjectBranches(String uuid) { - int i1 = new Random().nextInt(9_000); - db.executeInsert( - "PROJECT_BRANCHES", - "UUID", uuid, - "PROJECT_UUID", "PU_" + uuid, - "KEE", "KEE_" + uuid, - "KEY_TYPE", uuid + "_KT", - "CREATED_AT", 12 + i1, - "UPDATED_AT", 500 + i1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest.java deleted file mode 100644 index c6b7ba55a5e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v78; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.apache.commons.lang.math.RandomUtils; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.config.internal.MapSettings; -import org.sonar.api.impl.utils.TestSystem2; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.util.stream.Collectors.toList; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class UpdateSecurityHotspotsStatusesTest { - - private static final long PAST = 5_000_000_000L; - private static final long NOW = 10_000_000_000L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(UpdateSecurityHotspotsStatusesTest.class, "schema.sql"); - - private MapSettings settings = new MapSettings(); - private TestSystem2 system2 = new TestSystem2().setNow(NOW); - private MigrationEsClient esClient = mock(MigrationEsClient.class); - - private DataChange underTest = new UpdateSecurityHotspotsStatuses(db.database(), settings.asConfig(), system2, esClient, UuidFactoryFast.getInstance()); - - @Test - public void migrate_open_and_reopen_hotspots() throws SQLException { - int rule = insertRule(4); - String issue1 = insertIssue("OPEN", null, 4, rule); - String issue2 = insertIssue("REOPENED", null, 4, rule); - // Other type of issues should not be updated - String issue3 = insertIssue("OPEN", null, 1, rule); - String issue4 = insertIssue("REOPENED", null, 2, rule); - String issue5 = insertIssue("OPEN", null, 3, rule); - - underTest.execute(); - - assertIssues( - tuple(issue1, "TO_REVIEW", null, 4, NOW), - tuple(issue2, "TO_REVIEW", null, 4, NOW), - // Not updated - tuple(issue3, "OPEN", null, 1, PAST), - tuple(issue4, "REOPENED", null, 2, PAST), - tuple(issue5, "OPEN", null, 3, PAST)); - } - - @Test - public void migrate_resolved_as_fixed_and_wont_fix_hotspots() throws SQLException { - int rule = insertRule(4); - String issue1 = insertIssue("RESOLVED", "FIXED", 4, rule); - String issue2 = insertIssue("RESOLVED", "WONTFIX", 4, rule); - // Other type of issues should not be updated - String issue3 = insertIssue("RESOLVED", "FIXED", 1, rule); - String issue4 = insertIssue("RESOLVED", "WONTFIX", 2, rule); - String issue5 = insertIssue("RESOLVED", "WONTFIX", 3, rule); - - underTest.execute(); - - assertIssues( - tuple(issue1, "IN_REVIEW", null, 4, NOW), - tuple(issue2, "REVIEWED", "FIXED", 4, NOW), - // Not updated - tuple(issue3, "RESOLVED", "FIXED", 1, PAST), - tuple(issue4, "RESOLVED", "WONTFIX", 2, PAST), - tuple(issue5, "RESOLVED", "WONTFIX", 3, PAST)); - } - - @Test - public void insert_issue_changes() throws SQLException { - int rule = insertRule(4); - String issue1 = insertIssue("REOPENED", null, 4, rule); - // No changelog on OPEN issue as there was no previous state - String issue2 = insertIssue("OPEN", null, 4, rule); - String issue3 = insertIssue("RESOLVED", "FIXED", 4, rule); - String issue4 = insertIssue("RESOLVED", "WONTFIX", 4, rule); - - underTest.execute(); - - assertIssueChanges( - tuple(issue1, "diff", "status=REOPENED|TO_REVIEW,resolution=", NOW, NOW, NOW), - tuple(issue3, "diff", "status=RESOLVED|IN_REVIEW,resolution=FIXED|", NOW, NOW, NOW), - tuple(issue4, "diff", "status=RESOLVED|REVIEWED,resolution=WONTFIX|FIXED", NOW, NOW, NOW)); - } - - @Test - public void do_not_update_vulnerabilities_coming_from_hotspot() throws SQLException { - int rule = insertRule(4); - String issue1 = insertIssue("OPEN", null, 3, rule); - - underTest.execute(); - - assertIssues(tuple(issue1, "OPEN", null, 3, PAST)); - assertNoIssueChanges(); - } - - @Test - public void do_not_update_closed_hotspots() throws SQLException { - int rule = insertRule(4); - String issue1 = insertIssue("CLOSED", "FIXED", 4, rule); - String issue2 = insertIssue("CLOSED", "REMOVED", 4, rule); - - underTest.execute(); - - assertIssues( - tuple(issue1, "CLOSED", "FIXED", 4, PAST), - tuple(issue2, "CLOSED", "REMOVED", 4, PAST)); - assertNoIssueChanges(); - } - - @Test - public void do_nothing_on_sonarcloud() throws SQLException { - settings.setProperty("sonar.sonarcloud.enabled", "true"); - int rule = insertRule(4); - String issue1 = insertIssue("OPEN", null, 4, rule); - - underTest.execute(); - - assertIssues(tuple(issue1, "OPEN", null, 4, PAST)); - assertNoIssueChanges(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - int rule = insertRule(4); - String issue1 = insertIssue("OPEN", null, 4, rule); - String issue2 = insertIssue("REOPENED", null, 4, rule); - - underTest.execute(); - assertIssues( - tuple(issue1, "TO_REVIEW", null, 4, NOW), - tuple(issue2, "TO_REVIEW", null, 4, NOW)); - - // Set a new date for NOW in order to check that issues has not been updated again - system2.setNow(NOW + 1_000_000_000L); - underTest.execute(); - assertIssues( - tuple(issue1, "TO_REVIEW", null, 4, NOW), - tuple(issue2, "TO_REVIEW", null, 4, NOW)); - } - - @Test - public void issues_index_is_removed() throws SQLException { - underTest.execute(); - - verify(esClient).deleteIndexes("issues"); - } - - private void assertIssues(Tuple... expectedTuples) { - assertThat(db.select("SELECT kee, status, resolution, issue_type, updated_at FROM issues") - .stream() - .map(map -> new Tuple(map.get("KEE"), map.get("STATUS"), map.get("RESOLUTION"), map.get("ISSUE_TYPE"), map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoIssueChanges() { - assertThat(db.countRowsOfTable("issue_changes")).isZero(); - } - - private void assertIssueChanges(Tuple... expectedTuples) { - assertThat(db.select("SELECT issue_key, change_type, change_data, created_at, updated_at, issue_change_creation_date FROM issue_changes") - .stream() - .map(map -> new Tuple(map.get("ISSUE_KEY"), map.get("CHANGE_TYPE"), map.get("CHANGE_DATA"), map.get("CREATED_AT"), map.get("UPDATED_AT"), - map.get("ISSUE_CHANGE_CREATION_DATE"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private String insertIssue(String status, @Nullable String resolution, int issueType, int ruleId) { - String issueKey = randomAlphabetic(3); - db.executeInsert( - "ISSUES", - "KEE", issueKey, - "STATUS", status, - "RESOLUTION", resolution, - "RULE_ID", ruleId, - "ISSUE_TYPE", issueType, - "COMPONENT_UUID", randomAlphanumeric(10), - "PROJECT_UUID", randomAlphanumeric(10), - "MANUAL_SEVERITY", false, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return issueKey; - } - - private int insertRule(int ruleType) { - int id = RandomUtils.nextInt(); - db.executeInsert("RULES", - "ID", id, - "RULE_TYPE", ruleType, - "IS_EXTERNAL", false, - "PLUGIN_RULE_KEY", randomAlphanumeric(3), - "PLUGIN_NAME", randomAlphanumeric(3), - "SCOPE", "MAIN", - "IS_AD_HOC", false, - "CREATED_AT", PAST, - "UPDATED_AT", PAST); - return id; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchemaTest.java similarity index 73% rename from server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest.java rename to server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchemaTest.java index a4077965244..af0b1b77415 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchemaTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v56; +package org.sonar.server.platform.db.migration.version.v79; import java.sql.Connection; import java.sql.ResultSet; @@ -50,50 +50,69 @@ public class CreateInitialSchemaTest { } } assertThat(tables).containsOnly( - "active_dashboards", "active_rules", "active_rule_parameters", - "activities", - "authors", + "alm_app_installs", + "analysis_properties", "ce_activity", "ce_queue", - "dashboards", + "ce_scanner_context", + "ce_task_characteristics", + "ce_task_input", + "ce_task_message", + "default_qprofiles", + "deprecated_rule_keys", "duplications_index", + "es_queue", "events", + "event_component_changes", "file_sources", "groups", "groups_users", "group_roles", + "internal_component_props", + "internal_properties", "issues", "issue_changes", - "issue_filters", - "issue_filter_favourites", - "loaded_templates", + "live_measures", "manual_measures", - "measure_filters", - "measure_filter_favourites", "metrics", "notifications", + "organizations", + "organization_alm_bindings", + "organization_members", + "org_qprofiles", + "org_quality_gates", "permission_templates", "perm_templates_groups", "perm_templates_users", + "perm_tpl_characteristics", + "plugins", "projects", + "project_alm_bindings", + "project_branches", "project_links", + "project_mappings", "project_measures", "project_qprofiles", "properties", + "qprofile_changes", + "qprofile_edit_groups", + "qprofile_edit_users", "quality_gates", "quality_gate_conditions", - "resource_index", "rules", + "rules_metadata", "rules_parameters", "rules_profiles", + "rule_repositories", "snapshots", "users", + "user_properties", "user_roles", "user_tokens", - "widgets", - "widget_properties"); + "webhooks", + "webhook_deliveries"); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/DbVersion79Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/DbVersion79Test.java index e5eba60177e..51fa25d635b 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/DbVersion79Test.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/DbVersion79Test.java @@ -20,22 +20,28 @@ package org.sonar.server.platform.db.migration.version.v79; import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; +import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; public class DbVersion79Test { - private DbVersion underTest = new DbVersion79(); + private DbVersion79 underTest = new DbVersion79(); @Test - public void migrationNumber_starts_at_2800() { - verifyMinimumMigrationNumber(underTest, 2800); + public void verify_no_support_component() { + assertThat(underTest.getSupportComponents()).isEmpty(); + } + + @Test + public void migrationNumber_starts_at_1153() { + verifyMinimumMigrationNumber(underTest, 1); } @Test public void verify_migration_count() { - verifyMigrationCount(underTest, 5); + verifyMigrationCount(underTest, 2); } + } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOpsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOpsTest.java deleted file mode 100644 index e9cb62b0d8c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOpsTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class MigrateVstsProviderToAzureDevOpsTest { - - private final static String SELECT_PROPERTIES = "SELECT prop_key, is_empty, text_value, clob_value FROM properties"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateVstsProviderToAzureDevOpsTest.class, "properties.sql"); - - private MigrateVstsProviderToAzureDevOps underTest = new MigrateVstsProviderToAzureDevOps(db.database()); - - @Test - public void migration_must_update_the_database() throws SQLException { - insertProperty("sonar.pullrequest.provider", "any.value_here", null, false); - insertProperty("sonar.pullrequest.provider", "VSTS", null, false); - insertProperty("sonar.pullrequest.provider", "VSTS / TFS", null, false); - insertProperty("whatever.property", "nothingspecial", null, false); - insertProperty("whatever.property", null, "nothing.special", false); - - underTest.execute(); - - assertPropertyContainsInAnyOrder( - tuple("sonar.pullrequest.provider", "any.value_here", null, false), - tuple("sonar.pullrequest.provider", "Azure DevOps Services", null, false), - tuple("sonar.pullrequest.provider", "Azure DevOps", null, false), // Single change - tuple("whatever.property", "nothingspecial", null, false), - tuple("whatever.property", null, "nothing.special", false) - ); - } - - @Test - public void migration_must_be_reentrant() throws SQLException { - insertProperty("sonar.pullrequest.provider", "any.value_here", null, false); - insertProperty("sonar.pullrequest.provider", "VSTS", null, false); - insertProperty("sonar.pullrequest.provider", "VSTS / TFS", null, false); - insertProperty("whatever.property", "nothingspecial", null, false); - insertProperty("whatever.property", null, "nothing.special", false); - - underTest.execute(); - underTest.execute(); - - assertPropertyContainsInAnyOrder( - tuple("sonar.pullrequest.provider", "any.value_here", null, false), - tuple("sonar.pullrequest.provider", "Azure DevOps Services", null, false), - tuple("sonar.pullrequest.provider", "Azure DevOps", null, false), // Single change - tuple("whatever.property", "nothingspecial", null, false), - tuple("whatever.property", null, "nothing.special", false) - ); - } - - @Test - public void migration_is_doing_nothing_when_no_data() throws SQLException { - assertThat(db.countRowsOfTable("properties")).isEqualTo(0); - underTest.execute(); - assertThat(db.countRowsOfTable("properties")).isEqualTo(0); - } - - private void insertProperty(String propKey, @Nullable String textValue, @Nullable String clobValue, boolean isEmpty) { - HashMap map = new HashMap<>(); - map.put("PROP_KEY", propKey); - map.put("TEXT_VALUE", textValue); - map.put("CLOB_VALUE", clobValue); - map.put("IS_EMPTY", isEmpty); - db.executeInsert("PROPERTIES", map); - } - - private void assertPropertyContainsInAnyOrder(Tuple... tuples) { - assertThat(db.select(SELECT_PROPERTIES) - .stream() - .map(p -> new Tuple(p.get("PROP_KEY"), p.get("TEXT_VALUE"), p.get("CLOB_VALUE"), p.get("IS_EMPTY"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder(tuples); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchemaTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchemaTest.java new file mode 100644 index 00000000000..7817f522149 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchemaTest.java @@ -0,0 +1,257 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v79; + +import java.sql.SQLException; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.stream.Stream; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.SonarRuntime; +import org.sonar.api.utils.System2; +import org.sonar.api.utils.Version; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.core.util.stream.MoreCollectors; +import org.sonar.db.CoreDbTester; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class PopulateInitialSchemaTest { + + private static final long NOW = 1_500L; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private final Random random = new Random(); + private final Version version = Version.create(1 + random.nextInt(10), 1 + random.nextInt(10), random.nextInt(10)); + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private System2 system2 = mock(System2.class); + private SonarRuntime sonarRuntime = mock(SonarRuntime.class); + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateInitialSchemaTest.class, "v79.sql"); + + private PopulateInitialSchema underTest = new PopulateInitialSchema(db.database(), system2, uuidFactory, sonarRuntime); + + @Before + public void setUp() { + when(sonarRuntime.getApiVersion()).thenReturn(version); + } + + @Test + public void migration_inserts_users_and_groups() throws SQLException { + when(system2.now()).thenReturn(NOW); + + underTest.execute(); + + verifyAdminUser(); + long userGroupId = verifyGroup("sonar-users", "Any new users created will automatically join this group"); + verifyGroup("sonar-administrators", "System administrators"); + String qgUuid = verifyQualityGate(); + String orgUuid = verifyDefaultOrganization(userGroupId, qgUuid); + verifyOrgQualityGate(orgUuid, qgUuid); + verifyInternalProperties(orgUuid); + verifyRolesOfAdminsGroup(); + verifyRolesOfUsersGroup(); + verifyRolesOfAnyone(); + verifyMembershipOfAdminUser(); + } + + private void verifyAdminUser() { + Map cols = db.selectFirst("select " + + "login as \"LOGIN\", " + + "name as \"NAME\", " + + "email as \"EMAIL\", " + + "external_id as \"EXTERNAL_ID\", " + + "external_login as \"EXTERNAL_LOGIN\", " + + "external_identity_provider as \"EXT_IDENT_PROVIDER\", " + + "user_local as \"USER_LOCAL\", " + + "crypted_password as \"CRYPTED_PASSWORD\", " + + "salt as \"SALT\", " + + "hash_method as \"HASH_METHOD\", " + + "is_root as \"IS_ROOT\", " + + "onboarded as \"ONBOARDED\", " + + "created_at as \"CREATED_AT\", " + + "updated_at as \"UPDATED_AT\" " + + "from users where login='admin'"); + assertThat(cols.get("LOGIN")).isEqualTo("admin"); + assertThat(cols.get("NAME")).isEqualTo("Administrator"); + assertThat(cols.get("EMAIL")).isNull(); + assertThat(cols.get("EXTERNAL_ID")).isEqualTo("admin"); + assertThat(cols.get("EXTERNAL_LOGIN")).isEqualTo("admin"); + assertThat(cols.get("EXT_IDENT_PROVIDER")).isEqualTo("sonarqube"); + assertThat(cols.get("USER_LOCAL")).isEqualTo(true); + assertThat(cols.get("CRYPTED_PASSWORD")).isEqualTo("$2a$12$uCkkXmhW5ThVK8mpBvnXOOJRLd64LJeHTeCkSuB3lfaR2N0AYBaSi"); + assertThat(cols.get("SALT")).isNull(); + assertThat(cols.get("HASH_METHOD")).isEqualTo("BCRYPT"); + assertThat(cols.get("IS_ROOT")).isEqualTo(false); + assertThat(cols.get("ONBOARDED")).isEqualTo(true); + assertThat(cols.get("CREATED_AT")).isEqualTo(NOW); + assertThat(cols.get("UPDATED_AT")).isEqualTo(NOW); + } + + private long verifyGroup(String expectedName, String expectedDescription) { + List> rows = db.select("select " + + "id as \"ID\"," + + "name as \"name\", " + + "description as \"description\", " + + "created_at as \"CREATED_AT\", " + + "updated_at as \"UPDATED_AT\" " + + "from groups where name='" + expectedName + "'"); + assertThat(rows).hasSize(1); + + Map row = rows.get(0); + assertThat(row.get("name")).isEqualTo(expectedName); + assertThat(row.get("description")).isEqualTo(expectedDescription); + assertThat(((Date) row.get("CREATED_AT")).getTime()).isEqualTo(NOW); + assertThat(((Date) row.get("UPDATED_AT")).getTime()).isEqualTo(NOW); + + return (long) row.get("ID"); + } + + private String verifyQualityGate() { + List> rows = db.select("select " + + "uuid as \"UUID\", " + + "name as \"NAME\", " + + "is_built_in as \"BUILTIN\"," + + "created_at as \"CREATED_AT\", " + + "updated_at as \"UPDATED_AT\"" + + " from quality_gates"); + assertThat(rows).hasSize(1); + + Map row = rows.get(0); + assertThat(row.get("NAME")).isEqualTo("Sonar way"); + assertThat(row.get("BUILTIN")).isEqualTo(true); + assertThat(((Date) row.get("CREATED_AT")).getTime()).isEqualTo(NOW); + assertThat(((Date) row.get("UPDATED_AT")).getTime()).isEqualTo(NOW); + return (String) row.get("UUID"); + } + + private String verifyDefaultOrganization(long userGroupId, String defaultQQUuid) { + List> rows = db.select("select " + + "uuid as \"UUID\", " + + "kee as \"KEE\", " + + "name as \"NAME\", " + + "guarded as \"GUARDED\", " + + "new_project_private as \"PRIVATE\", " + + "default_group_id as \"GROUP_ID\", " + + "default_quality_gate_uuid as \"QG_UUID\", " + + "subscription as \"SUBSCRIPTION\", " + + "created_at as \"CREATED_AT\", " + + "updated_at as \"UPDATED_AT\"" + + " from organizations"); + assertThat(rows).hasSize(1); + + Map row = rows.get(0); + assertThat(row.get("KEE")).isEqualTo("default-organization"); + assertThat(row.get("NAME")).isEqualTo("Default Organization"); + assertThat(row.get("GUARDED")).isEqualTo(true); + assertThat(row.get("PRIVATE")).isEqualTo(false); + assertThat(row.get("GROUP_ID")).isEqualTo(userGroupId); + assertThat(row.get("QG_UUID")).isEqualTo(defaultQQUuid); + assertThat(row.get("SUBSCRIPTION")).isEqualTo("SONARQUBE"); + assertThat(row.get("CREATED_AT")).isEqualTo(NOW); + assertThat(row.get("UPDATED_AT")).isEqualTo(NOW); + return (String) row.get("UUID"); + } + + private void verifyOrgQualityGate(String orgUuid, String qgUuid) { + List> rows = db.select("select " + + "uuid as \"UUID\", " + + "organization_uuid as \"ORG\", " + + "quality_gate_uuid as \"QG\"" + + " from org_quality_gates"); + assertThat(rows).hasSize(1); + + Map row = rows.get(0); + assertThat(row.get("UUID")).isNotNull(); + assertThat(row.get("ORG")).isEqualTo(orgUuid); + assertThat(row.get("QG")).isEqualTo(qgUuid); + } + + private void verifyInternalProperties(String orgUuid) { + List> rows = db.select("select " + + "kee as \"KEE\", " + + "is_empty as \"EMPTY\", " + + "text_value as \"VAL\"," + + "created_at as \"CREATED_AT\" " + + " from internal_properties"); + assertThat(rows).hasSize(3); + + Map> rowsByKey = rows.stream().collect(MoreCollectors.uniqueIndex(t -> (String) t.get("KEE"))); + verifyInternalProperty(rowsByKey, "organization.default", orgUuid); + verifyInternalProperty(rowsByKey, "installation.date", String.valueOf(system2.now())); + verifyInternalProperty(rowsByKey, "installation.version", version.toString()); + } + + private static void verifyInternalProperty(Map> rowsByKey, String key, String val) { + Map row = rowsByKey.get(key); + assertThat(row.get("KEE")).isEqualTo(key); + assertThat(row.get("EMPTY")).isEqualTo(false); + assertThat(row.get("VAL")).isEqualTo(val); + assertThat(row.get("CREATED_AT")).isEqualTo(NOW); + } + + private void verifyRolesOfAdminsGroup() { + assertThat(selectRoles("sonar-administrators")).containsOnly("admin", "profileadmin", "gateadmin", "provisioning", "applicationcreator", "portfoliocreator"); + } + + private void verifyRolesOfUsersGroup() { + assertThat(selectRoles("sonar-users")).isEmpty(); + } + + private void verifyRolesOfAnyone() { + List> rows = db.select("select gr.role as \"role\" " + + "from group_roles gr where gr.group_id is null"); + Stream roles = rows.stream() + .map(row -> (String) row.get("role")); + assertThat(roles).containsOnly("provisioning", "scan"); + } + + private Stream selectRoles(String groupName) { + List> rows = db.select("select gr.role as \"role\" " + + "from group_roles gr " + + "inner join groups g on gr.group_id = g.id " + + "where g.name='" + groupName + "'"); + return rows.stream() + .map(row -> (String) row.get("role")); + } + + private void verifyMembershipOfAdminUser() { + List> rows = db.select("select g.name as \"groupName\" from groups g " + + "inner join groups_users gu on gu.group_id = g.id " + + "inner join users u on gu.user_id = u.id " + + "where u.login='admin'"); + List groupNames = rows.stream() + .map(row -> (String) row.get("groupName")) + .collect(MoreCollectors.toArrayList()); + assertThat(groupNames).containsOnly("sonar-administrators", "sonar-users"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersionTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersionTest.java deleted file mode 100644 index 5944bb29f01..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersionTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; -import org.apache.commons.lang.math.RandomUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.SonarRuntime; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.Version; -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.groups.Tuple.tuple; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateInstallDateAndVersionTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateInstallDateAndVersionTest.class, "schema.sql"); - - private System2 system2 = mock(System2.class); - private SonarRuntime sonarRuntime = mock(SonarRuntime.class); - - private DataChange underTest = new PopulateInstallDateAndVersion(db.database(), sonarRuntime, system2); - - private Function, Object> field(String name) { - return m -> m.get(name); - } - - @Before - public void before() { - Version version = Version.create(7, 9, 0); - when(sonarRuntime.getApiVersion()).thenReturn(version); - when(system2.now()).thenReturn(RandomUtils.nextLong()); - truncateUsers(); - truncateInternalProperties(); - } - - @Test - public void migrateFreshInstall() throws SQLException { - Long createdAt = system2.now() - (23 * 60 * 60 * 1000); - insertAdminUser(createdAt); - - underTest.execute(); - - assertThat(db.select("select * from internal_properties")).extracting( - field("CREATED_AT"), field("CLOB_VALUE"), - field("KEE"), field("TEXT_VALUE"), field("IS_EMPTY")) - .containsExactlyInAnyOrder( - tuple(system2.now(), null, "installation.date", String.valueOf(createdAt), false), - tuple(system2.now(), null, "installation.version", "7.9", false)); - } - - @Test - public void migrateOldInstance() throws SQLException { - Long createdAt = system2.now() - (25 * 60 * 60 * 1000); - insertAdminUser(createdAt); - - underTest.execute(); - - assertThat(db.select("select * from internal_properties")).extracting( - field("CREATED_AT"), field("CLOB_VALUE"), - field("KEE"), field("TEXT_VALUE"), field("IS_EMPTY")) - .containsExactlyInAnyOrder( - tuple(system2.now(), null, "installation.date", String.valueOf(createdAt), false)); - } - - @Test - public void migrateNoUsers() throws SQLException { - underTest.execute(); - - assertThat(db.select("select * from internal_properties").stream().count()).isEqualTo(0); - } - - private void insertAdminUser(long createdAt) { - Map values = new HashMap<>(); - values.put("UUID", "UUID"); - values.put("login", "admin"); - values.put("name", "Administrator"); - values.put("email", null); - values.put("EXTERNAL_ID", "admin"); - values.put("EXTERNAL_LOGIN", "admin"); - values.put("external_identity_provider", "sonarqube"); - values.put("user_local", true); - values.put("crypted_password", "a373a0e667abb2604c1fd571eb4ad47fe8cc0878"); - values.put("salt", "48bc4b0d93179b5103fd3885ea9119498e9d161b"); - values.put("created_at", createdAt); - values.put("updated_at", createdAt); - values.put("IS_ROOT", true); - values.put("ONBOARDED", false); - db.executeInsert("users", values); - } - - private void truncateUsers() { - db.executeUpdateSql("truncate table users"); - } - - private void truncateInternalProperties() { - db.executeUpdateSql("truncate table internal_properties"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/ReindexIssuesAndRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/ReindexIssuesAndRulesTest.java deleted file mode 100644 index be656e9750a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/ReindexIssuesAndRulesTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.config.internal.MapSettings; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.es.MigrationEsClient; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; - -public class ReindexIssuesAndRulesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createEmpty(); - - private MapSettings settings = new MapSettings(); - private MigrationEsClient esClient = mock(MigrationEsClient.class); - - private DataChange underTest = new ReindexIssuesAndRules(db.database(), settings.asConfig(), esClient); - - @Test - public void update_es_indexes() throws SQLException { - settings.setProperty("sonar.sonarcloud.enabled", "false"); - - underTest.execute(); - - verify(esClient).deleteIndexes("issues", "rules"); - } - - @Test - public void do_nothing_on_sonarcloud() throws SQLException { - settings.setProperty("sonar.sonarcloud.enabled", "true"); - - underTest.execute(); - - verifyZeroInteractions(esClient); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRatingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRatingTest.java deleted file mode 100644 index b06c4936acf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRatingTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang.math.RandomUtils; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static com.google.common.primitives.Longs.asList; -import static java.lang.String.format; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; - -public class RemoveQGConditionsOnSecurityReviewRatingTest { - - private static final String TABLE_QUALITY_GATE_CONDITIONS = "quality_gate_conditions"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RemoveQGConditionsOnSecurityReviewRatingTest.class, "quality_gate_conditions.sql"); - - private RemoveQGConditionsOnSecurityReviewRating underTest = new RemoveQGConditionsOnSecurityReviewRating(db.database()); - - @Test - public void migrate() throws SQLException { - long securityReviewRatingMetric = insertMetric("security_review_rating"); - long otherMetric = insertMetric("other"); - insertQualityGateCondition(securityReviewRatingMetric); - insertQualityGateCondition(securityReviewRatingMetric); - long conditionOnOtherMetric = insertQualityGateCondition(otherMetric); - - underTest.execute(); - - verifyConditionIds(asList(conditionOnOtherMetric)); - } - - @Test - public void do_nothing_when_no_condition_on_security_review_rating() throws SQLException { - long otherMetric = insertMetric("other"); - long condition1 = insertQualityGateCondition(otherMetric); - long condition2 = insertQualityGateCondition(otherMetric); - - underTest.execute(); - - verifyConditionIds(asList(condition1, condition2)); - } - - @Test - public void do_nothing_when_no_condition() throws SQLException { - insertMetric("other"); - - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isZero(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long securityReviewRatingMetric = insertMetric("security_review_rating"); - long otherMetric = insertMetric("other"); - insertQualityGateCondition(securityReviewRatingMetric); - insertQualityGateCondition(securityReviewRatingMetric); - long conditionOnOtherMetric = insertQualityGateCondition(otherMetric); - - underTest.execute(); - underTest.execute(); - - verifyConditionIds(asList(conditionOnOtherMetric)); - } - - private void verifyConditionIds(List expectedConditionIds) { - List> results = db.select("select ID from " + TABLE_QUALITY_GATE_CONDITIONS); - assertThat(results.stream() - .map(map -> (long) map.get("ID")) - .collect(toList())) - .containsExactlyInAnyOrderElementsOf(expectedConditionIds); - } - - private long insertQualityGateCondition(long metricId) { - long qualityGateId = RandomUtils.nextInt(); - Map values = new HashMap<>(ImmutableMap.of("QGATE_ID", qualityGateId, "METRIC_ID", metricId, "OPERATOR", "GT")); - values.put("VALUE_ERROR", RandomUtils.nextInt()); - db.executeInsert(TABLE_QUALITY_GATE_CONDITIONS, values); - String sql = format("select id as \"id\" from %s where qgate_id='%s' and metric_id='%s'", TABLE_QUALITY_GATE_CONDITIONS, qualityGateId, metricId); - return (Long) db - .selectFirst(sql) - .get("id"); - } - - private long insertMetric(String key) { - db.executeInsert("metrics", "NAME", key); - return (Long) db.selectFirst(format("select id as \"id\" from metrics where name='%s'", key)).get("id"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContextTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContextTest.java deleted file mode 100644 index 695b8a6436f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContextTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v79; - -import java.nio.charset.StandardCharsets; -import java.sql.Blob; -import java.sql.SQLException; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TruncateEnvAndSystemVarsFromScannerContextTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(TruncateEnvAndSystemVarsFromScannerContextTest.class, "ce_scanner_context.sql"); - - private TruncateEnvAndSystemVarsFromScannerContext underTest = new TruncateEnvAndSystemVarsFromScannerContext(db.database()); - - private static final String ENTRY_WITH_ENV_AND_SYSTEM_VARS = "Environment variables:\n" + - " - PATH=blablahblah\n" + - "System properties:\n" + - " - java.class.version=55.0\n" + - "\n" + - " - user.language=en\n" + - "SonarQube plugins:\n" + - " - SonarCSS 1.0.3.724 (cssfamily)\n" + - "Global server settings:\n" + - " - sonar.core.startTime=2019-06-18T12:53:09+0200\n" + - "Project server settings:\n" + - "Project scanner properties:\n" + - " - sonar.verbose=true"; - - private static final String TRUNCATED_ENTRY = "SonarQube plugins:\n" + - " - SonarCSS 1.0.3.724 (cssfamily)\n" + - "Global server settings:\n" + - " - sonar.core.startTime=2019-06-18T12:53:09+0200\n" + - "Project server settings:\n" + - "Project scanner properties:\n" + - " - sonar.verbose=true"; - - @Test - public void execute() throws SQLException { - insert_entry("887f07ff-91bb-4e62-8e4b-660d5b40b16a", ENTRY_WITH_ENV_AND_SYSTEM_VARS); - insert_entry("9d2429cc-155a-4327-8ed7-48fdbe93edd0", TRUNCATED_ENTRY); - - underTest.execute(); - - Map result = db.select("select TASK_UUID, CONTEXT_DATA from CE_SCANNER_CONTEXT") - .stream() - .collect(HashMap::new, (m, v) -> m.put((String) v.get("TASK_UUID"), readBlob((Blob) v.get("CONTEXT_DATA"))), HashMap::putAll); - assertThat(result).hasSize(2); - assertThat(result.get("887f07ff-91bb-4e62-8e4b-660d5b40b16a")).isEqualTo(TRUNCATED_ENTRY); - assertThat(result.get("9d2429cc-155a-4327-8ed7-48fdbe93edd0")).isEqualTo(TRUNCATED_ENTRY); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insert_entry("887f07ff-91bb-4e62-8e4b-660d5b40b16a", ENTRY_WITH_ENV_AND_SYSTEM_VARS); - insert_entry("9d2429cc-155a-4327-8ed7-48fdbe93edd0", TRUNCATED_ENTRY); - - underTest.execute(); - underTest.execute(); - - Map result = db.select("select TASK_UUID, CONTEXT_DATA from CE_SCANNER_CONTEXT") - .stream() - .collect(HashMap::new, (m, v) -> m.put((String) v.get("TASK_UUID"), readBlob((Blob) v.get("CONTEXT_DATA"))), HashMap::putAll); - assertThat(result).hasSize(2); - assertThat(result.get("887f07ff-91bb-4e62-8e4b-660d5b40b16a")).isEqualTo(TRUNCATED_ENTRY); - assertThat(result.get("9d2429cc-155a-4327-8ed7-48fdbe93edd0")).isEqualTo(TRUNCATED_ENTRY); - } - - private String readBlob(Blob blob) throws IllegalStateException { - try { - return new String(blob.getBytes(1, (int) blob.length()), StandardCharsets.UTF_8); - } catch (SQLException e) { - throw new IllegalStateException(e); - } - } - - private void insert_entry(String uuid, String content) { - db.executeInsert( - "CE_SCANNER_CONTEXT", - "TASK_UUID", uuid, - "CONTEXT_DATA", content.getBytes(StandardCharsets.UTF_8), - "CREATED_AT", new Date().getTime(), - "UPDATED_AT", new Date().getTime()); - } -} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProviderImplTest/internal_properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProviderImplTest/internal_properties.sql similarity index 100% rename from server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidProviderImplTest/internal_properties.sql rename to server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/DefaultOrganizationUuidProviderImplTest/internal_properties.sql diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest/v56.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest/v56.sql deleted file mode 100644 index d0c61c969ac..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest/v56.sql +++ /dev/null @@ -1,47 +0,0 @@ -CREATE TABLE "GROUPS_USERS" ( - "USER_ID" INTEGER, - "GROUP_ID" INTEGER -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); - - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); - - -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "REMEMBER_TOKEN" VARCHAR(500), - "REMEMBER_TOKEN_EXPIRES_AT" TIMESTAMP, - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest/schema.sql deleted file mode 100644 index 127fc346a9f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "REMEMBER_TOKEN" VARCHAR(500), - "REMEMBER_TOKEN_EXPIRES_AT" TIMESTAMP, - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest/old_ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest/old_ce_activity.sql deleted file mode 100644 index 8fbdcb6cce4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest/old_ce_activity.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "SNAPSHOT_ID" INTEGER NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest/events_before_6-0.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest/events_before_6-0.sql deleted file mode 100644 index e0c04fc1904..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest/events_before_6-0.sql +++ /dev/null @@ -1,12 +0,0 @@ - -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(400), - "COMPONENT_UUID" VARCHAR(50), - "SNAPSHOT_ID" INTEGER, - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql deleted file mode 100644 index 2f918746508..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "SNAPSHOT_ID" INTEGER, - "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" BINARY(167772150) - ); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest/old_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest/old_projects.sql deleted file mode 100644 index 1c469e80b26..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest/old_projects.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(4000) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql deleted file mode 100644 index 6ac3885a261..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest/project_measures_5.6.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest/project_measures_5.6.sql deleted file mode 100644 index c4f1eab4b8d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest/project_measures_5.6.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER, - "RULE_ID" INTEGER, - "RULES_CATEGORY_ID" INTEGER, - "TEXT_VALUE" VARCHAR(4000), - "TENDENCY" INTEGER, - "MEASURE_DATE" TIMESTAMP, - "PROJECT_ID" INTEGER, - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "URL" VARCHAR(2000), - "DESCRIPTION" VARCHAR(4000), - "RULE_PRIORITY" INTEGER, - "CHARACTERISTIC_ID" INTEGER, - "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" BINARY(167772150) -); - -CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); - -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest/old_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest/old_snapshots.sql deleted file mode 100644 index 1472d580371..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest/old_snapshots.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "PROJECT_ID" INTEGER NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_PROJECT_ID" INTEGER, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest/rules_profiles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest/rules_profiles.sql deleted file mode 100644 index cddbb2038a8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest/rules_profiles.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -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/v60/AddProfileKeyToActivitiesTest/activities.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest/activities.sql deleted file mode 100644 index 338d203db7d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest/activities.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVITIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOG_KEY" VARCHAR(250), - "CREATED_AT" TIMESTAMP, - "USER_LOGIN" VARCHAR(255), - "LOG_TYPE" VARCHAR(250), - "LOG_ACTION" VARCHAR(250), - "LOG_MESSAGE" VARCHAR(250), - "DATA_FIELD" CLOB(2147483647) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest/rules_profiles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest/rules_profiles.sql deleted file mode 100644 index efa759b85e5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest/rules_profiles.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest/old_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest/old_snapshots.sql deleted file mode 100644 index d8e6c110791..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest/old_snapshots.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest/old_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest/old_projects.sql deleted file mode 100644 index d8331447c2f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest/old_projects.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ROOT_ID" INTEGER, - "UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_RESOURCE_ID" INTEGER, - "LONG_NAME" VARCHAR(2000), - "PERSON_ID" INTEGER, - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest/in_progress_events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest/in_progress_events.sql deleted file mode 100644 index 6f84d3b6dd4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest/in_progress_events.sql +++ /dev/null @@ -1,15 +0,0 @@ - -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50), - "COMPONENT_UUID" VARCHAR(50), - "SNAPSHOT_ID" INTEGER, - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); - - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest/in_progress_events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest/in_progress_events.sql deleted file mode 100644 index 6f84d3b6dd4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest/in_progress_events.sql +++ /dev/null @@ -1,15 +0,0 @@ - -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50), - "COMPONENT_UUID" VARCHAR(50), - "SNAPSHOT_ID" INTEGER, - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); - - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql deleted file mode 100644 index 5f58ad529ce..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "SNAPSHOT_ID" INTEGER, - // NULLABLE at that time - "ANALYSIS_UUID" VARCHAR(50), - "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" BINARY(167772150) - ); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest/in_progress_snapshots_and_children_tables.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest/in_progress_snapshots_and_children_tables.sql deleted file mode 100644 index d77a2eab205..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest/in_progress_snapshots_and_children_tables.sql +++ /dev/null @@ -1,101 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "PROJECT_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_PROJECT_ID" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); - -CREATE TABLE "DUPLICATIONS_INDEX" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL -); - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER, - "RULE_ID" INTEGER, - "RULES_CATEGORY_ID" INTEGER, - "TEXT_VALUE" VARCHAR(4000), - "TENDENCY" INTEGER, - "MEASURE_DATE" TIMESTAMP, - "PROJECT_ID" INTEGER, - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "URL" VARCHAR(2000), - "DESCRIPTION" VARCHAR(4000), - "RULE_PRIORITY" INTEGER, - "CHARACTERISTIC_ID" INTEGER, - "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" BINARY(167772150) -); - -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "SNAPSHOT_ID" INTEGER NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL -); - -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(400), - "COMPONENT_UUID" VARCHAR(50), - "SNAPSHOT_ID" INTEGER, - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql deleted file mode 100644 index 3fabd832864..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql +++ /dev/null @@ -1,668 +0,0 @@ -CREATE TABLE "GROUPS_USERS" ( - "USER_ID" INTEGER, - "GROUP_ID" INTEGER -); - -CREATE TABLE "RULES_PARAMETERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000) -); - -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PROJECT_QPROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(255) NOT NULL -); - -CREATE TABLE "WIDGETS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DASHBOARD_ID" INTEGER NOT NULL, - "WIDGET_KEY" VARCHAR(256) NOT NULL, - "NAME" VARCHAR(256), - "DESCRIPTION" VARCHAR(1000), - "COLUMN_INDEX" INTEGER, - "ROW_INDEX" INTEGER, - "CONFIGURED" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "RESOURCE_ID" INTEGER -); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); - -CREATE TABLE "SCHEMA_MIGRATIONS" ( -"VERSION" VARCHAR(256) NOT NULL -); - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_LOGIN" VARCHAR(255), - "NOTE_CREATED_AT" TIMESTAMP, - "NOTE_UPDATED_AT" TIMESTAMP, - "REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); - - -CREATE TABLE "WIDGET_PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "WIDGET_ID" INTEGER NOT NULL, - "KEE" VARCHAR(100), - "TEXT_VALUE" VARCHAR(4000) -); - -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(400), - "COMPONENT_UUID" VARCHAR(50), - "SNAPSHOT_ID" INTEGER, - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); - -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); - -CREATE TABLE "QUALITY_GATE_CONDITIONS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "PERIOD" INTEGER, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512), - "RESOURCE_ID" INTEGER, - "TEXT_VALUE" CLOB(2147483647), - "USER_ID" INTEGER -); - -CREATE TABLE "PROJECT_LINKS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "COMPONENT_UUID" VARCHAR(50), - "LINK_TYPE" VARCHAR(20), - "NAME" VARCHAR(128), - "HREF" VARCHAR(2048) NOT NULL -); - -CREATE TABLE "DUPLICATIONS_INDEX" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL -); - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "SNAPSHOT_ID" INTEGER, - "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" BINARY(167772150) -); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ROOT_ID" INTEGER, - "UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_RESOURCE_ID" INTEGER, - "LONG_NAME" VARCHAR(2000), - "PERSON_ID" INTEGER, - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT -); - -CREATE TABLE "MANUAL_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); - -CREATE TABLE "ACTIVE_RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 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 -); - -CREATE TABLE "NOTIFICATIONS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DATA" BLOB(167772150) -); - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE TABLE "ACTIVE_DASHBOARDS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DASHBOARD_ID" INTEGER NOT NULL, - "USER_ID" INTEGER, - "ORDER_INDEX" INTEGER -); - -CREATE TABLE "ACTIVE_RULE_PARAMETERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_KEY" VARCHAR(128), - "VALUE" VARCHAR(4000) -); - -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); - -CREATE TABLE "DASHBOARDS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "NAME" VARCHAR(256), - "DESCRIPTION" VARCHAR(1000), - "COLUMN_LAYOUT" VARCHAR(20), - "SHARED" BOOLEAN, - "IS_GLOBAL" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "METRICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER NOT NULL DEFAULT 0, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, - "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 TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(15) -); - -CREATE TABLE "AUTHORS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PERSON_ID" INTEGER, - "LOGIN" VARCHAR(255), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "MEASURE_FILTERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "SHARED" BOOLEAN NOT NULL DEFAULT FALSE, - "USER_ID" INTEGER, - "DESCRIPTION" VARCHAR(4000), - "DATA" CLOB(2147483647), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "MEASURE_FILTER_FAVOURITES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER NOT NULL, - "MEASURE_FILTER_ID" INTEGER NOT NULL, - "CREATED_AT" TIMESTAMP -); - -CREATE TABLE "ISSUES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(50) UNIQUE NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "EFFORT" INTEGER, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50) NULL, - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "LOCATIONS" BLOB(167772150), - "ISSUE_TYPE" TINYINT -); - -CREATE TABLE "ISSUE_CHANGES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(40), - "CHANGE_DATA" VARCHAR(16777215), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); - -CREATE TABLE "ISSUE_FILTERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "SHARED" BOOLEAN NOT NULL DEFAULT FALSE, - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "DATA" CLOB(2147483647), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "ISSUE_FILTER_FAVOURITES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_LOGIN" VARCHAR(255) NOT NULL, - "ISSUE_FILTER_ID" INTEGER NOT NULL, - "CREATED_AT" TIMESTAMP -); - -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERM_TPL_CHARACTERISTICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); - -CREATE TABLE "PERM_TEMPLATES_USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERM_TEMPLATES_GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - - -CREATE TABLE "ACTIVITIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOG_KEY" VARCHAR(250), - "CREATED_AT" TIMESTAMP, - "USER_LOGIN" VARCHAR(255), - "LOG_TYPE" VARCHAR(250), - "LOG_ACTION" VARCHAR(250), - "LOG_MESSAGE" VARCHAR(250), - "DATA_FIELD" CLOB(2147483647) -); - -CREATE TABLE "FILE_SOURCES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "BINARY_DATA" BLOB(167772150), - "DATA_TYPE" VARCHAR(20), - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); - -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); - -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "SNAPSHOT_ID" INTEGER NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL -); - -CREATE TABLE "USER_TOKENS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); - --- ---------------------------------------------- --- DDL Statements for indexes --- ---------------------------------------------- - -CREATE UNIQUE INDEX "ACTIVITIES_LOG_KEY" ON "ACTIVITIES" ("LOG_KEY"); - -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); - -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); - -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); - -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX" ("HASH"); - -CREATE INDEX "DUPLICATIONS_INDEX_SID" ON "DUPLICATIONS_INDEX" ("SNAPSHOT_ID"); - -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); - -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); - -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); - -CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); - -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); - -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME"); - -CREATE INDEX "EVENTS_SNAPSHOT_ID" ON "EVENTS" ("SNAPSHOT_ID"); - -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID"); - -CREATE INDEX "WIDGETS_WIDGETKEY" ON "WIDGETS" ("WIDGET_KEY"); - -CREATE INDEX "WIDGETS_DASHBOARDS" ON "WIDGETS" ("DASHBOARD_ID"); - -CREATE INDEX "SNAPSHOTS_QUALIFIER" ON "SNAPSHOTS" ("QUALIFIER"); - -CREATE INDEX "SNAPSHOTS_ROOT" ON "SNAPSHOTS" ("ROOT_SNAPSHOT_ID"); - -CREATE INDEX "SNAPSHOTS_PARENT" ON "SNAPSHOTS" ("PARENT_SNAPSHOT_ID"); - -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); - -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS" ("RULE_ID"); - -CREATE INDEX "ACTIVE_DASHBOARDS_DASHBOARDID" ON "ACTIVE_DASHBOARDS" ("DASHBOARD_ID"); - -CREATE INDEX "ACTIVE_DASHBOARDS_USERID" ON "ACTIVE_DASHBOARDS" ("USER_ID"); - -CREATE INDEX "UNIQUE_SCHEMA_MIGRATIONS" ON "SCHEMA_MIGRATIONS" ("VERSION"); - -CREATE INDEX "WIDGET_PROPERTIES_WIDGETS" ON "WIDGET_PROPERTIES" ("WIDGET_ID"); - -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES" ("COMPONENT_UUID"); - -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); - -CREATE INDEX "PROJECTS_ROOT_ID" ON "PROJECTS" ("ROOT_ID"); - -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); - -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); - -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); - -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - -CREATE UNIQUE INDEX "UNIQ_AUTHOR_LOGINS" ON "AUTHORS" ("LOGIN"); - -CREATE INDEX "MEASURE_FILTERS_NAME" ON "MEASURE_FILTERS" ("NAME"); - -CREATE INDEX "MEASURE_FILTER_FAVS_USERID" ON "MEASURE_FILTER_FAVOURITES" ("USER_ID"); - -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); - -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); - -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); - -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); - -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); - -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); - -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); - -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES" ("UPDATED_AT"); - -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES" ("KEE"); - -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES" ("ISSUE_KEY"); - -CREATE INDEX "ISSUE_FILTERS_NAME" ON "ISSUE_FILTERS" ("NAME"); - -CREATE INDEX "ISSUE_FILTER_FAVS_USER" ON "ISSUE_FILTER_FAVOURITES" ("USER_LOGIN"); - -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); - -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); - -CREATE INDEX "SNAPSHOTS_ROOT_COMPONENT" ON "SNAPSHOTS" ("ROOT_COMPONENT_UUID"); - -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); - -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); - -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); - -CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ID"); - -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); - -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); - -CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); - -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT"); - -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES" ("PROJECT_UUID", "PROFILE_KEY"); - -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); - -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); - -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); - -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); - -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); - -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS" ("TOKEN_HASH"); - -CREATE UNIQUE INDEX "USER_TOKENS_LOGIN_NAME" ON "USER_TOKENS" ("LOGIN", "NAME"); - -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); - -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); - -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/v60/CreatePermTemplatesCharacteristicsTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest/in_progress_project_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest/in_progress_project_measures.sql deleted file mode 100644 index 42d924883b9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest/in_progress_project_measures.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER, - "RULE_ID" INTEGER, - "RULES_CATEGORY_ID" INTEGER, - "TEXT_VALUE" VARCHAR(4000), - "TENDENCY" INTEGER, - "MEASURE_DATE" TIMESTAMP, - "PROJECT_ID" INTEGER, - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "URL" VARCHAR(2000), - "DESCRIPTION" VARCHAR(4000), - "RULE_PRIORITY" INTEGER, - "CHARACTERISTIC_ID" INTEGER, - "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" BINARY(167772150), - - // new column, introduced in migration 1214 - "COMPONENT_UUID" VARCHAR(50) -); - -CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); - -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest/in_progress_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest/in_progress_snapshots.sql deleted file mode 100644 index 8e89fd56335..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest/in_progress_snapshots.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql deleted file mode 100644 index d051017969b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ROOT_ID" INTEGER, - "UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_RESOURCE_ID" INTEGER, - "LONG_NAME" VARCHAR(2000), - "PERSON_ID" INTEGER, - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT -); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql deleted file mode 100644 index 5f58ad529ce..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "SNAPSHOT_ID" INTEGER, - // NULLABLE at that time - "ANALYSIS_UUID" VARCHAR(50), - "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" BINARY(167772150) - ); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql deleted file mode 100644 index 5bd4e10d8de..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50), - "COMPONENT_UUID" VARCHAR(50), - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest/in_progress_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest/in_progress_snapshots.sql deleted file mode 100644 index 89c13c7e102..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest/in_progress_snapshots.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "PROJECT_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_PROJECT_ID" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest/in_progress_project_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest/in_progress_project_measures.sql deleted file mode 100644 index 42d924883b9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest/in_progress_project_measures.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER, - "RULE_ID" INTEGER, - "RULES_CATEGORY_ID" INTEGER, - "TEXT_VALUE" VARCHAR(4000), - "TENDENCY" INTEGER, - "MEASURE_DATE" TIMESTAMP, - "PROJECT_ID" INTEGER, - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "URL" VARCHAR(2000), - "DESCRIPTION" VARCHAR(4000), - "RULE_PRIORITY" INTEGER, - "CHARACTERISTIC_ID" INTEGER, - "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" BINARY(167772150), - - // new column, introduced in migration 1214 - "COMPONENT_UUID" VARCHAR(50) -); - -CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); - -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest/activities.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest/activities.sql deleted file mode 100644 index fead19a9ef2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest/activities.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVITIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOG_KEY" VARCHAR(250), - "PROFILE_KEY" VARCHAR(255), - "CREATED_AT" TIMESTAMP, - "USER_LOGIN" VARCHAR(255), - "LOG_TYPE" VARCHAR(250), - "LOG_ACTION" VARCHAR(250), - "LOG_MESSAGE" VARCHAR(250), - "DATA_FIELD" CLOB(2147483647) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest/in_progress_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest/in_progress_snapshots.sql deleted file mode 100644 index e87bc84183e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest/in_progress_snapshots.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - // NULLABLE - "UUID" VARCHAR(50), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest/in_progress_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest/in_progress_projects.sql deleted file mode 100644 index 5ea7d165ad3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest/in_progress_projects.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ROOT_ID" INTEGER, - "UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_RESOURCE_ID" INTEGER, - "LONG_NAME" VARCHAR(2000), - "PERSON_ID" INTEGER, - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "ROOT_UUID" VARCHAR(50), - "COPY_COMPONENT_UUID" VARCHAR(50), - "DEVELOPER_UUID" VARCHAR(50) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest/in_progress_ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest/in_progress_ce_activity.sql deleted file mode 100644 index 25d5c6cb28f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest/in_progress_ce_activity.sql +++ /dev/null @@ -1,52 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "SNAPSHOT_ID" INTEGER NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL -); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest/in_progress_events_with_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest/in_progress_events_with_snapshots.sql deleted file mode 100644 index 3b66dd23009..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest/in_progress_events_with_snapshots.sql +++ /dev/null @@ -1,48 +0,0 @@ - -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50), - "COMPONENT_UUID" VARCHAR(50), - "SNAPSHOT_ID" INTEGER, - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql deleted file mode 100644 index 203419ad2bd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql +++ /dev/null @@ -1,54 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "SNAPSHOT_ID" INTEGER, - // NULLABLE at that time - "ANALYSIS_UUID" VARCHAR(50), - "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" BINARY(167772150) - ); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql deleted file mode 100644 index 526a759d76d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql +++ /dev/null @@ -1,45 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50), - "COMPONENT_UUID" VARCHAR(50), - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL -); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest/in_progress_snapshots_with_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest/in_progress_snapshots_with_projects.sql deleted file mode 100644 index 64128b7e4c2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest/in_progress_snapshots_with_projects.sql +++ /dev/null @@ -1,57 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "PROJECT_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_PROJECT_ID" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ROOT_ID" INTEGER, - "UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_RESOURCE_ID" INTEGER, - "LONG_NAME" VARCHAR(2000), - "PERSON_ID" INTEGER, - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest/in_progress_measures_with_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest/in_progress_measures_with_projects.sql deleted file mode 100644 index 94d9362daaa..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest/in_progress_measures_with_projects.sql +++ /dev/null @@ -1,65 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER, - "RULE_ID" INTEGER, - "RULES_CATEGORY_ID" INTEGER, - "TEXT_VALUE" VARCHAR(4000), - "TENDENCY" INTEGER, - "MEASURE_DATE" TIMESTAMP, - "PROJECT_ID" INTEGER, - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "URL" VARCHAR(2000), - "DESCRIPTION" VARCHAR(4000), - "RULE_PRIORITY" INTEGER, - "CHARACTERISTIC_ID" INTEGER, - "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" BINARY(167772150), - - // new column, introduced in migration 1214 - "COMPONENT_UUID" VARCHAR(50) -); - -CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); - -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest/rules_profiles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest/rules_profiles.sql deleted file mode 100644 index 8f6183f65fe..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest/rules_profiles.sql +++ /dev/null @@ -1,84 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT -); - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "SNAPSHOT_ID" INTEGER, - "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" BINARY(167772150) -); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); - -CREATE TABLE "METRICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER NOT NULL DEFAULT 0, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, - "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 -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest/activities.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest/activities.sql deleted file mode 100644 index fead19a9ef2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest/activities.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVITIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOG_KEY" VARCHAR(250), - "PROFILE_KEY" VARCHAR(255), - "CREATED_AT" TIMESTAMP, - "USER_LOGIN" VARCHAR(255), - "LOG_TYPE" VARCHAR(250), - "LOG_ACTION" VARCHAR(250), - "LOG_MESSAGE" VARCHAR(250), - "DATA_FIELD" CLOB(2147483647) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest/schema.sql deleted file mode 100644 index fa7acc48f55..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest/schema.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE "ACTIVITIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOG_KEY" VARCHAR(250), - "PROFILE_KEY" VARCHAR(255) NOT NULL, - "CREATED_AT" TIMESTAMP, - "USER_LOGIN" VARCHAR(255), - "LOG_TYPE" VARCHAR(250), - "LOG_ACTION" VARCHAR(250), - "LOG_MESSAGE" VARCHAR(250), - "DATA_FIELD" CLOB(2147483647) -); - -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest/in_progress_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest/in_progress_snapshots.sql deleted file mode 100644 index e87bc84183e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest/in_progress_snapshots.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - // NULLABLE - "UUID" VARCHAR(50), - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest/in_progress_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest/in_progress_projects.sql deleted file mode 100644 index 5ea7d165ad3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest/in_progress_projects.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ROOT_ID" INTEGER, - "UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_RESOURCE_ID" INTEGER, - "LONG_NAME" VARCHAR(2000), - "PERSON_ID" INTEGER, - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "ROOT_UUID" VARCHAR(50), - "COPY_COMPONENT_UUID" VARCHAR(50), - "DEVELOPER_UUID" VARCHAR(50) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest/in_progress_projects_and_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest/in_progress_projects_and_snapshots.sql deleted file mode 100644 index 92f64e965a6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest/in_progress_projects_and_snapshots.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - // NULLABLE at the time - "UUID_PATH" VARCHAR(4000), - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT -); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest/schema.sql deleted file mode 100644 index cae775f31cb..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest/old_ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest/old_ce_activity.sql deleted file mode 100644 index a519e005821..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest/old_ce_activity.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest/schema.sql deleted file mode 100644 index 8f8df334379..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "ACTIVITIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOG_KEY" VARCHAR(250), - "PROFILE_KEY" VARCHAR(255) NOT NULL, - "CREATED_AT" TIMESTAMP, - "USER_LOGIN" VARCHAR(255), - "LOG_TYPE" VARCHAR(250), - "LOG_ACTION" VARCHAR(250), - "LOG_MESSAGE" VARCHAR(250), - "DATA_FIELD" CLOB(2147483647) -); -CREATE UNIQUE INDEX "ACTIVITIES_LOG_KEY" ON "ACTIVITIES" ("LOG_KEY"); - -CREATE TABLE "QPROFILE_CHANGES" ( - "KEE" VARCHAR(40) NOT NULL PRIMARY KEY, - "QPROFILE_KEY" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_DATA" CLOB -); -CREATE INDEX "QPROFILE_CHANGES_QPROFILE_KEY" ON "QPROFILE_CHANGES" ("QPROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest/schema.sql deleted file mode 100644 index 1030e93bff0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest/schema.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE "DASHBOARDS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "NAME" VARCHAR(256), - "DESCRIPTION" VARCHAR(1000), - "COLUMN_LAYOUT" VARCHAR(20), - "SHARED" BOOLEAN, - "IS_GLOBAL" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "ACTIVE_DASHBOARDS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DASHBOARD_ID" INTEGER NOT NULL, - "USER_ID" INTEGER, - "ORDER_INDEX" INTEGER -); - -CREATE TABLE "WIDGETS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DASHBOARD_ID" INTEGER NOT NULL, - "WIDGET_KEY" VARCHAR(256) NOT NULL, - "NAME" VARCHAR(256), - "DESCRIPTION" VARCHAR(1000), - "COLUMN_INDEX" INTEGER, - "ROW_INDEX" INTEGER, - "CONFIGURED" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "RESOURCE_ID" INTEGER -); - -CREATE TABLE "WIDGET_PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "WIDGET_ID" INTEGER NOT NULL, - "KEE" VARCHAR(100), - "TEXT_VALUE" VARCHAR(4000) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest/schema.sql deleted file mode 100644 index 2b74746090d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test/properties_and_properties_2_tables.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test/properties_and_properties_2_tables.sql deleted file mode 100644 index 9781eda6197..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test/properties_and_properties_2_tables.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512), - "RESOURCE_ID" INTEGER, - "TEXT_VALUE" CLOB(2147483647), - "USER_ID" INTEGER -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "PROPERTIES2" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES2_KEY" ON "PROPERTIES2" ("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest/properties_and_internal_properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest/properties_and_internal_properties.sql deleted file mode 100644 index e38510f469a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest/properties_and_internal_properties.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512), - "RESOURCE_ID" INTEGER, - "TEXT_VALUE" CLOB(2147483647), - "USER_ID" INTEGER -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); - -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest/table_users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest/table_users.sql deleted file mode 100644 index 8c4967278f8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest/table_users.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest/previous-group_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest/previous-group_roles.sql deleted file mode 100644 index a711f616070..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest/previous-group_roles.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest/previous-groups.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest/previous-groups.sql deleted file mode 100644 index 250a9a8f45b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest/previous-groups.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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/v62/AddOrganizationUuidToPermissionTemplatesTest/previous-permission_templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest/previous-permission_templates.sql deleted file mode 100644 index a690318b027..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest/previous-permission_templates.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest/previous-user_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest/previous-user_roles.sql deleted file mode 100644 index 75957baf6e7..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest/previous-user_roles.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); - -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest/organizations_and_internal_properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest/organizations_and_internal_properties.sql deleted file mode 100644 index 26cf56a69f2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest/organizations_and_internal_properties.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest/roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest/roles.sql deleted file mode 100644 index 4d08a027079..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest/roles.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); - - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest/schema.sql deleted file mode 100644 index e842593fef6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "ISSUE_FILTERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "SHARED" BOOLEAN NOT NULL DEFAULT FALSE, - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "DATA" CLOB(2147483647), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE INDEX "ISSUE_FILTERS_NAME" ON "ISSUE_FILTERS" ("NAME"); - - -CREATE TABLE "ISSUE_FILTER_FAVOURITES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_LOGIN" VARCHAR(255) NOT NULL, - "ISSUE_FILTER_ID" INTEGER NOT NULL, - "CREATED_AT" TIMESTAMP -); -CREATE INDEX "ISSUE_FILTER_FAVS_USER" ON "ISSUE_FILTER_FAVOURITES" ("USER_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest/schema.sql deleted file mode 100644 index f7331d4bb8a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "MEASURE_FILTERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "SHARED" BOOLEAN NOT NULL DEFAULT FALSE, - "USER_ID" INTEGER, - "DESCRIPTION" VARCHAR(4000), - "DATA" CLOB(2147483647), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE INDEX "MEASURE_FILTERS_NAME" ON "MEASURE_FILTERS" ("NAME"); - - -CREATE TABLE "MEASURE_FILTER_FAVOURITES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER NOT NULL, - "MEASURE_FILTER_ID" INTEGER NOT NULL, - "CREATED_AT" TIMESTAMP -); -CREATE INDEX "MEASURE_FILTER_FAVS_USERID" ON "MEASURE_FILTER_FAVOURITES" ("USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest/schema.sql deleted file mode 100644 index 6456acc22fd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest/schema.sql +++ /dev/null @@ -1,47 +0,0 @@ -CREATE TABLE "ACTIVE_DASHBOARDS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DASHBOARD_ID" INTEGER NOT NULL, - "USER_ID" INTEGER, - "ORDER_INDEX" INTEGER -); -CREATE INDEX "ACTIVE_DASHBOARDS_DASHBOARDID" ON "ACTIVE_DASHBOARDS" ("DASHBOARD_ID"); -CREATE INDEX "ACTIVE_DASHBOARDS_USERID" ON "ACTIVE_DASHBOARDS" ("USER_ID"); - - -CREATE TABLE "DASHBOARDS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "NAME" VARCHAR(256), - "DESCRIPTION" VARCHAR(1000), - "COLUMN_LAYOUT" VARCHAR(20), - "SHARED" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "WIDGETS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DASHBOARD_ID" INTEGER NOT NULL, - "WIDGET_KEY" VARCHAR(256) NOT NULL, - "NAME" VARCHAR(256), - "DESCRIPTION" VARCHAR(1000), - "COLUMN_INDEX" INTEGER, - "ROW_INDEX" INTEGER, - "CONFIGURED" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "RESOURCE_ID" INTEGER -); -CREATE INDEX "WIDGETS_WIDGETKEY" ON "WIDGETS" ("WIDGET_KEY"); -CREATE INDEX "WIDGETS_DASHBOARDS" ON "WIDGETS" ("DASHBOARD_ID"); - - -CREATE TABLE "WIDGET_PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "WIDGET_ID" INTEGER NOT NULL, - "KEE" VARCHAR(100), - "TEXT_VALUE" VARCHAR(4000) -); -CREATE INDEX "WIDGET_PROPERTIES_WIDGETS" ON "WIDGET_PROPERTIES" ("WIDGET_ID"); - - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest/in_progress_group_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest/in_progress_group_roles.sql deleted file mode 100644 index b7c45cfd68e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest/in_progress_group_roles.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); - -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest/in_progress_groups.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest/in_progress_groups.sql deleted file mode 100644 index 4a6fd1f49b9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest/in_progress_groups.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "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/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest/in_progress_permission_templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest/in_progress_permission_templates.sql deleted file mode 100644 index 163e5ecb021..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest/in_progress_permission_templates.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest/in_progress_user_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest/in_progress_user_roles.sql deleted file mode 100644 index e4d1b024417..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest/in_progress_user_roles.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest/users_with_nullable_root.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest/users_with_nullable_root.sql deleted file mode 100644 index 733b337f897..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest/users_with_nullable_root.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "IS_ROOT" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest/users_and_permissions_tables.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest/users_and_permissions_tables.sql deleted file mode 100644 index 54ad1ab20d0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest/users_and_permissions_tables.sql +++ /dev/null @@ -1,52 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "IS_ROOT" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); - -CREATE TABLE "GROUPS_USERS" ( - "USER_ID" INTEGER, - "GROUP_ID" INTEGER -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest/group_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest/group_roles.sql deleted file mode 100644 index 775ab11911e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest/group_roles.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); - -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); - -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest/user_groups.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest/user_groups.sql deleted file mode 100644 index 0ee6f37fe25..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest/user_groups.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest/permission_templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest/permission_templates.sql deleted file mode 100644 index cc29ea296da..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest/permission_templates.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest/user_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest/user_roles.sql deleted file mode 100644 index 8448b6e6002..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest/user_roles.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest/schema.sql deleted file mode 100644 index 39a62ddfdc6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); - - -CREATE TABLE "QUALITY_GATE_CONDITIONS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "PERIOD" INTEGER, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); - -CREATE TABLE "METRICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER NOT NULL DEFAULT 0, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, - "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/v63/AddColumnGuardedToOrganizationsTest/previous-organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest/previous-organizations.sql deleted file mode 100644 index 9275a44ab8d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest/previous-organizations.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v63/AddDefaultPermTemplateColumnsToOrganizationsTest/previous-organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest/previous-organizations.sql deleted file mode 100644 index 825bf68611d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest/previous-organizations.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest/projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest/projects.sql deleted file mode 100644 index 2851fc8cf65..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest/projects.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest/previous-projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest/previous-projects.sql deleted file mode 100644 index ee02648e0b9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest/previous-projects.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest/previous-organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest/previous-organizations.sql deleted file mode 100644 index d581374bfba..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest/previous-organizations.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v63/AddUuidToEventsTest/previous-events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest/previous-events.sql deleted file mode 100644 index b0712271a84..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest/previous-events.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest/project_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest/project_measures.sql deleted file mode 100644 index 00ef5e22307..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest/project_measures.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest/properties.sql deleted file mode 100644 index dfc39d8d285..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -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/v63/DropTableResourceIndexTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest/schema.sql deleted file mode 100644 index be7a240bff8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RESOURCE_INDEX" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400) NOT NULL, - "POSITION" INTEGER NOT NULL, - "NAME_SIZE" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, - "QUALIFIER" VARCHAR(10) NOT NULL -); -CREATE INDEX "RESOURCE_INDEX_KEY" ON "RESOURCE_INDEX" ("KEE"); -CREATE INDEX "RESOURCE_INDEX_COMPONENT" ON "RESOURCE_INDEX" ("COMPONENT_UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest/organizations_with_nullable_guarded.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest/organizations_with_nullable_guarded.sql deleted file mode 100644 index 0600e9c8101..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest/organizations_with_nullable_guarded.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v63/MakeDefaultOrganizationGuardedTest/organizations_and_internal_properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest/organizations_and_internal_properties.sql deleted file mode 100644 index 8e67d9f9bfc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest/organizations_and_internal_properties.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueReentranceTest/organizations_with_unique_index.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueReentranceTest/organizations_with_unique_index.sql deleted file mode 100644 index 12d83796405..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueReentranceTest/organizations_with_unique_index.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueTest/organizations_with_non_unique_index.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueTest/organizations_with_non_unique_index.sql deleted file mode 100644 index 12d83796405..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeIndexOnOrganizationsKeeUniqueTest/organizations_with_non_unique_index.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest/projects_with_nullable_organization.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest/projects_with_nullable_organization.sql deleted file mode 100644 index 7c72f32071f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest/projects_with_nullable_organization.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ORGANIZATION_UUID" VARCHAR(40), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest/in_progress_events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest/in_progress_events.sql deleted file mode 100644 index d83b16dd817..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest/in_progress_events.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest/organizations.sql deleted file mode 100644 index 0600e9c8101..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest/organizations.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest/properties_and_organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest/properties_and_organizations.sql deleted file mode 100644 index d6b052f42e2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest/properties_and_organizations.sql +++ /dev/null @@ -1,47 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "DEFAULT_PERM_TEMPLATE" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); - -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest/projects_with_nullable_organization.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest/projects_with_nullable_organization.sql deleted file mode 100644 index 7c72f32071f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest/projects_with_nullable_organization.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "ORGANIZATION_UUID" VARCHAR(40), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest/in_progress_events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest/in_progress_events.sql deleted file mode 100644 index d83b16dd817..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest/in_progress_events.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest/in_progress_users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest/in_progress_users.sql deleted file mode 100644 index d631feae68e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest/in_progress_users.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCountTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCountTest/ce_activity.sql deleted file mode 100644 index 512e00bcf2c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddCeActivityWorkerUuidAndExecutionCountTest/ce_activity.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCountTest/ce_queue.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCountTest/ce_queue.sql deleted file mode 100644 index 50faa80d9c5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddCeQueueWorkerUuidAndExecutionCountTest/ce_queue.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivateTest/organizations_without_new_project_private_column.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivateTest/organizations_without_new_project_private_column.sql deleted file mode 100644 index e1066f0bf12..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddColumnNewProjectPrivateTest/organizations_without_new_project_private_column.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v64/AddColumnProjectsPrivateTest/projects_without_private_column.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivateTest/projects_without_private_column.sql deleted file mode 100644 index 95331fa3d8d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddColumnProjectsPrivateTest/projects_without_private_column.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizationsTest/previous-organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizationsTest/previous-organizations.sql deleted file mode 100644 index 4d43779b462..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddDefaultGroupIdToOrganizationsTest/previous-organizations.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v64/AddIndexLoadedTemplatesTypeTest/loaded_templates_without_index.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesTypeTest/loaded_templates_without_index.sql deleted file mode 100644 index 1670e896e7f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddIndexLoadedTemplatesTypeTest/loaded_templates_without_index.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(64) NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParametersTest/active_rule_parameters_without_index.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParametersTest/active_rule_parameters_without_index.sql deleted file mode 100644 index dd1904476f1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddIndexOnActiveRuleParametersTest/active_rule_parameters_without_index.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_KEY" VARCHAR(128), - "VALUE" VARCHAR(4000) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuidTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuidTest/initial.sql deleted file mode 100644 index c78c7f1d4ab..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddQualityProfileOrganizationUuidTest/initial.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); -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/v64/AddTagsToProjectsTest/previous-projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjectsTest/previous-projects.sql deleted file mode 100644 index b061c390b92..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/AddTagsToProjectsTest/previous-projects.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10), -); - -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphansTest/loaded-templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphansTest/loaded-templates.sql deleted file mode 100644 index a0de1fe51dd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CleanLoadedTemplateOrphansTest/loaded-templates.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(15) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsersTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsersTest/initial.sql deleted file mode 100644 index 3ea20b3f6b2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CleanOrphanRowsInGroupsUsersTest/initial.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "GROUPS_USERS" ( - "USER_ID" INTEGER, - "GROUP_ID" INTEGER -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); - -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganizationTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganizationTest/initial.sql deleted file mode 100644 index 4db5fdb0192..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateMembersGroupsInEachOrganizationTest/initial.sql +++ /dev/null @@ -1,66 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(100) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERM_TEMPLATES_GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTableTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateOrganizationMembersTableTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadataTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/CreateRulesMetadataTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSettingTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSettingTest/initial.sql deleted file mode 100644 index dfc39d8d285..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DeleteDefaultGroupSettingTest/initial.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -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/v64/DeletePermissionTemplatesLinkedToRemovedUsersTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsersTest/initial.sql deleted file mode 100644 index 860823d0038..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DeletePermissionTemplatesLinkedToRemovedUsersTest/initial.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRulesTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRulesTest/rules.sql deleted file mode 100644 index de12d87f46a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropMetadataColumnsFromRulesTest/rules.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_LOGIN" VARCHAR(255), - "NOTE_CREATED_AT" TIMESTAMP, - "NOTE_UPDATED_AT" TIMESTAMP, - "REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKeyTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKeyTest/initial.sql deleted file mode 100644 index 0014a2ddce6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileKeyTest/initial.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); -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/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest/initial.sql deleted file mode 100644 index 1803644d492..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/DropUniqueIndexOnQualityProfileOrganizationUuidAndKeyTest/initial.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_QPROF_ORG_AND_KEY" ON "RULES_PROFILES" ("ORGANIZATION_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumnTest/loaded-templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumnTest/loaded-templates.sql deleted file mode 100644 index a0de1fe51dd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/ExtendLoadedTemplateTypeColumnTest/loaded-templates.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(15) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullableTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullableTest/ce_activity.sql deleted file mode 100644 index 02a14de9c2a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeCeActivityExecutionCountNotNullableTest/ce_activity.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullableTest/ce_queue.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullableTest/ce_queue.sql deleted file mode 100644 index 61e8ab0f078..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeCeQueueExecutionCountNotNullableTest/ce_queue.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullableTest/organizations_with_nullable_new_project_private_column.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullableTest/organizations_with_nullable_new_project_private_column.sql deleted file mode 100644 index 3d4afa1e75b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeColumnNewProjectPrivateNotNullableTest/organizations_with_nullable_new_project_private_column.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "NEW_PROJECT_PRIVATE" BOOLEAN NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v64/MakeColumnProjectsPrivateNotNullableTest/projects_with_nullable_private_column.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullableTest/projects_with_nullable_private_column.sql deleted file mode 100644 index 64d498d0a91..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeColumnProjectsPrivateNotNullableTest/projects_with_nullable_private_column.sql +++ /dev/null @@ -1,45 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissionsTest/projects_and_group_roles_and_user_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissionsTest/projects_and_group_roles_and_user_roles.sql deleted file mode 100644 index 30977a18097..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeComponentsPrivateBasedOnPermissionsTest/projects_and_group_roles_and_user_roles.sql +++ /dev/null @@ -1,93 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); - -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullableTest/projects_with_nullable_project_uuid.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullableTest/projects_with_nullable_project_uuid.sql deleted file mode 100644 index 95331fa3d8d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeProjectUuidNotNullableTest/projects_with_nullable_project_uuid.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUniqueTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUniqueTest/initial.sql deleted file mode 100644 index 29ff1d55f0b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileKeyUniqueTest/initial.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUniqueTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUniqueTest/initial.sql deleted file mode 100644 index 29ff1d55f0b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/MakeQualityProfileOrganizationUuidAndKeyUniqueTest/initial.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizationsTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizationsTest/initial.sql deleted file mode 100644 index edee0316d50..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateColumnDefaultGroupIdOfOrganizationsTest/initial.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivateTest/projects_with_nullable_private_column.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivateTest/projects_with_nullable_private_column.sql deleted file mode 100644 index 64d498d0a91..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateColumnProjectsPrivateTest/projects_with_nullable_private_column.sql +++ /dev/null @@ -1,45 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest/initial.sql deleted file mode 100644 index 6b92f403982..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest/initial.sql +++ /dev/null @@ -1,77 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS" ( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL -); -CREATE PRIMARY KEY ON "ORGANIZATION_MEMBERS" ("ORGANIZATION_UUID", "USER_ID"); - -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); - -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); - -CREATE TABLE "GROUPS_USERS" ( - "USER_ID" INTEGER, - "GROUP_ID" INTEGER -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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/v64/PopulateRulesMetadataTest/rules_and_rules_metadata_and_organization_and_internal_properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest/rules_and_rules_metadata_and_organization_and_internal_properties.sql deleted file mode 100644 index 0ca9ff069c6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest/rules_and_rules_metadata_and_organization_and_internal_properties.sql +++ /dev/null @@ -1,73 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); - -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_LOGIN" VARCHAR(255), - "NOTE_CREATED_AT" TIMESTAMP, - "NOTE_UPDATED_AT" TIMESTAMP, - "REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); - -CREATE TABLE "RULES_METADATA" ( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_LOGIN" 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), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - 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/v64/PurgeComponentsWithoutProjectUuidTest/projects_and_children_tables.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuidTest/projects_and_children_tables.sql deleted file mode 100644 index e987c571ca5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/PurgeComponentsWithoutProjectUuidTest/projects_and_children_tables.sql +++ /dev/null @@ -1,242 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - -CREATE TABLE "DUPLICATIONS_INDEX" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 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 -); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX" ("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX" ("ANALYSIS_UUID", "COMPONENT_UUID"); - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); - -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); - -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID"); - -CREATE TABLE "PROJECT_LINKS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "COMPONENT_UUID" VARCHAR(50), - "LINK_TYPE" VARCHAR(20), - "NAME" VARCHAR(128), - "HREF" VARCHAR(2048) NOT NULL -); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); - -CREATE TABLE "ISSUES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(50) UNIQUE NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "EFFORT" INTEGER, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50) NULL, - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT -); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES" ("UPDATED_AT"); - -CREATE TABLE "FILE_SOURCES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "BINARY_DATA" BLOB, - "DATA_TYPE" VARCHAR(20), - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT"); - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -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/v64/RestoreSonarUsersGroupsTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroupsTest/initial.sql deleted file mode 100644 index 54244e9d6ed..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/RestoreSonarUsersGroupsTest/initial.sql +++ /dev/null @@ -1,65 +0,0 @@ -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); - -CREATE TABLE "PERM_TEMPLATES_GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroupTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroupTest/initial.sql deleted file mode 100644 index 41790ff294d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetAllUsersIntoSonarUsersGroupTest/initial.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "GROUPS_USERS" ( - "USER_ID" INTEGER, - "GROUP_ID" INTEGER -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_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/v64/SetCopyComponentUuidOnLocalViewsTest/in_progress_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest/in_progress_projects.sql deleted file mode 100644 index c8113a8215c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest/in_progress_projects.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50), - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalseTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalseTest/initial.sql deleted file mode 100644 index 67543769715..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetNewProjectPrivateToFalseTest/initial.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v64/SetOrganizationMembersIntoMembersGroupTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroupTest/initial.sql deleted file mode 100644 index ffcb12a0cc7..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetOrganizationMembersIntoMembersGroupTest/initial.sql +++ /dev/null @@ -1,61 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "IS_DEFAULT" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "GROUPS_USERS" ( - "USER_ID" INTEGER, - "GROUP_ID" INTEGER -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); - -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "ORGANIZATION_MEMBERS" ( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL -); -CREATE PRIMARY KEY ON "ORGANIZATION_MEMBERS" ("ORGANIZATION_UUID", "USER_ID"); - - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefaultTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefaultTest/initial.sql deleted file mode 100644 index a67a0e57925..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToDefaultTest/initial.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); -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/v64/SetQualityProfileOrganizationUuidToNotNullableTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToNotNullableTest/initial.sql deleted file mode 100644 index a67a0e57925..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SetQualityProfileOrganizationUuidToNotNullableTest/initial.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); -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/v64/SupportPrivateProjectInDefaultPermissionTemplateTest/organizations_and_groups_and_permission_templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplateTest/organizations_and_groups_and_permission_templates.sql deleted file mode 100644 index 93ab5a73b9f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SupportPrivateProjectInDefaultPermissionTemplateTest/organizations_and_groups_and_permission_templates.sql +++ /dev/null @@ -1,55 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERM_TEMPLATES_GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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/v64/SupportProjectVisibilityInTemplatesTest/permission_templates_and_groups.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplatesTest/permission_templates_and_groups.sql deleted file mode 100644 index 3164a3566fb..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/SupportProjectVisibilityInTemplatesTest/permission_templates_and_groups.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERM_TEMPLATES_GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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/v64/UpgradeQualityTemplateLoadedTemplatesTest/organizations_internal_properties_and_loaded_templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplatesTest/organizations_internal_properties_and_loaded_templates.sql deleted file mode 100644 index d6be8c2977a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v64/UpgradeQualityTemplateLoadedTemplatesTest/organizations_internal_properties_and_loaded_templates.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); - -CREATE TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(64) NOT NULL -); -CREATE INDEX "IX_LOADED_TEMPLATES_TYPE" ON "LOADED_TEMPLATES" ("TEMPLATE_TYPE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfilesTest/rules_profiles_6_4.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfilesTest/rules_profiles_6_4.sql deleted file mode 100644 index 0014a2ddce6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddBuiltInFlagToRulesProfilesTest/rules_profiles_6_4.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT -); -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/v65/AddIndexOnEsQueueCreatedAtTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAtTest/initial.sql deleted file mode 100644 index 4c0d2b532b2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexOnEsQueueCreatedAtTest/initial.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ES_QUEUE" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "DOC_TYPE" VARCHAR(40) NOT NULL, - "DOC_ID" VARCHAR(4000) NOT NULL, - "DOC_ID_TYPE" VARCHAR(20), - "DOC_ROUTING" VARCHAR(4000), - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ES_QUEUE" ON "ES_QUEUE" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest/initial.sql deleted file mode 100644 index 43d3ab5c3c1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest/initial.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_CHANGES" ( - "KEE" VARCHAR(40) NOT NULL PRIMARY KEY, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_DATA" CLOB -); -CREATE INDEX "QPROFILE_CHANGES_QPROFILE_KEY" ON "QPROFILE_CHANGES" ("RULES_PROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboardedTest/users_without_onboarded_column.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboardedTest/users_without_onboarded_column.sql deleted file mode 100644 index d631feae68e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddUsersOnboardedTest/users_without_onboarded_column.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRolesTest/group_roles_and_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRolesTest/group_roles_and_projects.sql deleted file mode 100644 index 396d1c7ac90..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInGroupRolesTest/group_roles_and_projects.sql +++ /dev/null @@ -1,55 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasuresTest/manual_measures_and_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasuresTest/manual_measures_and_projects.sql deleted file mode 100644 index 238b5b87afa..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInManualMeasuresTest/manual_measures_and_projects.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES" ("COMPONENT_UUID"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinksTest/project_links_and_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinksTest/project_links_and_projects.sql deleted file mode 100644 index 78a37841c57..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInProjectLinksTest/project_links_and_projects.sql +++ /dev/null @@ -1,53 +0,0 @@ -CREATE TABLE "PROJECT_LINKS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "COMPONENT_UUID" VARCHAR(50), - "LINK_TYPE" VARCHAR(20), - "NAME" VARCHAR(128), - "HREF" VARCHAR(2048) NOT NULL -); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInPropertiesTest/properties_and_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInPropertiesTest/properties_and_projects.sql deleted file mode 100644 index 6d62b229804..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInPropertiesTest/properties_and_projects.sql +++ /dev/null @@ -1,57 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRolesTest/user_roles_and_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRolesTest/user_roles_and_projects.sql deleted file mode 100644 index 930ac35232c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CleanOrphanRowsInUserRolesTest/user_roles_and_projects.sql +++ /dev/null @@ -1,55 +0,0 @@ -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTableTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateEsQueueTableTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfilesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateTableDefaultQProfilesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfilesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/CreateTableOrgQProfilesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSettingTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSettingTest/properties.sql deleted file mode 100644 index dfc39d8d285..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteCeWorkerCountSettingTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -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/v65/DeleteLoadedTemplatesOnQProfilesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfilesTest/initial.sql deleted file mode 100644 index d3c72d43b4d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteLoadedTemplatesOnQProfilesTest/initial.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(64) NOT NULL -); -CREATE INDEX "IX_LOADED_TEMPLATES_TYPE" ON "LOADED_TEMPLATES" ("TEMPLATE_TYPE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfilesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfilesTest/initial.sql deleted file mode 100644 index 7c23f212676..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DeleteOrphansFromRulesProfilesTest/initial.sql +++ /dev/null @@ -1,57 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "IS_BUILT_IN" BOOLEAN NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); - -CREATE TABLE "ORG_QPROFILES" ( - "UUID" VARCHAR(255) NOT NULL PRIMARY KEY, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "PARENT_UUID" VARCHAR(255), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); -CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); - - -CREATE TABLE "ACTIVE_RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 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 -); -CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ID"); - - -CREATE TABLE "ACTIVE_RULE_PARAMETERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_KEY" VARCHAR(128), - "VALUE" VARCHAR(4000) -); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS" ("ACTIVE_RULE_ID"); - - -CREATE TABLE "QPROFILE_CHANGES" ( - "KEE" VARCHAR(40) NOT NULL PRIMARY KEY, - "QPROFILE_KEY" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_DATA" CLOB -); -CREATE INDEX "QPROFILE_CHANGES_QPROFILE_KEY" ON "QPROFILE_CHANGES" ("QPROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuidTest/events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuidTest/events.sql deleted file mode 100644 index a4d0d1f235d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIndexEventsComponentUuidTest/events.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuidTest/manual_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuidTest/manual_measures.sql deleted file mode 100644 index c9ca78e50d1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIndexManualMeasuresComponentUuidTest/manual_measures.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -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/v65/DropIsDefaultColumnFromRulesProfilesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfilesTest/initial.sql deleted file mode 100644 index 2890a4409c8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropIsDefaultColumnFromRulesProfilesTest/initial.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "IS_BUILT_IN" BOOLEAN NOT NULL -); -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/v65/DropOrgColumnsFromRulesProfilesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfilesTest/initial.sql deleted file mode 100644 index 7c1c1fedab0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropOrgColumnsFromRulesProfilesTest/initial.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "IS_BUILT_IN" BOOLEAN NOT NULL -); -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/v65/DropTableAuthorsTest/authors.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropTableAuthorsTest/authors.sql deleted file mode 100644 index db6e3e8628a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/DropTableAuthorsTest/authors.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "AUTHORS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PERSON_ID" INTEGER, - "LOGIN" VARCHAR(255), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE UNIQUE INDEX "UNIQ_AUTHOR_LOGINS" ON "AUTHORS" ("LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssuesTest/issues_and_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssuesTest/issues_and_projects.sql deleted file mode 100644 index 6722d72cd58..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/EnsureIssueProjectUuidConsistencyOnIssuesTest/issues_and_projects.sql +++ /dev/null @@ -1,83 +0,0 @@ -CREATE TABLE "ISSUES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(50) UNIQUE NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "EFFORT" INTEGER, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50) NULL, - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT -); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES" ("UPDATED_AT"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullableTest/events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullableTest/events.sql deleted file mode 100644 index a4d0d1f235d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeEventsComponentUuidNotNullableTest/events.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullableTest/manual_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullableTest/manual_measures.sql deleted file mode 100644 index a719be57847..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeManualMeasuresComponentUuidNotNullableTest/manual_measures.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullableTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullableTest/initial.sql deleted file mode 100644 index a5bb40d635f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeRulesProfilesIsBuiltInNotNullableTest/initial.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "IS_BUILT_IN" BOOLEAN -); -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/v65/MakeUsersOnboardedNotNullableTest/users_with_nullable_onboarded_column.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullableTest/users_with_nullable_onboarded_column.sql deleted file mode 100644 index 44a02df3f3d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/MakeUsersOnboardedNotNullableTest/users_with_nullable_onboarded_column.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuidTest/events_and_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuidTest/events_and_snapshots.sql deleted file mode 100644 index 1aff12a80e3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateEventsComponentUuidTest/events_and_snapshots.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID"); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfilesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfilesTest/initial.sql deleted file mode 100644 index ca6b10cad6e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateOrgQProfilesTest/initial.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "IS_BUILT_IN" BOOLEAN NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); - -CREATE TABLE "ORG_QPROFILES" ( - "UUID" VARCHAR(255) NOT NULL PRIMARY KEY, - "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 -); -CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); -CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfilesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfilesTest/initial.sql deleted file mode 100644 index 06d6511fbf8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateTableDefaultQProfilesTest/initial.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "IS_BUILT_IN" BOOLEAN NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); - - -CREATE TABLE "DEFAULT_QPROFILES" ( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "LANGUAGE" VARCHAR(20) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE PRIMARY KEY ON "DEFAULT_QPROFILES" ("ORGANIZATION_UUID", "LANGUAGE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboardedTest/users_with_onboarded_column.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboardedTest/users_with_onboarded_column.sql deleted file mode 100644 index 44a02df3f3d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateUsersOnboardedTest/users_with_onboarded_column.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperDataTest/projects_and_child_tables.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperDataTest/projects_and_child_tables.sql deleted file mode 100644 index 7f11d12ecbc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PurgeDeveloperDataTest/projects_and_child_tables.sql +++ /dev/null @@ -1,147 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); - - -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); - - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); - - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); - - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuidTest/events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuidTest/events.sql deleted file mode 100644 index 08f78db2d76..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RecreateIndexEventsComponentUuidTest/events.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "EVENTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "CATEGORY" VARCHAR(50), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000) -); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuidTest/manual_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuidTest/manual_measures.sql deleted file mode 100644 index a719be57847..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RecreateIndexManualMeasuresComponentUuidTest/manual_measures.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest/initial.sql deleted file mode 100644 index cb28a6fccd1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/RenameQProfileKeyToRulesProfileUuidOnQProfileChangesTest/initial.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_CHANGES" ( - "KEE" VARCHAR(40) NOT NULL PRIMARY KEY, - "QPROFILE_KEY" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_DATA" CLOB -); -CREATE INDEX "QPROFILE_CHANGES_QPROFILE_KEY" ON "QPROFILE_CHANGES" ("QPROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalseTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalseTest/initial.sql deleted file mode 100644 index a5bb40d635f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToFalseTest/initial.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "PARENT_KEE" VARCHAR(255), - "RULES_UPDATED_AT" VARCHAR(100), - "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "IS_BUILT_IN" BOOLEAN -); -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/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest/initial.sql deleted file mode 100644 index 041f3acd203..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/SetRulesProfilesIsBuiltInToTrueForDefaultOrganizationTest/initial.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "IS_BUILT_IN" BOOLEAN NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); - -CREATE TABLE "ORG_QPROFILES" ( - "UUID" VARCHAR(255) NOT NULL PRIMARY KEY, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "PARENT_UUID" VARCHAR(255), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); -CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); - - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfilesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfilesTest/initial.sql deleted file mode 100644 index 6ce198e77d6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/UpdateOrgQProfilesToPointToBuiltInProfilesTest/initial.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "IS_BUILT_IN" BOOLEAN NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); - -CREATE TABLE "ORG_QPROFILES" ( - "UUID" VARCHAR(255) NOT NULL PRIMARY KEY, - "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 -); -CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); -CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTableTest/ce_activity_6_5.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTableTest/ce_activity_6_5.sql deleted file mode 100644 index 588109c67ff..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddErrorTypeColumnToCeActivityTableTest/ce_activity_6_5.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddIncrementalColumnToSnapshotsTableTest/old_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddIncrementalColumnToSnapshotsTableTest/old_snapshots.sql deleted file mode 100644 index b5ef3ce6992..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddIncrementalColumnToSnapshotsTableTest/old_snapshots.sql +++ /dev/null @@ -1,29 +0,0 @@ - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRulesTest/rules_6_5.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRulesTest/rules_6_5.sql deleted file mode 100644 index 375442e561b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/AddPluginKeyToRulesTest/rules_6_5.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "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), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristicsTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristicsTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTablePluginsTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTablePluginsTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranchesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranchesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroupsTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditGroupsTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsersTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/CreateTableQProfileEditUsersTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest/settings_and_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest/settings_and_projects.sql deleted file mode 100644 index 6d62b229804..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest/settings_and_projects.sql +++ /dev/null @@ -1,57 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsersTest/users.sql deleted file mode 100644 index 8d6baaacafa..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/FixEmptyIdentityProviderInUsersTest/users.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/MakeAnalysisUuidNotNullOnWebhookDeliveriesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/MakeAnalysisUuidNotNullOnWebhookDeliveriesTest/initial.sql deleted file mode 100644 index 1d8b219839a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/MakeAnalysisUuidNotNullOnWebhookDeliveriesTest/initial.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "WEBHOOK_DELIVERIES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "COMPONENT_UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(40), - "CE_TASK_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "SUCCESS" BOOLEAN NOT NULL, - "HTTP_STATUS" INT, - "DURATION_MS" INT, - "PAYLOAD" CLOB NOT NULL, - "ERROR_STACKTRACE" CLOB, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); -CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); -CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest/initial.sql deleted file mode 100644 index 7ae1777df16..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest/initial.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "BRANCH_TYPE" VARCHAR(5), - "MERGE_BRANCH_UUID" VARCHAR(50), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID"); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PurgeTablePropertiesTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PurgeTablePropertiesTest/properties.sql deleted file mode 100644 index dfc39d8d285..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PurgeTablePropertiesTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -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/v67/AddAnalysisUuidToWebhookDeliveriesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest/initial.sql deleted file mode 100644 index e4509afd200..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest/initial.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "WEBHOOK_DELIVERIES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "COMPONENT_UUID" VARCHAR(40) NOT NULL, - "CE_TASK_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "SUCCESS" BOOLEAN NOT NULL, - "HTTP_STATUS" INT, - "DURATION_MS" INT, - "PAYLOAD" CLOB NOT NULL, - "ERROR_STACKTRACE" CLOB, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); -CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); -CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsersTest/users.sql deleted file mode 100644 index 8d6baaacafa..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CleanupDisabledUsersTest/users.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerIdTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerIdTest/properties.sql deleted file mode 100644 index dfc39d8d285..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CopyDeprecatedServerIdTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -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/v67/CreateTableAnalysisPropertiesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/CreateTableAnalysisPropertiesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/DropOldLicensesTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/DropOldLicensesTest/properties.sql deleted file mode 100644 index dfc39d8d285..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/DropOldLicensesTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT -); -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/v67/MigratePreviousAnalysisToPreviousVersionTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersionTest/properties.sql deleted file mode 100644 index d84c238cd48..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/MigratePreviousAnalysisToPreviousVersionTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -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/v67/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest/initial.sql deleted file mode 100644 index de520902cff..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest/initial.sql +++ /dev/null @@ -1,46 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647) -); - -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); - - -CREATE TABLE "WEBHOOK_DELIVERIES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "COMPONENT_UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(40), - "CE_TASK_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "SUCCESS" BOOLEAN NOT NULL, - "HTTP_STATUS" INT, - "DURATION_MS" INT, - "PAYLOAD" CLOB NOT NULL, - "ERROR_STACKTRACE" CLOB, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); -CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); -CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); -CREATE INDEX "ANALYSES_UUID" ON "WEBHOOK_DELIVERIES" ("ANALYSIS_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest/initial.sql deleted file mode 100644 index 0e120b5f08a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest/initial.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "WEBHOOK_DELIVERIES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "COMPONENT_UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(40) NULL, - "CE_TASK_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "SUCCESS" BOOLEAN NOT NULL, - "HTTP_STATUS" INT, - "DURATION_MS" INT, - "PAYLOAD" CLOB NOT NULL, - "ERROR_STACKTRACE" CLOB, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); -CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); -CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizationsTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizationsTest/organizations.sql deleted file mode 100644 index 406f6290605..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddDefaultQualityGateUuidToOrganizationsTest/organizations.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( -"UUID" VARCHAR(40) NOT NULL PRIMARY KEY, -"KEE" VARCHAR(32) NOT NULL, -"NAME" VARCHAR(64) NOT NULL, -"DESCRIPTION" VARCHAR(256), -"URL" VARCHAR(256), -"AVATAR_URL" VARCHAR(256), -"GUARDED" BOOLEAN NOT NULL, -"USER_ID" INTEGER, -"DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), -"DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), -"DEFAULT_GROUP_ID" INTEGER, -"NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, -"CREATED_AT" BIGINT NOT NULL, -"UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v70/AddHomepageToUsersTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsersTest/initial.sql deleted file mode 100644 index 8d6baaacafa..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddHomepageToUsersTest/initial.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest/quality_gates.sql deleted file mode 100644 index 811a5d45965..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddIsBuiltInToQualityGatesTest/quality_gates.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndexTest/live_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndexTest/live_measures.sql deleted file mode 100644 index 291df9899c4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddLiveMeasuresMetricIndexTest/live_measures.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "LIVE_MEASURES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "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" BINARY, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -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/v70/AddSnapshotIsLastIndexTest/snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndexTest/snapshots.sql deleted file mode 100644 index 7d8f2963a86..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddSnapshotIsLastIndexTest/snapshots.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGatesTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGatesTest/quality_gates.sql deleted file mode 100644 index f7e89fee40c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AddUuidToQualityGatesTest/quality_gates.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganizationTest/org_quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganizationTest/org_quality_gates.sql deleted file mode 100644 index 27a328ebe7d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/AssociateQualityGatesToDefaultOrganizationTest/org_quality_gates.sql +++ /dev/null @@ -1,46 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "ORG_QUALITY_GATES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "QUALITY_GATE_UUID" VARCHAR(40) NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_ORG_QUALITY_GATES" ON "ORG_QUALITY_GATES" ("ORGANIZATION_UUID","QUALITY_GATE_UUID"); - - -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(20) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGateTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGateTest/quality_gates.sql deleted file mode 100644 index b90299a13c5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateBuiltInQualityGateTest/quality_gates.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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/v70/CreateOrgQualityGatesTableTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateOrgQualityGatesTableTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasuresTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateTableLiveMeasuresTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresPTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/CreateTempTableLiveMeasuresPTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasuresTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasuresTest/initial.sql deleted file mode 100644 index be55d6f14e8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeleteFileMeasuresTest/initial.sql +++ /dev/null @@ -1,98 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); - - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSettingTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSettingTest/properties.sql deleted file mode 100644 index d84c238cd48..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeleteGlobalSonarQualityGateSettingTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -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/v70/DeletePersonAndFileMeasuresTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeletePersonAndFileMeasuresTest/initial.sql deleted file mode 100644 index be55d6f14e8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeletePersonAndFileMeasuresTest/initial.sql +++ /dev/null @@ -1,98 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); - - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasuresTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasuresTest/initial.sql deleted file mode 100644 index be55d6f14e8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DeletePersonMeasuresTest/initial.sql +++ /dev/null @@ -1,98 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); - - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasuresTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasuresTest/initial.sql deleted file mode 100644 index 00ef5e22307..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropIndexOnPersonMeasuresTest/initial.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTableTest/loaded_templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTableTest/loaded_templates.sql deleted file mode 100644 index d3c72d43b4d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropLoadedTemplatesTableTest/loaded_templates.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(64) NOT NULL -); -CREATE INDEX "IX_LOADED_TEMPLATES_TYPE" ON "LOADED_TEMPLATES" ("TEMPLATE_TYPE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndexTest/snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndexTest/snapshots.sql deleted file mode 100644 index 53bee7b6bce..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropSnapshotIsLastIndexTest/snapshots.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE INDEX "IX_SNAPSHOT_IS_LAST" ON "SNAPSHOTS" ("ISLAST"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresPTest/live_measures_p.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresPTest/live_measures_p.sql deleted file mode 100644 index 0632f993b4e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropTempTableLiveMeasuresPTest/live_measures_p.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE "LIVE_MEASURES_P" ( - "PROJECT_UUID" VARCHAR(50) NOT NULL, - CONSTRAINT "PK_LIVE_MEASURES_P" PRIMARY KEY ("PROJECT_UUID") -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesNameTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesNameTest/quality_gates.sql deleted file mode 100644 index a3af576cd68..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/DropUniqueIndexOnQualityGatesNameTest/quality_gates.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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" ON "QUALITY_GATES" ("NAME"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES" ("UUID"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullableTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullableTest/quality_gates.sql deleted file mode 100644 index 52b9423f526..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/MakeQualityGatesIsBuiltInNotNullableTest/quality_gates.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGatesTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGatesTest/quality_gates.sql deleted file mode 100644 index 8ea864766b2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/MakeUuidNotNullableOnQualityGatesTest/quality_gates.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGateTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGateTest/organizations.sql deleted file mode 100644 index 1adb6bbc747..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateDefaultQualityGateTest/organizations.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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/v70/PopulateLiveMeasuresTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest/initial.sql deleted file mode 100644 index cf0c97555c1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest/initial.sql +++ /dev/null @@ -1,121 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); --- temporary index added by previous DB migration -CREATE INDEX "IX_SNAPSHOT_IS_LAST" ON "SNAPSHOTS" ("ISLAST"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); - - -CREATE TABLE "LIVE_MEASURES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "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" BINARY, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES" ("PROJECT_UUID"); - --- temporary table created by previous DB migration -CREATE TABLE "LIVE_MEASURES_P" ( - "PROJECT_UUID" VARCHAR(50) NOT NULL, - CONSTRAINT "PK_LIVE_MEASURES_P" PRIMARY KEY ("PROJECT_UUID") -); - - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -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/v70/PopulateOrgQualityGates/org_quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGates/org_quality_gates.sql deleted file mode 100644 index 2f6043beca0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateOrgQualityGates/org_quality_gates.sql +++ /dev/null @@ -1,37 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "ORG_QUALITY_GATES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "QUALITY_GATE_UUID" VARCHAR(40) NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_ORG_QUALITY_GATES" ON "ORG_QUALITY_GATES" ("ORGANIZATION_UUID","QUALITY_GATE_UUID"); - - -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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/v70/PopulateQualityGatesIsBuiltInTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltInTest/quality_gates.sql deleted file mode 100644 index 52b9423f526..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateQualityGatesIsBuiltInTest/quality_gates.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGatesTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGatesTest/quality_gates.sql deleted file mode 100644 index 8ea864766b2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/PopulateUuidOnQualityGatesTest/quality_gates.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrgTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrgTest/initial.sql deleted file mode 100644 index a9959d138c0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/ReadGlobalSonarQualityGateSettingToDefaultOrgTest/initial.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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"); - -CREATE TABLE "ORG_QUALITY_GATES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "QUALITY_GATE_UUID" VARCHAR(40) NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_ORG_QUALITY_GATES" ON "ORG_QUALITY_GATES" ("ORGANIZATION_UUID","QUALITY_GATE_UUID"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(20) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplatesTest/loaded_templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplatesTest/loaded_templates.sql deleted file mode 100644 index d3c72d43b4d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/RemoveQualityGateLoadedTemplatesTest/loaded_templates.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(64) NOT NULL -); -CREATE INDEX "IX_LOADED_TEMPLATES_TYPE" ON "LOADED_TEMPLATES" ("TEMPLATE_TYPE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest/quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest/quality_gates.sql deleted file mode 100644 index 52b9423f526..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest/quality_gates.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest/organizations.sql deleted file mode 100644 index 161b7f8e71c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v70/SetDefaultQualityGateUuidAsNotNullableInOrganizationsTest/organizations.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("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/v71/AddKeyTypeInProjectBranchesTest/project_branches.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranchesTest/project_branches.sql deleted file mode 100644 index 7f1ef8adc6d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddKeyTypeInProjectBranchesTest/project_branches.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID"); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranchesTest/project_branches.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranchesTest/project_branches.sql deleted file mode 100644 index d3680968980..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddPullRequestBinaryInProjectBranchesTest/project_branches.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "KEY_TYPE" VARCHAR(12) NOT NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID"); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE", "KEY_TYPE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddRuleScopeTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddRuleScopeTest/rules.sql deleted file mode 100644 index 7bc032ceb37..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddRuleScopeTest/rules.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "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), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTableTest/webhook-deliveries.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTableTest/webhook-deliveries.sql deleted file mode 100644 index 27263b0804b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/AddWebhookKeyToWebhookDeliveriesTableTest/webhook-deliveries.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "WEBHOOK_DELIVERIES" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "COMPONENT_UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(40), - "CE_TASK_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "SUCCESS" BOOLEAN NOT NULL, - "HTTP_STATUS" INT, - "DURATION_MS" INT, - "PAYLOAD" CLOB NOT NULL, - "ERROR_STACKTRACE" CLOB, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); -CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); -CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); -CREATE INDEX "ANALYSIS_UUID" ON "WEBHOOK_DELIVERIES" ("ANALYSIS_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferencesTest/properties_and_quality_gates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferencesTest/properties_and_quality_gates.sql deleted file mode 100644 index 7e565f13087..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CleanBrokenProjectToQGReferencesTest/properties_and_quality_gates.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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/v71/CleanCeChildTablesOrphansTest/ce_tables.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphansTest/ce_tables.sql deleted file mode 100644 index cab879a5f89..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CleanCeChildTablesOrphansTest/ce_tables.sql +++ /dev/null @@ -1,69 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); - - -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); - -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); - -CREATE TABLE "CE_TASK_CHARACTERISTICS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "TASK_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000) -); -CREATE INDEX "CE_TASK_CHARACTERISTICS_TASK_UUID" ON "CE_TASK_CHARACTERISTICS" ("TASK_UUID"); - - -CREATE TABLE "CE_TASK_INPUT" ( - "TASK_UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "INPUT_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); - - -CREATE TABLE "CE_SCANNER_CONTEXT" ( - "TASK_UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "CONTEXT_DATA" BLOB NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTableTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateDeprecatedRuleKeysTableTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2Test/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateTableProjectLinks2Test/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTableTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/CreateWebhooksTableTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopiesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopiesTest/initial.sql deleted file mode 100644 index 918014dbb44..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DeleteMeasuresOfProjectCopiesTest/initial.sql +++ /dev/null @@ -1,68 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - - -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotPropertiesTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotPropertiesTest/properties.sql deleted file mode 100644 index d84c238cd48..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DeleteSettingsDefinedInSonarDotPropertiesTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -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/v71/DropTableProjectLinksTest/project_links.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinksTest/project_links.sql deleted file mode 100644 index 9588643a463..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/DropTableProjectLinksTest/project_links.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "PROJECT_LINKS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "COMPONENT_UUID" VARCHAR(50), - "LINK_TYPE" VARCHAR(20), - "NAME" VARCHAR(128), - "HREF" VARCHAR(2048) NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequestTest/project_branches.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequestTest/project_branches.sql deleted file mode 100644 index e05ff3bd2bb..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/IncreaseBranchTypeSizeForPullRequestTest/project_branches.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "BRANCH_TYPE" VARCHAR(5), - "MERGE_BRANCH_UUID" VARCHAR(50), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID"); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranchesTest/project_branches.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranchesTest/project_branches.sql deleted file mode 100644 index 6441ce1ca02..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MakeKeyTypeNotNullableInProjectBranchesTest/project_branches.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "KEY_TYPE" VARCHAR(12) NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID"); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRulesTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRulesTest/rules.sql deleted file mode 100644 index 1708db814f4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MakeScopeNotNullableInRulesTest/rules.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" 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), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTableTest/migrate_webhooks.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTableTest/migrate_webhooks.sql deleted file mode 100644 index a0cd8c422e5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/MigrateWebhooksToWebhooksTableTest/migrate_webhooks.sql +++ /dev/null @@ -1,76 +0,0 @@ -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(20) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); - - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - - -CREATE TABLE "WEBHOOKS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "PK_WEBHOOKS" ON "WEBHOOKS" ("UUID"); -CREATE INDEX "ORGANIZATION_WEBHOOK" ON "WEBHOOKS" ("ORGANIZATION_UUID"); -CREATE INDEX "PROJECT_WEBHOOK" ON "WEBHOOKS" ("PROJECT_UUID"); - - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2Test/project_links2.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2Test/project_links2.sql deleted file mode 100644 index ef474cc6421..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/PopulateTableProjectLinks2Test/project_links2.sql +++ /dev/null @@ -1,64 +0,0 @@ -CREATE TABLE "PROJECT_LINKS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "COMPONENT_UUID" VARCHAR(50), - "LINK_TYPE" VARCHAR(20), - "NAME" VARCHAR(128), - "HREF" VARCHAR(2048) NOT NULL -); - -CREATE TABLE "PROJECT_LINKS2" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "LINK_TYPE" VARCHAR(20) NOT NULL, - "NAME" VARCHAR(128), - "HREF" VARCHAR(2048) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinksTest/project_links2.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinksTest/project_links2.sql deleted file mode 100644 index c29900dbd64..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/RenameTableProjectLinks2ToProjectLinksTest/project_links2.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PROJECT_LINKS2" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "LINK_TYPE" VARCHAR(20) NOT NULL, - "NAME" VARCHAR(128), - "HREF" VARCHAR(2048) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranchesTest/project_branches.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranchesTest/project_branches.sql deleted file mode 100644 index b7553cf6dcc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/ReplaceIndexInProjectBranchesTest/project_branches.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "KEY_TYPE" VARCHAR(12) NOT NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID"); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranchesTest/project_branches.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranchesTest/project_branches.sql deleted file mode 100644 index 6441ce1ca02..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/SetKeyTypeToBranchInProjectBranchesTest/project_branches.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL PRIMARY KEY, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "KEY_TYPE" VARCHAR(12) NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID"); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMainTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMainTest/rules.sql deleted file mode 100644 index 1708db814f4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/SetRuleScopeToMainTest/rules.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" 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), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeysTest/templates.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeysTest/templates.sql deleted file mode 100644 index e80e57d0eef..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/UpdatePermissionTooLongTemplateKeysTest/templates.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesDataTest/rules_and_qprofile_changes.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesDataTest/rules_and_qprofile_changes.sql deleted file mode 100644 index ea146a6d3c3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v71/UseRuleIdInQPChangesDataTest/rules_and_qprofile_changes.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "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), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); - -CREATE TABLE "QPROFILE_CHANGES" ( - "KEE" VARCHAR(40) NOT NULL PRIMARY KEY, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_DATA" CLOB -); -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/v72/AddExternalIdToUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest/users.sql deleted file mode 100644 index 63f3678158c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest/users.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCountTest/file_sources.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCountTest/file_sources.sql deleted file mode 100644 index 4df5eff4862..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddFileSourceLineCountTest/file_sources.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "FILE_SOURCES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB, - "BINARY_DATA" BLOB, - "DATA_TYPE" VARCHAR(20), - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); -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/v72/AddHashMethodToUsersTableTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTableTest/users.sql deleted file mode 100644 index c5103149b55..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddHashMethodToUsersTableTest/users.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSourcesTest/fileSources.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSourcesTest/fileSources.sql deleted file mode 100644 index 48ceb31c0a1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddLineHashesVersionToFileSourcesTest/fileSources.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "FILE_SOURCES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB, - "BINARY_DATA" BLOB, - "DATA_TYPE" VARCHAR(20), - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); -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/v72/AddOrganizationUuidToUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest/users.sql deleted file mode 100644 index 3d35b327f62..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest/users.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "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_ID" VARCHAR(255) NOT NULL, - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS" ("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS" ("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddRuleExternalTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddRuleExternalTest/rules.sql deleted file mode 100644 index f661e2fc5c4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddRuleExternalTest/rules.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" VARCHAR(20) NOT NULL, - "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), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers/users.sql deleted file mode 100644 index 7788824d1bc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers/users.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "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_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParametersTest/rules_parameters.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParametersTest/rules_parameters.sql deleted file mode 100644 index 26b436bb1f9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexOnRulesParametersTest/rules_parameters.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000) -); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS" ("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest/users.sql deleted file mode 100644 index 5d8477543c8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest/users.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_ID" VARCHAR(255), - "EXTERNAL_LOGIN" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTableTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/CreateAlmAppInstallsTableTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTableTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/CreateProjectMappingsTableTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizationsTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizationsTest/organizations.sql deleted file mode 100644 index e08101aeddc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/DropUserIdFromOrganizationsTest/organizations.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsersTest/users.sql deleted file mode 100644 index 5d8477543c8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/FixDuplicationInExternalLoginOnUsersTest/users.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_ID" VARCHAR(255), - "EXTERNAL_LOGIN" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSizeTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSizeTest/users.sql deleted file mode 100644 index 3cf041df7dc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/IncreaseCryptedPasswordSizeTest/users.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullableTest/file_sources.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullableTest/file_sources.sql deleted file mode 100644 index ac8ae8eba78..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeFileSourceLineCountNotNullableTest/file_sources.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "FILE_SOURCES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB, - "LINE_COUNT" INTEGER, - "BINARY_DATA" BLOB, - "DATA_TYPE" VARCHAR(20), - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); -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/v72/MakeSomeColumnsOfUsersNotNullableTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest/users.sql deleted file mode 100644 index 5d8477543c8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest/users.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_ID" VARCHAR(255), - "EXTERNAL_LOGIN" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCountTest/file_sources.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCountTest/file_sources.sql deleted file mode 100644 index ac8ae8eba78..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateFileSourceLineCountTest/file_sources.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "FILE_SOURCES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB, - "LINE_COUNT" INTEGER, - "BINARY_DATA" BLOB, - "DATA_TYPE" VARCHAR(20), - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); -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/v72/PopulateHashMethodOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsersTest/users.sql deleted file mode 100644 index 7788824d1bc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateHashMethodOnUsersTest/users.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "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_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest/schema.sql deleted file mode 100644 index a3d5dc0b618..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest/schema.sql +++ /dev/null @@ -1,47 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "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_ID" VARCHAR(255) NOT NULL, - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS" ("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS" ("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); - -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "USER_ID" INTEGER, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest/users.sql deleted file mode 100644 index d5b823e4b60..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest/users.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255), - "LOGIN" VARCHAR(255), - "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_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParametersTest/rules_parameters_etc.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParametersTest/rules_parameters_etc.sql deleted file mode 100644 index 3ceb8ea5762..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PurgeDuplicateRulesParametersTest/rules_parameters_etc.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000) -); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS" ("RULE_ID"); - -CREATE TABLE "ACTIVE_RULE_PARAMETERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_KEY" VARCHAR(128), - "VALUE" VARCHAR(4000) -); -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/v72/PurgeOrphansForCETest/ce.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCETest/ce.sql deleted file mode 100644 index 53f08abdc36..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PurgeOrphansForCETest/ce.sql +++ /dev/null @@ -1,75 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); - - -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); - - -CREATE TABLE "CE_TASK_CHARACTERISTICS" ( - "UUID" VARCHAR(40) NOT NULL, - "TASK_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - - CONSTRAINT "PK_CE_TASK_CHARACTERISTICS" PRIMARY KEY ("UUID") -); -CREATE INDEX "CE_TASK_CHARACTERISTICS_TASK_UUID" ON "CE_TASK_CHARACTERISTICS" ("TASK_UUID"); - - -CREATE TABLE "CE_TASK_INPUT" ( - "TASK_UUID" VARCHAR(40) NOT NULL, - "INPUT_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_CE_TASK_INPUT" PRIMARY KEY ("TASK_UUID") -); - - -CREATE TABLE "CE_SCANNER_CONTEXT" ( - "TASK_UUID" VARCHAR(40) NOT NULL, - "CONTEXT_DATA" BLOB NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_CE_SCANNER_CONTEXT" PRIMARY KEY ("TASK_UUID") -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest/users.sql deleted file mode 100644 index c88da101896..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest/users.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_ID" VARCHAR(255), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameIssuesAssigneeToAssigneeUuidTest/issues.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameIssuesAssigneeToAssigneeUuidTest/issues.sql deleted file mode 100644 index af9aacdc1e3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameIssuesAssigneeToAssigneeUuidTest/issues.sql +++ /dev/null @@ -1,37 +0,0 @@ -CREATE TABLE "ISSUES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(50) UNIQUE NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "EFFORT" INTEGER, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50) NULL, - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT -); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); -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/v72/RenameLoginToUserUuidOnTableUserTokensTest/user_tokens.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokensTest/user_tokens.sql deleted file mode 100644 index acb1b33f18a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameLoginToUserUuidOnTableUserTokensTest/user_tokens.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "USER_TOKENS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS" ("TOKEN_HASH"); -CREATE UNIQUE INDEX "USER_TOKENS_LOGIN_NAME" ON "USER_TOKENS" ("LOGIN", "NAME"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest/rules_metadata.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest/rules_metadata.sql deleted file mode 100644 index 69c506a80b1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameNoteUserLoginToNoteUserUuidOnTableRulesMetadataTest/rules_metadata.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "RULES_METADATA" ( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB, - "NOTE_USER_LOGIN" 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), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - CONSTRAINT PK_RULES_METADATA PRIMARY KEY (RULE_ID,ORGANIZATION_UUID) -); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest/ce_activity.sql deleted file mode 100644 index fe5d1ba980b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeActivityTest/ce_activity.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); - -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest/ce_queue.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest/ce_queue.sql deleted file mode 100644 index 0927e642262..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameSubmitterLoginToSubmitterUuidOnTableCeQueueTest/ce_queue.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_LOGIN" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasuresTest/manual_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasuresTest/manual_measures.sql deleted file mode 100644 index 598cb6885d2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableManualMeasuresTest/manual_measures.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES" ("COMPONENT_UUID"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChangesTest/qprofile_changes.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChangesTest/qprofile_changes.sql deleted file mode 100644 index 470f3119820..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameUserLoginToUserUuidOnTableQProfileChangesTest/qprofile_changes.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_CHANGES" ( - "KEE" VARCHAR(40) NOT NULL PRIMARY KEY, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_DATA" CLOB -); -CREATE INDEX "QP_CHANGES_RULES_PROFILE_UUID" ON "QPROFILE_CHANGES" ("RULES_PROFILE_UUID"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest/users.sql deleted file mode 100644 index 5d8477543c8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest/users.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_ID" VARCHAR(255), - "EXTERNAL_LOGIN" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40) -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssuesTest/issues.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssuesTest/issues.sql deleted file mode 100644 index af9aacdc1e3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddFromHotspotFlagToIssuesTest/issues.sql +++ /dev/null @@ -1,37 +0,0 @@ -CREATE TABLE "ISSUES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(50) UNIQUE NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "EFFORT" INTEGER, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50) NULL, - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT -); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); -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/v73/AddIndexOnOrganizationMembersTest/organization_members.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembersTest/organization_members.sql deleted file mode 100644 index b14c1697212..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddIndexOnOrganizationMembersTest/organization_members.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS" ( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - - 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/v73/AddSecurityStandardsToRulesTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRulesTest/rules.sql deleted file mode 100644 index c1718d4b7c0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddSecurityStandardsToRulesTest/rules.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "IS_EXTERNAL" BOOLEAN, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" VARCHAR(20) NOT NULL, - "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), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizationsTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizationsTest/organizations.sql deleted file mode 100644 index 03d195923b4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/AddSubscriptionToOrganizationsTest/organizations.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - 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/v73/CreateProjectAlmBindingsTableTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/CreateProjectAlmBindingsTableTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizationsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizationsTest/schema.sql deleted file mode 100644 index 74222845568..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/FixMissingQualityProfilesOnOrganizationsTest/schema.sql +++ /dev/null @@ -1,59 +0,0 @@ - -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, - - CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY ("UUID") -); -CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); -CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); - -CREATE TABLE "DEFAULT_QPROFILES" ( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "LANGUAGE" VARCHAR(20) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_DEFAULT_QPROFILES" PRIMARY KEY ("ORGANIZATION_UUID", "LANGUAGE") -); -CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES" ("QPROFILE_UUID"); - -CREATE TABLE "RULES_PROFILES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "IS_BUILT_IN" BOOLEAN NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); - -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - 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/v73/PopulateHotspotAdminPermissionOnGroupsTest/group_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroupsTest/group_roles.sql deleted file mode 100644 index 6ea4f53d266..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnGroupsTest/group_roles.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest/perm_tpl_characteristics.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest/perm_tpl_characteristics.sql deleted file mode 100644 index df0d57b9ebc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesCharacteristicsTest/perm_tpl_characteristics.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN NOT NULL DEFAULT FALSE, - "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/v73/PopulateHotspotAdminPermissionOnTemplatesGroupsTest/perm_templates_groups.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroupsTest/perm_templates_groups.sql deleted file mode 100644 index 0e133ab7882..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesGroupsTest/perm_templates_groups.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsersTest/perm_templates_users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsersTest/perm_templates_users.sql deleted file mode 100644 index 649e019f428..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnTemplatesUsersTest/perm_templates_users.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsersTest/user_roles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsersTest/user_roles.sql deleted file mode 100644 index 180c8c5fbb8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateHotspotAdminPermissionOnUsersTest/user_roles.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranchesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranchesTest/schema.sql deleted file mode 100644 index 99611469235..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateMainApplicationBranchesTest/schema.sql +++ /dev/null @@ -1,61 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "KEY_TYPE" VARCHAR(12) NOT NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "PULL_REQUEST_BINARY" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_PROJECT_BRANCHES" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE_KEY_TYPE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE", "KEY_TYPE"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizationsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizationsTest/schema.sql deleted file mode 100644 index 03c3509082f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/PopulateSubscriptionOnOrganizationsTest/schema.sql +++ /dev/null @@ -1,67 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullableTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullableTest/organizations.sql deleted file mode 100644 index 5e615118f7c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v73/SetSubscriptionOnOrganizationsNotNullableTest/organizations.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "SUBSCRIPTION" VARCHAR(40), - 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/v74/AddAdHocColumnsInInRulesMetadataTest/rules_metadata.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadataTest/rules_metadata.sql deleted file mode 100644 index 1b344c861a4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddAdHocColumnsInInRulesMetadataTest/rules_metadata.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "RULES_METADATA" ( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB, - "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), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY ("RULE_ID", "ORGANIZATION_UUID") -); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest/group_roles_and_internal_properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest/group_roles_and_internal_properties.sql deleted file mode 100644 index 8871f93bca8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddApplicationCreatorAndPortfolioCreatorToSonarAdministratorTest/group_roles_and_internal_properties.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512), - "RESOURCE_ID" INTEGER, - "TEXT_VALUE" CLOB(2147483647), - "USER_ID" INTEGER -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); - -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizationsTest/previous-organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizationsTest/previous-organizations.sql deleted file mode 100644 index c344758a90a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddDefaultPermTemplateColumnsToOrganizationsTest/previous-organizations.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - 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/v74/AddIsAdHocToRulesTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRulesTest/rules.sql deleted file mode 100644 index 19fd9844826..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddIsAdHocToRulesTest/rules.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "IS_EXTERNAL" BOOLEAN, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" VARCHAR(20) NOT NULL, - "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), - "SECURITY_STANDARDS" VARCHAR(4000), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivityTest/ce_activity.sql deleted file mode 100644 index 540c11a8dd5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeActivityTest/ce_activity.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueueTest/ce_queue.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueueTest/ce_queue.sql deleted file mode 100644 index b1282536589..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpColumnsToCeQueueTest/ce_queue.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivityTest/ce_activity.sql deleted file mode 100644 index fb0d7303aae..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/AddTmpLastKeyColumnsToCeActivityTest/ce_activity.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_TMP_CMPT_UUID" ON "CE_ACTIVITY" ("TMP_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_TMP_MAIN_CMPT_UUID" ON "CE_ACTIVITY" ("TMP_MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTablesTest/ce_tables.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTablesTest/ce_tables.sql deleted file mode 100644 index 8856d15ca6b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CleanOrphanRowsInCeTablesTest/ce_tables.sql +++ /dev/null @@ -1,83 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE" ("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); - - -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN, - "IS_LAST_KEY" VARCHAR(55), - "MAIN_IS_LAST" BOOLEAN, - "MAIN_IS_LAST_KEY" VARCHAR(55), - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY" ("MAIN_IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY" ("MAIN_IS_LAST", "STATUS"); - - -CREATE TABLE "CE_TASK_CHARACTERISTICS" ( - "UUID" VARCHAR(40) NOT NULL, - "TASK_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - - CONSTRAINT "PK_CE_TASK_CHARACTERISTICS" PRIMARY KEY ("UUID") -); -CREATE INDEX "CE_TASK_CHARACTERISTICS_TASK_UUID" ON "CE_TASK_CHARACTERISTICS" ("TASK_UUID"); - - -CREATE TABLE "CE_TASK_INPUT" ( - "TASK_UUID" VARCHAR(40) NOT NULL, - "INPUT_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_CE_TASK_INPUT" PRIMARY KEY ("TASK_UUID") -); - - -CREATE TABLE "CE_SCANNER_CONTEXT" ( - "TASK_UUID" VARCHAR(40) NOT NULL, - "CONTEXT_DATA" BLOB NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_CE_SCANNER_CONTEXT" PRIMARY KEY ("TASK_UUID") -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissionsTest/perm_templates_groups.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissionsTest/perm_templates_groups.sql deleted file mode 100644 index 0a8c29211f0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CreateApplicationsAndPortfoliosCreatorPermissionsTest/perm_templates_groups.sql +++ /dev/null @@ -1,49 +0,0 @@ -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "PERM_TEMPLATES_GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - 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/v74/CreateCeTaskMessageTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/CreateCeTaskMessageTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest/organizations.sql deleted file mode 100644 index d5bcfd25874..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest/organizations.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - 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/v74/FinalizeMainComponentUuidColumnsToCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest/ce_activity.sql deleted file mode 100644 index b4e110b67e7..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest/ce_activity.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "TMP_IS_LAST" BOOLEAN, - "TMP_IS_LAST_KEY" VARCHAR(55), - "TMP_MAIN_IS_LAST" BOOLEAN, - "TMP_MAIN_IS_LAST_KEY" VARCHAR(55), - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_TMP_CPNT_UUID" ON "CE_ACTIVITY" ("TMP_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_TMP_MAIN_CPNT_UUID" ON "CE_ACTIVITY" ("TMP_MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_T_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_T_ISLAST" ON "CE_ACTIVITY" ("TMP_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST", "STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest/ce_queue.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest/ce_queue.sql deleted file mode 100644 index c42f2cb7c3b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest/ce_queue.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_TMP_CPNT_UUID" ON "CE_QUEUE" ("TMP_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_TMP_MAIN_CPNT_UUID" ON "CE_QUEUE" ("TMP_MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest/ce_activity.sql deleted file mode 100644 index 4dfeabe82e8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest/ce_activity.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "TMP_IS_LAST" BOOLEAN, - "TMP_IS_LAST_KEY" VARCHAR(55), - "TMP_MAIN_IS_LAST" BOOLEAN, - "TMP_MAIN_IS_LAST_KEY" VARCHAR(55), - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_T_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_T_ISLAST" ON "CE_ACTIVITY" ("TMP_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST", "STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLengthTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLengthTest/organizations.sql deleted file mode 100644 index 4583ca9967b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/IncreaseOrganizationsKeeAndNameLengthTest/organizations.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizationsTest/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizationsTest/organizations.sql deleted file mode 100644 index d5bcfd25874..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateDefaultPermTemplateOnOrganizationsTest/organizations.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - 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/v74/PopulateIsAdHocOnRulesTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRulesTest/rules.sql deleted file mode 100644 index 2179b79d9ad..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateIsAdHocOnRulesTest/rules.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "IS_EXTERNAL" BOOLEAN, - "IS_AD_HOC" BOOLEAN, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" VARCHAR(20) NOT NULL, - "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), - "SECURITY_STANDARDS" VARCHAR(4000), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRulesTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRulesTest/rules.sql deleted file mode 100644 index 19fd9844826..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateNullValuesOfIsExternalOnRulesTest/rules.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "IS_EXTERNAL" BOOLEAN, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" VARCHAR(20) NOT NULL, - "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), - "SECURITY_STANDARDS" VARCHAR(4000), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivityTest/ce_activity.sql deleted file mode 100644 index 68242f666e7..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeActivityTest/ce_activity.sql +++ /dev/null @@ -1,87 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_TMP_CMPT_UUID" ON "CE_ACTIVITY" ("TMP_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_TMP_MAIN_CMPT_UUID" ON "CE_ACTIVITY" ("TMP_MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); - -CREATE TABLE "CE_TASK_CHARACTERISTICS" ( - "UUID" VARCHAR(40) NOT NULL, - "TASK_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - - CONSTRAINT "PK_CE_TASK_CHARACTERISTICS" PRIMARY KEY ("UUID") -); -CREATE INDEX "CE_TASK_CHARACTERISTICS_TASK_UUID" ON "CE_TASK_CHARACTERISTICS" ("TASK_UUID"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueueTest/ce_queue.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueueTest/ce_queue.sql deleted file mode 100644 index 96cd2eab03c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpColumnsToCeQueueTest/ce_queue.sql +++ /dev/null @@ -1,77 +0,0 @@ -CREATE TABLE "CE_QUEUE" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "STARTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_TMP_COMPONENT_UUID" ON "CE_QUEUE" ("TMP_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_TMP_MAIN_CMPT_UUID" ON "CE_QUEUE" ("TMP_MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); - -CREATE TABLE "CE_TASK_CHARACTERISTICS" ( - "UUID" VARCHAR(40) NOT NULL, - "TASK_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - - CONSTRAINT "PK_CE_TASK_CHARACTERISTICS" PRIMARY KEY ("UUID") -); -CREATE INDEX "CE_TASK_CHARACTERISTICS_TASK_UUID" ON "CE_TASK_CHARACTERISTICS" ("TASK_UUID"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivityTest/ce_activity.sql deleted file mode 100644 index b4e110b67e7..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/PopulateTmpLastKeyColumnsToCeActivityTest/ce_activity.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE "CE_ACTIVITY" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_COMPONENT_UUID" VARCHAR(40) NULL, - "TMP_MAIN_COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, - "STATUS" VARCHAR(15) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "TMP_IS_LAST" BOOLEAN, - "TMP_IS_LAST_KEY" VARCHAR(55), - "TMP_MAIN_IS_LAST" BOOLEAN, - "TMP_MAIN_IS_LAST_KEY" VARCHAR(55), - "SUBMITTER_UUID" VARCHAR(255) NULL, - "WORKER_UUID" VARCHAR(40) NULL, - "EXECUTION_COUNT" INTEGER NOT NULL, - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT NULL, - "EXECUTED_AT" BIGINT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXECUTION_TIME_MS" BIGINT NULL, - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB, - "ERROR_TYPE" VARCHAR(20) -); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_TMP_CPNT_UUID" ON "CE_ACTIVITY" ("TMP_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_TMP_MAIN_CPNT_UUID" ON "CE_ACTIVITY" ("TMP_MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_T_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_T_ISLAST" ON "CE_ACTIVITY" ("TMP_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST", "STATUS"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRulesTest/rules.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRulesTest/rules.sql deleted file mode 100644 index 2179b79d9ad..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/SetIsExternalAndIsAdHocNotNullableInRulesTest/rules.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "IS_EXTERNAL" BOOLEAN, - "IS_AD_HOC" BOOLEAN, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" VARCHAR(20) NOT NULL, - "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), - "SECURITY_STANDARDS" VARCHAR(4000), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChangesTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddEventComponentChangesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstallTest/almAppInstalls.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstallTest/almAppInstalls.sql deleted file mode 100644 index a266dd515cc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddIsOwnerUserColumnInAlmAppInstallTest/almAppInstalls.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ALM_APP_INSTALLS" ( - "UUID" VARCHAR(40) NOT NULL, - "ALM_ID" VARCHAR(40) NOT NULL, - "OWNER_ID" VARCHAR(4000) NOT NULL, - "INSTALL_ID" VARCHAR(4000) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_ALM_APP_INSTALLS" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "ALM_APP_INSTALLS_OWNER" ON "ALM_APP_INSTALLS" ("ALM_ID", "OWNER_ID"); -CREATE UNIQUE INDEX "ALM_APP_INSTALLS_INSTALL" ON "ALM_APP_INSTALLS" ("ALM_ID", "INSTALL_ID"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstallTest/almAppInstalls.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstallTest/almAppInstalls.sql deleted file mode 100644 index d73225bde8c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/AddUserExternalIdColumnInAlmAppInstallTest/almAppInstalls.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "ALM_APP_INSTALLS" ( - "UUID" VARCHAR(40) NOT NULL, - "ALM_ID" VARCHAR(40) NOT NULL, - "OWNER_ID" VARCHAR(4000) NOT NULL, - "IS_OWNER_USER" BOOLEAN, - "INSTALL_ID" VARCHAR(4000) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_ALM_APP_INSTALLS" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "ALM_APP_INSTALLS_OWNER" ON "ALM_APP_INSTALLS" ("ALM_ID", "OWNER_ID"); -CREATE UNIQUE INDEX "ALM_APP_INSTALLS_INSTALL" ON "ALM_APP_INSTALLS" ("ALM_ID", "INSTALL_ID"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest/almAppInstalls.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest/almAppInstalls.sql deleted file mode 100644 index ac7b9bcbbc1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest/almAppInstalls.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ALM_APP_INSTALLS" ( - "UUID" VARCHAR(40) NOT NULL, - "ALM_ID" VARCHAR(40) NOT NULL, - "OWNER_ID" VARCHAR(4000) NOT NULL, - "IS_OWNER_USER" BOOLEAN, - "INSTALL_ID" VARCHAR(4000) NOT NULL, - "USER_EXTERNAL_ID" VARCHAR(255), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_ALM_APP_INSTALLS" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "ALM_APP_INSTALLS_OWNER" ON "ALM_APP_INSTALLS" ("ALM_ID", "OWNER_ID"); -CREATE UNIQUE INDEX "ALM_APP_INSTALLS_INSTALL" ON "ALM_APP_INSTALLS" ("ALM_ID", "INSTALL_ID"); -CREATE INDEX "ALM_APP_INSTALLS_EXTERNAL_ID" ON "ALM_APP_INSTALLS" ("USER_EXTERNAL_ID"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTableTest/user_properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTableTest/user_properties.sql deleted file mode 100644 index 11e714df797..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexInUserPropertiesTableTest/user_properties.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_PROPERTIES" ( - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "TEXT_VALUE" VARCHAR(4000) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_USER_PROPERTIES" PRIMARY KEY ("UUID") -); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTableTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTableTest/users.sql deleted file mode 100644 index 31365666f5a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/AddUniqueIndexOnExternalLoginInUsersTableTest/users.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "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_ID" VARCHAR(255) NOT NULL, - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS" ("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS" ("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasuresTest/project_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasuresTest/project_measures.sql deleted file mode 100644 index dc4e4390dd8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteModuleAndFolderMeasuresTest/project_measures.sql +++ /dev/null @@ -1,67 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_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" BINARY -); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSettingTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSettingTest/properties.sql deleted file mode 100644 index d84c238cd48..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteUselessOnboardingSettingTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -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/v76/DeleteUselessPropertyTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteUselessPropertyTest/properties.sql deleted file mode 100644 index d84c238cd48..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/DeleteUselessPropertyTest/properties.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -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/v76/FixDirectionOfMetricsTest/metrics.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetricsTest/metrics.sql deleted file mode 100644 index ced0a62e6d2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/FixDirectionOfMetricsTest/metrics.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "METRICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER NOT NULL DEFAULT 0, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, - "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/v76/MigrateModulePropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest/schema.sql deleted file mode 100644 index 1cbb2b7781e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "ROOT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10) -); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT, - "IS_EMPTY" BOOLEAN 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/v76/MigrateNoMoreUsedQualityGateConditionsTest/qg-schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditionsTest/qg-schema.sql deleted file mode 100644 index 6082612e609..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v76/MigrateNoMoreUsedQualityGateConditionsTest/qg-schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "METRICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER NOT NULL DEFAULT 0, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, - "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"); - -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "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"); - -CREATE TABLE "QUALITY_GATE_CONDITIONS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "PERIOD" INTEGER, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshotTest/snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshotTest/snapshots.sql deleted file mode 100644 index 30a335b114e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddBuildStringToSnapshotTest/snapshots.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "PROJECT_VERSION" VARCHAR(100), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokensTest/user_tokens.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokensTest/user_tokens.sql deleted file mode 100644 index b5a59aa6d3d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUserTokensTest/user_tokens.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "USER_TOKENS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS" ("TOKEN_HASH"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS" ("USER_UUID", "NAME"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsersTest/users.sql deleted file mode 100644 index 2c9eebd768e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddLastConnectionDateToUsersTest/users.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "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_ID" VARCHAR(255) NOT NULL, - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS" ("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -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 INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranchesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranchesTest/initial.sql deleted file mode 100644 index 2330dcfd9ab..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddManualBaselineToProjectBranchesTest/initial.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "KEY_TYPE" VARCHAR(12) NOT NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "PULL_REQUEST_BINARY" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_PROJECT_BRANCHES" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE_KEY_TYPE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE", "KEY_TYPE"); - -INSERT INTO "PROJECT_BRANCHES" VALUES ('foo', 'bar', 'kee', 'BRANCH', 'LONG', NULL, NULL, 0, 0); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBindingTest/org_alm_binding.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBindingTest/org_alm_binding.sql deleted file mode 100644 index 8b0128ce331..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddMembersSyncFlagToOrgAlmBindingTest/org_alm_binding.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ORGANIZATION_ALM_BINDINGS" ( - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "ALM_APP_INSTALL_UUID" VARCHAR(40) NOT NULL, - "ALM_ID" VARCHAR(40) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "USER_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - CONSTRAINT "PK_ORGANIZATION_ALM_BINDINGS" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "ORG_ALM_BINDINGS_ORG" ON "ORGANIZATION_ALM_BINDINGS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "ORG_ALM_BINDINGS_INSTALL" ON "ORGANIZATION_ALM_BINDINGS" ("ALM_APP_INSTALL_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundredTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundredTest/schema.sql deleted file mode 100644 index 65a4b55c97e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteFavoritesExceedingOneHundredTest/schema.sql +++ /dev/null @@ -1,59 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); - -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiersTest/schema.sql deleted file mode 100644 index 65a4b55c97e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteFavouritesOnNotSupportedComponentQualifiersTest/schema.sql +++ /dev/null @@ -1,59 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); - -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); - -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSourcesTest/file_sources.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSourcesTest/file_sources.sql deleted file mode 100644 index 9a93cbcee9d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DeleteTestDataTypeFromFileSourcesTest/file_sources.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "FILE_SOURCES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB, - "LINE_HASHES_VERSION" INTEGER, - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "DATA_TYPE" VARCHAR(20), - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSourcesTest/file_sources.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSourcesTest/file_sources.sql deleted file mode 100644 index 9a93cbcee9d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropDataTypeFromFileSourcesTest/file_sources.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "FILE_SOURCES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB, - "LINE_HASHES_VERSION" INTEGER, - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "DATA_TYPE" VARCHAR(20), - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT"); \ No newline at end of file diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueueTest/es_queue.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueueTest/es_queue.sql deleted file mode 100644 index d110642a3a5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/TruncateEsQueueTest/es_queue.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ES_QUEUE" ( - "UUID" VARCHAR(40) NOT NULL, - "DOC_TYPE" VARCHAR(40) NOT NULL, - "DOC_ID" VARCHAR(4000) NOT NULL, - "DOC_ID_TYPE" VARCHAR(20), - "DOC_ROUTING" VARCHAR(4000), - "CREATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_ES_QUEUE" PRIMARY KEY ("UUID") -); -CREATE INDEX "ES_QUEUE_CREATED_AT" ON "ES_QUEUE" ("CREATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuidTest/org_qprofiles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuidTest/org_qprofiles.sql deleted file mode 100644 index eeb2d5681c6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddIndexToOrgQProfileParentUuidTest/org_qprofiles.sql +++ /dev/null @@ -1,14 +0,0 @@ -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, - - CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY ("UUID") -); -CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); -CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevisionTest/snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevisionTest/snapshots.sql deleted file mode 100644 index 89b83ad1f76..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddSnapshotRevisionTest/snapshots.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "BUILD_STRING" VARCHAR(100), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecretTest/webhooks.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecretTest/webhooks.sql deleted file mode 100644 index f78c777760b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/AddWebhooksSecretTest/webhooks.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "WEBHOOKS" ( - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_WEBHOOKS" PRIMARY KEY ("UUID") -); -CREATE INDEX "ORGANIZATION_WEBHOOK" ON "WEBHOOKS" ("ORGANIZATION_UUID"); -CREATE INDEX "PROJECT_WEBHOOK" ON "WEBHOOKS" ("PROJECT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest/schema.sql deleted file mode 100644 index d84c238cd48..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotificationsTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -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/v78/MigrateRevisionTest/snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/MigrateRevisionTest/snapshots.sql deleted file mode 100644 index 993aeb14007..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/MigrateRevisionTest/snapshots.sql +++ /dev/null @@ -1,45 +0,0 @@ -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, - "CREATED_AT" BIGINT, - "BUILD_DATE" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "VERSION" VARCHAR(500), - "BUILD_STRING" VARCHAR(100), - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" BIGINT, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" BIGINT, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" BIGINT, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" BIGINT, - "REVISION" VARCHAR(100) -); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); - - -CREATE TABLE "ANALYSIS_PROPERTIES" ( - "UUID" character varying(40) PRIMARY KEY, - "SNAPSHOT_UUID" character varying(40) NOT NULL, - "KEE" character varying(512) NOT NULL, - "TEXT_VALUE" character varying(4000), - "CLOB_VALUE" text, - "IS_EMPTY" boolean NOT NULL, - "CREATED_AT" bigint NOT NULL -); - -CREATE UNIQUE INDEX "PK_ANALYSIS_PROPERTIES" ON "ANALYSIS_PROPERTIES"("UUID"); -CREATE INDEX "IX_SNAPSHOT_UUID" ON "ANALYSIS_PROPERTIES"("SNAPSHOT_UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranchesTest/project_and_project_branches.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranchesTest/project_and_project_branches.sql deleted file mode 100644 index d8f071e7ed5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/RemoveOrphansFromProjectBranchesTest/project_and_project_branches.sql +++ /dev/null @@ -1,62 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(1500) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "DEPRECATED_KEE" VARCHAR(400), - "PATH" VARCHAR(2000), - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), - "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT, - "B_CHANGED" BOOLEAN, - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_UUID_PATH" VARCHAR(1500), - "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "B_NAME" VARCHAR(500), - "B_PATH" VARCHAR(2000), - "B_QUALIFIER" VARCHAR(10) -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); - -CREATE TABLE "PROJECT_BRANCHES" ( - "UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "KEY_TYPE" VARCHAR(12) NOT NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "PULL_REQUEST_BINARY" BLOB, - "MANUAL_BASELINE_ANALYSIS_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_PROJECT_BRANCHES" PRIMARY KEY ("UUID") -); -CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE_KEY_TYPE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE", "KEY_TYPE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest/schema.sql deleted file mode 100644 index 4e190ab8446..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest/schema.sql +++ /dev/null @@ -1,81 +0,0 @@ -CREATE TABLE "ISSUES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(50) UNIQUE NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "EFFORT" INTEGER, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50) NULL, - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "TAGS" VARCHAR(4000), - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN NULL -); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES" ("UPDATED_AT"); - -CREATE TABLE "ISSUE_CHANGES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(40), - "CHANGE_DATA" VARCHAR(16777215), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES" ("KEE"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES" ("ISSUE_KEY"); - -CREATE TABLE "RULES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(16777215), - "DESCRIPTION_FORMAT" VARCHAR(20), - "PRIORITY" INTEGER, - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "IS_AD_HOC" BOOLEAN NOT NULL, - "TEMPLATE_ID" INTEGER, - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "NAME" VARCHAR(200), - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "SCOPE" VARCHAR(20) NOT NULL, - "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), - "SECURITY_STANDARDS" VARCHAR(4000), - "RULE_TYPE" TINYINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchemaTest/empty.sql similarity index 100% rename from server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest/empty.sql rename to server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/CreateInitialSchemaTest/empty.sql diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOpsTest/properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOpsTest/properties.sql deleted file mode 100644 index a81f731fd80..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/MigrateVstsProviderToAzureDevOpsTest/properties.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" INTEGER, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -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/v79/PopulateInitialSchemaTest/v79.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchemaTest/v79.sql new file mode 100644 index 00000000000..26147e6f907 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/PopulateInitialSchemaTest/v79.sql @@ -0,0 +1,968 @@ +CREATE TABLE "ORGANIZATIONS" ( + "UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(300) NOT NULL, + "NAME" VARCHAR(300) NOT NULL, + "DESCRIPTION" VARCHAR(256), + "URL" VARCHAR(256), + "AVATAR_URL" VARCHAR(256), + "GUARDED" BOOLEAN NOT NULL, + "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), + "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), + "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), + "DEFAULT_GROUP_ID" INTEGER, + "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, + "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, + "SUBSCRIPTION" VARCHAR(40) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); + +CREATE TABLE "ORGANIZATION_MEMBERS" ( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + + CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY ("ORGANIZATION_UUID", "USER_ID") +); +CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS" ("USER_ID"); + +CREATE TABLE "GROUPS_USERS" ( + "USER_ID" INTEGER, + "GROUP_ID" INTEGER +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); + + +CREATE TABLE "RULES_PARAMETERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000), + "DESCRIPTION" 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"); + + +CREATE TABLE "RULES_PROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "IS_BUILT_IN" BOOLEAN NOT NULL +); +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, + + CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY ("UUID") +); +CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); +CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); +CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES" ("PARENT_UUID"); + + +CREATE TABLE "DEFAULT_QPROFILES" ( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "LANGUAGE" VARCHAR(20) NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_DEFAULT_QPROFILES" PRIMARY KEY ("ORGANIZATION_UUID", "LANGUAGE") +); +CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES" ("QPROFILE_UUID"); + + +CREATE TABLE "PROJECT_QPROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "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"); + + +CREATE TABLE "QPROFILE_EDIT_USERS" ( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT, + + 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"); + + +CREATE TABLE "QPROFILE_EDIT_GROUPS" ( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT, + + 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"); + + +CREATE TABLE "GROUPS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + + +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(50) NOT NULL, + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "VERSION" VARCHAR(500), + "BUILD_STRING" VARCHAR(100), + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT, + "REVISION" VARCHAR(100) +); +CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); +CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); + +CREATE TABLE "GROUP_ROLES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "RESOURCE_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL +); +CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); + + +CREATE TABLE "RULE_REPOSITORIES" ( + "KEE" VARCHAR(200) NOT NULL, + "LANGUAGE" VARCHAR(20) NOT NULL, + "NAME" VARCHAR(4000) NOT NULL, + "CREATED_AT" BIGINT, + + CONSTRAINT "PK_RULE_REPOSITORIES" PRIMARY KEY ("KEE") +); + +CREATE TABLE "DEPRECATED_RULE_KEYS" ( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "OLD_REPOSITORY_KEY" VARCHAR(200) NOT NULL, + "OLD_RULE_KEY" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT, + + 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"); + +CREATE TABLE "RULES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "DESCRIPTION" VARCHAR(16777215), + "DESCRIPTION_FORMAT" VARCHAR(20), + "PRIORITY" INTEGER, + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "IS_AD_HOC" BOOLEAN NOT NULL, + "TEMPLATE_ID" INTEGER, + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "NAME" VARCHAR(200), + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "SCOPE" VARCHAR(20) NOT NULL, + "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), + "SECURITY_STANDARDS" VARCHAR(4000), + "RULE_TYPE" TINYINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); + +CREATE TABLE "RULES_METADATA" ( + "RULE_ID" INTEGER NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NOTE_DATA" CLOB, + "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" VARCHAR(16777215), + "AD_HOC_SEVERITY" VARCHAR(10), + "AD_HOC_TYPE" TINYINT, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY ("RULE_ID", "ORGANIZATION_UUID") +); + +CREATE TABLE "EVENTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(400), + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "CATEGORY" VARCHAR(50), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000) +); +CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID"); +CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID"); +CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID"); + +CREATE TABLE "EVENT_COMPONENT_CHANGES" ( + "UUID" VARCHAR(40) NOT NULL, + "EVENT_UUID" VARCHAR(40) NOT NULL, + "EVENT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "EVENT_ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "CHANGE_CATEGORY" VARCHAR(20) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_KEY" VARCHAR(400) NOT NULL, + "COMPONENT_NAME" VARCHAR(2000) NOT NULL, + "COMPONENT_BRANCH_KEY" VARCHAR(255), + "CREATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_EVENT_COMPONENT_CHANGES" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "EVENT_COMPONENT_CHANGES_UNIQUE" ON "EVENT_COMPONENT_CHANGES" ("EVENT_UUID", "CHANGE_CATEGORY", "COMPONENT_UUID"); +CREATE INDEX "EVENT_CPNT_CHANGES_CPNT" ON "EVENT_COMPONENT_CHANGES" ("EVENT_COMPONENT_UUID"); +CREATE INDEX "EVENT_CPNT_CHANGES_ANALYSIS" ON "EVENT_COMPONENT_CHANGES" ("EVENT_ANALYSIS_UUID"); + + +CREATE TABLE "QUALITY_GATES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "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"); + + +CREATE TABLE "QUALITY_GATE_CONDITIONS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "PERIOD" INTEGER, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, +); + +CREATE TABLE "ORG_QUALITY_GATES" ( + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, + + CONSTRAINT "PK_ORG_QUALITY_GATES" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "UNIQ_ORG_QUALITY_GATES" ON "ORG_QUALITY_GATES" ("ORGANIZATION_UUID","QUALITY_GATE_UUID"); + +CREATE TABLE "PROPERTIES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" INTEGER, + "USER_ID" INTEGER, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB, + "CREATED_AT" BIGINT +); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); + + +CREATE TABLE "PROJECT_LINKS" ( + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "LINK_TYPE" VARCHAR(20) NOT NULL, + "NAME" VARCHAR(128), + "HREF" VARCHAR(2048) NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + + CONSTRAINT "PK_PROJECT_LINKS" PRIMARY KEY ("UUID") +); +CREATE INDEX "PROJECT_LINKS_PROJECT" ON "PROJECT_LINKS" ("PROJECT_UUID"); + + +CREATE TABLE "DUPLICATIONS_INDEX" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 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 +); +CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX" ("HASH"); +CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX" ("ANALYSIS_UUID", "COMPONENT_UUID"); + + +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" BINARY, + "UPDATE_MARKER" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + 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 "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "ANALYSIS_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" BINARY +); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES" ("ANALYSIS_UUID", "METRIC_ID"); + + +CREATE TABLE "INTERNAL_PROPERTIES" ( + "KEE" VARCHAR(20) NOT NULL, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB, + "CREATED_AT" BIGINT, + + CONSTRAINT "PK_INTERNAL_PROPERTIES" PRIMARY KEY ("KEE") +); + + +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(400), + "UUID" VARCHAR(50) NOT NULL, + "UUID_PATH" VARCHAR(1500) NOT NULL, + "ROOT_UUID" VARCHAR(50) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(1500), + "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "PRIVATE" BOOLEAN NOT NULL, + "TAGS" VARCHAR(500), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_COMPONENT_UUID" VARCHAR(50), + "LONG_NAME" VARCHAR(2000), + "DEVELOPER_UUID" VARCHAR(50), + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT, + "B_CHANGED" BOOLEAN, + "B_COPY_COMPONENT_UUID" VARCHAR(50), + "B_DESCRIPTION" VARCHAR(2000), + "B_ENABLED" BOOLEAN, + "B_UUID_PATH" VARCHAR(1500), + "B_LANGUAGE" VARCHAR(20), + "B_LONG_NAME" VARCHAR(500), + "B_MODULE_UUID" VARCHAR(50), + "B_MODULE_UUID_PATH" VARCHAR(1500), + "B_NAME" VARCHAR(500), + "B_PATH" VARCHAR(2000), + "B_QUALIFIER" VARCHAR(10) +); +CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID"); +CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); +CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); +CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); +CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); +CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); +CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); + +CREATE TABLE "INTERNAL_COMPONENT_PROPS" ( + "UUID" VARCHAR(40) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "KEE" VARCHAR(512) NOT NULL, + "VALUE" VARCHAR(4000), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + CONSTRAINT "INTERNAL_COMPONENT_PROPS_UUID" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "UNIQUE_COMPONENT_UUID_KEE" ON "INTERNAL_COMPONENT_PROPS" ("COMPONENT_UUID", "KEE"); + +CREATE TABLE "MANUAL_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES" ("COMPONENT_UUID"); + + +CREATE TABLE "ACTIVE_RULES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 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 +); +CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ID"); + + +CREATE TABLE "NOTIFICATIONS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "DATA" BLOB +); + + +CREATE TABLE "USER_ROLES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "RESOURCE_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL +); +CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); + + +CREATE TABLE "ACTIVE_RULE_PARAMETERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "RULES_PARAMETER_KEY" VARCHAR(128), + "VALUE" VARCHAR(4000) +); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS" ("ACTIVE_RULE_ID"); + + +CREATE TABLE "USERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "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_ID" VARCHAR(255) NOT NULL, + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS" ("UUID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); +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 INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); + + +CREATE TABLE "METRICS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER NOT NULL DEFAULT 0, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, + "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"); + + +CREATE TABLE "ISSUES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(50) UNIQUE NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "EFFORT" INTEGER, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50) NULL, + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "TAGS" VARCHAR(4000), + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN NULL +); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); +CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES" ("UPDATED_AT"); + + +CREATE TABLE "ISSUE_CHANGES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(50), + "ISSUE_KEY" VARCHAR(50) NOT NULL, + "USER_LOGIN" VARCHAR(255), + "CHANGE_TYPE" VARCHAR(40), + "CHANGE_DATA" VARCHAR(16777215), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CHANGE_CREATION_DATE" BIGINT +); +CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES" ("KEE"); +CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES" ("ISSUE_KEY"); + + +CREATE TABLE "PERMISSION_TEMPLATES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "KEY_PATTERN" VARCHAR(500), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + + +CREATE TABLE "PERM_TPL_CHARACTERISTICS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN NOT NULL DEFAULT FALSE, + "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"); + + +CREATE TABLE "PERM_TEMPLATES_USERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + + +CREATE TABLE "PERM_TEMPLATES_GROUPS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + + +CREATE TABLE "QPROFILE_CHANGES" ( + "KEE" VARCHAR(40) NOT NULL, + "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, + "CHANGE_TYPE" VARCHAR(20) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "USER_UUID" VARCHAR(255), + "CHANGE_DATA" CLOB, + + CONSTRAINT "PK_QPROFILE_CHANGES" PRIMARY KEY ("KEE") +); +CREATE INDEX "QP_CHANGES_RULES_PROFILE_UUID" ON "QPROFILE_CHANGES" ("RULES_PROFILE_UUID"); + + +CREATE TABLE "FILE_SOURCES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "LINE_HASHES" CLOB, + "LINE_HASHES_VERSION" INTEGER, + "LINE_COUNT" INTEGER NOT NULL, + "BINARY_DATA" BLOB, + "DATA_HASH" VARCHAR(50), + "SRC_HASH" VARCHAR(50), + "REVISION" VARCHAR(100), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); +CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES" ("FILE_UUID"); +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT"); + + +CREATE TABLE "CE_QUEUE" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40) NULL, + "STATUS" VARCHAR(15) NOT NULL, + "SUBMITTER_UUID" VARCHAR(255) NULL, + "WORKER_UUID" VARCHAR(40) NULL, + "EXECUTION_COUNT" INTEGER NOT NULL, + "STARTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); +CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE" ("COMPONENT_UUID"); +CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE" ("MAIN_COMPONENT_UUID"); +CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); + + +CREATE TABLE "CE_ACTIVITY" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40) NULL, + "ANALYSIS_UUID" VARCHAR(50) NULL, + "STATUS" VARCHAR(15) NOT NULL, + "IS_LAST" BOOLEAN, + "IS_LAST_KEY" VARCHAR(55), + "MAIN_IS_LAST" BOOLEAN, + "MAIN_IS_LAST_KEY" VARCHAR(55), + "SUBMITTER_UUID" VARCHAR(255) NULL, + "WORKER_UUID" VARCHAR(40) NULL, + "EXECUTION_COUNT" INTEGER NOT NULL, + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT NULL, + "EXECUTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "EXECUTION_TIME_MS" BIGINT NULL, + "ERROR_MESSAGE" VARCHAR(1000), + "ERROR_STACKTRACE" CLOB, + "ERROR_TYPE" VARCHAR(20) +); +CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); +CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY" ("COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY" ("COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); +CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); +CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY" ("MAIN_IS_LAST_KEY"); +CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY" ("MAIN_IS_LAST", "STATUS"); + + +CREATE TABLE "CE_TASK_CHARACTERISTICS" ( + "UUID" VARCHAR(40) NOT NULL, + "TASK_UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + + CONSTRAINT "PK_CE_TASK_CHARACTERISTICS" PRIMARY KEY ("UUID") +); +CREATE INDEX "CE_TASK_CHARACTERISTICS_TASK_UUID" ON "CE_TASK_CHARACTERISTICS" ("TASK_UUID"); + + +CREATE TABLE "CE_TASK_INPUT" ( + "TASK_UUID" VARCHAR(40) NOT NULL, + "INPUT_DATA" BLOB, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_CE_TASK_INPUT" PRIMARY KEY ("TASK_UUID") +); + + +CREATE TABLE "CE_SCANNER_CONTEXT" ( + "TASK_UUID" VARCHAR(40) NOT NULL, + "CONTEXT_DATA" BLOB NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_CE_SCANNER_CONTEXT" PRIMARY KEY ("TASK_UUID") +); + +CREATE TABLE "CE_TASK_MESSAGE" ( + "UUID" VARCHAR(40) NOT NULL, + "TASK_UUID" VARCHAR(40) NOT NULL, + "MESSAGE" VARCHAR(4000) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + + CONSTRAINT "CE_TASK_MESSAGE" PRIMARY KEY ("UUID") +); +CREATE INDEX "CE_TASK_MESSAGE_TASK" ON "CE_TASK_MESSAGE" ("TASK_UUID"); + + +CREATE TABLE "USER_TOKENS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 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 +); +CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS" ("TOKEN_HASH"); +CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS" ("USER_UUID", "NAME"); + + +CREATE TABLE "ES_QUEUE" ( + "UUID" VARCHAR(40) NOT NULL, + "DOC_TYPE" VARCHAR(40) NOT NULL, + "DOC_ID" VARCHAR(4000) NOT NULL, + "DOC_ID_TYPE" VARCHAR(20), + "DOC_ROUTING" VARCHAR(4000), + "CREATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_ES_QUEUE" PRIMARY KEY ("UUID") +); +CREATE INDEX "ES_QUEUE_CREATED_AT" ON "ES_QUEUE" ("CREATED_AT"); + + +CREATE TABLE "PLUGINS" ( + "UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(200) NOT NULL, + "BASE_PLUGIN_KEY" VARCHAR(200), + "FILE_HASH" VARCHAR(200) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_PLUGINS" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "PLUGINS_KEY" ON "PLUGINS" ("KEE"); + + +CREATE TABLE "PROJECT_BRANCHES" ( + "UUID" VARCHAR(50) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "KEE" VARCHAR(255) NOT NULL, + "KEY_TYPE" VARCHAR(12) NOT NULL, + "BRANCH_TYPE" VARCHAR(12), + "MERGE_BRANCH_UUID" VARCHAR(50), + "PULL_REQUEST_BINARY" BLOB, + "MANUAL_BASELINE_ANALYSIS_UUID" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_PROJECT_BRANCHES" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE_KEY_TYPE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE", "KEY_TYPE"); + + +CREATE TABLE "ANALYSIS_PROPERTIES" ( + "UUID" VARCHAR(40) NOT NULL, + "SNAPSHOT_UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(512) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB, + "IS_EMPTY" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_ANALYSIS_PROPERTIES" PRIMARY KEY ("UUID") +); +CREATE INDEX "SNAPSHOT_UUID" ON "ANALYSIS_PROPERTIES" ("SNAPSHOT_UUID"); + + +CREATE TABLE "WEBHOOKS" ( + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "URL" VARCHAR(2000) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "PROJECT_UUID" VARCHAR(40), + "SECRET" VARCHAR(200), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_WEBHOOKS" PRIMARY KEY ("UUID") +); +CREATE INDEX "ORGANIZATION_WEBHOOK" ON "WEBHOOKS" ("ORGANIZATION_UUID"); +CREATE INDEX "PROJECT_WEBHOOK" ON "WEBHOOKS" ("PROJECT_UUID"); + + +CREATE TABLE "WEBHOOK_DELIVERIES" ( + "UUID" VARCHAR(40) NOT NULL, + "WEBHOOK_UUID" VARCHAR(40) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NOT NULL, + "ANALYSIS_UUID" VARCHAR(40), + "CE_TASK_UUID" VARCHAR(40), + "NAME" VARCHAR(100) NOT NULL, + "URL" VARCHAR(2000) NOT NULL, + "SUCCESS" BOOLEAN NOT NULL, + "HTTP_STATUS" INT, + "DURATION_MS" INT NOT NULL, + "PAYLOAD" CLOB NOT NULL, + "ERROR_STACKTRACE" CLOB, + "CREATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY ("UUID") +); +CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); +CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); +CREATE INDEX "ANALYSIS_UUID" ON "WEBHOOK_DELIVERIES" ("ANALYSIS_UUID"); + + +CREATE TABLE "ALM_APP_INSTALLS" ( + "UUID" VARCHAR(40) NOT NULL, + "ALM_ID" VARCHAR(40) NOT NULL, + "OWNER_ID" VARCHAR(4000) NOT NULL, + "IS_OWNER_USER" BOOLEAN NOT NULL, + "INSTALL_ID" VARCHAR(4000) NOT NULL, + "USER_EXTERNAL_ID" VARCHAR(255), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_ALM_APP_INSTALLS" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "ALM_APP_INSTALLS_OWNER" ON "ALM_APP_INSTALLS" ("ALM_ID", "OWNER_ID"); +CREATE UNIQUE INDEX "ALM_APP_INSTALLS_INSTALL" ON "ALM_APP_INSTALLS" ("ALM_ID", "INSTALL_ID"); +CREATE INDEX "ALM_APP_INSTALLS_EXTERNAL_ID" ON "ALM_APP_INSTALLS" ("USER_EXTERNAL_ID"); + +CREATE TABLE "PROJECT_ALM_BINDINGS" ( + "UUID" VARCHAR(40) NOT NULL, + "ALM_ID" VARCHAR(40) NOT NULL, + "REPO_ID" VARCHAR(256) NOT NULL, + "PROJECT_UUID" VARCHAR(40) NOT NULL, + "GITHUB_SLUG" VARCHAR(256) NULL, + "URL" VARCHAR(2000) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + CONSTRAINT "PK_PROJECT_ALM_BINDINGS" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "PROJECT_ALM_BINDINGS_ALM_REPO" ON "PROJECT_ALM_BINDINGS" ("ALM_ID", "REPO_ID"); +CREATE UNIQUE INDEX "PROJECT_ALM_BINDINGS_PROJECT" ON "PROJECT_ALM_BINDINGS" ("PROJECT_UUID"); + +CREATE TABLE "PROJECT_MAPPINGS" ( + "UUID" VARCHAR(40) NOT NULL, + "KEY_TYPE" VARCHAR(200) NOT NULL, + "KEE" VARCHAR(4000) NOT NULL, + "PROJECT_UUID" VARCHAR(40) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + CONSTRAINT "PK_PROJECT_MAPPINGS" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "KEY_TYPE_KEE" ON "PROJECT_MAPPINGS" ("KEY_TYPE", "KEE"); +CREATE INDEX "PROJECT_UUID" ON "PROJECT_MAPPINGS" ("PROJECT_UUID"); + +CREATE TABLE "ORGANIZATION_ALM_BINDINGS" ( + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "ALM_APP_INSTALL_UUID" VARCHAR(40) NOT NULL, + "ALM_ID" VARCHAR(40) NOT NULL, + "URL" VARCHAR(2000) NOT NULL, + "USER_UUID" VARCHAR(255) NOT NULL, + "MEMBERS_SYNC_ENABLED" BOOLEAN, + "CREATED_AT" BIGINT NOT NULL, + CONSTRAINT "PK_ORGANIZATION_ALM_BINDINGS" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "ORG_ALM_BINDINGS_ORG" ON "ORGANIZATION_ALM_BINDINGS" ("ORGANIZATION_UUID"); +CREATE UNIQUE INDEX "ORG_ALM_BINDINGS_INSTALL" ON "ORGANIZATION_ALM_BINDINGS" ("ALM_APP_INSTALL_UUID"); + +CREATE TABLE "USER_PROPERTIES" ( + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(255) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "TEXT_VALUE" VARCHAR(4000) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_USER_PROPERTIES" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "USER_PROPERTIES_USER_UUID_KEE" ON "USER_PROPERTIES" ("USER_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersionTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersionTest/schema.sql deleted file mode 100644 index 67390214cd8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/PopulateInstallDateAndVersionTest/schema.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(20) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT, - - CONSTRAINT "PK_INTERNAL_PROPERTIES" PRIMARY KEY ("KEE") -); - -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "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_ID" VARCHAR(255) NOT NULL, - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS" ("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -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 INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRatingTest/quality_gate_conditions.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRatingTest/quality_gate_conditions.sql deleted file mode 100644 index 163b1e77172..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/RemoveQGConditionsOnSecurityReviewRatingTest/quality_gate_conditions.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "PERIOD" INTEGER, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); - -CREATE TABLE "METRICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER NOT NULL DEFAULT 0, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, - "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/v79/TruncateEnvAndSystemVarsFromScannerContextTest/ce_scanner_context.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContextTest/ce_scanner_context.sql deleted file mode 100644 index 1a7591ac05c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v79/TruncateEnvAndSystemVarsFromScannerContextTest/ce_scanner_context.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "CE_SCANNER_CONTEXT" ( - "TASK_UUID" VARCHAR(40) NOT NULL, - "CONTEXT_DATA" BLOB NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_CE_SCANNER_CONTEXT" PRIMARY KEY ("TASK_UUID") -); -- 2.39.5