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 29853fbbb5ebe7e344e738cf11addc936b6851f8..d2d6988d15ca9bed78e4831e36a09a7746504cf3 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 @@ -27,17 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; 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.v00.DbVersion00; -import org.sonar.server.platform.db.migration.version.v80.DbVersion80; -import org.sonar.server.platform.db.migration.version.v81.DbVersion81; -import org.sonar.server.platform.db.migration.version.v82.DbVersion82; -import org.sonar.server.platform.db.migration.version.v83.DbVersion83; -import org.sonar.server.platform.db.migration.version.v84.DbVersion84; -import org.sonar.server.platform.db.migration.version.v85.DbVersion85; -import org.sonar.server.platform.db.migration.version.v86.DbVersion86; -import org.sonar.server.platform.db.migration.version.v87.DbVersion87; -import org.sonar.server.platform.db.migration.version.v88.DbVersion88; -import org.sonar.server.platform.db.migration.version.v89.DbVersion89; -import org.sonar.server.platform.db.migration.version.v89.util.NetworkInterfaceProvider; public class MigrationConfigurationModule extends Module { @Override @@ -45,16 +34,6 @@ public class MigrationConfigurationModule extends Module { add( // DbVersion implementations DbVersion00.class, - DbVersion80.class, - DbVersion81.class, - DbVersion82.class, - DbVersion83.class, - DbVersion84.class, - DbVersion85.class, - DbVersion86.class, - DbVersion87.class, - DbVersion88.class, - DbVersion89.class, // migration steps MigrationStepRegistryImpl.class, @@ -66,7 +45,6 @@ public class MigrationConfigurationModule extends Module { // Utility classes DbPrimaryKeyConstraintFinder.class, - DropPrimaryKeySqlGenerator.class, - NetworkInterfaceProvider.class); + DropPrimaryKeySqlGenerator.class); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/CreateNewCodePeriodTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/CreateNewCodePeriodTable.java deleted file mode 100644 index 563378f25759b9d9a2764a5ed82ac1aec66d0c1e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/CreateNewCodePeriodTable.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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.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 CreateNewCodePeriodTable extends DdlChange { - - private static final String TABLE_NAME = "new_code_periods"; - - private static final VarcharColumnDef UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - - private static final VarcharColumnDef PROJECT_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef BRANCH_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("branch_uuid") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build(); - - /** - * Available values: - * * PREVIOUS_VERSION - * * NUMBER_OF_DAYS - * * DATE - * * SPECIFIC_ANALYSIS - */ - private static final VarcharColumnDef TYPE = newVarcharColumnDefBuilder() - .setColumnName("type") - .setIsNullable(false) - .setLimit(30) - .build(); - - private static final VarcharColumnDef VALUE = newVarcharColumnDefBuilder() - .setColumnName("value") - .setIsNullable(true) - .setLimit(40) - .build(); - - private static final BigIntegerColumnDef UPDATED_AT = newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build(); - - private static final BigIntegerColumnDef CREATED_AT = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - public CreateNewCodePeriodTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID_COLUMN) - .addColumn(PROJECT_UUID_COLUMN) - .addColumn(BRANCH_UUID_COLUMN) - .addColumn(TYPE) - .addColumn(VALUE) - .addColumn(UPDATED_AT) - .addColumn(CREATED_AT) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("uniq_new_code_periods") - .setUnique(true) - .addColumn(PROJECT_UUID_COLUMN) - .addColumn(BRANCH_UUID_COLUMN) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/CreateProjectQualityGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/CreateProjectQualityGatesTable.java deleted file mode 100644 index fc35c06625d1411937a24858a1bb067e4a6f896e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/CreateProjectQualityGatesTable.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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.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; - -@SupportsBlueGreen -public class CreateProjectQualityGatesTable extends DdlChange { - - private static final String TABLE_NAME = "project_qgates"; - - private static final VarcharColumnDef PROJECT_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef QUALITY_GATE_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("quality_gate_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - - public CreateProjectQualityGatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(PROJECT_UUID_COLUMN) - .addColumn(QUALITY_GATE_UUID_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("uniq_project_qgates") - .setUnique(true) - .addColumn(PROJECT_UUID_COLUMN) - .addColumn(QUALITY_GATE_UUID_COLUMN) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/DbVersion80.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/DbVersion80.java deleted file mode 100644 index 80ffa0eabd247d77193d4a9597c60fc6723e1dbf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/DbVersion80.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion80 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(3000, "Set Organizations#guarded column nullable", MakeOrganizationsGuardedNullable.class) - .add(3001, "Create ProjectQualityGates table", CreateProjectQualityGatesTable.class) - .add(3002, "Make index on DEPRECATED_RULE_KEYS.RULE_ID non unique", MakeDeprecatedRuleKeysRuleIdIndexNonUnique.class) - .add(3003, "Populate ProjectQualityGate table from Properties table", PopulateProjectQualityGatesTable.class) - .add(3004, "Rename ANALYSIS_PROPERTIES.SNAPSHOT_UUID to ANALYSIS_UUID", RenameAnalysisPropertiesSnapshotUuid.class) - .add(3005, "Remove default quality gate property from Properties table", RemoveDefaultQualityGateFromPropertiesTable.class) - .add(3006, "Create NEW_CODE_PERIOD table", CreateNewCodePeriodTable.class) - .add(3007, "Populate NEW_CODE_PERIOD table", PopulateNewCodePeriodTable.class) - .add(3008, "Remove leak period properties", RemoveLeakPeriodProperties.class) - .add(3009, "Remove GitHub login generation strategy property", RemoveGitHubLoginGenerationStrategyProperty.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUnique.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUnique.java deleted file mode 100644 index 6b317ed906c8fe2861f0a8bd38132c1fab22d980..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUnique.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class MakeDeprecatedRuleKeysRuleIdIndexNonUnique extends DdlChange { - private static final String TABLE_NAME = "deprecated_rule_keys"; - private static final IntegerColumnDef RULE_ID_COLUMN = IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("rule_id") - .setIsNullable(false) - .build(); - - public MakeDeprecatedRuleKeysRuleIdIndexNonUnique(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("rule_id_deprecated_rule_keys") - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("rule_id_deprecated_rule_keys") - .setUnique(false) - .addColumn(RULE_ID_COLUMN) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullable.java deleted file mode 100644 index 209e623bcd3060bdcb659eee72d2679d948a8c42..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullable.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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 MakeOrganizationsGuardedNullable extends DdlChange { - - public MakeOrganizationsGuardedNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "organizations") - .updateColumn(newBooleanColumnDefBuilder() - .setColumnName("guarded") - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTable.java deleted file mode 100644 index 37e3c5a42d7197e089b08a0d1d82b47bb574c233..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTable.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import java.time.LocalDate; -import java.time.ZoneId; -import java.time.format.DateTimeParseException; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -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.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 PopulateNewCodePeriodTable extends DataChange { - private static final Logger LOG = Loggers.get(PopulateNewCodePeriodTable.class); - - private static final String TYPE_PREVIOUS_VERSION = "PREVIOUS_VERSION"; - private static final String TYPE_NUMBER_OF_DAYS = "NUMBER_OF_DAYS"; - private static final String TYPE_SPECIFIC_ANALYSIS = "SPECIFIC_ANALYSIS"; - - private static final String LEAK_PERIOD_PROP_KEY = "sonar.leak.period"; - - private final UuidFactory uuidFactory; - private final System2 system2; - - public PopulateNewCodePeriodTable(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - List branchUuidsAlreadyMigrated = populateFromManualBaselines(context); - populateFromSettings(context, branchUuidsAlreadyMigrated); - } - - private List populateFromManualBaselines(Context context) throws SQLException { - List projectBranchManualBaselines = context.prepareSelect( - "SELECT pb.uuid, pb.project_uuid, pb.manual_baseline_analysis_uuid FROM project_branches pb WHERE pb.manual_baseline_analysis_uuid IS NOT NULL") - .list(row -> { - String branchUuid = row.getString(1); - String projectUuid = row.getString(2); - String manualBaselineAnalysisUuid = row.getString(3); - return new ProjectBranchManualBaselineDto(branchUuid, projectUuid, manualBaselineAnalysisUuid); - }); - - if (!projectBranchManualBaselines.isEmpty()) { - populateWithManualBaselines(context, projectBranchManualBaselines); - } - - return projectBranchManualBaselines.stream() - .map(pb -> pb.branchUuid) - .collect(Collectors.toList()); - } - - private void populateFromSettings(Context context, List branchUuidsAlreadyMigrated) throws SQLException { - // migrate global setting - String globalSetting = context - .prepareSelect("SELECT props.text_value FROM properties props WHERE props.prop_key = '" + LEAK_PERIOD_PROP_KEY + "' AND props.resource_id IS NULL") - .get(r -> r.getString(1)); - if (globalSetting != null) { - populateGlobalSetting(context, globalSetting); - } - - List projectLeakPeriodProperties = new ArrayList<>(); - context.prepareSelect( - "SELECT projs.uuid, projs.main_branch_project_uuid, props.text_value " - + "FROM properties props INNER JOIN projects projs ON props.resource_id = projs.id " - + "WHERE props.prop_key = '" + LEAK_PERIOD_PROP_KEY + "' AND props.resource_id IS NOT NULL ") - .scroll(row -> { - String branchUuid = row.getString(1); - if (branchUuidsAlreadyMigrated.contains(branchUuid)) { - return; - } - String mainBranchUuid = row.getString(2); - String value = row.getString(3); - if (mainBranchUuid == null) { - mainBranchUuid = branchUuid; - } - projectLeakPeriodProperties.add(new BranchLeakPeriodPropertyDto(branchUuid, mainBranchUuid, value)); - }); - - populateWithSettings(context, projectLeakPeriodProperties); - } - - private void populateGlobalSetting(Context context, String value) { - Optional typeValue = tryParse(context, null, value); - typeValue.ifPresent(tp -> { - try (Upsert upsertQuery = prepareUpsertNewCodePeriodQuery(context)) { - long currentTime = system2.now(); - insert(upsertQuery, null, null, tp.type, tp.value, currentTime); - upsertQuery - .execute() - .commit(); - } catch (SQLException e) { - LOG.warn("Failed to migrate the global property for the new code period", e); - } - }); - } - - private void populateWithSettings(Context context, List projectLeakPeriodProperties) throws SQLException { - try (Upsert upsertQuery = prepareUpsertNewCodePeriodQuery(context)) { - long currentTime = system2.now(); - boolean commit = false; - - for (BranchLeakPeriodPropertyDto branchLeakPeriodProperty : projectLeakPeriodProperties) { - Optional typeValueOpt = tryParse(context, branchLeakPeriodProperty.branchUuid, branchLeakPeriodProperty.value); - if (!typeValueOpt.isPresent()) { - continue; - } - - TypeValuePair typeValue = typeValueOpt.get(); - - String branchUuid = null; - if (!branchLeakPeriodProperty.isMainBranch() || TYPE_SPECIFIC_ANALYSIS.equals(typeValue.type)) { - branchUuid = branchLeakPeriodProperty.branchUuid; - } - - insert(upsertQuery, branchLeakPeriodProperty.mainBranchUuid, branchUuid, typeValue.type, typeValue.value, currentTime); - commit = true; - } - - if (commit) { - upsertQuery - .execute() - .commit(); - } - } - } - - private void populateWithManualBaselines(Context context, List projectBranchManualBaselines) throws SQLException { - try (Upsert upsertQuery = prepareUpsertNewCodePeriodQuery(context)) { - long currentTime = system2.now(); - - for (ProjectBranchManualBaselineDto projectBranchManualBaseline : projectBranchManualBaselines) { - insert(upsertQuery, projectBranchManualBaseline.projectUuid, projectBranchManualBaseline.branchUuid, TYPE_SPECIFIC_ANALYSIS, - projectBranchManualBaseline.manualBaselineAnalysisUuid, currentTime); - } - upsertQuery - .execute() - .commit(); - } - } - - private void insert(Upsert upsert, @Nullable String projectUuid, @Nullable String branchUuid, String type, @Nullable String value, long currentTime) throws SQLException { - upsert - .setString(1, uuidFactory.create()) - .setString(2, projectUuid) - .setString(3, branchUuid) - .setString(4, type) - .setString(5, value) - .setLong(6, currentTime) - .setLong(7, currentTime) - .addBatch(); - } - - private static Upsert prepareUpsertNewCodePeriodQuery(Context context) throws SQLException { - return context.prepareUpsert("INSERT INTO new_code_periods(" + - "uuid, " + - "project_uuid," + - "branch_uuid," + - "type," + - "value," + - "updated_at," + - "created_at" + - ") VALUES (?, ?, ?, ?, ?, ?, ?)"); - } - - private static Optional tryParse(Context context, @Nullable String branchUuid, String value) { - try { - if (value.equals("previous_version")) { - return Optional.of(new TypeValuePair(TYPE_PREVIOUS_VERSION, null)); - } - - try { - Integer.parseInt(value); - return Optional.of(new TypeValuePair(TYPE_NUMBER_OF_DAYS, value)); - } catch (NumberFormatException e) { - // ignore - } - - if (branchUuid == null) { - return Optional.empty(); - } - - try { - LocalDate localDate = LocalDate.parse(value); - Optional snapshot = findFirstSnapshot(context, branchUuid, localDate.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli()); - return snapshot.map(uuid -> new TypeValuePair(TYPE_SPECIFIC_ANALYSIS, uuid)); - } catch (DateTimeParseException e) { - // ignore - } - - List versions = getVersionsByMostRecentFirst(context, branchUuid); - Optional versionMatch = versions.stream().filter(v -> v.version.equals(value)).findFirst(); - return versionMatch.map(e -> new TypeValuePair(TYPE_SPECIFIC_ANALYSIS, e.analysisUuid)); - } catch (SQLException e) { - LOG.warn("Failed to migrate a property for the new code period", e); - return Optional.empty(); - } - } - - private static List getVersionsByMostRecentFirst(Context context, String branchUuid) throws SQLException { - return context.prepareSelect("SELECT name, analysis_uuid FROM events " - + "WHERE component_uuid = '" + branchUuid + "' AND category = 'Version' " - + "ORDER BY created_at DESC") - .list(r -> new EventDto(r.getString(1), r.getString(2))); - } - - private static Optional findFirstSnapshot(Context context, String branchUuid, long date) throws SQLException { - String analysisUuid = context.prepareSelect("SELECT uuid FROM snapshots " - + "WHERE component_uuid = '" + branchUuid + "' AND created_at > " + date + " AND status = 'P' " - + "ORDER BY created_at ASC") - .get(r -> r.getString(1)); - return Optional.ofNullable(analysisUuid); - } - - private static class TypeValuePair { - private final String type; - @Nullable - private final String value; - - private TypeValuePair(String type, @Nullable String value) { - this.type = type; - this.value = value; - } - } - - private static class EventDto { - private final String version; - private final String analysisUuid; - - private EventDto(String version, String analysisUuid) { - this.version = version; - this.analysisUuid = analysisUuid; - } - } - - private static class ProjectBranchManualBaselineDto { - private final String branchUuid; - private final String projectUuid; - private final String manualBaselineAnalysisUuid; - - ProjectBranchManualBaselineDto(String branchUuid, String projectUuid, String manualBaselineAnalysisUuid) { - this.branchUuid = branchUuid; - this.projectUuid = projectUuid; - this.manualBaselineAnalysisUuid = manualBaselineAnalysisUuid; - } - } - - private static class BranchLeakPeriodPropertyDto { - private final String branchUuid; - private final String mainBranchUuid; - private final String value; - - BranchLeakPeriodPropertyDto(String branchUuid, String mainBranchUuid, String value) { - this.branchUuid = branchUuid; - this.mainBranchUuid = mainBranchUuid; - this.value = value; - } - - private boolean isMainBranch() { - return mainBranchUuid.equals(branchUuid); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/PopulateProjectQualityGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/PopulateProjectQualityGatesTable.java deleted file mode 100644 index 4fe66e59e3655715b632140231a10a0cef752588..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/PopulateProjectQualityGatesTable.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import java.util.List; -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 PopulateProjectQualityGatesTable extends DataChange { - - public PopulateProjectQualityGatesTable(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - List projectQualityGates = context.prepareSelect( - "select prj.uuid, qg.uuid from properties p \n" + - "join projects prj on p.resource_id = prj.id\n" + - "join quality_gates qg on qg.id = CAST(p.text_value AS int)\n" + - "where p.prop_key = 'sonar.qualitygate'\n" + - "and not exists(select pqg.project_uuid from project_qgates pqg where pqg.project_uuid = prj.uuid)") - .list(row -> { - String projectUuid = row.getString(1); - String qualityGateUuid = row.getString(2); - return new ProjectQualityGate(projectUuid, qualityGateUuid); - }); - - if (!projectQualityGates.isEmpty()) { - populateProjectQualityGates(context, projectQualityGates); - } - } - - private static void populateProjectQualityGates(Context context, List projectQualityGates) throws SQLException { - Upsert insertQuery = prepareInsertProjectQualityGateQuery(context); - for (ProjectQualityGate projectQualityGate : projectQualityGates) { - insertQuery - .setString(1, projectQualityGate.projectUuid) - .setString(2, projectQualityGate.qualityGateUuid) - .addBatch(); - } - insertQuery - .execute() - .commit(); - } - - private static Upsert prepareInsertProjectQualityGateQuery(Context context) throws SQLException { - return context.prepareUpsert("insert into project_qgates(project_uuid, quality_gate_uuid) VALUES (?, ?)"); - } - - private static class ProjectQualityGate { - private final String projectUuid; - private final String qualityGateUuid; - - ProjectQualityGate(String projectUuid, String qualityGateUuid) { - this.projectUuid = projectUuid; - this.qualityGateUuid = qualityGateUuid; - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTable.java deleted file mode 100644 index 3675a5d40b148ec90c28b99a56dbd5d7ec7bab0a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTable.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class RemoveDefaultQualityGateFromPropertiesTable extends DataChange { - - public RemoveDefaultQualityGateFromPropertiesTable(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("delete from properties where prop_key='sonar.qualitygate'") - .execute() - .commit(); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveGitHubLoginGenerationStrategyProperty.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveGitHubLoginGenerationStrategyProperty.java deleted file mode 100644 index e9dc7060369af0aa32db4b58c92d6be553f7d843..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveGitHubLoginGenerationStrategyProperty.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class RemoveGitHubLoginGenerationStrategyProperty extends DataChange { - private static final String GH_LOGIN_STRATEGY_PROP_KEY = "sonar.auth.github.loginStrategy"; - - public RemoveGitHubLoginGenerationStrategyProperty(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("delete from properties where prop_key='" + GH_LOGIN_STRATEGY_PROP_KEY + "'") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveLeakPeriodProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveLeakPeriodProperties.java deleted file mode 100644 index f591b89b770a1e8c33ddca04d19ae68e03123e70..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RemoveLeakPeriodProperties.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class RemoveLeakPeriodProperties extends DataChange { - private static final String LEAK_PERIOD_PROP_KEY = "sonar.leak.period"; - - public RemoveLeakPeriodProperties(Database db) { - super(db); - } - - @Override - protected void execute(DataChange.Context context) throws SQLException { - context.prepareUpsert("delete from properties where prop_key='" + LEAK_PERIOD_PROP_KEY + "'") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RenameAnalysisPropertiesSnapshotUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RenameAnalysisPropertiesSnapshotUuid.java deleted file mode 100644 index 78f88ddf4afd0be234ab08dfba5e649fb7be447a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/RenameAnalysisPropertiesSnapshotUuid.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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.UUID_SIZE; - -public class RenameAnalysisPropertiesSnapshotUuid extends DdlChange { - private static final VarcharColumnDef ANALYSIS_UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("analysis_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - - public RenameAnalysisPropertiesSnapshotUuid(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - String tableName = "analysis_properties"; - - context.execute(new DropIndexBuilder(getDialect()) - .setTable(tableName) - .setName("ix_snapshot_uuid") - .build()); - - context.execute(new RenameColumnsBuilder(getDialect(), tableName) - .renameColumn("snapshot_uuid", ANALYSIS_UUID_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(tableName) - .setName("analysis_properties_analysis") - .setUnique(false) - .addColumn(ANALYSIS_UUID_COLUMN) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/package-info.java deleted file mode 100644 index 1e1cfe4f8dd12c52196d728d6fe013e0fc8a21e3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v80/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v80; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumn.java deleted file mode 100644 index ce976e3e68950410b0f24468e7ca6c68f98d08f7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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 AddExcludeBranchFromPurgeColumn extends DdlChange { - private static final String TABLE = "project_branches"; - private static final String NEW_COLUMN = "exclude_from_purge"; - - public AddExcludeBranchFromPurgeColumn(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(newBooleanColumnDefBuilder() - .setColumnName(NEW_COLUMN) - .setIsNullable(false) - .setDefaultValue(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/CreateAlmSettingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/CreateAlmSettingsTable.java deleted file mode 100644 index a1794a86f6e66ba3e75d1b6ebd0a896987224337..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/CreateAlmSettingsTable.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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 CreateAlmSettingsTable extends DdlChange { - - private static final String TABLE_NAME = "alm_settings"; - - private static final VarcharColumnDef KEY = newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(200) - .build(); - - public CreateAlmSettingsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("alm_id") - .setIsNullable(false) - .setLimit(40) - .build()) - .addColumn(KEY) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("url") - .setIsNullable(true) - .setLimit(2000) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("app_id") - .setIsNullable(true) - .setLimit(80) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("private_key") - .setIsNullable(true) - .setLimit(2000) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("pat") - .setIsNullable(true) - .setLimit(2000) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .addColumn(KEY) - .setName("uniq_alm_settings") - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/CreateProjectAlmSettingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/CreateProjectAlmSettingsTable.java deleted file mode 100644 index 7ab94318864344fa9151dbd61a01f5fc84de1039..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/CreateProjectAlmSettingsTable.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CreateProjectAlmSettingsTable extends DdlChange { - - private static final String TABLE_NAME = "project_alm_settings"; - - private static final VarcharColumnDef PROJECT_UUID = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(UUID_VARCHAR_SIZE) - .build(); - - private static final VarcharColumnDef ALM_SETTING_UUID = newVarcharColumnDefBuilder() - .setColumnName("alm_setting_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - - public CreateProjectAlmSettingsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build()) - .addColumn(ALM_SETTING_UUID) - .addColumn(PROJECT_UUID) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("alm_repo") - .setIsNullable(true) - .setLimit(256) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("alm_slug") - .setIsNullable(true) - .setLimit(256) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .addColumn(PROJECT_UUID) - .setName("uniq_project_alm_settings") - .setUnique(true) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .addColumn(ALM_SETTING_UUID) - .setName("project_alm_settings_alm") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java deleted file mode 100644 index 5fd5f8dc0f48dfd270fcbedaadb54275153238e1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion81 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(3100, "Create ALM_SETTINGS table", CreateAlmSettingsTable.class) - .add(3101, "Create PROJECT_ALM_SETTINGS table", CreateProjectAlmSettingsTable.class) - .add(3102, "Migrate property 'sonar.alm.github.app.privateKey.secured' to 'sonar.alm.github.app.privateKeyContent.secured'", - MigrateDeprecatedGithubPrivateKeyToNewKey.class) - .add(3103, "Migrate GitHub ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateGithubAlmSettings.class) - .add(3104, "Migrate Bitbucket ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateBitbucketAlmSettings.class) - .add(3105, "Migrate Azure ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateAzureAlmSettings.class) - .add(3106, "Delete 'sonar.pullrequest.provider' property", DeleteSonarPullRequestProviderProperty.class) - .add(3107, "Migrate default branches to keep global setting", MigrateDefaultBranchesToKeepSetting.class) - .add(3108, "Add EXCLUDE_FROM_PURGE column", AddExcludeBranchFromPurgeColumn.class) - .add(3109, "Populate EXCLUDE_FROM_PURGE column", PopulateExcludeBranchFromPurgeColumn.class) - .add(3110, "Remove 'sonar.branch.longLivedBranches.regex'", RemoveLLBRegexSetting.class) - .add(3111, "Rename 'sonar.dbcleaner.daysBeforeDeletingInactiveShortLivingBranches' setting", - RenameDaysBeforeDeletingInactiveSLBSetting.class) - .add(3112, "Migrate short and long living branches types to common BRANCH type", MigrateSlbsAndLlbsToCommonType.class) - .add(3113, "Migrate short and long living branches types to common BRANCH type in ce tasks table", - MigrateSlbsAndLlbsToCommonTypeInCeTasks.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DeleteSonarPullRequestProviderProperty.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DeleteSonarPullRequestProviderProperty.java deleted file mode 100644 index b5fd4fe121531d6869555241a979b337b88541e9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DeleteSonarPullRequestProviderProperty.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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 DeleteSonarPullRequestProviderProperty extends DataChange { - - public DeleteSonarPullRequestProviderProperty(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 = ?") - .setString(1, "sonar.pullrequest.provider"); - massUpdate.update("delete from properties where id = ?"); - massUpdate.execute((row, handler) -> { - handler.setLong(1, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateAzureAlmSettings.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateAzureAlmSettings.java deleted file mode 100644 index bde1abf615e5d11ada99967175de8e0d009bf170..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateAzureAlmSettings.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.TreeSet; -import java.util.function.Function; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -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; -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.Upsert; - -public class MigrateAzureAlmSettings extends DataChange { - - private static final String PROVIDER = "sonar.pullrequest.provider"; - private static final String AZURE_TOKEN = "sonar.pullrequest.vsts.token.secured"; - private static final String PROVIDER_VALUE = "Azure DevOps"; - private static final String ALM_SETTING_ID = "azure_devops"; - - private static final String INSERT_SQL = "insert into project_alm_settings (uuid, project_uuid, alm_setting_uuid, created_at, updated_at) values (?, ?, ?, ?, ?)"; - private static final String DELETE_SQL = "delete from properties where prop_key = ? and resource_id=?"; - - private final UuidFactory uuidFactory; - private final System2 system2; - - public MigrateAzureAlmSettings(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - List tokens = loadTokens(context); - if (tokens.isEmpty()) { - return; - } - Map globalPropertiesByKey = loadGlobalProperties(context); - Map almSettingUuidByTokens = loadOrInsertAlmSettings(context, tokens); - - String globalProvider = getGlobalProperty(globalPropertiesByKey, PROVIDER); - String globalToken = getGlobalProperty(globalPropertiesByKey, AZURE_TOKEN); - - insertProjectAlmSettings(context, globalProvider, globalToken, almSettingUuidByTokens); - context.prepareUpsert("delete from properties where prop_key = ?") - .setString(1, AZURE_TOKEN) - .execute() - .commit(); - } - - @CheckForNull - private static String getGlobalProperty(Map globalPropertiesByKey, String propertyKey) { - Property globalProperty = globalPropertiesByKey.getOrDefault(propertyKey, null); - return globalProperty != null ? globalProperty.getValue() : null; - } - - private static Map loadGlobalProperties(Context context) throws SQLException { - return context - .prepareSelect("select prop_key, text_value from properties where prop_key in (?, ?) " + - "and resource_id is null " + - "and text_value is not null ") - .setString(1, PROVIDER) - .setString(2, AZURE_TOKEN) - .list(Property::new) - .stream() - .collect(Collectors.toMap(Property::getKey, Function.identity())); - } - - private static List loadTokens(Context context) throws SQLException { - return new ArrayList<>(context - .prepareSelect("select distinct text_value from properties where prop_key = ?") - .setString(1, AZURE_TOKEN) - .list(row -> row.getString(1))); - } - - private Map loadOrInsertAlmSettings(Context context, List tokens) throws SQLException { - Map almSettingUuidByTokens = loadExistingAlmSettingUuidByToken(context); - TreeSet tokensWithNoAlmSetting = new TreeSet<>(tokens); - tokensWithNoAlmSetting.removeAll(almSettingUuidByTokens.keySet()); - if (tokensWithNoAlmSetting.isEmpty()) { - return almSettingUuidByTokens; - } - int index = almSettingUuidByTokens.isEmpty() ? 0 : (almSettingUuidByTokens.size() + 1); - if (tokensWithNoAlmSetting.size() == 1) { - String token = tokensWithNoAlmSetting.first(); - String almSettingUuid = insertAlmSetting(context, token, index); - almSettingUuidByTokens.put(token, almSettingUuid); - return almSettingUuidByTokens; - } - for (String token : tokensWithNoAlmSetting) { - String almSettingUuid = insertAlmSetting(context, token, index); - almSettingUuidByTokens.put(token, almSettingUuid); - index++; - } - return almSettingUuidByTokens; - } - - private static Map loadExistingAlmSettingUuidByToken(Context context) throws SQLException { - Select select = context.prepareSelect("select uuid, pat from alm_settings where alm_id=?") - .setString(1, ALM_SETTING_ID); - return select - .list(row -> new AlmSetting(row.getString(1), row.getString(2))) - .stream() - .collect(Collectors.toMap(AlmSetting::getPersonalAccessToken, AlmSetting::getUuid)); - } - - private String insertAlmSetting(Context context, String token, int index) throws SQLException { - String almSettingUuid = uuidFactory.create(); - context.prepareUpsert("insert into alm_settings (uuid, alm_id, kee, pat, updated_at, created_at) values (?, ?, ?, ?, ?, ?)") - .setString(1, almSettingUuid) - .setString(2, ALM_SETTING_ID) - .setString(3, index == 0 ? PROVIDER_VALUE : (PROVIDER_VALUE + " " + index)) - .setString(4, token) - .setLong(5, system2.now()) - .setLong(6, system2.now()) - .execute() - .commit(); - return almSettingUuid; - } - - private void insertProjectAlmSettings(Context context, @Nullable String globalProvider, @Nullable String globalToken, - Map almSettingUuidByTokens) throws SQLException { - final Buffer buffer = new Buffer(globalProvider); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select prop_key, text_value, prj.uuid, prj.id from properties prop " + - "inner join projects prj on prj.id=prop.resource_id " + - "where prop.prop_key in (?, ?) " + - "order by prj.id asc") - .setString(1, PROVIDER) - .setString(2, AZURE_TOKEN); - massUpdate.update(INSERT_SQL); - massUpdate.update(DELETE_SQL); - massUpdate.execute((row, update, updateIndex) -> { - boolean shouldExecuteUpdate = false; - String projectUuid = row.getString(3); - Long projectId = row.getLong(4); - // Set last projectUuid the first time - if (buffer.getLastProjectUuid() == null) { - buffer.setLastProject(projectUuid, projectId); - } - - // When current projectUuid is different from last processed projectUuid, feed the prepared statement - if (!projectUuid.equals(buffer.getLastProjectUuid())) { - if (updateIndex == 0) { - // Insert new row in PROJECT_ALM_SETTINGS - shouldExecuteUpdate = updateStatementIfNeeded(buffer, buffer.getLastProjectUuid(), update, globalToken, almSettingUuidByTokens); - } else { - // Delete old property - shouldExecuteUpdate = deleteProperty(buffer.getLastProjectId(), buffer, update); - buffer.clear(); - // Update last projectUuid in buffer only when it has changed - buffer.setLastProject(projectUuid, projectId); - } - } - // Update remaining buffer values only once, and only after delete - if (updateIndex == 1) { - String propertyKey = row.getString(1); - String propertyValue = row.getString(2); - if (propertyKey.equals(PROVIDER)) { - buffer.setProvider(propertyValue); - } else if (propertyKey.equals(AZURE_TOKEN)) { - buffer.setToken(propertyValue); - } - buffer.setCurrentProject(projectUuid, projectId); - } - return shouldExecuteUpdate; - }); - String projectUuid = buffer.getCurrentProjectUuid(); - if (projectUuid == null) { - return; - } - // Process last entry - Upsert upsert = context.prepareUpsert(INSERT_SQL); - boolean shouldExecuteInsert = updateStatementIfNeeded(buffer, projectUuid, upsert, globalToken, almSettingUuidByTokens); - if (shouldExecuteInsert) { - upsert.execute().commit(); - } - if (buffer.shouldUpdate()) { - context.prepareUpsert(DELETE_SQL) - .setString(1, AZURE_TOKEN) - .setLong(2, buffer.getCurrentProjectId()) - .execute() - .commit(); - } - } - - private static boolean deleteProperty(long effectiveProjectId, Buffer buffer, SqlStatement update) throws SQLException { - if (buffer.shouldUpdate()) { - update.setString(1, AZURE_TOKEN); - update.setLong(2, effectiveProjectId); - return true; - } - return false; - } - - private boolean updateStatementIfNeeded(Buffer buffer, String projectUuid, SqlStatement update, @Nullable String globalToken, - Map almSettingUuidByTokens) - throws SQLException { - String token = buffer.getToken(); - String almSettingUuid = token == null ? almSettingUuidByTokens.get(globalToken) : almSettingUuidByTokens.get(token); - if (!buffer.shouldUpdate() || almSettingUuid == null) { - return false; - } - update.setString(1, uuidFactory.create()); - update.setString(2, projectUuid); - update.setString(3, almSettingUuid); - update.setLong(4, system2.now()); - update.setLong(5, system2.now()); - return true; - } - - private static class AlmSetting { - private final String uuid; - private final String personalAccessToken; - - AlmSetting(String uuid, String personalAccessToken) { - this.uuid = uuid; - this.personalAccessToken = personalAccessToken; - } - - String getUuid() { - return uuid; - } - - String getPersonalAccessToken() { - return personalAccessToken; - } - } - - private static class Property { - private final String key; - private final String value; - - Property(Select.Row row) throws SQLException { - this.key = row.getString(1); - this.value = row.getString(2); - } - - String getKey() { - return key; - } - - String getValue() { - return value; - } - } - - private static class Buffer { - private final String globalProvider; - private String lastProjectUuid; - private String currentProjectUuid; - private Long lastProjectId; - private Long currentProjectId; - private String provider; - private String token; - - private Buffer(@Nullable String globalProvider) { - this.globalProvider = globalProvider; - } - - Buffer setLastProject(@Nullable String projectUuid, @Nullable Long projectId) { - this.lastProjectUuid = projectUuid; - this.lastProjectId = projectId; - return this; - } - - @CheckForNull - String getLastProjectUuid() { - return lastProjectUuid; - } - - @CheckForNull - Long getLastProjectId() { - return lastProjectId; - } - - Buffer setCurrentProject(@Nullable String projectUuid, @Nullable Long projectId) { - this.currentProjectUuid = projectUuid; - this.currentProjectId = projectId; - return this; - } - - @CheckForNull - String getCurrentProjectUuid() { - return currentProjectUuid; - } - - @CheckForNull - Long getCurrentProjectId() { - return currentProjectId; - } - - Buffer setProvider(@Nullable String provider) { - this.provider = provider; - return this; - } - - @CheckForNull - String getToken() { - return token; - } - - Buffer setToken(@Nullable String token) { - this.token = token; - return this; - } - - boolean shouldUpdate() { - if (provider != null) { - return provider.equals(PROVIDER_VALUE); - } - return Objects.equals(globalProvider, PROVIDER_VALUE); - } - - void clear() { - this.lastProjectUuid = null; - this.currentProjectUuid = null; - this.lastProjectId = null; - this.currentProjectId = null; - this.provider = null; - this.token = null; - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettings.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettings.java deleted file mode 100644 index c4abd3d9843bd86b2f96258aae6ef2919f0b1f49..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettings.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import com.google.common.collect.ImmutableSet; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -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; -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.Upsert; - -public class MigrateBitbucketAlmSettings extends DataChange { - - private static final String PROVIDER = "sonar.pullrequest.provider"; - - // Global settings - private static final String BITBUCKET_SERVER_URL = "sonar.pullrequest.bitbucketserver.serverUrl"; - private static final String BITBUCKET_TOKEN = "sonar.pullrequest.bitbucketserver.token.secured"; - // Project setting - private static final String BITBUCKET_PROJECT = "sonar.pullrequest.bitbucketserver.project"; - private static final String BITBUCKET_REPOSITORY = "sonar.pullrequest.bitbucketserver.repository"; - - private static final Set MANDATORY_GLOBAL_KEYS = ImmutableSet.of(BITBUCKET_SERVER_URL, BITBUCKET_TOKEN); - - private static final String PROVIDER_VALUE = "Bitbucket Server"; - - private static final String ALM_SETTING_BITBUCKET_ID = "bitbucket"; - - private static final String INSERT_SQL = "insert into project_alm_settings (uuid, project_uuid, alm_setting_uuid, alm_repo, alm_slug, created_at, updated_at) values " + - "(?, ?, ?, ?, ?, ?, ?)"; - private static final String DELETE_SQL = "delete from properties where prop_key in (?, ?) and resource_id=?"; - - private final UuidFactory uuidFactory; - private final System2 system2; - - public MigrateBitbucketAlmSettings(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - Map globalPropertiesByKey = loadGlobalProperties(context); - - if (globalPropertiesByKey.keySet().containsAll(MANDATORY_GLOBAL_KEYS)) { - String almSettingUuid = loadOrInsertAlmSetting(context, globalPropertiesByKey); - Property globalProviderProperty = globalPropertiesByKey.getOrDefault(PROVIDER, null); - String globalProvider = globalProviderProperty != null ? globalProviderProperty.getValue() : null; - - insertProjectAlmSettings(context, globalProvider, almSettingUuid); - } - context.prepareUpsert("delete from properties where prop_key in (?, ?, ?, ?)") - .setString(1, BITBUCKET_SERVER_URL) - .setString(2, BITBUCKET_TOKEN) - .setString(3, BITBUCKET_PROJECT) - .setString(4, BITBUCKET_REPOSITORY) - .execute() - .commit(); - } - - private static Map loadGlobalProperties(Context context) throws SQLException { - return context - .prepareSelect("select id, prop_key, text_value from properties where prop_key in (?, ?, ?) " + - "and resource_id is null " + - "and text_value is not null ") - .setString(1, PROVIDER) - .setString(2, BITBUCKET_SERVER_URL) - .setString(3, BITBUCKET_TOKEN) - .list(Property::new) - .stream() - .collect(Collectors.toMap(Property::getKey, Function.identity())); - } - - private String loadOrInsertAlmSetting(Context context, Map globalPropertiesByKey) throws SQLException { - String almSettingUuid = loadAlmSetting(context); - if (almSettingUuid != null) { - return almSettingUuid; - } - return insertAlmSetting(context, globalPropertiesByKey); - } - - @CheckForNull - private static String loadAlmSetting(Context context) throws SQLException { - List list = context.prepareSelect("select uuid from alm_settings where alm_id=?") - .setString(1, ALM_SETTING_BITBUCKET_ID) - .list(row -> row.getString(1)); - if (list.isEmpty()) { - return null; - } - return list.get(0); - } - - private String insertAlmSetting(Context context, Map globalPropertiesByKey) throws SQLException { - String almSettingUuid = uuidFactory.create(); - context.prepareUpsert("insert into alm_settings (uuid, alm_id, kee, url, pat, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?)") - .setString(1, almSettingUuid) - .setString(2, ALM_SETTING_BITBUCKET_ID) - .setString(3, PROVIDER_VALUE) - .setString(4, globalPropertiesByKey.get(BITBUCKET_SERVER_URL).getValue()) - .setString(5, globalPropertiesByKey.get(BITBUCKET_TOKEN).getValue()) - .setLong(6, system2.now()) - .setLong(7, system2.now()) - .execute() - .commit(); - return almSettingUuid; - } - - private void insertProjectAlmSettings(Context context, @Nullable String globalProvider, String almSettingUuid) throws SQLException { - final Buffer buffer = new Buffer(globalProvider); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select prop_key, text_value, prj.uuid, prj.id from properties prop " + - "inner join projects prj on prj.id=prop.resource_id " + - "where prop.prop_key in (?, ?, ?) " + - "order by prj.id asc") - .setString(1, PROVIDER) - .setString(2, BITBUCKET_PROJECT) - .setString(3, BITBUCKET_REPOSITORY); - massUpdate.update(INSERT_SQL); - massUpdate.update(DELETE_SQL); - massUpdate.execute((row, update, updateIndex) -> { - boolean shouldExecuteUpdate = false; - String projectUuid = row.getString(3); - Long projectId = row.getLong(4); - // Set last projectUuid the first time - if (buffer.getLastProjectUuid() == null) { - buffer.setLastProject(projectUuid, projectId); - } - - // When current projectUuid is different from last processed projectUuid, feed the prepared statement - if (!projectUuid.equals(buffer.getLastProjectUuid())) { - if (updateIndex == 0) { - // Insert new row in PROJECT_ALM_SETTINGS - shouldExecuteUpdate = updateStatementIfNeeded(buffer, buffer.getLastProjectUuid(), update, almSettingUuid); - } else { - // Delete old property - shouldExecuteUpdate = deleteProperty(buffer.getLastProjectId(), buffer, update); - buffer.clear(); - // Update last projectUuid in buffer only when it has changed - buffer.setLastProject(projectUuid, projectId); - } - } - // Update remaining buffer values only once, and only after delete - if (updateIndex == 1) { - String propertyKey = row.getString(1); - String propertyValue = row.getString(2); - switch (propertyKey) { - case PROVIDER: - buffer.setProvider(propertyValue); - break; - case BITBUCKET_PROJECT: - buffer.setRepository(propertyValue); - break; - case BITBUCKET_REPOSITORY: - buffer.setSlug(propertyValue); - break; - default: - throw new IllegalStateException("Provider " + propertyKey + " is unknown"); - } - buffer.setCurrentProject(projectUuid, projectId); - } - return shouldExecuteUpdate; - }); - String projectUuid = buffer.getCurrentProjectUuid(); - if (projectUuid == null) { - return; - } - // Process last entry - Upsert upsert = context.prepareUpsert(INSERT_SQL); - if (updateStatementIfNeeded(buffer, projectUuid, upsert, almSettingUuid)) { - upsert.execute().commit(); - } - if (buffer.shouldDelete()) { - context.prepareUpsert(DELETE_SQL) - .setString(1, BITBUCKET_PROJECT) - .setString(2, BITBUCKET_REPOSITORY) - .setLong(3, buffer.getCurrentProjectId()) - .execute() - .commit(); - } - } - - private static boolean deleteProperty(long effectiveProjectId, Buffer buffer, SqlStatement update) throws SQLException { - if (buffer.shouldDelete()) { - update.setString(1, BITBUCKET_PROJECT); - update.setString(2, BITBUCKET_REPOSITORY); - update.setLong(3, effectiveProjectId); - return true; - } - return false; - } - - private boolean updateStatementIfNeeded(Buffer buffer, String effectiveProjectUuid, SqlStatement update, String almSettingUuid) - throws SQLException { - String repository = buffer.getRepository(); - String slug = buffer.getSlug(); - if (!buffer.shouldUpdate()) { - return false; - } - update.setString(1, uuidFactory.create()); - update.setString(2, effectiveProjectUuid); - update.setString(3, almSettingUuid); - update.setString(4, repository); - update.setString(5, slug); - update.setLong(6, system2.now()); - update.setLong(7, system2.now()); - return true; - } - - private static class Property { - private final long id; - private final String key; - private final String value; - - Property(Select.Row row) throws SQLException { - this.id = row.getLong(1); - this.key = row.getString(2); - this.value = row.getString(3); - } - - public long getId() { - return id; - } - - public String getKey() { - return key; - } - - public String getValue() { - return value; - } - } - - private static class Buffer { - private final String globalProvider; - private String lastProjectUuid; - private String currentProjectUuid; - private Long lastProjectId; - private Long currentProjectId; - private String provider; - private String repository; - private String slug; - - private Buffer(@Nullable String globalProvider) { - this.globalProvider = globalProvider; - } - - Buffer setLastProject(@Nullable String projectUuid, @Nullable Long projectId) { - this.lastProjectUuid = projectUuid; - this.lastProjectId = projectId; - return this; - } - - @CheckForNull - String getLastProjectUuid() { - return lastProjectUuid; - } - - @CheckForNull - Long getLastProjectId() { - return lastProjectId; - } - - Buffer setCurrentProject(@Nullable String projectUuid, @Nullable Long projectId) { - this.currentProjectUuid = projectUuid; - this.currentProjectId = projectId; - return this; - } - - @CheckForNull - String getCurrentProjectUuid() { - return currentProjectUuid; - } - - @CheckForNull - Long getCurrentProjectId() { - return currentProjectId; - } - - Buffer setProvider(@Nullable String provider) { - this.provider = provider; - return this; - } - - @CheckForNull - String getRepository() { - return repository; - } - - Buffer setRepository(@Nullable String repository) { - this.repository = repository; - return this; - } - - @CheckForNull - String getSlug() { - return slug; - } - - Buffer setSlug(@Nullable String slug) { - this.slug = slug; - return this; - } - - boolean shouldUpdate() { - if (repository == null || slug == null) { - return false; - } - if (Objects.equals(provider, PROVIDER_VALUE)) { - return true; - } - return provider == null && Objects.equals(globalProvider, PROVIDER_VALUE); - } - - boolean shouldDelete() { - if (provider != null) { - return provider.equals(PROVIDER_VALUE); - } - return Objects.equals(globalProvider, PROVIDER_VALUE); - } - - void clear() { - this.lastProjectUuid = null; - this.currentProjectUuid = null; - this.lastProjectId = null; - this.currentProjectId = null; - this.provider = null; - this.repository = null; - this.slug = null; - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSetting.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSetting.java deleted file mode 100644 index ab9c6635b03b339bd1499234f67a8f2c50bf2db4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSetting.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.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 static java.lang.Boolean.FALSE; -import static java.lang.Boolean.TRUE; - -@SupportsBlueGreen -public class MigrateDefaultBranchesToKeepSetting extends DataChange { - private static final Logger LOG = Loggers.get(MigrateDefaultBranchesToKeepSetting.class); - private static final String DEPRECATED_KEY = "sonar.branch.longLivedBranches.regex"; - private static final String NEW_KEY = "sonar.dbcleaner.branchesToKeepWhenInactive"; - - private final System2 system; - - public MigrateDefaultBranchesToKeepSetting(Database db, System2 system) { - super(db); - this.system = system; - } - - @Override - protected void execute(Context context) throws SQLException { - Long now = system.now(); - try { - Long numberOfNewProps = context.prepareSelect("select count(*) from properties props where props.prop_key = '" + NEW_KEY + "'") - .get(row -> row.getLong(1)); - if (numberOfNewProps != null && numberOfNewProps > 0) { - // no need for a migration - return; - } - - Boolean defaultPropertyOverridden = context.prepareSelect("select count(*) from properties props where props.prop_key = '" + DEPRECATED_KEY + "'") - .get(row -> row.getLong(1) > 0); - if (FALSE.equals(defaultPropertyOverridden)) { - migrateDefaultDeprecatedSettings(context, now); - } else { - migrateOverriddenDeprecatedSettings(context, now); - } - } catch (Exception ex) { - LOG.error("Failed to migrate to new '{}' setting.", NEW_KEY); - throw ex; - } - } - - private static void migrateDefaultDeprecatedSettings(Context context, Long time) throws SQLException { - Boolean anyProjectAlreadyExists = context.prepareSelect("select count(*) from projects").get(row -> row.getLong(1) > 0); - String newSettingValue = "master,develop,trunk"; - - // if old `sonar.branch.longLivedBranches.regex` setting was at default value but there were already projects analyzed we need to add the - // old defaults of - // that setting to the defaults of the new `sonar.dbcleaner.branchesToKeepWhenInactive` setting for backward compatibility - if (TRUE.equals(anyProjectAlreadyExists)) { - newSettingValue = "master,develop,trunk,branch-.*,release-.*"; - } - - context - .prepareUpsert("insert into properties (prop_key, is_empty, text_value, created_at) values (?, ?, ?, ?)") - .setString(1, NEW_KEY) - .setBoolean(2, false) - .setString(3, newSettingValue) - .setLong(4, time) - .execute() - .commit(); - } - - private static void migrateOverriddenDeprecatedSettings(Context context, Long time) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select resource_id, text_value from properties props where props.prop_key = '" + DEPRECATED_KEY + "'"); - massUpdate.rowPluralName("properties"); - massUpdate.update("insert into properties (resource_id, prop_key, is_empty, text_value, created_at) values (?, ?, ?, ?, ?)"); - massUpdate.execute((row, update) -> { - update.setLong(1, row.getNullableLong(1)); - update.setString(2, NEW_KEY); - update.setBoolean(3, false); - update.setString(4, row.getString(2)); - update.setLong(5, time); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateDeprecatedGithubPrivateKeyToNewKey.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateDeprecatedGithubPrivateKeyToNewKey.java deleted file mode 100644 index 93e0ff7dba00ef63f9f89613fc027065aa8bfd45..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateDeprecatedGithubPrivateKeyToNewKey.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.util.Base64; -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 java.nio.charset.StandardCharsets.UTF_8; - -public class MigrateDeprecatedGithubPrivateKeyToNewKey extends DataChange { - - private static final String OLD_KEY = "sonar.alm.github.app.privateKey.secured"; - private static final String NEW_KEY = "sonar.alm.github.app.privateKeyContent.secured"; - - public MigrateDeprecatedGithubPrivateKeyToNewKey(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - Long newPropertyId = context.prepareSelect("select id from properties where prop_key = ?") - .setString(1, NEW_KEY) - .get(Select.LONG_READER); - if (newPropertyId != null) { - context.prepareUpsert("delete from properties where prop_key = ? ") - .setString(1, OLD_KEY) - .execute() - .commit(); - return; - } - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id, text_value from properties where prop_key = ?") - .setString(1, OLD_KEY); - massUpdate.update("update properties set prop_key = ?, text_value = ? where id = ?"); - massUpdate.execute((row, handler) -> { - String propertyEncodedInBAse64 = row.getString(2); - String propertyDecoded = new String(Base64.getDecoder().decode(propertyEncodedInBAse64), UTF_8); - handler.setString(1, NEW_KEY); - handler.setString(2, propertyDecoded); - handler.setLong(3, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateGithubAlmSettings.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateGithubAlmSettings.java deleted file mode 100644 index 7a104dc603725afcc95fab7b1ae2794e329a7ef4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateGithubAlmSettings.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import com.google.common.collect.ImmutableSet; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -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; -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.Upsert; - -public class MigrateGithubAlmSettings extends DataChange { - - private static final String PROVIDER = "sonar.pullrequest.provider"; - - // Global settings - private static final String GITHUB_ENDPOINT = "sonar.pullrequest.github.endpoint"; - private static final String GITHUB_APP_ID = "sonar.alm.github.app.id"; - private static final String GITHUB_APP_PRIVATE_KEY = "sonar.alm.github.app.privateKeyContent.secured"; - private static final String GITHUB_APP_NAME = "sonar.alm.github.app.name"; - // Project setting - private static final String GITHUB_REPOSITORY = "sonar.pullrequest.github.repository"; - - private static final Set MANDATORY_GLOBAL_KEYS = ImmutableSet.of(GITHUB_ENDPOINT, GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY); - - private static final String PROVIDER_VALUE = "GitHub"; - - private static final String ALM_SETTING_GITHUB_ID = "github"; - - private static final String INSERT_SQL = "insert into project_alm_settings (uuid, project_uuid, alm_setting_uuid, alm_repo, created_at, updated_at) values (?, ?, ?, ?, ?, ?)"; - private static final String DELETE_SQL = "delete from properties where prop_key = ? and resource_id = ?"; - - private final UuidFactory uuidFactory; - private final System2 system2; - - public MigrateGithubAlmSettings(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - Map globalPropertiesByKey = loadGlobalProperties(context); - - if (globalPropertiesByKey.keySet().containsAll(MANDATORY_GLOBAL_KEYS)) { - String gitHubAlmSettingUuid = loadOrInsertAlmSetting(context, globalPropertiesByKey); - Property globalProviderProperty = globalPropertiesByKey.getOrDefault(PROVIDER, null); - String globalProvider = globalProviderProperty != null ? globalProviderProperty.getValue() : null; - - insertProjectAlmSettings(context, globalProvider, gitHubAlmSettingUuid); - } - - context.prepareUpsert("delete from properties where prop_key in (?, ?, ?, ?, ?)") - .setString(1, GITHUB_ENDPOINT) - .setString(2, GITHUB_APP_ID) - .setString(3, GITHUB_APP_PRIVATE_KEY) - .setString(4, GITHUB_APP_NAME) - .setString(5, GITHUB_REPOSITORY) - .execute() - .commit(); - } - - private static Map loadGlobalProperties(Context context) throws SQLException { - return context - .prepareSelect("select prop_key, text_value from properties where prop_key in (?, ?, ?, ?, ?) " + - "and resource_id is null " + - "and text_value is not null ") - .setString(1, PROVIDER) - .setString(2, GITHUB_ENDPOINT) - .setString(3, GITHUB_APP_ID) - .setString(4, GITHUB_APP_PRIVATE_KEY) - .setString(5, GITHUB_APP_NAME) - .list(Property::new) - .stream() - .collect(Collectors.toMap(Property::getKey, Function.identity())); - } - - private String loadOrInsertAlmSetting(Context context, Map globalPropertiesByKey) throws SQLException { - String gitHubAlmSettingUuid = loadAlmSetting(context); - if (gitHubAlmSettingUuid != null) { - return gitHubAlmSettingUuid; - } - return insertAlmSetting(context, globalPropertiesByKey); - } - - @CheckForNull - private static String loadAlmSetting(Context context) throws SQLException { - List list = context.prepareSelect("select uuid from alm_settings where alm_id=?") - .setString(1, ALM_SETTING_GITHUB_ID) - .list(row -> row.getString(1)); - if (list.isEmpty()) { - return null; - } - return list.get(0); - } - - private String insertAlmSetting(Context context, Map globalPropertiesByKey) throws SQLException { - String gitHubAlmSettingUuid = uuidFactory.create(); - Property appName = globalPropertiesByKey.get(GITHUB_APP_NAME); - context.prepareUpsert("insert into alm_settings (uuid, alm_id, kee, url, app_id, private_key, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?, ?)") - .setString(1, gitHubAlmSettingUuid) - .setString(2, ALM_SETTING_GITHUB_ID) - .setString(3, appName == null ? PROVIDER_VALUE : appName.getValue()) - .setString(4, globalPropertiesByKey.get(GITHUB_ENDPOINT).getValue()) - .setString(5, globalPropertiesByKey.get(GITHUB_APP_ID).getValue()) - .setString(6, globalPropertiesByKey.get(GITHUB_APP_PRIVATE_KEY).getValue()) - .setLong(7, system2.now()) - .setLong(8, system2.now()) - .execute() - .commit(); - return gitHubAlmSettingUuid; - } - - private void insertProjectAlmSettings(Context context, @Nullable String globalProvider, String almSettingUuid) throws SQLException { - final Buffer buffer = new Buffer(globalProvider); - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select prop_key, text_value, prj.uuid, prj.id from properties prop " + - "inner join projects prj on prj.id=prop.resource_id " + - "where prop.prop_key in (?, ?) " + - "order by prj.id asc") - .setString(1, PROVIDER) - .setString(2, GITHUB_REPOSITORY); - massUpdate.update(INSERT_SQL); - massUpdate.update(DELETE_SQL); - massUpdate.execute((row, update, updateIndex) -> { - boolean shouldExecuteUpdate = false; - String projectUuid = row.getString(3); - Long projectId = row.getLong(4); - // Set last projectUuid the first time - if (buffer.getLastProjectUuid() == null) { - buffer.setLastProject(projectUuid, projectId); - } - // When current projectUuid is different from last processed projectUuid, feed the prepared statement - if (!projectUuid.equals(buffer.getLastProjectUuid())) { - if (updateIndex == 0) { - // Insert new row in PROJECT_ALM_SETTINGS - shouldExecuteUpdate = updateStatementIfNeeded(buffer.getLastProjectUuid(), buffer, update, almSettingUuid); - } else { - // Delete old property - shouldExecuteUpdate = deleteProperty(buffer.getLastProjectId(), buffer, update); - buffer.clear(); - // Update last projectUuid in buffer only when it has changed - buffer.setLastProject(projectUuid, projectId); - } - } - // Update remaining buffer values only once, and only after delete - if (updateIndex == 1) { - String propertyKey = row.getString(1); - String propertyValue = row.getString(2); - if (propertyKey.equals(PROVIDER)) { - buffer.setProvider(propertyValue); - } else if (propertyKey.equals(GITHUB_REPOSITORY)) { - buffer.setRepository(propertyValue); - } - buffer.setCurrentProject(projectUuid, projectId); - } - return shouldExecuteUpdate; - }); - String projectUuid = buffer.getCurrentProjectUuid(); - if (projectUuid == null) { - return; - } - // Process last entry - Upsert upsert = context.prepareUpsert(INSERT_SQL); - if (updateStatementIfNeeded(projectUuid, buffer, upsert, almSettingUuid)) { - upsert.execute().commit(); - } - if (buffer.shouldDelete()) { - context.prepareUpsert(DELETE_SQL) - .setString(1, GITHUB_REPOSITORY) - .setLong(2, buffer.getCurrentProjectId()) - .execute() - .commit(); - } - } - - private static boolean deleteProperty(long effectiveProjectId, Buffer buffer, SqlStatement update) throws SQLException { - if (buffer.shouldDelete()) { - update.setString(1, GITHUB_REPOSITORY); - update.setLong(2, effectiveProjectId); - return true; - } - return false; - } - - private boolean updateStatementIfNeeded(String effectiveProjectUuid, Buffer buffer, SqlStatement update, String almSettingUuid) - throws SQLException { - if (!buffer.shouldUpdate()) { - return false; - } - update.setString(1, uuidFactory.create()); - update.setString(2, effectiveProjectUuid); - update.setString(3, almSettingUuid); - update.setString(4, buffer.getRepository()); - update.setLong(5, system2.now()); - update.setLong(6, system2.now()); - return true; - } - - private static class Property { - private final String key; - private final String value; - - Property(Select.Row row) throws SQLException { - this.key = row.getString(1); - this.value = row.getString(2); - } - - String getKey() { - return key; - } - - String getValue() { - return value; - } - } - - private static class Buffer { - private final String globalProvider; - private String lastProjectUuid; - private String currentProjectUuid; - private Long lastProjectId; - private Long currentProjectId; - private String provider; - private String repository; - - public Buffer(@Nullable String globalProvider) { - this.globalProvider = globalProvider; - } - - Buffer setLastProject(@Nullable String projectUuid, @Nullable Long projectId) { - this.lastProjectUuid = projectUuid; - this.lastProjectId = projectId; - return this; - } - - @CheckForNull - String getLastProjectUuid() { - return lastProjectUuid; - } - - @CheckForNull - Long getLastProjectId() { - return lastProjectId; - } - - Buffer setCurrentProject(@Nullable String projectUuid, @Nullable Long projectId) { - this.currentProjectUuid = projectUuid; - this.currentProjectId = projectId; - return this; - } - - @CheckForNull - String getCurrentProjectUuid() { - return currentProjectUuid; - } - - @CheckForNull - Long getCurrentProjectId() { - return currentProjectId; - } - - Buffer setProvider(@Nullable String provider) { - this.provider = provider; - return this; - } - - @CheckForNull - String getRepository() { - return repository; - } - - Buffer setRepository(@Nullable String repository) { - this.repository = repository; - return this; - } - - boolean shouldUpdate() { - if (repository == null) { - return false; - } - if (Objects.equals(provider, PROVIDER_VALUE)) { - return true; - } - return provider == null && Objects.equals(globalProvider, PROVIDER_VALUE); - } - - boolean shouldDelete() { - if (provider != null) { - return provider.equals(PROVIDER_VALUE); - } - return Objects.equals(globalProvider, PROVIDER_VALUE); - } - - void clear() { - this.lastProjectUuid = null; - this.currentProjectUuid = null; - this.lastProjectId = null; - this.currentProjectId = null; - this.provider = null; - this.repository = null; - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonType.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonType.java deleted file mode 100644 index cb0ead3e85fd4ed0af4c07dab9f7e5fad3eb1563..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonType.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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; - -@SupportsBlueGreen -public class MigrateSlbsAndLlbsToCommonType extends DataChange { - private final System2 system; - - public MigrateSlbsAndLlbsToCommonType(Database db, System2 system) { - super(db); - this.system = system; - } - - @Override - protected void execute(Context context) throws SQLException { - long now = system.now(); - - context.prepareUpsert("update project_branches set branch_type = 'BRANCH', updated_at=? where branch_type = 'SHORT' or branch_type = 'LONG'") - .setLong(1, now) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasks.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasks.java deleted file mode 100644 index 8e5d783221237e311be563cce5e03c430c5a9502..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasks.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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 MigrateSlbsAndLlbsToCommonTypeInCeTasks extends DataChange { - static final String TABLE = "ce_task_characteristics"; - - public MigrateSlbsAndLlbsToCommonTypeInCeTasks(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("update " + TABLE + " set text_value = 'BRANCH' where kee = 'branchType' and text_value in ('LONG', 'SHORT')") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/PopulateExcludeBranchFromPurgeColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/PopulateExcludeBranchFromPurgeColumn.java deleted file mode 100644 index 6474a9e38339d4a953f0597dd938ab79ab209bd9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/PopulateExcludeBranchFromPurgeColumn.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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; - -@SupportsBlueGreen -public class PopulateExcludeBranchFromPurgeColumn extends DataChange { - private final System2 system; - - public PopulateExcludeBranchFromPurgeColumn(Database db, System2 system) { - super(db); - this.system = system; - } - - @Override - public void execute(Context context) throws SQLException { - Long now = system.now(); - context.prepareUpsert("update project_branches set exclude_from_purge = ?, updated_at = ? where branch_type = ?") - .setBoolean(1, true) - .setLong(2, now) - .setString(3, "LONG") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java deleted file mode 100644 index 0857f2cf101f1972386e3c561536a89b5aa428f8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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 RemoveLLBRegexSetting extends DataChange { - - public RemoveLLBRegexSetting(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("delete from properties where prop_key='sonar.branch.longLivedBranches.regex'") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsProperty.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsProperty.java deleted file mode 100644 index 7bcdf01d684134dd7920173edfb239a0ab6512ef..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsProperty.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class RemoveNewsboxDismissHotspotsProperty extends DataChange { - - public RemoveNewsboxDismissHotspotsProperty(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("delete from user_properties where kee='newsbox.dismiss.hotspots'") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSetting.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSetting.java deleted file mode 100644 index d6be247387fbcd1268637e7d41428c204c88a2ef..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSetting.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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 RenameDaysBeforeDeletingInactiveSLBSetting extends DataChange { - static final String TABLE = "properties"; - static final String OLD_PROPERTY_NAME = "sonar.dbcleaner.daysBeforeDeletingInactiveShortLivingBranches"; - static final String NEW_PROPERTY_NAME = "sonar.dbcleaner.daysBeforeDeletingInactiveBranchesAndPRs"; - - public RenameDaysBeforeDeletingInactiveSLBSetting(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("update " + TABLE + " set prop_key='" + NEW_PROPERTY_NAME + "' where prop_key='" + OLD_PROPERTY_NAME + "'") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/package-info.java deleted file mode 100644 index 9150f9723b2313b48a8332692095aac461a957c7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v81; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/AddIndexOnSlugOfProjectAlmSettings.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/AddIndexOnSlugOfProjectAlmSettings.java deleted file mode 100644 index cfa57b122dd0e1d95af0f3674019b4e56278b15a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/AddIndexOnSlugOfProjectAlmSettings.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnSlugOfProjectAlmSettings extends DdlChange { - - private static final String TABLE_NAME = "project_alm_settings"; - private static final String INDEX_NAME = "project_alm_settings_slug"; - - public AddIndexOnSlugOfProjectAlmSettings(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - return; - } - - CreateIndexBuilder builder = new CreateIndexBuilder() - .setTable(TABLE_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("alm_slug") - .setIsNullable(true) - .setLimit(256) - .build()) - .setName(INDEX_NAME) - .setUnique(false); - - context.execute(builder.build()); - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/CreateAlmPatsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/CreateAlmPatsTable.java deleted file mode 100644 index 4cd963d865db347a50fd39bc95a5fa4419016d42..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/CreateAlmPatsTable.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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 CreateAlmPatsTable extends DdlChange { - - private static final String TABLE_NAME = "alm_pats"; - - private static final VarcharColumnDef userUuidColumn = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(false) - .setLimit(256) - .build(); - - private static final VarcharColumnDef alm_setting_uuid = newVarcharColumnDefBuilder() - .setColumnName("alm_setting_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - - public CreateAlmPatsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("pat") - .setIsNullable(false) - .setLimit(2000) - .build()) - .addColumn(userUuidColumn) - .addColumn(alm_setting_uuid) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .addColumn(userUuidColumn) - .addColumn(alm_setting_uuid) - .setName("uniq_alm_pats") - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/CreateProjectsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/CreateProjectsTable.java deleted file mode 100644 index 488da0ba18be17d84ddc3e1fc524b1adcd783372..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/CreateProjectsTable.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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.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.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 CreateProjectsTable extends DdlChange { - - private static final String TABLE_NAME = "projects"; - - private static final VarcharColumnDef UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef KEE_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(false) - .setLimit(400) - .build(); - private static final VarcharColumnDef QUALIFIER_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("qualifier") - .setIsNullable(false) - .setLimit(10) - .build(); - private static final VarcharColumnDef ORGANIZATION_UUID_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - private static final VarcharColumnDef NAME_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("name") - .setLimit(2000) - .build(); - private static final VarcharColumnDef DESCRIPTION_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("description") - .setLimit(2000) - .build(); - private static final BooleanColumnDef PRIVATE_COLUMN = newBooleanColumnDefBuilder() - .setColumnName("private") - .setIsNullable(false) - .build(); - private static final VarcharColumnDef TAGS_COLUMN = newVarcharColumnDefBuilder() - .setColumnName("tags") - .setLimit(500) - .build(); - private static final BigIntegerColumnDef CREATED_AT = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(true) - .build(); - private static final BigIntegerColumnDef UPDATED_AT = newBigIntegerColumnDefBuilder() - .setColumnName("updated_at") - .setIsNullable(false) - .build(); - - public CreateProjectsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .withPkConstraintName("pk_new_projects") - .addPkColumn(UUID_COLUMN) - .addColumn(KEE_COLUMN) - .addColumn(QUALIFIER_COLUMN) - .addColumn(ORGANIZATION_UUID_COLUMN) - .addColumn(NAME_COLUMN) - .addColumn(DESCRIPTION_COLUMN) - .addColumn(PRIVATE_COLUMN) - .addColumn(TAGS_COLUMN) - .addColumn(CREATED_AT) - .addColumn(UPDATED_AT) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("uniq_projects_kee") - .setUnique(true) - .addColumn(KEE_COLUMN) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("idx_qualifier") - .addColumn(QUALIFIER_COLUMN) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java deleted file mode 100644 index 475899465d7e841279e772ebd2720af86f95e304..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion82 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(3200, "Drop 'In Review' Security Hotspots status ", DropSecurityHotSpotsInReviewStatus.class) - .add(3201, "Migrate Manual Vulnerabilities to Security Hotspots ", MigrateManualVulnerabilitiesToSecurityHotSpots.class) - .add(3202, "Remove 'newsbox.dismiss.hotspots' user property", RemoveNewsboxDismissHotspotsProperty.class) - .add(3203, "Ensure Security Hotspots have status TO_REVIEW", EnsureHotspotDefaultStatusIsToReview.class) - .add(3204, "Rename table 'PROJECTS' to 'COMPONENTS'", RenameProjectsTableToComponents.class) - .add(3205, "Add PROJECTS table", CreateProjectsTable.class) - .add(3206, "Populate PROJECTS table", PopulateProjectsTable.class) - .add(3207, "Drop 'TAGS' column from COMPONENTS table", DropTagsColumnFromComponentsTable.class) - .add(3209, "Create ALM_PATS table", CreateAlmPatsTable.class) - .add(3210, "Add index on ALM_slug", AddIndexOnSlugOfProjectAlmSettings.class) - .add(3211, "Delete conditions using 'security_hotspots' and 'new_security_hotspots' metrics", DeleteQgateConditionsUsingSecurityHotspotMetrics.class) - .add(3212, "Remove old Security Review Rating LiveMeasures", DeleteSecurityReviewRatingLiveMeasures.class) - - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetrics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetrics.java deleted file mode 100644 index 724d9bcbd6c1619b32abde8bef7d004e9da0349e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetrics.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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 DeleteQgateConditionsUsingSecurityHotspotMetrics extends DataChange { - - public DeleteQgateConditionsUsingSecurityHotspotMetrics(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select qgc.id from quality_gate_conditions qgc " + - " inner join metrics m on m.id = qgc.metric_id and " + - " m.name in ('security_hotspots', 'new_security_hotspots')"); - massUpdate.update("delete from quality_gate_conditions where id = ?"); - massUpdate.execute((row, handler) -> { - handler.setLong(1, row.getLong(1)); - return true; - }); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasures.java deleted file mode 100644 index 4808e77bb89b44cd2c02f0dfdc333c73549d747d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasures.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import javax.annotation.Nullable; -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 DeleteSecurityReviewRatingLiveMeasures extends DataChange { - - private static final String SECURITY_REVIEW_RATING_METRIC_KEY = "security_review_rating"; - private static final String SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY = "security_review_rating_effort"; - - public DeleteSecurityReviewRatingLiveMeasures(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - Integer reviewRatingId = getMetricId(context, SECURITY_REVIEW_RATING_METRIC_KEY); - Integer reviewRatingEffortId = getMetricId(context, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - deleteMetricFromLiveMeasures(context, reviewRatingId); - deleteMetricFromLiveMeasures(context, reviewRatingEffortId); - } - - @Nullable - private static Integer getMetricId(Context context, String metricName) throws SQLException { - return context.prepareSelect("select id from metrics where name = ?") - .setString(1, metricName) - .get(row -> row.getNullableInt(1)); - } - - private static void deleteMetricFromLiveMeasures(Context context, @Nullable Integer metricId) throws SQLException { - if (metricId == null) { - return; - } - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select lm.uuid from live_measures lm inner join components c on lm.component_uuid = c.uuid and lm.metric_id = ?") - .setInt(1, metricId); - massUpdate.update("delete from live_measures where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatus.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatus.java deleted file mode 100644 index 61914b444385420457eb44909632c0877c95403e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatus.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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 DropSecurityHotSpotsInReviewStatus extends DataChange { - - private System2 system; - - public DropSecurityHotSpotsInReviewStatus(Database db, System2 system) { - super(db); - this.system = system; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id,kee from issues where status = 'IN_REVIEW'"); - massUpdate.update("update issues set status = 'TO_REVIEW' where id = ? and status = 'IN_REVIEW'"); - massUpdate.update("insert into issue_changes(issue_key, change_type, change_data, created_at, updated_at, issue_change_creation_date) " + - "VALUES(?, 'diff', 'status=IN_REVIEW|TO_REVIEW', ?, ?, ?)"); - massUpdate.execute((row, update, updateIndex) -> { - - if (updateIndex == 0) { - update.setLong(1, row.getLong(1)); - } else if (updateIndex == 1) { - long currentTime = system.now(); - update.setString(1, row.getString(2)) - .setLong(2, currentTime) - .setLong(3, currentTime) - .setLong(4, currentTime); - } - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTable.java deleted file mode 100644 index 24e1a4419d95c8002b08fae1234591183745b7f4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTable.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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 DropTagsColumnFromComponentsTable extends DdlChange { - - static final String TABLE = "components"; - static final String[] COLUMNS_TO_DROP = new String[] {"tags", "developer_uuid", "authorization_updated_at"}; - - public DropTagsColumnFromComponentsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE, COLUMNS_TO_DROP).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReview.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReview.java deleted file mode 100644 index f4437c6e642552bb30e6b5b73ebe65b44a2e74ba..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReview.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import org.sonar.api.rules.RuleType; -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 org.sonar.api.issue.Issue.STATUS_OPEN; -import static org.sonar.api.issue.Issue.STATUS_TO_REVIEW; - -public class EnsureHotspotDefaultStatusIsToReview extends DataChange { - public EnsureHotspotDefaultStatusIsToReview(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select id from issues where issue_type = ? and status = ?") - .setInt(1, RuleType.SECURITY_HOTSPOT.getDbConstant()) - .setString(2, STATUS_OPEN); - massUpdate.update("update issues set status = ? where id = ?"); - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - update.setString(1, STATUS_TO_REVIEW); - update.setLong(2, id); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpots.java deleted file mode 100644 index bb352a659475b69efd0a652448b750fae3730c31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpots.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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 static org.sonar.api.issue.Issue.STATUS_TO_REVIEW; -import static org.sonar.api.rules.RuleType.VULNERABILITY; - -public class MigrateManualVulnerabilitiesToSecurityHotSpots extends DataChange { - private System2 system; - - public MigrateManualVulnerabilitiesToSecurityHotSpots(Database db, System2 system) { - super(db); - this.system = system; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate updateIssues = context.prepareMassUpdate(); - updateIssues.select("select id, kee, project_uuid, component_uuid from issues where from_hotspot = ? and issue_type = ?") - .setBoolean(1, true) - .setInt(2, 3); - updateIssues.update("update issues set issue_type = ?, status = ? where id = ? and from_hotspot = ? and issue_type = ?"); - updateIssues.update("insert into issue_changes(issue_key, change_type, change_data, created_at, updated_at, issue_change_creation_date) " + - "VALUES(?, ?, ?, ?, ?, ?)"); - - updateIssues.execute((row, update, updateIndex) -> { - if (updateIndex == 0) { - update.setInt(1, 4) - .setString(2, STATUS_TO_REVIEW) - .setLong(3, row.getLong(1)) - .setBoolean(4, true) - .setInt(5, VULNERABILITY.getDbConstant()); - } else if (updateIndex == 1) { - long currentTime = system.now(); - update.setString(1, row.getString(2)) - .setString(2, "diff") - .setString(3, "type=VULNERABILITY|SECURITY_HOTSPOT,status=OPEN|TO_REVIEW") - .setLong(4, currentTime) - .setLong(5, currentTime) - .setLong(6, currentTime); - } - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTable.java deleted file mode 100644 index b89b46b3371d1a74be4f4aeddf09f7886ad28439..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTable.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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; - -@SupportsBlueGreen -public class PopulateProjectsTable extends DataChange { - private final System2 system; - - public PopulateProjectsTable(Database db, System2 system) { - super(db); - this.system = system; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select cp.uuid, cp.kee, cp.qualifier, cp.organization_uuid, cp.name, cp.description, cp.private, cp.tags, cp.created_at " + - "from components cp " + - "left join projects np on np.uuid = cp.uuid " + - "where cp.scope = 'PRJ' and cp.qualifier in ('TRK', 'APP') and cp.main_branch_project_uuid is null and np.uuid is null"); - massUpdate.rowPluralName("projects"); - massUpdate.update("insert into projects (uuid, kee, qualifier, organization_uuid, name, description, private, tags, created_at, updated_at) " + - "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - update.setString(2, row.getString(2)); - update.setString(3, row.getString(3)); - update.setString(4, row.getString(4)); - update.setString(5, row.getNullableString(5)); - update.setString(6, row.getNullableString(6)); - update.setBoolean(7, row.getBoolean(7)); - update.setString(8, row.getNullableString(8)); - Date createdAtDate = row.getNullableDate(9); - update.setLong(9, createdAtDate != null ? createdAtDate.getTime() : null); - update.setLong(10, system.now()); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsProperty.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsProperty.java deleted file mode 100644 index fb64d412c0f8b36378ec4cb160e712c3cb6c81bf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsProperty.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class RemoveNewsboxDismissHotspotsProperty extends DataChange { - - public RemoveNewsboxDismissHotspotsProperty(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("delete from user_properties where kee='newsbox.dismiss.hotspots'") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponents.java deleted file mode 100644 index dffc71544a3e9bfc1176c229bcd8f6c2b414ae60..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponents.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class RenameProjectsTableToComponents extends DdlChange { - public RenameProjectsTableToComponents(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new RenameTableBuilder(getDialect()).setName("projects").setNewName("components").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/package-info.java deleted file mode 100644 index ea0fd57ccf1f0510f337b6106f649a021819371a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v82; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/AddSummaryEnabledColumnToAlmSettings.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/AddSummaryEnabledColumnToAlmSettings.java deleted file mode 100644 index fde0f229578502fff5c079e6927bcd0a7f06116c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/AddSummaryEnabledColumnToAlmSettings.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83; - -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; - -import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddSummaryEnabledColumnToAlmSettings extends DdlChange { - private static final String TABLE = "project_alm_settings"; - private static final String NEW_COLUMN = "summary_comment_enabled"; - - private static final BooleanColumnDef SUMMARY_COMMENT_ENABLED = newBooleanColumnDefBuilder() - .setColumnName(NEW_COLUMN) - .setIsNullable(true) - .setDefaultValue(null) - .build(); - - public AddSummaryEnabledColumnToAlmSettings(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(SUMMARY_COMMENT_ENABLED) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java deleted file mode 100644 index 0722bc53b96df4d7c9cb0d5b790dffc3bb3dc632..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; -import org.sonar.server.platform.db.migration.version.v83.grouproles.AddComponentUuidColumnToGroupRoles; -import org.sonar.server.platform.db.migration.version.v83.grouproles.DropResourceIdFromGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v83.grouproles.MigrateResourceIdToUuidInGroupRoles; -import org.sonar.server.platform.db.migration.version.v83.properties.AddComponentUuidColumnToProperties; -import org.sonar.server.platform.db.migration.version.v83.properties.DropResourceIdFromPropertiesTable; -import org.sonar.server.platform.db.migration.version.v83.properties.MigrateResourceIdToUuidInProperties; -import org.sonar.server.platform.db.migration.version.v83.userroles.AddComponentUuidColumnToUserRoles; -import org.sonar.server.platform.db.migration.version.v83.userroles.DropResourceIdFromUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.userroles.MigrateResourceIdToUuidInUserRoles; - -public class DbVersion83 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(3300, "Add 'summary_comment_enabled' boolean column to 'project_alm_settings'", AddSummaryEnabledColumnToAlmSettings.class) - .add(3301, "Enable 'summary_comment_enabled' for GitHub based projects", PopulateSummaryCommentEnabledColumnForGitHub.class) - .add(3302, "Add 'component_uuid' column to 'properties'", AddComponentUuidColumnToProperties.class) - .add(3303, "Migrate 'resource_id' to 'component_uuid' in 'properties'", MigrateResourceIdToUuidInProperties.class) - .add(3304, "Remove column 'resource_id' in 'properties'", DropResourceIdFromPropertiesTable.class) - .add(3305, "Add 'component_uuid' column to 'group_roles'", AddComponentUuidColumnToGroupRoles.class) - .add(3306, "Migrate 'resource_id' to 'component_uuid' in 'group_roles'", MigrateResourceIdToUuidInGroupRoles.class) - .add(3307, "Remove column 'resource_id' in 'group_roles'", DropResourceIdFromGroupRolesTable.class) - .add(3308, "Add 'component_uuid' column to 'user_roles'", AddComponentUuidColumnToUserRoles.class) - .add(3309, "Migrate 'resource_id' to 'component_uuid' in 'user_roles'", MigrateResourceIdToUuidInUserRoles.class) - .add(3310, "Remove column 'resource_id' in 'user_roles'", DropResourceIdFromUserRolesTable.class) - .add(3311, "Remove column 'id' in 'components'", DropIdFromComponentsTable.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java deleted file mode 100644 index adc93ac9486c9f1502b90e4622805dd08348eb87..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83; - -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.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdFromComponentsTable extends DdlChange { - - static final String TABLE_NAME = "components"; - static final String COLUMN_NAME = "id"; - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropIdFromComponentsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, COLUMN_NAME, true)); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, COLUMN_NAME).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHub.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHub.java deleted file mode 100644 index 64adb04b5cf94528829d7a9d4ee7c9bb02f24209..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHub.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83; - -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 PopulateSummaryCommentEnabledColumnForGitHub extends DataChange { - - private final System2 system; - - public PopulateSummaryCommentEnabledColumnForGitHub(Database db, System2 system) { - super(db); - this.system = system; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from alm_settings where alm_id = ? ") - .setString(1, "github"); - massUpdate.update("update project_alm_settings set summary_comment_enabled = ?, updated_at = ? where alm_setting_uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setBoolean(1, true) - .setLong(2, system.now()) - .setString(3, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRoles.java deleted file mode 100644 index a0a404e95e79d5d01d9d7a82bd0ffb62f483f683..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRoles.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.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; - -public class AddComponentUuidColumnToGroupRoles extends DdlChange { - private static final String TABLE = "group_roles"; - private static final String NEW_COLUMN = "component_uuid"; - private static final String INDEX1 = "group_roles_component_uuid"; - - public AddComponentUuidColumnToGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName(NEW_COLUMN) - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(column) - .build()); - - CreateIndexBuilder index1 = new CreateIndexBuilder() - .setTable(TABLE) - .addColumn(column) - .setName(INDEX1) - .setUnique(false); - context.execute(index1.build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTable.java deleted file mode 100644 index 9b3e9d98f329ceabc8f6fa825166b4715f773ed0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.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.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 DropResourceIdFromGroupRolesTable extends DdlChange { - - static final String TABLE = "group_roles"; - static final String COLUMN = "resource_id"; - static final String INDEX = "uniq_group_roles"; - - - public DropResourceIdFromGroupRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE).setName(INDEX).build()); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE).setName("group_roles_resource").build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE, COLUMN).build()); - - CreateIndexBuilder index = new CreateIndexBuilder() - .setTable(TABLE) - .addColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(VarcharColumnDef.UUID_SIZE).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("group_id").build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(VarcharColumnDef.UUID_SIZE).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("role").setLimit(64).build()) - .setName(INDEX) - .setUnique(true); - context.execute(index.build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRoles.java deleted file mode 100644 index 8c234d71508c41280fe0e621fd77470703d74ff6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRoles.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class MigrateResourceIdToUuidInGroupRoles extends DataChange { - public MigrateResourceIdToUuidInGroupRoles(Database db) { - super(db); - } - - @Override protected void execute(Context context) throws SQLException { - // remove roles associated with invalid resource - context.prepareUpsert("delete from group_roles " - + "where group_roles.resource_id is not null and not exists (select 1 from components c where group_roles.resource_id = c.id)") - .execute(); - - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select gp.id as gp_id, c.uuid as c_uuid from group_roles gp, components c where gp.resource_id = c.id and gp.component_uuid is null"); - massUpdate.update("update group_roles set component_uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - String componentUuid = row.getString(2); - Long propertyId = row.getLong(1); - - update.setString(1, componentUuid) - .setLong(2, propertyId); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/package-info.java deleted file mode 100644 index 9efc7fb4e7f7740afbb5f217fd71c75ad22a6a03..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/package-info.java deleted file mode 100644 index 3155e0776d31bde50ada8c11062bc0d7deea6e91..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v83; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToProperties.java deleted file mode 100644 index 192145a2ba5e5f50fa682ed41122c5dd94696c57..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToProperties.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.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 AddComponentUuidColumnToProperties extends DdlChange { - private static final String TABLE = "properties"; - private static final String NEW_COLUMN = "component_uuid"; - - public AddComponentUuidColumnToProperties(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName(NEW_COLUMN) - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(column) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTable.java deleted file mode 100644 index fe5f932399b46daef82efe5f9cde96bd726b2e1f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTable.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropResourceIdFromPropertiesTable extends DdlChange { - - static final String TABLE = "properties"; - static final String COLUMN = "resource_id"; - - public DropResourceIdFromPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE, COLUMN).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInProperties.java deleted file mode 100644 index 93f8559248aad16bccd20f9999b26f7bd4f803a9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInProperties.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class MigrateResourceIdToUuidInProperties extends DataChange { - public MigrateResourceIdToUuidInProperties(Database db) { - super(db); - } - - @Override protected void execute(Context context) throws SQLException { - // remove properties associated with invalid resource - context.prepareUpsert("delete from properties where properties.resource_id is not null and not exists (select 1 from components c where properties.resource_id = c.id)") - .execute(); - - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select p.id as p_id, c.uuid as c_uuid from properties p, components c where p.resource_id = c.id and p.component_uuid is null"); - massUpdate.update("update properties set component_uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - String componentUuid = row.getString(2); - Long propertyId = row.getLong(1); - - update.setString(1, componentUuid) - .setLong(2, propertyId); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/package-info.java deleted file mode 100644 index ab461aa525811aeae9b656975bc97c5d4e1cff5f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v83.properties; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRoles.java deleted file mode 100644 index d3206237b0842d1c1d657e6242f4b9af9287dcc7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRoles.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.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; - -public class AddComponentUuidColumnToUserRoles extends DdlChange { - private static final String TABLE = "user_roles"; - private static final String NEW_COLUMN = "component_uuid"; - private static final String INDEX = "user_roles_component_uuid"; - - public AddComponentUuidColumnToUserRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef column = newVarcharColumnDefBuilder() - .setColumnName(NEW_COLUMN) - .setLimit(VarcharColumnDef.UUID_SIZE) - .setIsNullable(true) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(column) - .build()); - - CreateIndexBuilder index = new CreateIndexBuilder() - .setTable(TABLE) - .addColumn(column) - .setName(INDEX) - .setUnique(false); - context.execute(index.build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropResourceIdFromUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropResourceIdFromUserRolesTable.java deleted file mode 100644 index 8e547ad14dabb87e32aa49ced81b90bdb1032ccd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropResourceIdFromUserRolesTable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropResourceIdFromUserRolesTable extends DdlChange { - - static final String TABLE = "user_roles"; - static final String COLUMN = "resource_id"; - - public DropResourceIdFromUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE).setName("user_roles_resource").build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE, COLUMN).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRoles.java deleted file mode 100644 index 6b5f3321dff2e42e11e5791f9a09ad3b45a9dfce..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRoles.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class MigrateResourceIdToUuidInUserRoles extends DataChange { - public MigrateResourceIdToUuidInUserRoles(Database db) { - super(db); - } - - @Override protected void execute(Context context) throws SQLException { - // remove roles associated with invalid resource - context.prepareUpsert( - "delete from user_roles where user_roles.resource_id is not null and not exists (select 1 from components c where user_roles.resource_id = c.id)") - .execute(); - - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ur.id as ur_id, c.uuid as c_uuid from user_roles ur, components c where ur.resource_id = c.id and ur.component_uuid is null"); - massUpdate.update("update user_roles set component_uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - String componentUuid = row.getString(2); - Long id = row.getLong(1); - - update.setString(1, componentUuid) - .setLong(2, id); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/package-info.java deleted file mode 100644 index 72a860e74c1248bedd164f235e1c1e16556f68fa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSync.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSync.java deleted file mode 100644 index ba7eb7ff7dc16140a04770d03110a53599a3b4b7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSync.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import 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 AddProjectBranchesNeedIssueSync extends DdlChange { - public AddProjectBranchesNeedIssueSync(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "project_branches") - .addColumn(BooleanColumnDef.newBooleanColumnDefBuilder() - .setColumnName("need_issue_sync") - .setIsNullable(true) - .setDefaultValue(null) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/CreateSamlMessageIdsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/CreateSamlMessageIdsTable.java deleted file mode 100644 index 94c27282ddc451069503047744b7e0555603c61d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/CreateSamlMessageIdsTable.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import 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; - -public class CreateSamlMessageIdsTable extends DdlChange { - - private static final String TABLE_NAME = "saml_message_ids"; - private static final VarcharColumnDef MESSAGE_ID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("message_id") - .setLimit(255) - .setIsNullable(false) - .build(); - - public CreateSamlMessageIdsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .build()) - .addColumn(MESSAGE_ID_COLUMN) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("expiration_date") - .setIsNullable(false) - .build()) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build()) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("saml_message_ids_unique") - .addColumn(MESSAGE_ID_COLUMN) - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/CreateSessionTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/CreateSessionTokensTable.java deleted file mode 100644 index c015b04bd635b3898c9b4955f42a8011c1a89ed0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/CreateSessionTokensTable.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import 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.USER_UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; - -public class CreateSessionTokensTable extends DdlChange { - - private static final String TABLE_NAME = "session_tokens"; - private static final VarcharColumnDef USER_UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(USER_UUID_SIZE) - .setIsNullable(false) - .build(); - - public CreateSessionTokensTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setLimit(UUID_SIZE) - .setIsNullable(false) - .build()) - .addColumn(USER_UUID_COLUMN) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("expiration_date") - .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("session_tokens_user_uuid") - .addColumn(USER_UUID_COLUMN) - .setUnique(false) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84.java deleted file mode 100644 index d08316d59a92ef2a56a65ee68acc1fdf2199ac09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84.java +++ /dev/null @@ -1,798 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; -import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.AddUuidColumnToActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.DropIdColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.MakeActiveRuleParametersUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.PopulateActiveRuleParametersUuid; -import org.sonar.server.platform.db.migration.version.v84.activerules.AddActiveRuleUuidColumnToActiveRuleParameters; -import org.sonar.server.platform.db.migration.version.v84.activerules.AddIndexOnActiveRuleUuidOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v84.activerules.AddPrimaryKeyOnUuidColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.activerules.AddUuidColumnToActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.activerules.DropActiveRuleIdColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v84.activerules.DropIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.activerules.DropIndexOnActiveRuleIdOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v84.activerules.DropPrimaryKeyOnIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.activerules.MakeActiveRuleParametersActiveRuleUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v84.activerules.MakeActiveRulesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.activerules.PopulateActiveRuleParametersActiveRuleUuid; -import org.sonar.server.platform.db.migration.version.v84.activerules.PopulateActiveRulesUuid; -import org.sonar.server.platform.db.migration.version.v84.alm.AddClientIdAndClientSecretColumns; -import org.sonar.server.platform.db.migration.version.v84.ceactivity.AddPrimaryKeyOnUuidColumnOfCeActivityTable; -import org.sonar.server.platform.db.migration.version.v84.ceactivity.DropIdColumnOfCeActivityTable; -import org.sonar.server.platform.db.migration.version.v84.ceactivity.DropPrimaryKeyOnIdColumnOfCeActivityTable; -import org.sonar.server.platform.db.migration.version.v84.cequeue.AddPrimaryKeyOnUuidColumnOfCeQueueTable; -import org.sonar.server.platform.db.migration.version.v84.cequeue.DropIdColumnOfCeQueueTable; -import org.sonar.server.platform.db.migration.version.v84.cequeue.DropPrimaryKeyOnIdColumnOfCeQueueTable; -import org.sonar.server.platform.db.migration.version.v84.cequeue.DropUniqueIndexOnUuidColumnOfCeQueueTable; -import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable; -import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.AddUuidToDuplicationsIndexTable; -import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.DropIdColumnOfDuplicationsIndexTable; -import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable; -import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.MakeDuplicationsIndexUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.PopulateDuplicationsIndexUuid; -import org.sonar.server.platform.db.migration.version.v84.events.AddPrimaryKeyOnUuidColumnOfEventsTable; -import org.sonar.server.platform.db.migration.version.v84.events.DropIdColumnOfEventsTable; -import org.sonar.server.platform.db.migration.version.v84.events.DropPrimaryKeyOnIdColumnOfEventsTable; -import org.sonar.server.platform.db.migration.version.v84.filesources.AddPrimaryKeyOnUuidColumnOfFileSourcesTable; -import org.sonar.server.platform.db.migration.version.v84.filesources.AddUuidColumnToFileSourcesTable; -import org.sonar.server.platform.db.migration.version.v84.filesources.DropIdColumnOfFileSourcesTable; -import org.sonar.server.platform.db.migration.version.v84.filesources.DropPrimaryKeyOnIdColumnOfFileSourcesTable; -import org.sonar.server.platform.db.migration.version.v84.filesources.MakeFileSourcesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.filesources.PopulateFileSourcesUuid; -import org.sonar.server.platform.db.migration.version.v84.grouproles.AddPrimaryKeyOnUuidColumnOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v84.grouproles.AddUuidColumnToGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v84.grouproles.DropIdColumnOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v84.grouproles.DropPrimaryKeyOnIdColumnOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v84.grouproles.MakeGroupRolesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.grouproles.PopulateGroupRolesUuid; -import org.sonar.server.platform.db.migration.version.v84.groups.AddPrimaryKeyOnUuidColumnOfGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.AddUuidColumnToGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.DropIdColumnOfGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.DropPrimaryKeyOnIdColumnOfGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.MakeGroupsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.groups.PopulateGroupsUuid; -import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.AddGroupUuidColumnToGroupRoles; -import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.AddIndexOnGroupUuidOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.DropGroupIdColumnOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.DropIndexOnGroupIdOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.PopulateGroupRolesGroupUuid; -import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.AddGroupUuidColumnToGroupsUsers; -import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.AddIndexOnGroupUuidOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.DropGroupIdColumnOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.DropIndexOnGroupIdOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.MakeGroupsUsersGroupUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.PopulateGroupsUsersGroupUuid; -import org.sonar.server.platform.db.migration.version.v84.groups.organizations.AddDefaultGroupUuidColumnToOrganizations; -import org.sonar.server.platform.db.migration.version.v84.groups.organizations.DropDefaultGroupIdColumnOfOrganizationsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.organizations.PopulateOrganizationsDefaultGroupUuid; -import org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups.AddGroupUuidColumnToPermTemplatesGroups; -import org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups.DropGroupIdColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups.PopulatePermTemplatesGroupsGroupUuid; -import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.AddGroupUuidColumnToQProfileEditGroups; -import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.AddIndexOnGroupUuidOfQProfileEditGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.DropGroupIdColumnOfQProfileEditGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.DropIndexOnGroupIdOfQProfileEditGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.MakeQProfileEditGroupsGroupUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.PopulateQProfileEditGroupsGroupUuid; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.AddIndexOnIssueKeyOfIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.AddIndexOnKeeOfIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.AddPrimaryKeyOnUuidColumnOfIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.CopyIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.DropIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.RenameIssueChangesCopyToIssueChanges; -import org.sonar.server.platform.db.migration.version.v84.issues.AddPrimaryKeyOnKeeColumnOfIssuesTable; -import org.sonar.server.platform.db.migration.version.v84.manualmeasures.AddPrimaryKeyOnUuidColumnOfManualMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.manualmeasures.AddUuidColumnToManualMeasures; -import org.sonar.server.platform.db.migration.version.v84.manualmeasures.DropIdColumnOfManualMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.manualmeasures.DropPrimaryKeyOnIdColumnOfManualMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.manualmeasures.MakeManualMeasuresUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.manualmeasures.PopulateManualMeasureUuid; -import org.sonar.server.platform.db.migration.version.v84.metrics.AddPrimaryKeyOnUuidColumnOfMetricsTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.AddUuidColumnToMetricsTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.DropIdColumnOfMetricsTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.DropPrimaryKeyOnIdColumnOfMetricsTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.MakeMetricsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.metrics.PopulateMetricsUuid; -import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.AddIndexOnMetricUuidOfLiveMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.AddIndexOnProjectUuidOfLiveMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.AddPKeyOnUuidOfLiveMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.CopyLiveMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.DropLiveMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.RenameLiveMeasuresCopyToLiveMeasures; -import org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures.AddMetricUuidColumnToManualMeasures; -import org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures.DropMetricIdColumnOfManualMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures.MakeManualMeasuresMetricUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures.PopulateManualMeasuresMetricUuid; -import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.AddIndexOnMetricUuidOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.AddMetricUuidColumnToProjectMeasures; -import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.DeleteSecurityReviewRatingProjectMeasures; -import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.DropIndexOnMetricIdOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.DropMetricIdColumnOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.MakeProjectMeasuresMetricUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.PopulateProjectMeasuresMetricUuid; -import org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions.AddMetricUuidColumnToQualityGateConditions; -import org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions.DropMetricIdColumnOfQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions.MakeQualityGateConditionsMetricUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions.PopulateQualityGateConditionsMetricUuid; -import org.sonar.server.platform.db.migration.version.v84.notifications.AddPrimaryKeyOnUuidColumnOfNotificationTable; -import org.sonar.server.platform.db.migration.version.v84.notifications.AddUuidAndCreatedAtColumnsToNotification; -import org.sonar.server.platform.db.migration.version.v84.notifications.DropIdColumnOfNotificationTable; -import org.sonar.server.platform.db.migration.version.v84.notifications.DropPrimaryKeyOnIdColumnOfNotificationTable; -import org.sonar.server.platform.db.migration.version.v84.notifications.MakeNotificationUuidAndCreatedAtColumnsNotNullable; -import org.sonar.server.platform.db.migration.version.v84.notifications.PopulateNotificationUuidAndCreatedAt; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.AddUuidColumnToPermissionTemplates; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.DropIdColumnOfPermissionTemplatesTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.DropKeeColumnOfPermissionTemplatesTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.MakePermissionTemplateUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.PopulatePermissionTemplatesUuid; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups.AddTemplateUuidColumnToPermTemplatesGroups; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups.DropTemplateIdColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups.MakePermTemplatesGroupsTemplateUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups.PopulatePermTemplatesGroupsTemplateUuidColumn; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers.AddTemplateUuidColumnToPermTemplatesUsers; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers.DropTemplateIdColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers.MakePermTemplatesUsersTemplateUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers.PopulatePermTemplatesUsersTemplateUuidColumn; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.AddTemplateUuidColumnToPermTplCharacteristics; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.DropTemplateIdColumnOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.MakePermTplCharacteristicsTemplateUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.PopulatePermTplCharacteristicsTemplateUuidColumn; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.AddUuidColumnToPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.DropIdColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.MakePermTemplatesGroupsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.PopulatePermTemplatesGroupsUuid; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.AddUuidColumnToPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.DropIdColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.MakePermTemplatesUsersUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.PopulatePermTemplatesUsersUuid; -import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.AddUuidColumnToPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.DropIdColumnOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.MakePermTplCharacteristicsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.PopulatePermTplCharacteristicsUuid; -import org.sonar.server.platform.db.migration.version.v84.projectmeasures.AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.projectmeasures.AddTechIndexOnUuidOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.projectmeasures.AddUuidColumnToProjectMeasures; -import org.sonar.server.platform.db.migration.version.v84.projectmeasures.DropIdColumnOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.projectmeasures.DropPrimaryKeyOnIdColumnOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.projectmeasures.DropTechIndexOnUuidOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v84.projectmeasures.MakeProjectMeasuresUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.projectmeasures.PopulateProjectMeasureUuid; -import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.AddUuidColumnToProjectQProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.DropIdColumnOfProjectQProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.DropPrimaryKeyOnIdColumnOfProjectQProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.MakeProjectQProfilesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.PopulateProjectQProfilesUuid; -import org.sonar.server.platform.db.migration.version.v84.properties.AddPrimaryKeyOnUuidColumnOfPropertiesTable; -import org.sonar.server.platform.db.migration.version.v84.properties.AddUuidColumnToProperties; -import org.sonar.server.platform.db.migration.version.v84.properties.DropIdColumnOfPropertiesTable; -import org.sonar.server.platform.db.migration.version.v84.properties.DropPrimaryKeyOnIdColumnOfPropertiesTable; -import org.sonar.server.platform.db.migration.version.v84.properties.MakePropertiesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.properties.PopulatePropertiesUuid; -import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.AddUuidColumnToQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.DropIdColumnOfQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.MakeQualityGateConditionsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.PopulateQualityGateConditionsUuid; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.AddPrimaryKeyOnUuidColumnOfQGatesTable; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.AddQGateUuidColumnForQGateConditions; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropIdColumnOfQGateTable; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropOrphansQGateConditions; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropPrimaryKeyOnIdColumnOfQGatesTable; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropQGateIdColumnForQGateConditions; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropUniqueIndexOnUuidColumnOfQualityGatesTable; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.MakeQGateUuidColumnNotNullableForQGateConditions; -import org.sonar.server.platform.db.migration.version.v84.qualitygates.PopulateQGateUuidColumnForQGateConditions; -import org.sonar.server.platform.db.migration.version.v84.rules.AddPrimaryKeyOnUuidColumnOfRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.AddUuidAndTemplateUuidColumnsToRules; -import org.sonar.server.platform.db.migration.version.v84.rules.DropIdColumnOfRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.DropPrimaryKeyOnIdColumnOfRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.DropTemplateIdColumnOfRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.MakeRulesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rules.PopulateRulesTemplateUuid; -import org.sonar.server.platform.db.migration.version.v84.rules.PopulateRulesUuid; -import org.sonar.server.platform.db.migration.version.v84.rules.activerules.AddIndexToActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.activerules.AddRuleUuidColumnToActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.activerules.DropIndexOnRuleIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.activerules.DropRuleIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.activerules.MakeActiveRulesRuleUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rules.activerules.PopulateActiveRulesRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.AddIndexToDeprecatedRuleKeysTable; -import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.AddRuleUuidColumnToDeprecatedRuleKeysTable; -import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable; -import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.DropRuleIdColumnOfDeprecatedRuleKeysTable; -import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.MakeDeprecatedRuleKeysRuleUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.PopulateDeprecatedRuleKeysRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v84.rules.issues.AddIndexesToIssuesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.issues.CopyIssuesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.issues.DropIssuesTable; -import org.sonar.server.platform.db.migration.version.v84.rules.issues.RenameIssuesCopyToIssues; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.AddRuleUuidColumnToRulesMetadataTable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.DropPrimaryKeyOnIdColumnOfRulesMetadataTable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.DropRuleIdColumnOfRulesMetadataTable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.MakeRulesMetadataRuleUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.PopulateRulesMetadataRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.AddIndexesToRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.AddRuleUuidColumnToRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.DropIndexesOnRuleIdColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.DropRuleIdColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.MakeRulesParametersRuleUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.PopulateRulesParametersRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.AddPrimaryKeyOnUuidColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.AddUuidColumnToRulesParameters; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.DropIdColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.DropPrimaryKeyOnIdColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.MakeRulesParametersUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.PopulateRulesParametersUuid; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk.AddRulesParameterUuidColumnToActiveRuleParameters; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk.DropRulesParameterIdColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk.MakeActiveRuleParametersRulesParameterUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk.PopulateActiveRuleParametersRulesParameterUuid; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.AddPrimaryKeyOnUuidColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.AddUuidColumnToRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.DropIdColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.DropKeeColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.DropPrimaryKeyOnIdColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.DropUniqueIndexOnKeeColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.MakeRulesProfilesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.PopulateRulesProfilesUuid; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.AddProfileUuidColumnToActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.DropProfileIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.DropUniqueIndexOnProfileIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.MakeActiveRulesProfileUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.PopulateActiveRulesProfileUuid; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.orgqprofiles.PopulateOrgQProfilesRulesProfileUuid; -import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.qprofilechanges.PopulateQProfileChangesRulesProfileUuid; -import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.AddPrimaryKeyOnUuidColumnOfSnapshotsTable; -import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropIdColumnOfSnapshotsTable; -import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable; -import org.sonar.server.platform.db.migration.version.v84.userroles.AddPrimaryKeyOnUuidColumnOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v84.userroles.AddUuidColumnToUserRolesTable; -import org.sonar.server.platform.db.migration.version.v84.userroles.DropIdColumnOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v84.userroles.DropPrimaryKeyOnIdColumnOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v84.userroles.MakeUserRolesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.userroles.PopulateUserRolesUuid; -import org.sonar.server.platform.db.migration.version.v84.users.AddPrimaryKeyOnUuidColumnOfUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.DropIdColumnOfUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.DropPrimaryKeyOnIdColumnOfUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.DropUniqueIndexOnUuidColumnOfUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.AddIndexOnUserUuidOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.AddUserUuidColumnToGroupsUsers; -import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.DropIndexOnUserIdOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.DropUserIdColumnOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.MakeGroupsUsersUserUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.PopulateGroupsUsersUserUuid; -import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.AddIndexOnUserUuidOfOrganizationMembersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.AddUserUuidColumnToOrganizationMembers; -import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.DropIndexOnUserIdOfOrganizationMembersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.DropUserIdColumnOfOrganizationMembersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.MakeOrganizationMembersUserUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.PopulateOrganizationMembersUserUuid; -import org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers.AddUserUuidColumnToPermTemplatesUsers; -import org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers.DropUserIdColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers.MakePermTemplatesUsersUserUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers.PopulatePermTemplatesUsersUserUuid; -import org.sonar.server.platform.db.migration.version.v84.users.fk.properties.AddUserUuidColumnToPropertiesUsers; -import org.sonar.server.platform.db.migration.version.v84.users.fk.properties.DropUserIdColumnOfPropertiesTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.properties.PopulatePropertiesUserUuid; -import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.AddUserUuidColumnToQProfileEditUsers; -import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.DropUserIdColumnOfQProfileEditUsersTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.MakeQProfileEditUsersUserUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.PopulateQProfileEditUsersUserUuid; -import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.AddIndexOnUserUuidOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.AddUserUuidColumnToUserRoles; -import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.DropIndexOnUserIdOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.DropUserIdColumnOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.PopulateUserRolesUserUuid; -import org.sonar.server.platform.db.migration.version.v84.usertokens.AddPrimaryKeyOnUuidColumnOfUserTokensTable; -import org.sonar.server.platform.db.migration.version.v84.usertokens.AddUuidColumnToUserTokens; -import org.sonar.server.platform.db.migration.version.v84.usertokens.DropIdColumnOfUserTokensTable; -import org.sonar.server.platform.db.migration.version.v84.usertokens.DropPrimaryKeyOnIdColumnOfUserTokensTable; -import org.sonar.server.platform.db.migration.version.v84.usertokens.MakeUserTokensUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v84.usertokens.PopulateUserTokensUuid; -import org.sonar.server.platform.db.migration.version.v85.AddIndexOnProjectUuidOnIssueChangesTable; - -public class DbVersion84 implements DbVersion { - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - // Migration on EVENTS table - .add(3400, "Drop primary key on 'ID' column of 'EVENTS' table", DropPrimaryKeyOnIdColumnOfEventsTable.class) - .add(3401, "Add primary key on 'UUID' column of 'EVENTS' table", AddPrimaryKeyOnUuidColumnOfEventsTable.class) - .add(3402, "Drop column 'ID' of 'EVENTS' table", DropIdColumnOfEventsTable.class) - - // Migrations of NOTIFICATIONS table - .add(3403, "Add 'uuid' and 'createdAt' columns for notifications", AddUuidAndCreatedAtColumnsToNotification.class) - .add(3404, "Populate 'uuid' and 'createdAt columns for notifications", PopulateNotificationUuidAndCreatedAt.class) - .add(3405, "Make 'uuid' and 'createdAt' column not nullable for notifications", MakeNotificationUuidAndCreatedAtColumnsNotNullable.class) - .add(3406, "Drop primary key on 'ID' column of 'NOTIFICATIONS' table", DropPrimaryKeyOnIdColumnOfNotificationTable.class) - .add(3407, "Add primary key on 'UUID' column of 'NOTIFICATIONS' table", AddPrimaryKeyOnUuidColumnOfNotificationTable.class) - .add(3408, "Drop column 'ID' of 'NOTIFICATIONS' table", DropIdColumnOfNotificationTable.class) - - // Migration on SNAPSHOTS table - .add(3409, "Drop primary key on 'ID' column of 'SNAPSHOTS' table", DropPrimaryKeyOnIdColumnOfSnapshotsTable.class) - .add(3410, "Add primary key on 'UUID' column of 'SNAPSHOTS' table", AddPrimaryKeyOnUuidColumnOfSnapshotsTable.class) - .add(3411, "Drop column 'ID' of 'SNAPSHOTS' table", DropIdColumnOfSnapshotsTable.class) - - // Migration on CE_QUEUE table - .add(3412, "Drop unique index on 'uuid' column of 'CE_QUEUE' table", DropUniqueIndexOnUuidColumnOfCeQueueTable.class) - .add(3413, "Drop primary key on 'ID' column of 'CE_QUEUE' table", DropPrimaryKeyOnIdColumnOfCeQueueTable.class) - .add(3414, "Add primary key on 'UUID' column of 'CE_QUEUE' table", AddPrimaryKeyOnUuidColumnOfCeQueueTable.class) - .add(3415, "Drop column 'ID' of 'CE_QUEUE' table", DropIdColumnOfCeQueueTable.class) - - // Migration on CE_ACTIVITY table - .add(3416, "Drop primary key on 'ID' column of 'CE_ACTIVITY' table", DropPrimaryKeyOnIdColumnOfCeActivityTable.class) - .add(3417, "Add primary key on 'UUID' column of 'CE_ACTIVITY' table", AddPrimaryKeyOnUuidColumnOfCeActivityTable.class) - .add(3418, "Drop column 'ID' of 'CE_ACTIVITY' table", DropIdColumnOfCeActivityTable.class) - - // Migration of DUPLICATIONS_INDEX table - .add(3419, "Add 'uuid' columns for DUPLICATIONS_INDEX", AddUuidToDuplicationsIndexTable.class) - .add(3420, "Populate 'uuid' columns for DUPLICATIONS_INDEX", PopulateDuplicationsIndexUuid.class) - .add(3421, "Make 'uuid' column not nullable for DUPLICATIONS_INDEX", MakeDuplicationsIndexUuidColumnNotNullable.class) - .add(3422, "Drop primary key on 'ID' column of 'DUPLICATIONS_INDEX' table", DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.class) - .add(3423, "Add primary key on 'UUID' column of 'DUPLICATIONS_INDEX' table", AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.class) - .add(3424, "Drop column 'ID' of 'DUPLICATIONS_INDEX' table", DropIdColumnOfDuplicationsIndexTable.class) - - // Migration of ACTIVE_RULE_PARAMS table - .add(3425, "Add 'uuid' column for 'ACTIVE_RULE_PARAMS' table", AddUuidColumnToActiveRuleParametersTable.class) - .add(3426, "Populate 'uuid' column for 'ACTIVE_RULE_PARAMS' table", PopulateActiveRuleParametersUuid.class) - .add(3427, "Make 'uuid' column not nullable for 'ACTIVE_RULE_PARAMS' table", MakeActiveRuleParametersUuidColumnNotNullable.class) - .add(3428, "Drop primary key on 'ID' column of 'ACTIVE_RULE_PARAMS' table", DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.class) - .add(3429, "Add primary key on 'UUID' column of 'ACTIVE_RULE_PARAMS' table", AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.class) - .add(3430, "Drop column 'ID' of 'ACTIVE_RULE_PARAMS' table", DropIdColumnOfActiveRuleParametersTable.class) - - // Migration on PROJECT_MEASURES table - .add(3431, "Add 'uuid' columns for 'PROJECT_MEASURES'", AddUuidColumnToProjectMeasures.class) - .add(3432, "Add tech index on 'group_uuid' column of 'PROJECT_MEASURES' table", AddTechIndexOnUuidOfProjectMeasuresTable.class) - .add(3433, "Populate 'uuid' column for 'PROJECT_MEASURES'", PopulateProjectMeasureUuid.class) - .add(3434, "Drop tech index on 'group_id' column of 'PROJECT_MEASURES' table", DropTechIndexOnUuidOfProjectMeasuresTable.class) - .add(3435, "Make 'uuid' column not nullable for 'PROJECT_MEASURES'", MakeProjectMeasuresUuidColumnNotNullable.class) - .add(3436, "Drop primary key on 'ID' column of 'PROJECT_MEASURES' table", DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.class) - .add(3437, "Add primary key on 'UUID' column of 'PROJECT_MEASURES' table", AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.class) - .add(3438, "Drop column 'ID' of 'PROJECT_MEASURES' table", DropIdColumnOfProjectMeasuresTable.class) - - // Migration of USER_TOKENS table - .add(3439, "Add 'UUID' column on 'USER_TOKENS' table", AddUuidColumnToUserTokens.class) - .add(3440, "Populate 'uuid' for 'USER_TOKENS'", PopulateUserTokensUuid.class) - .add(3441, "Make 'uuid' column not nullable for user_tokens", MakeUserTokensUuidNotNullable.class) - .add(3442, "Drop primary key on 'ID' column of 'USER_TOKENS' table", DropPrimaryKeyOnIdColumnOfUserTokensTable.class) - .add(3443, "Add primary key on 'UUID' column of 'USER_TOKENS' table", AddPrimaryKeyOnUuidColumnOfUserTokensTable.class) - .add(3444, "Drop column 'ID' of 'USER_TOKENS' table", DropIdColumnOfUserTokensTable.class) - - // Migration on PROJECT_QPROFILES table - .add(3445, "Add 'uuid' column for 'PROJECT_QPROFILES'", AddUuidColumnToProjectQProfilesTable.class) - .add(3446, "Populate 'uuid' column for 'PROJECT_QPROFILES'", PopulateProjectQProfilesUuid.class) - .add(3447, "Make 'uuid' column not nullable for 'PROJECT_QPROFILES'", MakeProjectQProfilesUuidColumnNotNullable.class) - .add(3448, "Drop primary key on 'ID' column of 'PROJECT_QPROFILES' table", DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.class) - .add(3449, "Add primary key on 'UUID' column of 'PROJECT_QPROFILES' table", AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.class) - .add(3450, "Drop column 'ID' of 'PROJECT_QPROFILES' table", DropIdColumnOfProjectQProfilesTable.class) - - // Migration of MANUAL_MEASURES table - .add(3451, "Add 'uuid' column for 'MANUAL_MEASURES'", AddUuidColumnToManualMeasures.class) - .add(3452, "Populate 'uuid' column for 'MANUAL_MEASURES'", PopulateManualMeasureUuid.class) - .add(3453, "Make 'uuid' column not nullable for 'MANUAL_MEASURES'", MakeManualMeasuresUuidColumnNotNullable.class) - .add(3454, "Drop primary key on 'ID' column of 'MANUAL_MEASURES' table", DropPrimaryKeyOnIdColumnOfManualMeasuresTable.class) - .add(3455, "Add primary key on 'UUID' column of 'MANUAL_MEASURES' table", AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.class) - .add(3456, "Drop column 'ID' of 'MANUAL_MEASURES' table", DropIdColumnOfManualMeasuresTable.class) - - // Migration of GROUP_ROLES table - .add(3457, "Add 'UUID' column on 'GROUP_ROLES' table", AddUuidColumnToGroupRolesTable.class) - .add(3458, "Populate 'uuid' for 'GROUP_ROLES'", PopulateGroupRolesUuid.class) - .add(3459, "Make 'uuid' column not nullable for 'GROUP_ROLES'", MakeGroupRolesUuidColumnNotNullable.class) - .add(3460, "Drop primary key on 'ID' column of 'GROUP_ROLES' table", DropPrimaryKeyOnIdColumnOfGroupRolesTable.class) - .add(3461, "Add primary key on 'UUID' column of 'GROUP_ROLES' table", AddPrimaryKeyOnUuidColumnOfGroupRolesTable.class) - .add(3462, "Drop column 'ID' of 'GROUP_ROLES' table", DropIdColumnOfGroupRolesTable.class) - - // Migration of USER_ROLES table - .add(3463, "Add 'UUID' column on 'USER_ROLES' table", AddUuidColumnToUserRolesTable.class) - .add(3464, "Populate 'uuid' for 'USER_ROLES'", PopulateUserRolesUuid.class) - .add(3465, "Make 'uuid' column not nullable for 'USER_ROLES'", MakeUserRolesUuidColumnNotNullable.class) - .add(3466, "Drop primary key on 'ID' column of 'USER_ROLES' table", DropPrimaryKeyOnIdColumnOfUserRolesTable.class) - .add(3468, "Add primary key on 'UUID' column of 'USER_ROLES' table", AddPrimaryKeyOnUuidColumnOfUserRolesTable.class) - .add(3469, "Drop column 'ID' of 'USER_ROLES' table", DropIdColumnOfUserRolesTable.class) - - // Migration of FILE_SOURCES table - .add(3470, "Add 'UUID' column on 'FILE_SOURCES' table", AddUuidColumnToFileSourcesTable.class) - .add(3471, "Populate 'uuid' for 'FILE_SOURCES'", PopulateFileSourcesUuid.class) - .add(3472, "Make 'uuid' column not nullable for 'FILE_SOURCES'", MakeFileSourcesUuidColumnNotNullable.class) - .add(3473, "Drop primary key on 'ID' column of 'FILE_SOURCES' table", DropPrimaryKeyOnIdColumnOfFileSourcesTable.class) - .add(3474, "Add primary key on 'UUID' column of 'FILE_SOURCES' table", AddPrimaryKeyOnUuidColumnOfFileSourcesTable.class) - .add(3475, "Drop column 'ID' of 'FILE_SOURCES' table", DropIdColumnOfFileSourcesTable.class) - - // Migration of ISSUE_CHANGES table - .add(3476, "Copy 'ISSUE_CHANGES' table to 'ISSUE_CHANGES_COPY'", CopyIssueChangesTable.class) - .add(3477, "Drop 'ISSUE_CHANGES' table", DropIssueChangesTable.class) - .add(3478, "Rename table 'ISSUE_CHANGES_COPY' to 'ISSUE_CHANGES'", RenameIssueChangesCopyToIssueChanges.class) - .add(3479, "Add index on 'ISSUE_KEY' of 'ISSUE_CHANGES' table", AddIndexOnIssueKeyOfIssueChangesTable.class) - .add(3480, "Add index on 'KEE' of 'ISSUE_CHANGES' table", AddIndexOnKeeOfIssueChangesTable.class) - .add(3481, "Add primary key on 'UUID' column of 'ISSUE_CHANGES' table", AddPrimaryKeyOnUuidColumnOfIssueChangesTable.class) - .add(3482, "Add index on 'project_uuid' for table 'ISSUE_CHANGES'", AddIndexOnProjectUuidOnIssueChangesTable.class) - - // Migration of QUALITY_GATE_CONDITIONS table - .add(3483, "Add 'UUID' column on 'QUALITY_GATE_CONDITIONS' table", AddUuidColumnToQualityGateConditionsTable.class) - .add(3484, "Populate 'uuid' for 'QUALITY_GATE_CONDITIONS'", PopulateQualityGateConditionsUuid.class) - .add(3485, "Make 'uuid' column not nullable for 'QUALITY_GATE_CONDITIONS'", MakeQualityGateConditionsUuidColumnNotNullable.class) - .add(3486, "Drop primary key on 'ID' column of 'QUALITY_GATE_CONDITIONS' table", DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.class) - .add(3487, "Add primary key on 'UUID' column of 'QUALITY_GATE_CONDITIONS' table", AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.class) - .add(3488, "Drop column 'ID' of 'QUALITY_GATE_CONDITIONS' table", DropIdColumnOfQualityGateConditionsTable.class) - - // Migration of PERM_TEMPLATES_GROUPS table - .add(3489, "Add 'UUID' column on 'PERM_TEMPLATES_GROUPS' table", AddUuidColumnToPermTemplatesGroupsTable.class) - .add(3490, "Populate 'uuid' for 'PERM_TEMPLATES_GROUPS'", PopulatePermTemplatesGroupsUuid.class) - .add(3491, "Make 'uuid' column not nullable for 'PERM_TEMPLATES_GROUPS'", MakePermTemplatesGroupsUuidColumnNotNullable.class) - .add(3492, "Drop primary key on 'ID' column of 'PERM_TEMPLATES_GROUPS' table", DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.class) - .add(3493, "Add primary key on 'UUID' column of 'PERM_TEMPLATES_GROUPS' table", AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.class) - .add(3494, "Drop column 'ID' of 'PERM_TEMPLATES_GROUPS' table", DropIdColumnOfPermTemplatesGroupsTable.class) - - // Migration of PERM_TPL_CHARACTERISTICS table - .add(3495, "Add 'UUID' column on 'PERM_TPL_CHARACTERISTICS' table", AddUuidColumnToPermTplCharacteristicsTable.class) - .add(3496, "Populate 'uuid' for 'PERM_TPL_CHARACTERISTICS'", PopulatePermTplCharacteristicsUuid.class) - .add(3497, "Make 'uuid' column not nullable for 'PERM_TPL_CHARACTERISTICS'", MakePermTplCharacteristicsUuidColumnNotNullable.class) - .add(3498, "Drop primary key on 'ID' column of 'PERM_TPL_CHARACTERISTICS' table", DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.class) - .add(3499, "Add primary key on 'UUID' column of 'PERM_TPL_CHARACTERISTICS' table", AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.class) - .add(3500, "Drop column 'ID' of 'PERM_TPL_CHARACTERISTICS' table", DropIdColumnOfPermTplCharacteristicsTable.class) - - // Migration of PERM_TEMPLATES_USERS table - .add(3501, "Add 'UUID' column on 'PERM_TEMPLATES_USERS' table", AddUuidColumnToPermTemplatesUsersTable.class) - .add(3502, "Populate 'uuid' for 'PERM_TEMPLATES_USERS'", PopulatePermTemplatesUsersUuid.class) - .add(3503, "Make 'uuid' column not nullable for 'PERM_TEMPLATES_USERS'", MakePermTemplatesUsersUuidColumnNotNullable.class) - .add(3504, "Drop primary key on 'ID' column of 'PERM_TEMPLATES_USERS' table", DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.class) - .add(3505, "Add primary key on 'UUID' column of 'PERM_TEMPLATES_USERS' table", AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.class) - .add(3506, "Drop column 'ID' of 'PERM_TEMPLATES_USERS' table", DropIdColumnOfPermTemplatesUsersTable.class) - - // Migration of ACTIVE_RULES table - .add(3507, "Add 'UUID' column on 'ACTIVE_RULES' table", AddUuidColumnToActiveRulesTable.class) - .add(3508, "Populate 'uuid' for 'ACTIVE_RULES'", PopulateActiveRulesUuid.class) - .add(3509, "Make 'uuid' column not nullable for 'ACTIVE_RULES'", MakeActiveRulesUuidColumnNotNullable.class) - - // Migration of FK in ACTIVE_RULE_PARAMETERS to ACTIVE_RULES - .add(3510, "Add 'active_rule_uuid' column on 'ACTIVE_RULE_PARAMETERS' table", AddActiveRuleUuidColumnToActiveRuleParameters.class) - .add(3511, "Populate 'active_rule_uuid' for 'ACTIVE_RULE_PARAMETERS'", PopulateActiveRuleParametersActiveRuleUuid.class) - .add(3512, "Make 'active_rule_uuid' column not nullable for 'ACTIVE_RULE_PARAMETERS'", MakeActiveRuleParametersActiveRuleUuidNotNullable.class) - .add(3513, "Drop index on 'active_rule_id' column of 'ACTIVE_RULE_PARAMETERS' table", DropIndexOnActiveRuleIdOfActiveRuleParametersTable.class) - .add(3514, "Add index on 'active_rule_uuid' column of 'ACTIVE_RULE_PARAMETERS' table", AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.class) - - // Finish migration of ACTIVE_RULES - .add(3515, "Drop primary key on 'ID' column of 'ACTIVE_RULES' table", DropPrimaryKeyOnIdColumnOfActiveRulesTable.class) - .add(3516, "Add primary key on 'UUID' column of 'ACTIVE_RULES' table", AddPrimaryKeyOnUuidColumnOfActiveRulesTable.class) - .add(3517, "Drop column 'ID' of 'ACTIVE_RULES' table", DropIdColumnOfActiveRulesTable.class) - .add(3518, "Drop column 'active_rule_id' of 'ACTIVE_RULE_PARAMETERS' table", DropActiveRuleIdColumnOfActiveRuleParametersTable.class) - - // Migration on RULES_PARAMETERS table - populate uuid column - .add(3519, "Add 'uuid' column for 'RULES_PARAMETERS'", AddUuidColumnToRulesParameters.class) - .add(3520, "Populate 'uuid' column for 'RULES_PARAMETERS'", PopulateRulesParametersUuid.class) - .add(3521, "Make 'uuid' column not nullable for 'RULES_PARAMETERS'", MakeRulesParametersUuidColumnNotNullable.class) - - // Migration of ACTIVE_RULE_PARAMS FK to RULES_PARAMETERS, switch from ruleParamId to ruleParamUuid - .add(3522, "Add 'rules_parameter_uuid' column for 'ACTIVE_RULE_PARAMS' table", AddRulesParameterUuidColumnToActiveRuleParameters.class) - .add(3523, "Populate 'rules_parameter_uuid' column for 'ACTIVE_RULE_PARAMS' table", PopulateActiveRuleParametersRulesParameterUuid.class) - .add(3524, "Make 'rules_parameter_uuid' column not nullable for 'ACTIVE_RULE_PARAMS' table", MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.class) - .add(3525, "Drop column 'rules_parameter_id' of 'ACTIVE_RULE_PARAMS' table", DropRulesParameterIdColumnOfActiveRuleParametersTable.class) - - // Migration on RULES_PARAMETERS table change PK - .add(3526, "Drop primary key on 'ID' column of 'RULES_PARAMETERS' table", DropPrimaryKeyOnIdColumnOfRulesParametersTable.class) - .add(3527, "Add primary key on 'UUID' column of 'RULES_PARAMETERS' table", AddPrimaryKeyOnUuidColumnOfRulesParametersTable.class) - .add(3528, "Drop column 'ID' of 'RULES_PARAMETERS' table", DropIdColumnOfRulesParametersTable.class) - - // Migration of METRICS table - .add(3529, "Add 'UUID' column on 'METRICS' table", AddUuidColumnToMetricsTable.class) - .add(3530, "Populate 'uuid' for 'METRICS'", PopulateMetricsUuid.class) - .add(3531, "Make 'uuid' column not nullable for 'METRICS'", MakeMetricsUuidColumnNotNullable.class) - - // Migration of FK in PROJECT_MEASURES to METRICS - .add(3532, "Add 'metric_uuid' column on 'PROJECT_MEASURES' table", AddMetricUuidColumnToProjectMeasures.class) - .add(3533, "Populate 'metric_uuid' for 'PROJECT_MEASURES'", PopulateProjectMeasuresMetricUuid.class) - .add(3534, "Make 'metric_uuid' column not nullable for 'PROJECT_MEASURES'", MakeProjectMeasuresMetricUuidNotNullable.class) - .add(3535, "Drop index on 'metric_id' and 'analysis_uuid' columns of 'PROJECT_MEASURES' table", DropIndexOnMetricIdOfProjectMeasuresTable.class) - .add(3536, "Add index on 'metric_uuid' and 'analysis_uuid' columns of 'PROJECT_MEASURES' table", AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTable.class) - - // Migration of FK in QUALITY_GATE_CONDITIONS to METRICS - .add(3537, "Add 'metric_uuid' column on 'QUALITY_GATE_CONDITIONS' table", AddMetricUuidColumnToQualityGateConditions.class) - .add(3538, "Populate 'metric_uuid' for 'QUALITY_GATE_CONDITIONS'", PopulateQualityGateConditionsMetricUuid.class) - .add(3539, "Make 'metric_uuid' column not nullable for 'QUALITY_GATE_CONDITIONS'", MakeQualityGateConditionsMetricUuidNotNullable.class) - - // Migration of FK in LIVE_MEASURES to METRICS - .add(3540, "Copy 'LIVE_MEASURES' table to 'LIVE_MEASURES_COPY'", CopyLiveMeasuresTable.class) - .add(3541, "Drop 'LIVE_MEASURES' table", DropLiveMeasuresTable.class) - .add(3542, "Rename table 'LIVE_MEASURES_COPY' to 'LIVE_MEASURES'", RenameLiveMeasuresCopyToLiveMeasures.class) - .add(3543, "Add primary key on 'uuid' column of 'LIVE_MEASURES' table", AddPKeyOnUuidOfLiveMeasuresTable.class) - .add(3544, "Add index on 'project_uuid' column of 'LIVE_MEASURES' table", AddIndexOnProjectUuidOfLiveMeasuresTable.class) - .add(3545, "Add index on 'metric_uuid' column of 'LIVE_MEASURES' table", AddIndexOnMetricUuidOfLiveMeasuresTable.class) - - // Migration of FK in MANUAL_MEASURES to METRICS - .add(3546, "Add 'metric_uuid' column on 'MANUAL_MEASURES' table", AddMetricUuidColumnToManualMeasures.class) - .add(3547, "Populate 'metric_uuid' for 'MANUAL_MEASURES'", PopulateManualMeasuresMetricUuid.class) - .add(3548, "Make 'metric_uuid' column not nullable for 'MANUAL_MEASURES'", MakeManualMeasuresMetricUuidNotNullable.class) - - // Finish migration of METRICS - .add(3549, "Drop primary key on 'ID' column of 'METRICS' table", DropPrimaryKeyOnIdColumnOfMetricsTable.class) - .add(3550, "Add primary key on 'UUID' column of 'METRICS' table", AddPrimaryKeyOnUuidColumnOfMetricsTable.class) - .add(3551, "Drop column 'METRIC_ID' of 'PROJECT_MEASURES' table", DropMetricIdColumnOfProjectMeasuresTable.class) - .add(3552, "Drop column 'METRIC_ID' of 'QUALITY_GATE_CONDITIONS' table", DropMetricIdColumnOfQualityGateConditionsTable.class) - .add(3554, "Drop column 'METRIC_ID' of 'MANUAL_MEASURES' table", DropMetricIdColumnOfManualMeasuresTable.class) - .add(3555, "Drop column 'ID' of 'METRICS' table", DropIdColumnOfMetricsTable.class) - - // Migration of PERMISSION_TEMPLATES table - .add(3556, "Add 'UUID' column on 'PERMISSION_TEMPLATES' table", AddUuidColumnToPermissionTemplates.class) - .add(3557, "Populate 'uuid' for 'PERMISSION_TEMPLATES'", PopulatePermissionTemplatesUuid.class) - .add(3558, "Make 'uuid' column not nullable for user_tokens", MakePermissionTemplateUuidColumnNotNullable.class) - - // Migration of PERM_TEMPLATES_GROUPS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid - .add(3559, "Add 'template_uuid' column for 'PERM_TEMPLATES_GROUPS' table", AddTemplateUuidColumnToPermTemplatesGroups.class) - .add(3560, "Populate 'template_uuid' column for 'PERM_TEMPLATES_GROUPS' table", PopulatePermTemplatesGroupsTemplateUuidColumn.class) - .add(3561, "Make 'template_uuid' column not nullable for 'PERM_TEMPLATES_GROUPS' table", MakePermTemplatesGroupsTemplateUuidColumnNotNullable.class) - .add(3562, "Drop column 'template_id' of 'PERM_TEMPLATES_GROUPS' table", DropTemplateIdColumnOfPermTemplatesGroupsTable.class) - - // Migration of PERM_TEMPLATES_USERS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid - .add(3563, "Add 'template_uuid' column for 'PERM_TEMPLATES_USERS' table", AddTemplateUuidColumnToPermTemplatesUsers.class) - .add(3564, "Populate 'template_uuid' column for 'PERM_TEMPLATES_USERS' table", PopulatePermTemplatesUsersTemplateUuidColumn.class) - .add(3565, "Make 'template_uuid' column not nullable for 'PERM_TEMPLATES_USERS' table", MakePermTemplatesUsersTemplateUuidColumnNotNullable.class) - .add(3566, "Drop column 'template_id' of 'PERM_TEMPLATES_USERS' table", DropTemplateIdColumnOfPermTemplatesUsersTable.class) - - // Migration of PERM_TPL_CHARACTERISTICS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid - .add(3567, "Add 'template_uuid' column for 'PERM_TPL_CHARACTERISTICS' table", AddTemplateUuidColumnToPermTplCharacteristics.class) - .add(3568, "Populate 'template_uuid' column for 'PERM_TPL_CHARACTERISTICS' table", PopulatePermTplCharacteristicsTemplateUuidColumn.class) - .add(3569, "Make 'template_uuid' column not nullable for 'PERM_TPL_CHARACTERISTICS' table", MakePermTplCharacteristicsTemplateUuidColumnNotNullable.class) - .add(3570, "Drop unique constraint on 'template_id', 'permission_key' columns 'PERM_TPL_CHARACTERISTICS' table", - DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.class) - .add(3571, "Add unique constraint on 'template_uuid', 'permission_key' columns 'PERM_TPL_CHARACTERISTICS' table", - AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.class) - - .add(3572, "Drop column 'template_id' of 'PERM_TPL_CHARACTERISTICS' table", DropTemplateIdColumnOfPermTplCharacteristicsTable.class) - - .add(3573, "Drop primary key on 'ID' column of 'PERMISSION_TEMPLATES' table", DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.class) - .add(3574, "Add primary key on 'UUID' column of 'PERMISSION_TEMPLATES' table", AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.class) - - .add(3575, "Drop column 'ID' of 'PERMISSION_TEMPLATES' table", DropIdColumnOfPermissionTemplatesTable.class) - .add(3576, "Drop column 'KEE' of 'PERMISSION_TEMPLATES' table", DropKeeColumnOfPermissionTemplatesTable.class) - - // Migration on RULES_PROFILES table - .add(3577, "Add 'uuid' column for 'RULES_PROFILES'", AddUuidColumnToRulesProfilesTable.class) - .add(3578, "Populate 'uuid' column for 'RULES_PROFILES'", PopulateRulesProfilesUuid.class) - .add(3579, "Make 'uuid' column not nullable for 'RULES_PROFILES'", MakeRulesProfilesUuidColumnNotNullable.class) - - // Migration of ORG_QPROFILES FK to RULES_PROFILES - .add(3580, "Populate 'rules_profile_uuid' column for 'ORG_QPROFILES' table", PopulateOrgQProfilesRulesProfileUuid.class) - - // Migration of QPROFILE_CHANGES FK to RULES_PROFILES - .add(3581, "Populate 'rules_profile_uuid' column for 'QPROFILE_CHANGES' table", PopulateQProfileChangesRulesProfileUuid.class) - - // Migration of ACTIVE_RULES FK to RULES_PROFILES, switch from profile_id to profile_uuid - .add(3582, "Add 'profile_uuid' column for 'ACTIVE_RULES' table", AddProfileUuidColumnToActiveRulesTable.class) - .add(3583, "Populate 'profile_uuid' column for 'ACTIVE_RULES' table", PopulateActiveRulesProfileUuid.class) - .add(3584, "Make 'profile_uuid' column not nullable for 'ACTIVE_RULES' table", MakeActiveRulesProfileUuidColumnNotNullable.class) - - .add(3585, "Drop unique constraint on 'profile_id', 'rule_id' columns 'ACTIVE_RULES' table", DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.class) - .add(3586, "Add unique constraint on 'profile_uuid', 'rule_id' columns 'ACTIVE_RULES' table", AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.class) - - .add(3587, "Drop column 'profile_id' of 'ACTIVE_RULES' table", DropProfileIdColumnOfActiveRulesTable.class) - - .add(3588, "Drop unique constraint on 'kee' columns 'RULES_PROFILES' table", DropUniqueIndexOnKeeColumnOfRulesProfilesTable.class) - .add(3589, "Drop column 'kee' of 'RULES_PROFILES' table", DropKeeColumnOfRulesProfilesTable.class) - - .add(3590, "Drop primary key on 'ID' column of 'RULES_PROFILES' table", DropPrimaryKeyOnIdColumnOfRulesProfilesTable.class) - .add(3591, "Add primary key on 'UUID' column of 'RULES_PROFILES' table", AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.class) - .add(3592, "Drop column 'ID' of 'RULES_PROFILES' table", DropIdColumnOfRulesProfilesTable.class) - - // Migration of PROPERTIES table - .add(3593, "Add 'uuid' column for 'PROPERTIES'", AddUuidColumnToProperties.class) - .add(3594, "Populate 'uuid' for 'PROPERTIES'", PopulatePropertiesUuid.class) - .add(3595, "Make 'uuid' column not nullable for 'PROPERTIES'", MakePropertiesUuidColumnNotNullable.class) - .add(3596, "Drop primary key on 'ID' column of 'PROPERTIES' table", DropPrimaryKeyOnIdColumnOfPropertiesTable.class) - .add(3597, "Add primary key on 'UUID' column of 'PROPERTIES' table", AddPrimaryKeyOnUuidColumnOfPropertiesTable.class) - .add(3598, "Drop column 'ID' of 'PROPERTIES' table", DropIdColumnOfPropertiesTable.class) - - // Migration of GROUPS table - .add(3599, "Add 'UUID' column on 'GROUPS' table", AddUuidColumnToGroupsTable.class) - .add(3600, "Populate 'uuid' for 'GROUPS'", PopulateGroupsUuid.class) - .add(3601, "Make 'uuid' column not nullable for 'GROUPS'", MakeGroupsUuidColumnNotNullable.class) - - // Migration of FK in GROUP_ROLES to GROUPS - .add(3602, "Add 'group_uuid' column on 'GROUP_ROLES' table", AddGroupUuidColumnToGroupRoles.class) - .add(3603, "Populate 'group_uuid' for 'GROUP_ROLES'", PopulateGroupRolesGroupUuid.class) - .add(3604, "Drop index on 'group_id' column of 'GROUP_ROLES' table", DropIndexOnGroupIdOfGroupRolesTable.class) - .add(3605, "Add index on 'group_uuid' column of 'GROUP_ROLES' table", AddIndexOnGroupUuidOfGroupRolesTable.class) - - // Migration of FK in GROUPS_USERS to GROUPS - .add(3606, "Add 'group_uuid' column on 'GROUPS_USERS' table", AddGroupUuidColumnToGroupsUsers.class) - .add(3607, "Populate 'group_uuid' for 'GROUPS_USERS'", PopulateGroupsUsersGroupUuid.class) - .add(3608, "Make 'group_uuid' column not nullable for 'GROUPS_USERS'", MakeGroupsUsersGroupUuidNotNullable.class) - .add(3609, "Drop index on 'group_id' column of 'GROUPS_USERS' table", DropIndexOnGroupIdOfGroupsUsersTable.class) - .add(3610, "Add index on 'group_uuid' column of 'GROUPS_USERS' table", AddIndexOnGroupUuidOfGroupsUsersTable.class) - - // Migration of FK in ORGANIZATIONS to GROUPS - .add(3611, "Add 'default_group_uuid' column on 'ORGANIZATIONS' table", AddDefaultGroupUuidColumnToOrganizations.class) - .add(3612, "Populate 'default_group_uuid' for 'ORGANIZATIONS'", PopulateOrganizationsDefaultGroupUuid.class) - - // Migration of FK in PERM_TEMPLATES_GROUPS to GROUPS - .add(3613, "Add 'group_uuid' column on 'PERM_TEMPLATES_GROUPS' table", AddGroupUuidColumnToPermTemplatesGroups.class) - .add(3614, "Populate 'group_uuid' for 'PERM_TEMPLATES_GROUPS'", PopulatePermTemplatesGroupsGroupUuid.class) - - // Migration of FK in QPROFILE_EDIT_GROUPS to GROUPS - .add(3615, "Add 'group_uuid' column on 'QPROFILE_EDIT_GROUPS' table", AddGroupUuidColumnToQProfileEditGroups.class) - .add(3616, "Populate 'group_uuid' for 'QPROFILE_EDIT_GROUPS'", PopulateQProfileEditGroupsGroupUuid.class) - .add(3617, "Make 'group_uuid' column not nullable for 'QPROFILE_EDIT_GROUPS'", MakeQProfileEditGroupsGroupUuidNotNullable.class) - .add(3618, "Drop index on 'group_id' column of 'QPROFILE_EDIT_GROUPS' table", DropIndexOnGroupIdOfQProfileEditGroupsTable.class) - .add(3619, "Add index on 'group_uuid' column of 'QPROFILE_EDIT_GROUPS' table", AddIndexOnGroupUuidOfQProfileEditGroupsTable.class) - - // Finish migration of Groups - .add(3620, "Drop primary key on 'ID' column of 'GROUPS' table", DropPrimaryKeyOnIdColumnOfGroupsTable.class) - .add(3621, "Add primary key on 'UUID' column of 'GROUPS' table", AddPrimaryKeyOnUuidColumnOfGroupsTable.class) - - .add(3622, "Drop column 'group_id' of 'GROUP_ROLES' table", DropGroupIdColumnOfGroupRolesTable.class) - .add(3623, "Drop column 'group_id' of 'GROUPS_USERS' table", DropGroupIdColumnOfGroupsUsersTable.class) - .add(3624, "Drop column 'group_id' of 'ORGANIZATIONS' table", DropDefaultGroupIdColumnOfOrganizationsTable.class) - .add(3625, "Drop column 'group_id' of 'PERM_TEMPLATES_GROUPS' table", DropGroupIdColumnOfPermTemplatesGroupsTable.class) - .add(3626, "Drop column 'group_id' of 'QPROFILE_EDIT_GROUPS' table", DropGroupIdColumnOfQProfileEditGroupsTable.class) - .add(3627, "Drop column 'ID' of 'GROUPS' table", DropIdColumnOfGroupsTable.class) - - // Migration of QUALITY_GATES_CONDITIONS FK to QUALITY_GATES, switch from qgate_id to qgate_uuid - .add(3628, "Add 'qgate_uuid' column for quality gates conditions", AddQGateUuidColumnForQGateConditions.class) - .add(3629, "Populate 'qgate_uuid' column for quality gates conditions", PopulateQGateUuidColumnForQGateConditions.class) - .add(3630, "drop orphans quality gates conditions", DropOrphansQGateConditions.class) - .add(3631, "Make 'qgate_uuid' column not nullable for quality gates conditions", MakeQGateUuidColumnNotNullableForQGateConditions.class) - .add(3632, "Drop 'qgate_id' column for quality gates conditions", DropQGateIdColumnForQGateConditions.class) - - // Migrations of QUALITY_GATES table - .add(3633, "Drop primary key on 'ID' column of 'QUALITY_GATES' table", DropPrimaryKeyOnIdColumnOfQGatesTable.class) - .add(3634, "drop unique index on 'UUID' column of 'QUALITY_GATES' table", DropUniqueIndexOnUuidColumnOfQualityGatesTable.class) - .add(3635, "Add primary key on 'UUID' column of 'QUALITY_GATES' table", AddPrimaryKeyOnUuidColumnOfQGatesTable.class) - .add(3636, "Drop column 'ID' of 'QUALITY_GATES' table", DropIdColumnOfQGateTable.class) - - // Migration of FK in GROUPS_USERS to USERS - .add(3637, "Add 'user_uuid' column on 'GROUPS_USERS' table", AddUserUuidColumnToGroupsUsers.class) - .add(3638, "Populate 'user_uuid' for 'GROUPS_USERS'", PopulateGroupsUsersUserUuid.class) - .add(3639, "Make 'user_uuid' column not nullable for 'GROUPS_USERS'", MakeGroupsUsersUserUuidColumnNotNullable.class) - .add(3640, "Drop index on 'user_id' column of 'GROUPS_USERS' table", DropIndexOnUserIdOfGroupsUsersTable.class) - .add(3641, "Add index on 'user_uuid' column of 'GROUPS_USERS' table", AddIndexOnUserUuidOfGroupsUsersTable.class) - .add(3642, "Drop index on 'user_id', 'group_id' columns of 'GROUPS_USERS' table", DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.class) - .add(3643, "Add unique index on 'user_uuid', 'group_id' columns of 'GROUPS_USERS' table", AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.class) - .add(3644, "Drop column on 'user_id' column of 'GROUPS_USERS' table", DropUserIdColumnOfGroupsUsersTable.class) - - // Migration of FK in ORGANIZATION_MEMBERS to USERS - .add(3645, "Add 'user_uuid' column on 'ORGANIZATION_MEMBERS' table", AddUserUuidColumnToOrganizationMembers.class) - .add(3646, "Populate 'user_uuid' for 'ORGANIZATION_MEMBERS'", PopulateOrganizationMembersUserUuid.class) - .add(3647, "Make 'user_uuid' not-null for 'ORGANIZATION_MEMBERS'", MakeOrganizationMembersUserUuidColumnNotNullable.class) - .add(3648, "Drop index on 'user_id' column of 'ORGANIZATION_MEMBERS' table", DropIndexOnUserIdOfOrganizationMembersTable.class) - .add(3649, "Add index on 'user_uuid' column of 'ORGANIZATION_MEMBERS' table", AddIndexOnUserUuidOfOrganizationMembersTable.class) - .add(3650, "Drop primary key on 'user_id' column of 'ORGANIZATION_MEMBERS' table", DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.class) - .add(3651, "Add PK on 'user_uuid', 'organization_uuid' columns of 'ORGANIZATION_MEMBERS' table", AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.class) - .add(3652, "Drop column on 'user_id' column of 'ORGANIZATION_MEMBERS' table", DropUserIdColumnOfOrganizationMembersTable.class) - - // Migration of FK in PERM_TEMPLATES_USERS to USERS - .add(3653, "Add 'user_uuid' column on 'PERM_TEMPLATES_USERS' table", AddUserUuidColumnToPermTemplatesUsers.class) - .add(3654, "Populate 'user_uuid' for 'PERM_TEMPLATES_USERS'", PopulatePermTemplatesUsersUserUuid.class) - .add(3655, "Make 'user_uuid' not-null for 'PERM_TEMPLATES_USERS'", MakePermTemplatesUsersUserUuidColumnNotNullable.class) - .add(3656, "Drop column on 'user_id' column of 'PERM_TEMPLATES_USERS' table", DropUserIdColumnOfPermTemplatesUsersTable.class) - - // Migration of FK in PROPERTIES to USERS - .add(3657, "Add 'user_uuid' column on 'PROPERTIES' table", AddUserUuidColumnToPropertiesUsers.class) - .add(3658, "Populate 'user_uuid' for 'PROPERTIES'", PopulatePropertiesUserUuid.class) - .add(3659, "Drop column on 'user_id' column of 'PROPERTIES' table", DropUserIdColumnOfPropertiesTable.class) - - // Migration of FK in QPROFILE_EDIT_USERS to USERS - .add(3660, "Add 'user_uuid' column on 'QPROFILE_EDIT_USERS' table", AddUserUuidColumnToQProfileEditUsers.class) - .add(3661, "Populate 'user_uuid' for 'QPROFILE_EDIT_USERS'", PopulateQProfileEditUsersUserUuid.class) - .add(3662, "Make 'user_uuid' not-null for 'QPROFILE_EDIT_USERS'", MakeQProfileEditUsersUserUuidColumnNotNullable.class) - .add(3663, "Drop unique index on 'user_id','qprofile_uuid' columns of 'QPROFILE_EDIT_USERS' table", DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.class) - .add(3664, "Add unique index on 'user_uuid','qprofile_uuid' columns of 'QPROFILE_EDIT_USERS' table", AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.class) - .add(3665, "Drop column on 'user_id' column of 'QPROFILE_EDIT_USERS' table", DropUserIdColumnOfQProfileEditUsersTable.class) - - .add(3666, "Add 'user_uuid' column on 'USER_ROLES' table", AddUserUuidColumnToUserRoles.class) - .add(3667, "Populate 'user_uuid' for 'USER_ROLES'", PopulateUserRolesUserUuid.class) - .add(3668, "Drop unique index on 'user_id' column of 'USER_ROLES' table", DropIndexOnUserIdOfUserRolesTable.class) - .add(3669, "Add unique index on 'user_uuid' columns of 'USER_ROLES' table", AddIndexOnUserUuidOfUserRolesTable.class) - .add(3670, "Drop column on 'user_id' column of 'USER_ROLES' table", DropUserIdColumnOfUserRolesTable.class) - - .add(3671, "Drop unique index on 'user_id' column of 'USERS' table", DropUniqueIndexOnUuidColumnOfUsersTable.class) - .add(3672, "Drop PK index on 'id' column of 'USERS' table", DropPrimaryKeyOnIdColumnOfUsersTable.class) - .add(3673, "Add PK index on 'uuid' column of 'USERS' table", AddPrimaryKeyOnUuidColumnOfUsersTable.class) - .add(3674, "Drop 'id' column of 'USERS' table", DropIdColumnOfUsersTable.class) - - // Migration of RULES table - .add(3675, "Add 'uuid' column for 'RULES'", AddUuidAndTemplateUuidColumnsToRules.class) - .add(3676, "Populate 'uuid' column for 'RULES'", PopulateRulesUuid.class) - .add(3677, "Make 'uuid' column not nullable for 'RULES'", MakeRulesUuidColumnNotNullable.class) - .add(3678, "Populate 'templateUuid' column for 'RULES'", PopulateRulesTemplateUuid.class) - .add(3679, "Drop column 'templateId' column for 'RULES'", DropTemplateIdColumnOfRulesTable.class) - // Migration of RULES_METADATA FK to RULES, switch from rule_id to rule_uuid - .add(3680, "Add 'RULE_UUID' column for 'RULES_METADATA' table", AddRuleUuidColumnToRulesMetadataTable.class) - .add(3681, "Populate 'RULE_UUID' column for 'RULES_METADATA' table", PopulateRulesMetadataRuleUuidColumn.class) - .add(3682, "Make 'RULE_UUID' column not nullable for 'RULES_METADATA' table", MakeRulesMetadataRuleUuidColumnNotNullable.class) - .add(3683, "Drop primary key on 'RULE_ID' column of 'RULES_METADATA' table", DropPrimaryKeyOnIdColumnOfRulesMetadataTable.class) - .add(3684, "Add primary key on 'RULE_UUID' column of 'RULES_METADATA' table", AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.class) - .add(3685, "Drop column 'RULE_ID' of 'RULES_METADATA' table", DropRuleIdColumnOfRulesMetadataTable.class) - // Migration of RULES_PARAMETERS FK to RULES, switch from rule_id to rule_uuid - .add(3686, "Add 'RULE_UUID' column for 'RULES_PARAMETERS' table", AddRuleUuidColumnToRulesParametersTable.class) - .add(3687, "Populate 'RULE_UUID' column for 'RULES_PARAMETERS' table", PopulateRulesParametersRuleUuidColumn.class) - .add(3688, "Make 'RULE_UUID' column not nullable for 'RULES_PARAMETERS' table", MakeRulesParametersRuleUuidColumnNotNullable.class) - .add(3689, "Drop indexes on 'RULE_ID' of 'RULES_PARAMETERS' table", DropIndexesOnRuleIdColumnOfRulesParametersTable.class) - .add(3690, "Add indexes to 'RULES_PARAMETERS' table", AddIndexesToRulesParametersTable.class) - .add(3691, "Drop column 'RULE_ID' of 'RULES_PARAMETERS' table", DropRuleIdColumnOfRulesParametersTable.class) - // Migration of ACTIVE_RULES FK to RULES, switch from rule_id to rule_uuid - .add(3692, "Add 'RULE_UUID' column for 'ACTIVE_RULES' table", AddRuleUuidColumnToActiveRulesTable.class) - .add(3693, "Populate 'RULE_UUID' column for 'ACTIVE_RULES' table", PopulateActiveRulesRuleUuidColumn.class) - .add(3694, "Make 'RULE_UUID' column not nullable for 'ACTIVE_RULES' table", MakeActiveRulesRuleUuidColumnNotNullable.class) - .add(3695, "Drop indexes on 'RULE_ID' of 'ACTIVE_RULES' table", DropIndexOnRuleIdColumnOfActiveRulesTable.class) - .add(3696, "Add indexes to 'ACTIVE_RULES' table", AddIndexToActiveRulesTable.class) - .add(3697, "Drop column 'RULE_ID' of 'ACTIVE_RULES' table", DropRuleIdColumnOfActiveRulesTable.class) - // Migration of DEPRECATED_RULE_KEYS FK to RULES, switch from rule_id to rule_uuid - .add(3698, "Add 'RULE_UUID' column for 'DEPRECATED_RULE_KEYS' table", AddRuleUuidColumnToDeprecatedRuleKeysTable.class) - .add(3699, "Populate 'RULE_UUID' column for 'DEPRECATED_RULE_KEYS' table", PopulateDeprecatedRuleKeysRuleUuidColumn.class) - .add(3700, "Make 'RULE_UUID' column not nullable for 'DEPRECATED_RULE_KEYS' table", MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.class) - .add(3701, "Drop index on 'RULE_ID' of 'DEPRECATED_RULE_KEYS' table", DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.class) - .add(3702, "Add index to 'DEPRECATED_RULE_KEYS' table", AddIndexToDeprecatedRuleKeysTable.class) - .add(3703, "Drop column 'RULE_ID' of 'DEPRECATED_RULE_KEYS' table", DropRuleIdColumnOfDeprecatedRuleKeysTable.class) - // Migration of ISSUE FK to RULES, switch from rule_id to rule_uuid - .add(3704, "Copy 'ISSUES' table to 'ISSUES_COPY", CopyIssuesTable.class) - .add(3705, "Drop 'ISSUES' table", DropIssuesTable.class) - .add(3706, "Rename 'ISSUES_COPY' table to 'ISSUES'", RenameIssuesCopyToIssues.class) - .add(3707, "Add indexes to 'ISSUES' table", AddIndexesToIssuesTable.class) - .add(3708, "Add primary key on 'KEE' column of 'ISSUES' table", AddPrimaryKeyOnKeeColumnOfIssuesTable.class) - - // continue with RULES table cleanup - .add(3709, "Drop primary key on 'ID' column of 'RULES' table", DropPrimaryKeyOnIdColumnOfRulesTable.class) - .add(3710, "Add primary key on 'UUID' column of 'RULES' table", AddPrimaryKeyOnUuidColumnOfRulesTable.class) - .add(3711, "Drop column 'ID' of 'RULES' table", DropIdColumnOfRulesTable.class) - - .add(3800, "Remove favourites for components with qualifiers 'DIR', 'FIL', 'UTS'", RemoveFilesFavouritesFromProperties.class) - .add(3801, "Create 'SESSION_TOKENS' table", CreateSessionTokensTable.class) - .add(3802, "Create 'SAML_MESSAGE_IDS' table", CreateSamlMessageIdsTable.class) - - .add(3803, "Add 'need_issue_sync' column to 'project_branches' table", AddProjectBranchesNeedIssueSync.class) - .add(3804, "Populate 'need_issue_sync' of 'project_branches'", PopulateProjectBranchesNeedIssueSync.class) - .add(3805, "Make 'need_issue_sync' of 'project_branches' not null", MakeProjectBranchesNeedIssueSyncNonNull.class) - - // Migration of ALM_SETTINGS table - .add(3807, "Add columns 'CLIENT_ID' and 'CLIENT_SECRET' to 'ALM_SETTINGS' table", AddClientIdAndClientSecretColumns.class) - - - // Removing old data from project_measures - .add(3808, "Add index on 'metric_uuid' column of 'PROJECT_MEASURES' table", AddIndexOnMetricUuidOfProjectMeasuresTable.class) - .add(3809, "Remove old Security Review Rating ProjectMeasures", DeleteSecurityReviewRatingProjectMeasures.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/MakeProjectBranchesNeedIssueSyncNonNull.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/MakeProjectBranchesNeedIssueSyncNonNull.java deleted file mode 100644 index 098d456e05a10ee93e0a4465fa01d2752c6ac19c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/MakeProjectBranchesNeedIssueSyncNonNull.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import 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 MakeProjectBranchesNeedIssueSyncNonNull extends DdlChange { - public MakeProjectBranchesNeedIssueSyncNonNull(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "project_branches") - .updateColumn(BooleanColumnDef.newBooleanColumnDefBuilder() - .setColumnName("need_issue_sync") - .setIsNullable(false) - .setDefaultValue(null) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/PopulateProjectBranchesNeedIssueSync.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/PopulateProjectBranchesNeedIssueSync.java deleted file mode 100644 index 58c06c72c1c27d5f09d1b4724d09ac613cc99cb7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/PopulateProjectBranchesNeedIssueSync.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import 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 PopulateProjectBranchesNeedIssueSync extends DataChange { - public PopulateProjectBranchesNeedIssueSync(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from project_branches where need_issue_sync is null"); - massUpdate.update("update project_branches set need_issue_sync = ? where uuid = ?"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - update.setBoolean(1, false); - update.setString(2, uuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromProperties.java deleted file mode 100644 index 4acf4946eb178287d10a2f2a9b1bb778275562e3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromProperties.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import 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 RemoveFilesFavouritesFromProperties extends DataChange { - - public RemoveFilesFavouritesFromProperties(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select p.uuid from components c " + - "join properties p on c.uuid = p.component_uuid " + - "where p.prop_key = ? and c.qualifier in ('FIL', 'DIR', 'UTS')") - .setString(1, "favourite"); - massUpdate.update("delete from properties where uuid = ?"); - - massUpdate.execute((row, update) -> { - String propertyUuid = row.getString(1); - update.setString(1, propertyUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java deleted file mode 100644 index d7b3e44ee3160915b5fb429ebaa0229cf8e8f660..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("active_rule_parameters", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java deleted file mode 100644 index d40f5da21f329bc1e44a8e36571a22dee798eb38..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToActiveRuleParametersTable extends AddUuidColumnToTable { - private static final String TABLE = "active_rule_parameters"; - - public AddUuidColumnToActiveRuleParametersTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java deleted file mode 100644 index d83dee78f31a553118361c023c00434c5ac2ab10..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfActiveRuleParametersTable extends DropIdColumn { - private static final String TABLE = "active_rule_parameters"; - - public DropIdColumnOfActiveRuleParametersTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java deleted file mode 100644 index 5f08f125278e26018e0ea16673b8e1cef6514e3d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "active_rule_parameters"; - - public DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java deleted file mode 100644 index 4a0e26e5bfd3bbd62d10e499ce1f9d5b2edb914c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeActiveRuleParametersUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "active_rule_parameters"; - - public MakeActiveRuleParametersUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuid.java deleted file mode 100644 index a3bfff1bc31fea98e0b09aed571181f73ffc5bbf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRuleParametersUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateActiveRuleParametersUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from active_rule_parameters where uuid is null"); - massUpdate.update("update active_rule_parameters set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/package-info.java deleted file mode 100644 index bee0a90fed9fc6c597571638128094f11968a7e1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java deleted file mode 100644 index 50f566dc7c8df57353dda85061c0619a20b8ef38..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddActiveRuleUuidColumnToActiveRuleParameters extends DdlChange { - private static final String TABLE = "active_rule_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("active_rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddActiveRuleUuidColumnToActiveRuleParameters(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java deleted file mode 100644 index b07268a6710cb3f3cbacc77d5b07a74e0c884983..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnActiveRuleUuidOfActiveRuleParametersTable extends DdlChange { - private static final String TABLE_NAME = "active_rule_parameters"; - private static final String INDEX_NAME = "arp_active_rule_uuid"; - - public AddIndexOnActiveRuleUuidOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("active_rule_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java deleted file mode 100644 index 84ca9c65b9ea3988c73a43913a4072b110eec801..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfActiveRulesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("active_rules", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTable.java deleted file mode 100644 index 040380766c470f6a048c20b083aff6e5e2dcb503..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToActiveRulesTable extends AddUuidColumnToTable { - private static final String TABLE = "active_rules"; - - public AddUuidColumnToActiveRulesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java deleted file mode 100644 index af0bc07738e3723e1199f8add1d7d19582baf8bf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropActiveRuleIdColumnOfActiveRuleParametersTable extends DdlChange { - public DropActiveRuleIdColumnOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "active_rule_parameters", "active_rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTable.java deleted file mode 100644 index dcbaf505ef59f274e7bbcc1a200067d931312f11..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfActiveRulesTable extends DropIdColumn { - private static final String TABLE = "active_rules"; - - public DropIdColumnOfActiveRulesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java deleted file mode 100644 index 5df4a1b87d4a96151395110475e21f9d7f442351..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnActiveRuleIdOfActiveRuleParametersTable extends DropIndexChange { - private static final String TABLE_NAME = "active_rule_parameters"; - private static final String INDEX_NAME = "ix_arp_on_active_rule_id"; - - public DropIndexOnActiveRuleIdOfActiveRuleParametersTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java deleted file mode 100644 index 429da6e783cc731408ec00b6e8e963f9d27d7b46..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfActiveRulesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "active_rules"; - - public DropPrimaryKeyOnIdColumnOfActiveRulesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java deleted file mode 100644 index 0085b48c9c46cd4bc197fa34f3350f203d89cb42..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeActiveRuleParametersActiveRuleUuidNotNullable extends DdlChange { - private static final String TABLE = "active_rule_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("active_rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeActiveRuleParametersActiveRuleUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullable.java deleted file mode 100644 index b133c3c30ba16ad48ad465bd9497658ec21afb13..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeActiveRulesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "active_rules"; - - public MakeActiveRulesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuid.java deleted file mode 100644 index 66ec517d3a5d0ae4df2e5c3e18c8f2fd89fe2548..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuid.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.version.v84.util.OrphanData; - -public class PopulateActiveRuleParametersActiveRuleUuid extends DataChange { - - public PopulateActiveRuleParametersActiveRuleUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select arp.uuid, ar.uuid from active_rule_parameters arp " + - "join active_rules ar on arp.active_rule_id = ar.id"); - - massUpdate.update("update active_rule_parameters set active_rule_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - OrphanData.delete(context, "active_rule_parameters", "active_rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuid.java deleted file mode 100644 index 7fc115dba3bc3c4cffaf5e5f38844c08d822dbae..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRulesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateActiveRulesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from active_rules where uuid is null"); - massUpdate.update("update active_rules set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/package-info.java deleted file mode 100644 index b2f04d731fb5ebe3e2458693acd82abc045f7ab3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumns.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumns.java deleted file mode 100644 index eaa47034db130c8e110732944486ec356a9aeb67..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumns.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.alm; - -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 AddClientIdAndClientSecretColumns extends DdlChange { - - public AddClientIdAndClientSecretColumns(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "alm_settings") - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("client_id") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(80) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("client_secret") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(80) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/alm/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/alm/package-info.java deleted file mode 100644 index d69aad3d7ddbbb5c29b4123b759f1b449a690aad..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/alm/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.alm; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java deleted file mode 100644 index e741f96d7ef55b258101fcac12991623d0b7ac53..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.ceactivity; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfCeActivityTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfCeActivityTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("ce_activity", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTable.java deleted file mode 100644 index 05d20e57e1c46beac2f90824bf3cd0d90ab64fa5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.ceactivity; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfCeActivityTable extends DropIdColumn { - private static final String TABLE = "ce_activity"; - - public DropIdColumnOfCeActivityTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java deleted file mode 100644 index 430e8753c5198b06da93927f5c9857cdc43dd253..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.ceactivity; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfCeActivityTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "ce_activity"; - - public DropPrimaryKeyOnIdColumnOfCeActivityTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/package-info.java deleted file mode 100644 index d2615d12ad3935d5f919b93f2969524df0af7d64..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.ceactivity; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java deleted file mode 100644 index c83daed3b5db3a15a95bd00f8bf997f690ba4d78..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfCeQueueTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfCeQueueTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("ce_queue", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTable.java deleted file mode 100644 index 92a799d6cb91b6f966ad3fe9d910e4861de0c9b8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfCeQueueTable extends DropIdColumn { - private static final String TABLE = "ce_queue"; - - public DropIdColumnOfCeQueueTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java deleted file mode 100644 index 9c4d2317cea77fc8357677d0de507243bcaab2c4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfCeQueueTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "ce_queue"; - - public DropPrimaryKeyOnIdColumnOfCeQueueTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java deleted file mode 100644 index 4f7176f725091a0dc4cbd33a739739c58297ea76..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropUniqueIndexOnUuidColumnOfCeQueueTable extends DropIndexChange { - private static final String TABLE_NAME = "ce_queue"; - private static final String INDEX_NAME = "ce_queue_uuid"; - - public DropUniqueIndexOnUuidColumnOfCeQueueTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/package-info.java deleted file mode 100644 index 7fe531fdc5e11c349dc59763143732f42a14fcb4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/AddUuidColumnToTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/AddUuidColumnToTable.java deleted file mode 100644 index 078ae4b74aa569683244452c90a4cf5e4b46d902..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/AddUuidColumnToTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.common; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public abstract class AddUuidColumnToTable extends DdlChange { - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private String tableName; - - protected AddUuidColumnToTable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), tableName) - .addColumn(uuidColumnDefinition) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropIdColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropIdColumn.java deleted file mode 100644 index 6e5fc32a261293c9df304f46ed1edf173dbf2203..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropIdColumn.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.common; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public abstract class DropIdColumn extends DdlChange { - private Database db; - private String tableName; - - protected DropIdColumn(Database db, String tableName) { - super(db); - this.db = db; - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), tableName, "id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java deleted file mode 100644 index c0f287b915bd0b601a249b81cdbb02553c010f62..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.common; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public abstract class DropPrimaryKeyOnIdColumn extends DdlChange { - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - private final String tableName; - - protected DropPrimaryKeyOnIdColumn(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator, String tableName) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(tableName, "id", true)); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/MakeUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/MakeUuidColumnNotNullable.java deleted file mode 100644 index e249dd61cfb134c3ddbaf720fbb8a6283e964278..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/MakeUuidColumnNotNullable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.common; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public abstract class MakeUuidColumnNotNullable extends DdlChange { - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private String tableName; - - protected MakeUuidColumnNotNullable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), tableName) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/package-info.java deleted file mode 100644 index 66a583728c4518f06616982ac1a4cb5cea2030ed..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.common; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java deleted file mode 100644 index baedddf995ad5c1276c704e0087dac3600edda45..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("duplications_index", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTable.java deleted file mode 100644 index 3ca297267b5662efd9852f73e1f1f6d3886cca5a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidToDuplicationsIndexTable extends AddUuidColumnToTable { - private static final String TABLE = "duplications_index"; - - public AddUuidToDuplicationsIndexTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java deleted file mode 100644 index bb2b28974fc639af1ba07589babf86dc0560453c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfDuplicationsIndexTable extends DropIdColumn { - private static final String TABLE = "duplications_index"; - - public DropIdColumnOfDuplicationsIndexTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java deleted file mode 100644 index 14c06f2396eee89f257f3bf4604e705ff551f511..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "duplications_index"; - - public DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java deleted file mode 100644 index 3e67bc00126afd146de7be3cea01a591f8b1ee68..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeDuplicationsIndexUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "duplications_index"; - - public MakeDuplicationsIndexUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuid.java deleted file mode 100644 index 17d9dbde6e0f990e3ec6e2387eb96abfc4078016..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateDuplicationsIndexUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateDuplicationsIndexUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from duplications_index where uuid is null"); - massUpdate.update("update duplications_index set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/package-info.java deleted file mode 100644 index 2171403433ba95573e4411e4089d63e8395100a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java deleted file mode 100644 index 09fe7983a32b53011aed3af59b7771cac49c9f04..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.events; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfEventsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfEventsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("events", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTable.java deleted file mode 100644 index cfc63a75145bcba3a89fe9ffff789bd17e39d343..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.events; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfEventsTable extends DropIdColumn { - private static final String TABLE = "events"; - - public DropIdColumnOfEventsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java deleted file mode 100644 index 2388fb4d20212531783c712428e96b73b7d56e73..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.events; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfEventsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "events"; - - public DropPrimaryKeyOnIdColumnOfEventsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/package-info.java deleted file mode 100644 index 845eb01ab5f2b85a67118c2d4fe2d04fd1fd2a65..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.events; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java deleted file mode 100644 index b7d70ccc35525340bdc5a7c34e6fb66ec772890f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfFileSourcesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfFileSourcesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("file_sources", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTable.java deleted file mode 100644 index 9022e00061928b44ecafd2faadf1efe4d8c35b1a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToFileSourcesTable extends AddUuidColumnToTable { - private static final String TABLE = "file_sources"; - - public AddUuidColumnToFileSourcesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTable.java deleted file mode 100644 index 6730e70b0ec94ea15fd86c9261b3e6656a6679eb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfFileSourcesTable extends DropIdColumn { - private static final String TABLE = "file_sources"; - - public DropIdColumnOfFileSourcesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java deleted file mode 100644 index 2bdd375d06cd4367fd4731f4a948e1a2f70bd9aa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfFileSourcesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "file_sources"; - - public DropPrimaryKeyOnIdColumnOfFileSourcesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullable.java deleted file mode 100644 index 30e4dace66021b7e5cd4b2695f7199fe271e86ab..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeFileSourcesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "file_sources"; - - public MakeFileSourcesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuid.java deleted file mode 100644 index 51e05c3f46998371f8195acee09eed5440d56b3f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateFileSourcesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateFileSourcesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from file_sources where uuid is null"); - massUpdate.update("update file_sources set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/package-info.java deleted file mode 100644 index 269d8a9bc71f74516bfd9e0eda8a095e652efcdf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java deleted file mode 100644 index c58e73b91becf9d328d5591ce8dc7a15d76dd08a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfGroupRolesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfGroupRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("group_roles", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTable.java deleted file mode 100644 index d9bdaca01927a21e4c8518e9085797d4c44da2d8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToGroupRolesTable extends AddUuidColumnToTable { - private static final String TABLE = "group_roles"; - - public AddUuidColumnToGroupRolesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTable.java deleted file mode 100644 index 46f6350c841a7efe201fc3b3d8f477d5a2d7c8c1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfGroupRolesTable extends DdlChange { - - private Database db; - - public DropIdColumnOfGroupRolesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "group_roles", "id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java deleted file mode 100644 index ca9ab5bb23cc3d197daf1e1fa7155756a6f3f38c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfGroupRolesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "group_roles"; - - public DropPrimaryKeyOnIdColumnOfGroupRolesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullable.java deleted file mode 100644 index 3ee31a0b7eb00dc01d0fa3d2df71fa34b6462e06..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeGroupRolesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "group_roles"; - - public MakeGroupRolesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuid.java deleted file mode 100644 index 64e956f07d897046b5c0beeebc801ebcb3bb32ac..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupRolesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateGroupRolesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from group_roles where uuid is null"); - massUpdate.update("update group_roles set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/package-info.java deleted file mode 100644 index 2850e36ecc6de2a29a4ebd53d9c9f884af3cdd64..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java deleted file mode 100644 index 568275c479b309d3a23b29473732147959d45add..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfGroupsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("groups", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTable.java deleted file mode 100644 index 5c7b1661ab71e1303975ef892f4e60b7482506d1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToGroupsTable extends AddUuidColumnToTable { - private static final String TABLE = "groups"; - - public AddUuidColumnToGroupsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTable.java deleted file mode 100644 index 7ff7f7e77730bd31ea8df05defab455339809486..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfGroupsTable extends DropIdColumn { - private static final String TABLE = "groups"; - - public DropIdColumnOfGroupsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java deleted file mode 100644 index 225369a9755f3639ff61181376bc0478e54524d0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfGroupsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "groups"; - - public DropPrimaryKeyOnIdColumnOfGroupsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullable.java deleted file mode 100644 index 98ee04ce97b33d70cc2d2ed703656384604fc9b3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeGroupsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "groups"; - - public MakeGroupsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuid.java deleted file mode 100644 index 562f5bb023783e262744fcc797ab1d80b2a53d1e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateGroupsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from groups where uuid is null"); - massUpdate.update("update groups set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRoles.java deleted file mode 100644 index 2e420d586ff8a0e50ccf027ef191ee1fe0f95770..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRoles.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGroupUuidColumnToGroupRoles extends DdlChange { - private static final String TABLE = "group_roles"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddGroupUuidColumnToGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java deleted file mode 100644 index f7f5ff83e53b10799d163645364e6cb071d30987..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnGroupUuidOfGroupRolesTable extends DdlChange { - private static final String TABLE_NAME = "group_roles"; - private static final String INDEX_NAME = "uniq_group_roles"; - - public AddIndexOnGroupUuidOfGroupRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setIsNullable(true) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("role") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java deleted file mode 100644 index bf988a93c85ab7bfc1ee95d73d0f894b8a69bb87..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropGroupIdColumnOfGroupRolesTable extends DdlChange { - public DropGroupIdColumnOfGroupRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "group_roles", "group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java deleted file mode 100644 index 9cbb80ecd16aec5093d6935f6210fcbe11c238fb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnGroupIdOfGroupRolesTable extends DropIndexChange { - private static final String TABLE_NAME = "group_roles"; - private static final String INDEX_NAME = "uniq_group_roles"; - - public DropIndexOnGroupIdOfGroupRolesTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuid.java deleted file mode 100644 index 5e49d3c1952e33af629cfba7a5da7aa14b0c1608..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuid.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupRolesGroupUuid extends DataChange { - - public PopulateGroupRolesGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select gr.uuid, g.uuid " + - "from group_roles gr left outer join groups g on gr.group_id = g.id " + - "where g.id is null and gr.group_id is not null"); - - massUpdate.update("delete from group_roles where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select gr.uuid, g.uuid from group_roles gr " + - "join groups g on gr.group_id = g.id"); - - massUpdate.update("update group_roles set group_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/package-info.java deleted file mode 100644 index 77743ac04a7e323428e733eb3a57dead9048eb77..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java deleted file mode 100644 index 80e801971259884f703f58da5d57be961218880c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGroupUuidColumnToGroupsUsers extends DdlChange { - private static final String TABLE = "groups_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddGroupUuidColumnToGroupsUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java deleted file mode 100644 index 0c28eaeab9307ef30030567a523adbf4c1e2d718..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnGroupUuidOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME1 = "index_groups_users_group_uuid"; - private static final String INDEX_NAME2 = "groups_users_unique"; - - public AddIndexOnGroupUuidOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef groupUuid = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - if (!indexExists(INDEX_NAME1)) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME1) - .addColumn(groupUuid) - .build()); - } - if (!indexExists(INDEX_NAME2)) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME2) - .addColumn(groupUuid) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("user_id") - .setIsNullable(true) - .build()) - .build()); - } - } - - private boolean indexExists(String name) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, name, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java deleted file mode 100644 index 16fed171bd2f3765d8f65d72ae5cd4973fae71ea..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropGroupIdColumnOfGroupsUsersTable extends DdlChange { - public DropGroupIdColumnOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "groups_users", "group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java deleted file mode 100644 index a33da558967e28ae3259fcce72aca68e19c36584..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Optional; -import java.util.function.Consumer; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnGroupIdOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME1 = "index_groups_users_on_group_id"; - private static final String INDEX_NAME2 = "groups_users_unique"; - - public DropIndexOnGroupIdOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - Consumer dropIndex = idx -> context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(idx) - .build()); - - findExistingIndexName(INDEX_NAME1).ifPresent(dropIndex); - findExistingIndexName(INDEX_NAME2).ifPresent(dropIndex); - } - - private Optional findExistingIndexName(String indexName) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.findExistingIndex(connection, TABLE_NAME, indexName); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java deleted file mode 100644 index f5140979a13639b523e0ec336f75da40687de5a7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeGroupsUsersGroupUuidNotNullable extends DdlChange { - private static final String TABLE = "groups_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeGroupsUsersGroupUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuid.java deleted file mode 100644 index 8471be2eabb1b4cefe1c86dca8865197181beb28..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuid.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupsUsersGroupUuid extends DataChange { - - public PopulateGroupsUsersGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select gu.user_id, gu.group_id " + - "from groups_users gu " + - "left outer join groups g on gu.group_id = g.id " + - "where g.id is null and gu.group_id is not null"); - - massUpdate.update("delete from groups_users where user_id = ? and group_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - update.setLong(2, row.getLong(2)); - - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select gu.user_id, gu.group_id, g.uuid " + - "from groups_users gu " + - "join groups g on gu.group_id = g.id"); - - massUpdate.update("update groups_users set group_uuid = ? where user_id = ? and group_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(3)); - update.setLong(2, row.getLong(1)); - update.setLong(3, row.getLong(2)); - - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/package-info.java deleted file mode 100644 index 9c5d28896ad1a75df672cb840c1065c51fffce69..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java deleted file mode 100644 index 3cff3e8763717ebd8f0f83f153e6042828ea20e5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.organizations; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddDefaultGroupUuidColumnToOrganizations extends DdlChange { - private static final String TABLE = "organizations"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("default_group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddDefaultGroupUuidColumnToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java deleted file mode 100644 index efacc52b734f76165bd864809df8819726878653..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.organizations; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropDefaultGroupIdColumnOfOrganizationsTable extends DdlChange { - public DropDefaultGroupIdColumnOfOrganizationsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "organizations", "default_group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java deleted file mode 100644 index 90bee326c6565676b0f404917485fd08d5634cca..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.organizations; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateOrganizationsDefaultGroupUuid extends DataChange { - - public PopulateOrganizationsDefaultGroupUuid(Database db) { - super(db); - } - - private static void removeOrphans(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select o.uuid, g.uuid from organizations o join groups g on o.default_group_id = g.id"); - massUpdate.update("update organizations set default_group_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select o.uuid " + - "from organizations o " + - "left outer join groups g on o.default_group_id = g.id " + - "where g.id is null and o.default_group_id is not null"); - - massUpdate.update("delete from organizations where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - - removeOrphans(context); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/package-info.java deleted file mode 100644 index e9c71e313402b19cb6f1f603358cb1e578ea09a9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.groups.organizations; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/package-info.java deleted file mode 100644 index e36447e7cc15fd21facb5408383e7a75cc42857c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.groups; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java deleted file mode 100644 index cc167d9ae82e2ff2debb8788e8ed80dc43088d91..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGroupUuidColumnToPermTemplatesGroups extends DdlChange { - private static final String TABLE = "perm_templates_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddGroupUuidColumnToPermTemplatesGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index 1dc8dac90904eb70606b29b9b22d2ea1bf902d6f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropGroupIdColumnOfPermTemplatesGroupsTable extends DdlChange { - public DropGroupIdColumnOfPermTemplatesGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_groups", "group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java deleted file mode 100644 index 5c558b6cecae0029deba839344ce04e697007758..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesGroupsGroupUuid extends DataChange { - - public PopulatePermTemplatesGroupsGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptg.uuid " + - "from perm_templates_groups ptg " + - "left outer join groups g on ptg.group_id = g.id " + - "where g.id is null and ptg.group_id is not null"); - - massUpdate.update("delete from perm_templates_groups where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptg.uuid, g.uuid " + - "from perm_templates_groups ptg " + - "join groups g on ptg.group_id = g.id"); - - massUpdate.update("update perm_templates_groups set group_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/package-info.java deleted file mode 100644 index 52e4d425e6cabf4aab549b75f7f8baa039b070a6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java deleted file mode 100644 index 0bc91289144296a37029d11d1cdc82f58f0991ba..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGroupUuidColumnToQProfileEditGroups extends DdlChange { - private static final String TABLE = "qprofile_edit_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddGroupUuidColumnToQProfileEditGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java deleted file mode 100644 index 8e3f601946bd230da449b03600493862c3710c95..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnGroupUuidOfQProfileEditGroupsTable extends DdlChange { - private static final String TABLE_NAME = "qprofile_edit_groups"; - private static final String INDEX_NAME = "qprofile_edit_groups_unique"; - - public AddIndexOnGroupUuidOfQProfileEditGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("qprofile_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java deleted file mode 100644 index f3e36517d845d048ba3839d3a58bbf9b66dd25be..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropGroupIdColumnOfQProfileEditGroupsTable extends DdlChange { - public DropGroupIdColumnOfQProfileEditGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "qprofile_edit_groups", "group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java deleted file mode 100644 index 33769fd2aa570fae402cddf9c9b828df50b185c3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnGroupIdOfQProfileEditGroupsTable extends DropIndexChange { - private static final String TABLE_NAME = "qprofile_edit_groups"; - private static final String INDEX_NAME = "qprofile_edit_groups_unique"; - - public DropIndexOnGroupIdOfQProfileEditGroupsTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java deleted file mode 100644 index 83488737904e24369ad6e6f21b3ce46cb30dee6a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeQProfileEditGroupsGroupUuidNotNullable extends DdlChange { - private static final String TABLE = "qprofile_edit_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeQProfileEditGroupsGroupUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java deleted file mode 100644 index 7a871e0726bf446a20adbaf0f4dbc6f10125c755..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.version.v84.util.OrphanData; - -public class PopulateQProfileEditGroupsGroupUuid extends DataChange { - - public PopulateQProfileEditGroupsGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select qeg.uuid, g.uuid " + - "from qprofile_edit_groups qeg " + - "join groups g on qeg.group_id = g.id"); - - massUpdate.update("update qprofile_edit_groups set group_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - OrphanData.delete(context, "qprofile_edit_groups", "group_uuid"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/package-info.java deleted file mode 100644 index 606fbc6d3750c88c7f9fab57a03fbf56660837fa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTable.java deleted file mode 100644 index 5e09b14389351f60d7c7127ea108bcc0bd9de9be..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnIssueKeyOfIssueChangesTable extends DdlChange { - private static final String TABLE_NAME = "issue_changes"; - private static final String INDEX_NAME = "issue_changes_issue_key"; - - public AddIndexOnIssueKeyOfIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("issue_key") - .setIsNullable(true) - .setLimit(50) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTable.java deleted file mode 100644 index 308179b95f80b68c2eb2680ded348cb7572236a6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnKeeOfIssueChangesTable extends DdlChange { - private static final String TABLE_NAME = "issue_changes"; - private static final String INDEX_NAME = "issue_changes_kee"; - - public AddIndexOnKeeOfIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(true) - .setLimit(50) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java deleted file mode 100644 index 61d5411cd82a80a4f72f5d54d3ddef2a96e99e3b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfIssueChangesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("issue_changes", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTable.java deleted file mode 100644 index 8f09a04aeb28c1f2a933d70800426bc35672af7c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTable.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.dialect.MsSql; -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 CopyIssueChangesTable extends DdlChange { - private static final String COPY_NAME = "issue_changes_copy"; - - public CopyIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - - String query; - if (getDatabase().getDialect().getId().equals(MsSql.ID)) { - query = "select cast (ic.id AS VARCHAR(40)) AS uuid, ic.kee, ic.issue_key, ic.user_login, ic.change_type, " + - "ic.change_data, ic.created_at, ic.updated_at, ic.issue_change_creation_date, i.project_uuid " + - "INTO issue_changes_copy " + - "FROM issue_changes AS ic inner join issues i on i.kee = ic.issue_key"; - } else { - query = "create table issue_changes_copy " + - "(uuid, kee, issue_key, user_login, change_type, change_data, created_at, updated_at, issue_change_creation_date, project_uuid)" + - "as (" + - "SELECT cast (ic.id AS VARCHAR(40)) AS uuid, ic.kee, ic.issue_key, ic.user_login, ic.change_type, ic.change_data, ic.created_at, ic.updated_at, " - + "ic.issue_change_creation_date, i.project_uuid " + - "FROM issue_changes ic " + - "inner join issues i on i.kee = ic.issue_key " + - ")"; - } - - context.execute(query); - context.execute(new AlterColumnsBuilder(getDialect(), COPY_NAME).updateColumn( - newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE) - .build()).build()); - context.execute(new AlterColumnsBuilder(getDialect(), COPY_NAME).updateColumn( - newVarcharColumnDefBuilder() - .setColumnName("issue_key") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE) - .build()).build()); - context.execute(new AlterColumnsBuilder(getDialect(), COPY_NAME).updateColumn( - newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTable.java deleted file mode 100644 index 7b6b1420934d3952609f09afda6c4845a2ef1013..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIssueChangesTable extends DdlChange { - public DropIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropTableBuilder(getDialect(), "issue_changes").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChanges.java deleted file mode 100644 index d2f5bb1766aa49b16f361dcce19f5542a1a5084d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChanges.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class RenameIssueChangesCopyToIssueChanges extends DdlChange { - public RenameIssueChangesCopyToIssueChanges(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new RenameTableBuilder(getDialect()) - .setName("issue_changes_copy") - .setNewName("issue_changes") - .setAutoGeneratedId(false) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/package-info.java deleted file mode 100644 index 9be654131881c94c595961fff8e13c551d0c7e2f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java deleted file mode 100644 index ab48c555d58c14faa9f0b050907dbaf60721f6bb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnKeeColumnOfIssuesTable extends DdlChange { - private static final String TABLE_NAME = "issues"; - - public AddPrimaryKeyOnKeeColumnOfIssuesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder(TABLE_NAME, "kee").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/package-info.java deleted file mode 100644 index 5768a007cf06f9e16455569e66b5610497b70405..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.issues; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java deleted file mode 100644 index abcdd62ff1097f70f6fbcc7e59195c4730562707..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfManualMeasuresTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfManualMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("manual_measures", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidColumnToManualMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidColumnToManualMeasures.java deleted file mode 100644 index dcd30d2809eaa2b7b5e2639ef90c043a9410616b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidColumnToManualMeasures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidColumnToManualMeasures extends DdlChange { - private static final String TABLE = "manual_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddUuidColumnToManualMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTable.java deleted file mode 100644 index 6d847d62220ed8cd8fbb9a65ef268d7985e75344..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfManualMeasuresTable extends DdlChange { - - public DropIdColumnOfManualMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "manual_measures", "id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java deleted file mode 100644 index 01d9a702b43e842bfd690d5e49f8505b8661ee1f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfManualMeasuresTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfManualMeasuresTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("manual_measures", "id", true)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java deleted file mode 100644 index 33a606b6d486502f54786825112c9d966064f827..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeManualMeasuresUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "manual_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeManualMeasuresUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasureUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasureUuid.java deleted file mode 100644 index f67237a7e3b6a2abb8994928485caa5ef7ed3a28..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasureUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateManualMeasureUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateManualMeasureUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from manual_measures where uuid is null"); - massUpdate.update("update manual_measures set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/package-info.java deleted file mode 100644 index dae0c2b24249fa3edf761d14c5025678423e9939..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java deleted file mode 100644 index 4c98812c6a97157da2bf804dcba3a0da85c00750..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfMetricsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfMetricsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("metrics", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTable.java deleted file mode 100644 index 43efea12b680e9f6c0a15d41b700157131accfaa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToMetricsTable extends AddUuidColumnToTable { - private static final String TABLE = "metrics"; - - public AddUuidColumnToMetricsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTable.java deleted file mode 100644 index 026c931dd206ad7ae333bcadebe60da94a023b75..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfMetricsTable extends DropIdColumn { - private static final String TABLE = "metrics"; - - public DropIdColumnOfMetricsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java deleted file mode 100644 index 50e204ee5b687ddfb990b6df9ef4f5defdd377c2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfMetricsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "metrics"; - - public DropPrimaryKeyOnIdColumnOfMetricsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullable.java deleted file mode 100644 index c590689ea9d495a7e30f25c19c298e909673688f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeMetricsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "metrics"; - - public MakeMetricsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuid.java deleted file mode 100644 index d4d9ea11c7d411be3dd9c00876ee0418023679a9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuid.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateMetricsUuid extends DataChange { - public PopulateMetricsUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from metrics where uuid is null"); - massUpdate.update("update metrics set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - update.setString(1, Long.toString(id)); - update.setLong(2, id); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java deleted file mode 100644 index c05fd4427df8c9a1df90c481b691d0b7529d9dbc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnMetricUuidOfLiveMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "live_measures"; - private static final String INDEX_NAME = "live_measures_component"; - - public AddIndexOnMetricUuidOfLiveMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTable.java deleted file mode 100644 index 926391ad1c752e9155c57841385599a0bff21bd7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTable.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnProjectUuidOfLiveMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "live_measures"; - private static final String INDEX_NAME = "live_measures_project"; - - public AddIndexOnProjectUuidOfLiveMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddPKeyOnUuidOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddPKeyOnUuidOfLiveMeasuresTable.java deleted file mode 100644 index 575d834a1b28228c29c5b23d169b867a021fba97..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddPKeyOnUuidOfLiveMeasuresTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPKeyOnUuidOfLiveMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "live_measures"; - - public AddPKeyOnUuidOfLiveMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder(TABLE_NAME, "uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTable.java deleted file mode 100644 index 023708dc150c7bb23c84d1c6ff41311b7712734f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTable.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateTableAsBuilder; -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.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CopyLiveMeasuresTable extends DdlChange { - public CopyLiveMeasuresTable(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - CreateTableAsBuilder builder = new CreateTableAsBuilder(getDialect(), "live_measures_copy", "live_measures") - // this will cause the following changes: - // * Add METRIC_UUID with values in METRIC_ID casted to varchar - .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(VarcharColumnDef.UUID_SIZE).setIsNullable(false).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("project_uuid").setLimit(50).setIsNullable(false).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(50).setIsNullable(false).build()) - .addColumnWithCast(newVarcharColumnDefBuilder().setColumnName("metric_uuid").setLimit(40).setIsNullable(false).build(), "metric_id") - .addColumn(newDecimalColumnDefBuilder().setColumnName("value").build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("text_value").setLimit(4000).build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("variation").build()) - .addColumn(newBlobColumnDefBuilder().setColumnName("measure_data").build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("update_marker").setLimit(VarcharColumnDef.UUID_SIZE).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()); - context.execute(builder.build()); - - /* - * "UUID VARCHAR(40) NOT NULL", - * "PROJECT_UUID VARCHAR(50) NOT NULL", - * "COMPONENT_UUID VARCHAR(50) NOT NULL", - * "METRIC_UUID VARCHAR(40) NOT NULL", - * "VALUE DOUBLE", - * "TEXT_VALUE VARCHAR(4000)", - * "VARIATION DOUBLE", - * "MEASURE_DATA BLOB", - * "UPDATE_MARKER VARCHAR(40)", - * "CREATED_AT BIGINT NOT NULL", - * "UPDATED_AT BIGINT NOT NULL" - */ - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTable.java deleted file mode 100644 index c1a29a3736f838a55c4eb235baef2c0812aeb5da..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTable.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropLiveMeasuresTable extends DdlChange { - public DropLiveMeasuresTable(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new DropTableBuilder(getDialect(), "live_measures").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasures.java deleted file mode 100644 index c3cb5f3da113819be2dab7dea8289f558a916cdb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasures.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class RenameLiveMeasuresCopyToLiveMeasures extends DdlChange { - public RenameLiveMeasuresCopyToLiveMeasures(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new RenameTableBuilder(getDialect()) - .setName("live_measures_copy") - .setNewName("live_measures") - .setAutoGeneratedId(false) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/package-info.java deleted file mode 100644 index 7584643acb7ff4ef86d80a7211500fb0f214fdcb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java deleted file mode 100644 index 95107b6ef02d89f98881ba2956038b94152e9547..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddMetricUuidColumnToManualMeasures extends DdlChange { - private static final String TABLE = "manual_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddMetricUuidColumnToManualMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java deleted file mode 100644 index b41fd6e429ea44c4322c857425dd0182d81d8c63..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropMetricIdColumnOfManualMeasuresTable extends DdlChange { - public DropMetricIdColumnOfManualMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "manual_measures", "metric_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java deleted file mode 100644 index c3457b5c9bf4227e704ebecfb49ab92c4504adc0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeManualMeasuresMetricUuidNotNullable extends DdlChange { - private static final String TABLE = "manual_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeManualMeasuresMetricUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java deleted file mode 100644 index f404da74103e235b54798ce752210c5d1785759e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateManualMeasuresMetricUuid extends DataChange { - - public PopulateManualMeasuresMetricUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select mm.uuid, m.uuid " + - "from manual_measures mm " + - "join metrics m on mm.metric_id = m.id"); - - massUpdate.update("update manual_measures set metric_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from manual_measures where metric_uuid is null"); - massUpdate.update("delete from manual_measures where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/package-info.java deleted file mode 100644 index e74fa233db43f515914aa6036cfd5cb01bc4006f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/package-info.java deleted file mode 100644 index 62fb00a5c814a816096a483ef16c6218a1ecedb2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTable.java deleted file mode 100644 index 347edef0708b56b2944d893ff5bacdcc4fb0453f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTable.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "project_measures"; - private static final String INDEX_NAME = "measures_analysis_metric"; - - public AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("analysis_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java deleted file mode 100644 index 8473487e14faaf43cd9f180a1a2dbb2f42c84577..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnMetricUuidOfProjectMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "project_measures"; - private static final String INDEX_NAME = "project_measures_metric"; - - public AddIndexOnMetricUuidOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java deleted file mode 100644 index c871abfe5a7fe458b7f0b58d69c3f8b7aa5d3181..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddMetricUuidColumnToProjectMeasures extends DdlChange { - private static final String TABLE = "project_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddMetricUuidColumnToProjectMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasures.java deleted file mode 100644 index d4fc9f53eeec5dadaa5c3d3f4b31f2e1ed62a2d1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasures.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import javax.annotation.Nullable; -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 DeleteSecurityReviewRatingProjectMeasures extends DataChange { - - private static final String SECURITY_REVIEW_RATING_METRIC_KEY = "security_review_rating"; - private static final String SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY = "security_review_rating_effort"; - - public DeleteSecurityReviewRatingProjectMeasures(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - String reviewRatingUuid = getMetricUuid(context, SECURITY_REVIEW_RATING_METRIC_KEY); - String reviewRatingEffortUuid = getMetricUuid(context, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - if (reviewRatingUuid != null) { - deleteFromProjectMeasures(context, reviewRatingUuid, reviewRatingEffortUuid); - } - } - - @Nullable - private static String getMetricUuid(Context context, String metricName) throws SQLException { - return context.prepareSelect("select uuid from metrics where name = ?") - .setString(1, metricName) - .get(row -> row.getNullableString(1)); - } - - private static void deleteFromProjectMeasures(Context context, String reviewRatingUuid, @Nullable String reviewRatingEffortUuid) throws SQLException { - deleteFromProjectMeasures(context, reviewRatingUuid); - - if (reviewRatingEffortUuid != null) { - deleteFromProjectMeasures(context, reviewRatingEffortUuid); - } - } - - private static void deleteFromProjectMeasures(Context context, @Nullable String metricUuid) throws SQLException { - if (metricUuid == null) { - return; - } - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from project_measures where metric_uuid = ?") - .setString(1, metricUuid); - massUpdate.update("delete from project_measures where uuid = ?"); - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java deleted file mode 100644 index 99557ca0fafcbec3d74e13d40cd63a135f26c1f5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnMetricIdOfProjectMeasuresTable extends DropIndexChange { - private static final String TABLE_NAME = "project_measures"; - private static final String INDEX_NAME = "measures_analysis_metric"; - - public DropIndexOnMetricIdOfProjectMeasuresTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java deleted file mode 100644 index b8ee0a5901204f3cc01909a029d63a98f418ebb6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropMetricIdColumnOfProjectMeasuresTable extends DdlChange { - public DropMetricIdColumnOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "project_measures", "metric_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java deleted file mode 100644 index f3a06e9ee152b84f39394e1325fc6629c922f5a1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeProjectMeasuresMetricUuidNotNullable extends DdlChange { - private static final String TABLE = "project_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeProjectMeasuresMetricUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java deleted file mode 100644 index 2b3054a70de00338e96f91b7a7963816615403f7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateProjectMeasuresMetricUuid extends DataChange { - - public PopulateProjectMeasuresMetricUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select pm.uuid, m.uuid " + - "from project_measures pm " + - "join metrics m on pm.metric_id = m.id"); - - massUpdate.update("update project_measures set metric_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from project_measures where metric_uuid is null"); - massUpdate.update("delete from project_measures where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/package-info.java deleted file mode 100644 index ddc259643964cd6ee723e0ab005c3228a63a1d38..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java deleted file mode 100644 index 6c6ac7a0635bf81d5645cefc1e7b6cb3f0957e1a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddMetricUuidColumnToQualityGateConditions extends DdlChange { - private static final String TABLE = "quality_gate_conditions"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddMetricUuidColumnToQualityGateConditions(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java deleted file mode 100644 index 48f952d388d6afe5c736963629541ce0d264a5f9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropMetricIdColumnOfQualityGateConditionsTable extends DdlChange { - public DropMetricIdColumnOfQualityGateConditionsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "quality_gate_conditions", "metric_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java deleted file mode 100644 index b3c7e8b5aa3055fa1c119a2a1267f22d72fb3c78..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeQualityGateConditionsMetricUuidNotNullable extends DdlChange { - private static final String TABLE = "quality_gate_conditions"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeQualityGateConditionsMetricUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java deleted file mode 100644 index d0e139c8ffb4d772ab4f1b8a7bb60f38f7b44aba..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQualityGateConditionsMetricUuid extends DataChange { - - public PopulateQualityGateConditionsMetricUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select qgc.uuid, m.uuid " + - "from quality_gate_conditions qgc " + - "join metrics m on qgc.metric_id = m.id"); - - massUpdate.update("update quality_gate_conditions set metric_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from quality_gate_conditions where metric_uuid is null"); - massUpdate.update("delete from quality_gate_conditions where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/package-info.java deleted file mode 100644 index 282da5d425f39f0d55a73e127839b24cd4f63d16..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java deleted file mode 100644 index ba70fe2ab16384eadba7340572ce138d47dbf3a5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfNotificationTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfNotificationTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("notifications", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotification.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotification.java deleted file mode 100644 index 9429663f6973e15f7d33ac6ce4d6b425e5c7b1fe..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotification.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BigIntegerColumnDef; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidAndCreatedAtColumnsToNotification extends DdlChange { - private static final String TABLE = "notifications"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final BigIntegerColumnDef createdAtColumnDefinition = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(true) - .build(); - - public AddUuidAndCreatedAtColumnsToNotification(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .addColumn(createdAtColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTable.java deleted file mode 100644 index ac1313af5024e1db44149bd1856cf18aef9811f6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfNotificationTable extends DropIdColumn { - private static final String TABLE = "notifications"; - - public DropIdColumnOfNotificationTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java deleted file mode 100644 index 3b10433260a7469245c55be69d65e6335c4f8aa5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfNotificationTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "notifications"; - - public DropPrimaryKeyOnIdColumnOfNotificationTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java deleted file mode 100644 index 3b62fd589ad75ef21333c6c23a4fcb12fcd8a40c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BigIntegerColumnDef; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeNotificationUuidAndCreatedAtColumnsNotNullable extends DdlChange { - private static final String TABLE = "notifications"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final BigIntegerColumnDef createdAtColumnDefinition = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - - public MakeNotificationUuidAndCreatedAtColumnsNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .updateColumn(createdAtColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAt.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAt.java deleted file mode 100644 index 2185cb52ec09af4d348ba3cc33ec446decc1a879..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAt.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.sql.SQLException; -import java.util.concurrent.atomic.AtomicLong; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateNotificationUuidAndCreatedAt extends DataChange { - - private final UuidFactory uuidFactory; - private final System2 system2; - - public PopulateNotificationUuidAndCreatedAt(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from notifications where uuid is null"); - massUpdate.update("update notifications set uuid = ?, created_at = ? where id = ?"); - - // now - 7 days, to have previous notification in the past - long lastWeek = system2.now() - (1000 * 60 * 60 * 24 * 7); - - AtomicLong cpt = new AtomicLong(0); - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, lastWeek + cpt.longValue()); - update.setLong(3, row.getLong(1)); - cpt.addAndGet(1); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/package-info.java deleted file mode 100644 index a54123618e7886a91e5660d99d2fe8a5ca3f1e8b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/package-info.java deleted file mode 100644 index 06b4efd9079e013e4e33f29724af1dd19946af66..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java deleted file mode 100644 index 59c57ae55685c5e3717d05c59510d55d746b2b81..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("permission_templates", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplates.java deleted file mode 100644 index 21914ee8bbc64f6bd53ecad2c1d073dc6f1d6762..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplates.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToPermissionTemplates extends AddUuidColumnToTable { - private static final String TABLE_NAME = "permission_templates"; - - public AddUuidColumnToPermissionTemplates(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java deleted file mode 100644 index fd9eab90c9546c31b49fc65913dca38600a567ec..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfPermissionTemplatesTable extends DropIdColumn { - private static final String TABLE_NAME = "permission_templates"; - - public DropIdColumnOfPermissionTemplatesTable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java deleted file mode 100644 index caeaf79233b8e6097cd8e2930201e4c7f68d5152..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropKeeColumnOfPermissionTemplatesTable extends DdlChange { - - public DropKeeColumnOfPermissionTemplatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "permission_templates", "kee").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java deleted file mode 100644 index 7f8987ee03c27805348949159bd0fa0b4618b579..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "permission_templates"; - - public DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java deleted file mode 100644 index 0c7968c8e3880188a99228b7ced9f254f9f41484..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakePermissionTemplateUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE_NAME = "permission_templates"; - - public MakePermissionTemplateUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuid.java deleted file mode 100644 index f8e38043148fc21981973fe9ab3974304f354b1e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuid.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermissionTemplatesUuid extends DataChange { - - private UuidFactory uuidFactory; - - public PopulatePermissionTemplatesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select kee from permission_templates where uuid is null"); - massUpdate.update("update permission_templates set uuid = ? where kee = ?"); - - massUpdate.execute((row, update) -> { - String kee = row.getString(1); - String uuid = kee; - - //kee column was declared with 100 char length, so we regenerate if it happened - if (kee.length() > 40) { - uuid = uuidFactory.create(); - } - - update.setString(1, uuid); - update.setString(2, kee); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/package-info.java deleted file mode 100644 index 39206bbdcd93ce0f0df607df729145942c9328ff..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java deleted file mode 100644 index 67f87fbf4a5ba84970875c4bc9e62fc3d87f127d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddTemplateUuidColumnToPermTemplatesGroups extends DdlChange { - private static final String TABLE = "perm_templates_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddTemplateUuidColumnToPermTemplatesGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index 1e41ee71096731f696383014cce9f2ef6a1b2d83..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTemplateIdColumnOfPermTemplatesGroupsTable extends DdlChange { - - public DropTemplateIdColumnOfPermTemplatesGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_groups", "template_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java deleted file mode 100644 index 03cd8c28bd136397590b8495893edd34556335bc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakePermTemplatesGroupsTemplateUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "perm_templates_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakePermTemplatesGroupsTemplateUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java deleted file mode 100644 index 7b38a355be71da6e5a9be68d7c5a73d06e90d6a8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesGroupsTemplateUuidColumn extends DataChange { - - public PopulatePermTemplatesGroupsTemplateUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptg.uuid, pt.uuid " + - "from perm_templates_groups ptg " + - "join permission_templates pt on ptg.template_id = pt.id " + - "where ptg.template_uuid is null"); - massUpdate.update("update perm_templates_groups set template_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from perm_templates_groups where template_uuid is null"); - massUpdate.update("delete from perm_templates_groups where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/package-info.java deleted file mode 100644 index 4c5732b638ddfbb15a92eff65f8d17c77361c793..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java deleted file mode 100644 index c384639573bf2ad02c12fc4e87a501ab880126a0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddTemplateUuidColumnToPermTemplatesUsers extends DdlChange { - private static final String TABLE = "perm_templates_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddTemplateUuidColumnToPermTemplatesUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index 7d5be67bff018506c458eceb0302f8494c110362..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTemplateIdColumnOfPermTemplatesUsersTable extends DdlChange { - - public DropTemplateIdColumnOfPermTemplatesUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_users", "template_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java deleted file mode 100644 index a750dc4cce37033ae1a50f215025d9a7c575d3a4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakePermTemplatesUsersTemplateUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "perm_templates_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakePermTemplatesUsersTemplateUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java deleted file mode 100644 index 7440faeb74566ab3074588e41e3f35a6b840a1d7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesUsersTemplateUuidColumn extends DataChange { - - public PopulatePermTemplatesUsersTemplateUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptu.uuid, pt.uuid " + - "from perm_templates_users ptu " + - "join permission_templates pt on ptu.template_id = pt.id " + - "where ptu.template_uuid is null"); - massUpdate.update("update perm_templates_users set template_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from perm_templates_users where template_uuid is null"); - massUpdate.update("delete from perm_templates_users where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/package-info.java deleted file mode 100644 index 6dd2cd3ff8cab7815094b3b8a8f1904e40d7ae3a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java deleted file mode 100644 index 0acc3af355417503f4240ba7447edd96d766af16..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddTemplateUuidColumnToPermTplCharacteristics extends DdlChange { - private static final String TABLE = "perm_tpl_characteristics"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddTemplateUuidColumnToPermTplCharacteristics(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java deleted file mode 100644 index 61349a10e4f0a40af4325b9673880f9d65183619..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable extends DdlChange { - private static final String TABLE_NAME = "perm_tpl_characteristics"; - private static final String INDEX_NAME = "uniq_perm_tpl_charac"; - - public AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("permission_key") - .setIsNullable(false) - .setLimit(64) - .build()) - .build()); - } - - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java deleted file mode 100644 index cfee96347d1fd02810b8bfa8699639b943433c43..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTemplateIdColumnOfPermTplCharacteristicsTable extends DdlChange { - - public DropTemplateIdColumnOfPermTplCharacteristicsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_tpl_characteristics", "template_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java deleted file mode 100644 index 7b8702d8c07b52d28bc889f49bad9222ed584bdd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable extends DropIndexChange { - private static final String TABLE_NAME = "perm_tpl_characteristics"; - private static final String INDEX_NAME = "uniq_perm_tpl_charac"; - - public DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java deleted file mode 100644 index 5d816a11090536897c45164c7c908fe7257a62df..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakePermTplCharacteristicsTemplateUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "perm_tpl_characteristics"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakePermTplCharacteristicsTemplateUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java deleted file mode 100644 index 3403a82e507fb33ad76b75d23cf55988613b29a1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTplCharacteristicsTemplateUuidColumn extends DataChange { - - public PopulatePermTplCharacteristicsTemplateUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptc.uuid, pt.uuid " + - "from perm_tpl_characteristics ptc " + - "join permission_templates pt on ptc.template_id = pt.id " + - "where ptc.template_uuid is null"); - massUpdate.update("update perm_tpl_characteristics set template_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from perm_tpl_characteristics where template_uuid is null"); - massUpdate.update("delete from perm_tpl_characteristics where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/package-info.java deleted file mode 100644 index 23e0dbb9550001cfb72f61ce160824f43f495d3e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/package-info.java deleted file mode 100644 index 4fb25fe0605ec8bf5dfcfaa9913593da9f276e24..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index a55ce12aa749a5491b8f71667c6cc2b62cdc8635..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("perm_templates_groups", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java deleted file mode 100644 index 0923b2e484cd078d4fe8b64695987db38e1b3834..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToPermTemplatesGroupsTable extends AddUuidColumnToTable { - private static final String TABLE = "perm_templates_groups"; - - public AddUuidColumnToPermTemplatesGroupsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index 0f0b83714b5f349299a265260dba25bc90540067..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfPermTemplatesGroupsTable extends DropIdColumn { - private static final String TABLE = "perm_templates_groups"; - - public DropIdColumnOfPermTemplatesGroupsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index 54bc2582d5462f0f163bd8a96c28027886286915..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "perm_templates_groups"; - - public DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java deleted file mode 100644 index 79c6c7eee935fc713ff8be431cea2ad4593e4bd3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakePermTemplatesGroupsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "perm_templates_groups"; - - public MakePermTemplatesGroupsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java deleted file mode 100644 index 8ecad95df56bdb52e83c2c82add45766abe6e9b8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesGroupsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulatePermTemplatesGroupsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from perm_templates_groups where uuid is null"); - massUpdate.update("update perm_templates_groups set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/package-info.java deleted file mode 100644 index e6cd65843a61281b70a4c91f508eb7e50216d3d5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index b415fac6d6fe7c98cb0a5f76374e88ff66b04b8f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("perm_templates_users", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java deleted file mode 100644 index 25a16d58e7c293eefc6abb179715e27a813af8df..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToPermTemplatesUsersTable extends AddUuidColumnToTable { - private static final String TABLE = "perm_templates_users"; - - public AddUuidColumnToPermTemplatesUsersTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index 934f75dcbafe6c07470b5be932e39a3123e7d172..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfPermTemplatesUsersTable extends DropIdColumn { - private static final String TABLE = "perm_templates_users"; - - public DropIdColumnOfPermTemplatesUsersTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index 91dba020bb8c5a752eed45f40f9eaad703a59fa8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "perm_templates_users"; - - public DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java deleted file mode 100644 index b38fb2b229adfe4dfa9d36912560a9ea44fd8a02..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakePermTemplatesUsersUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "perm_templates_users"; - - public MakePermTemplatesUsersUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuid.java deleted file mode 100644 index ed67bc2829effb7d2082a031a41b7b7dba1a027f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesUsersUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulatePermTemplatesUsersUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from perm_templates_users where uuid is null"); - massUpdate.update("update perm_templates_users set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/package-info.java deleted file mode 100644 index fd09d1a820b8d7aaf2d16d987e6a396e884bc961..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java deleted file mode 100644 index 4cc6c017ae3ffa6e2544a6de8fe8a7ae42a35721..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("perm_tpl_characteristics", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java deleted file mode 100644 index 8a020290d7a2230773ca50f5c9a988dde0fed909..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToPermTplCharacteristicsTable extends AddUuidColumnToTable { - private static final String TABLE = "perm_tpl_characteristics"; - - public AddUuidColumnToPermTplCharacteristicsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java deleted file mode 100644 index f794e0d8b0a17ca6a54e66a3e57b63d6e6451d83..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfPermTplCharacteristicsTable extends DropIdColumn { - private static final String TABLE = "perm_tpl_characteristics"; - - public DropIdColumnOfPermTplCharacteristicsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java deleted file mode 100644 index a8892ff80705421b44537f958167d61181605995..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "perm_tpl_characteristics"; - - public DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java deleted file mode 100644 index aadc6b4de8a067132d7ef52658805de0a141f4e7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakePermTplCharacteristicsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "perm_tpl_characteristics"; - - public MakePermTplCharacteristicsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java deleted file mode 100644 index 36d85665dd1262097557edb335e78d5eaa0038f9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTplCharacteristicsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulatePermTplCharacteristicsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from perm_tpl_characteristics where uuid is null"); - massUpdate.update("update perm_tpl_characteristics set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/package-info.java deleted file mode 100644 index a17bb9edec9130685df99876bb21b9da129bc8eb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java deleted file mode 100644 index 685ff63e9211b976a5aeb9d8f2ab8e6a3f5d3357..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("project_measures", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTable.java deleted file mode 100644 index f03425d1543183fd74f97e1842dcab69afc58115..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTable.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddTechIndexOnUuidOfProjectMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "project_measures"; - private static final String INDEX_NAME = "tech_index_uuid"; - - public AddTechIndexOnUuidOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists(INDEX_NAME)) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists(String name) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, name, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidColumnToProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidColumnToProjectMeasures.java deleted file mode 100644 index 06b726088249494039fc68c2b7b27530db65516a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidColumnToProjectMeasures.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToProjectMeasures extends AddUuidColumnToTable { - private static final String TABLE = "project_measures"; - - public AddUuidColumnToProjectMeasures(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTable.java deleted file mode 100644 index 0ad1501e53d83e7dae86d7bd999c1b8b238509b7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfProjectMeasuresTable extends DropIdColumn { - private static final String TABLE = "project_measures"; - - public DropIdColumnOfProjectMeasuresTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java deleted file mode 100644 index 2dd32ab8fd1fe5864a36d6944f726c40ad8c597a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "project_measures"; - - public DropPrimaryKeyOnIdColumnOfProjectMeasuresTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTable.java deleted file mode 100644 index e38114d46b66034c66a57f2d4d2cf50cab8b1c89..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropTechIndexOnUuidOfProjectMeasuresTable extends DropIndexChange { - private static final String TABLE_NAME = "project_measures"; - private static final String INDEX_NAME = "tech_index_uuid"; - - public DropTechIndexOnUuidOfProjectMeasuresTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java deleted file mode 100644 index b78b7d0ac7705858c98128f968a4e29f5d7c9d76..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeProjectMeasuresUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "project_measures"; - - public MakeProjectMeasuresUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasureUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasureUuid.java deleted file mode 100644 index 002fe54ca2d479aab463236c00e8013c5c660222..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasureUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateProjectMeasureUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateProjectMeasureUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from project_measures where uuid is null"); - massUpdate.update("update project_measures set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/package-info.java deleted file mode 100644 index bb28fde3a0fa51aac9ca5223ec00d1797706d60e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java deleted file mode 100644 index 38654bc7cbed8dae618fd2c3ad447717a044f117..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("project_qprofiles", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java deleted file mode 100644 index 4ae689064d8a5c598f4f63e878fe328e05a58a76..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidColumnToProjectQProfilesTable extends DdlChange { - private static final String TABLE = "project_qprofiles"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddUuidColumnToProjectQProfilesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java deleted file mode 100644 index 84857120b64167abbd8253dfca12ffdb370eefd8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfProjectQProfilesTable extends DdlChange { - - private Database db; - - public DropIdColumnOfProjectQProfilesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "project_qprofiles", "id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java deleted file mode 100644 index 6fc9170dc657a736ca00f2b7398e4871980abfe5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("project_qprofiles", "id", true)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java deleted file mode 100644 index 7a5a68400210b9a3f80b1a2fb3b3b08778b8c043..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeProjectQProfilesUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "project_qprofiles"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeProjectQProfilesUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuid.java deleted file mode 100644 index 4452a953577ee044c24b59ffd0cd66496b57ad31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateProjectQProfilesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateProjectQProfilesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from project_qprofiles where uuid is null"); - massUpdate.update("update project_qprofiles set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/package-info.java deleted file mode 100644 index f3ea7bb72b91aae3a7f7139d7a983d2acf86eb2a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java deleted file mode 100644 index 30e6ff1ad19da0f11df12820fb7286424390182f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfPropertiesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("properties", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToProperties.java deleted file mode 100644 index 29629244ad3750c998b89ac13fda2afadff47c3f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToProperties extends AddUuidColumnToTable { - private static final String TABLE_NAME = "properties"; - - public AddUuidColumnToProperties(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTable.java deleted file mode 100644 index 0111a4345d100c4b80bf6558be6d0dc940ed7f7a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfPropertiesTable extends DdlChange { - - public DropIdColumnOfPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "properties", "id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java deleted file mode 100644 index 5096df04a4c355cf82afe28f3d936716759992f0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfPropertiesTable extends DropPrimaryKeyOnIdColumn { - - private static final String TABLE_NAME = "properties"; - - public DropPrimaryKeyOnIdColumnOfPropertiesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable.java deleted file mode 100644 index 5e9e447aee4c05eb84dbdad1c9b9b5d41bb17b00..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakePropertiesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE_NAME = "properties"; - - public MakePropertiesUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuid.java deleted file mode 100644 index 61cf206173944df6bdecc24bbd989b309bbeece9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePropertiesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulatePropertiesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from properties where uuid is null"); - massUpdate.update("update properties set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/package-info.java deleted file mode 100644 index 5d881bed586793fb9289834acd3ce9c61f8447b6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.properties; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java deleted file mode 100644 index ebf6682db90be78574a799b92bb9a9e2b106a060..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("quality_gate_conditions", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java deleted file mode 100644 index 5b12fb7cde892e4e97cc4718d7005a0d69e8d39b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToQualityGateConditionsTable extends AddUuidColumnToTable { - private static final String TABLE = "quality_gate_conditions"; - - public AddUuidColumnToQualityGateConditionsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java deleted file mode 100644 index e464525936f985186e7661c9f4533606027bf899..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfQualityGateConditionsTable extends DropIdColumn { - private static final String TABLE = "quality_gate_conditions"; - - public DropIdColumnOfQualityGateConditionsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java deleted file mode 100644 index dee71e256691074f143104646db9483d5acfdaed..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "quality_gate_conditions"; - - public DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java deleted file mode 100644 index ce11ddd106082f671cc993924a35d26c316d0244..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeQualityGateConditionsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "quality_gate_conditions"; - - public MakeQualityGateConditionsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuid.java deleted file mode 100644 index db5d72de35a0e3a74cdb9ad19c8a7ff8fb19f9dc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQualityGateConditionsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateQualityGateConditionsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from quality_gate_conditions where uuid is null"); - massUpdate.update("update quality_gate_conditions set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/package-info.java deleted file mode 100644 index 80513ced9089eafcf4c9de56a2903d9ca60ed666..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java deleted file mode 100644 index 3d222fa045df9b166cddc9853e97bd36b3bcdd79..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfQGatesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfQGatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("quality_gates", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditions.java deleted file mode 100644 index f1edcfb31326ac1d9faf936877a1c45b36941c26..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditions.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddQGateUuidColumnForQGateConditions extends DdlChange { - private static final String TABLE = "quality_gate_conditions"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("qgate_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddQGateUuidColumnForQGateConditions(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTable.java deleted file mode 100644 index faf335a500959a0807986bc5888268b7e471bdb6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfQGateTable extends DropIdColumn { - private static final String TABLE = "quality_gates"; - - public DropIdColumnOfQGateTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditions.java deleted file mode 100644 index 7418cf882c2472e762a09306a08a465b49812bc9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditions.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class DropOrphansQGateConditions extends DataChange { - - public DropOrphansQGateConditions(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from quality_gate_conditions where qgate_uuid is null"); - massUpdate.update("delete from quality_gate_conditions where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java deleted file mode 100644 index cf362b8603d789703a148dec9cc4d2828a003e34..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfQGatesTable extends DropPrimaryKeyOnIdColumn { - - private static final String TABLE_NAME = "quality_gates"; - - public DropPrimaryKeyOnIdColumnOfQGatesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditions.java deleted file mode 100644 index 7ac2522a5d0683c7eb18aebc669d14b548cf9527..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditions.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropQGateIdColumnForQGateConditions extends DdlChange { - - private Database db; - - public DropQGateIdColumnForQGateConditions(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "quality_gate_conditions", "qgate_id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java deleted file mode 100644 index 6d29940368b7c3ce22b68f41d246b4a5262a8882..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropUniqueIndexOnUuidColumnOfQualityGatesTable extends DropIndexChange { - private static final String INDEX_NAME = "uniq_quality_gates_uuid"; - private static final String TABLE_NAME = "quality_gates"; - - public DropUniqueIndexOnUuidColumnOfQualityGatesTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java deleted file mode 100644 index 9c9db09ddeb5556d585a37abd8881706e73507ba..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeQGateUuidColumnNotNullableForQGateConditions extends DdlChange { - private static final String TABLE = "quality_gate_conditions"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("qgate_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeQGateUuidColumnNotNullableForQGateConditions(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditions.java deleted file mode 100644 index f0a6890ed0ad842a01dff614dba57a939c9ae9d2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditions.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQGateUuidColumnForQGateConditions extends DataChange { - - public PopulateQGateUuidColumnForQGateConditions(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid, id from quality_gates"); - massUpdate.update("update quality_gate_conditions set qgate_uuid = ? where qgate_id = ? and qgate_uuid is null"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - update.setLong(2, row.getLong(2)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/package-info.java deleted file mode 100644 index 4b799e052a2925114d1591f685639a148bef8d30..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java deleted file mode 100644 index 8abf06f41302e27a8c3db87762bb1791b11853ca..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfRulesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("rules", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRules.java deleted file mode 100644 index 7dcf4b096058b3294004141f926fe210a1ed7f23..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRules.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidAndTemplateUuidColumnsToRules extends DdlChange { - private static final String TABLE = "rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final VarcharColumnDef templateUuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddUuidAndTemplateUuidColumnsToRules(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .addColumn(templateUuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTable.java deleted file mode 100644 index 2a5a72b6050d0e8e4202e10287d537783805d88e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfRulesTable extends DdlChange { - - public DropIdColumnOfRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "rules", "id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java deleted file mode 100644 index 0ad3ef2dd079f4303a82a8ee5fe0a55d6650cc8b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfRulesTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfRulesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("rules", "id", true)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTable.java deleted file mode 100644 index 234a404bd8517781922a062607b735a2a1cb37f4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTemplateIdColumnOfRulesTable extends DdlChange { - - public DropTemplateIdColumnOfRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "rules", "template_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullable.java deleted file mode 100644 index 14411b40c6ebb191bc3fb020607fa165d60ae3ae..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeRulesUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeRulesUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuid.java deleted file mode 100644 index d73e604c3fef1cae0afb28c8af953615b8e6b1f1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesTemplateUuid extends DataChange { - - public PopulateRulesTemplateUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select( - "select ru.id, rt.uuid from rules ru " + - "left join rules rt on rt.id = ru.template_id " + - "where ru.template_uuid is null and ru.template_id is not null"); - massUpdate.update("update rules set template_uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuid.java deleted file mode 100644 index bf7a5f3a2190ae5fa6623226a1f286113601c395..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuid.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesUuid extends DataChange { - public PopulateRulesUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from rules where uuid is null"); - massUpdate.update("update rules set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - long id = row.getLong(1); - update.setString(1, Long.toString(id)); - update.setLong(2, id); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTable.java deleted file mode 100644 index f59a20fb73b57e806efe4cee0e353b09bffeda10..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTable.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexToActiveRulesTable extends DdlChange { - private static final String TABLE = "active_rules"; - private static final String INDEX_NAME = "uniq_profile_rule_uuids"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final VarcharColumnDef profileUuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("profile_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddIndexToActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(INDEX_NAME) - .addColumn(profileUuidColumnDefinition) - .addColumn(uuidColumnDefinition) - .setUnique(true) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE, INDEX_NAME, connection); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java deleted file mode 100644 index 29f0cf3de12cbe01c730a3dd83084b08fceae538..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToActiveRulesTable extends DdlChange { - private static final String TABLE = "active_rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java deleted file mode 100644 index a0cdbf8c64b4bfe1e0eb5cf3676f7c9a82dfad73..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnRuleIdColumnOfActiveRulesTable extends DropIndexChange { - private static final String TABLE_NAME = "active_rules"; - private static final String INDEX_NAME = "uniq_profile_rule_ids"; - - public DropIndexOnRuleIdColumnOfActiveRulesTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java deleted file mode 100644 index ea1cd6a4685178dc241c8263397caa0838e951fa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfActiveRulesTable extends DdlChange { - - public DropRuleIdColumnOfActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "active_rules", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java deleted file mode 100644 index 575bf196ced996a04cd0dc4eacc66b85213439b8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeActiveRulesRuleUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "active_rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeActiveRulesRuleUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumn.java deleted file mode 100644 index c3609a2f3a2f176ecec4391ff928d79f652656ca..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumn.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.version.v84.util.OrphanData; - -public class PopulateActiveRulesRuleUuidColumn extends DataChange { - - public PopulateActiveRulesRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ar.rule_id, ru.uuid " + - "from active_rules ar " + - "join rules ru on ar.rule_id = ru.id " + - "where ar.rule_uuid is null"); - massUpdate.update("update active_rules set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - - OrphanData.delete(context, "active_rules", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/package-info.java deleted file mode 100644 index 261bc7cb3b5bc910ba051a1ff84ec9be99ebba38..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java deleted file mode 100644 index 0dfd1eebedbeada15f693b296c2b95d4cbb18106..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexToDeprecatedRuleKeysTable extends DdlChange { - private static final String TABLE = "deprecated_rule_keys"; - private static final String INDEX_NAME = "rule_uuid_deprecated_rule_keys"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddIndexToDeprecatedRuleKeysTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(INDEX_NAME) - .addColumn(uuidColumnDefinition) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE, INDEX_NAME, connection); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java deleted file mode 100644 index c6f8f3776734096e92d30aa047f766cd4bab1b84..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToDeprecatedRuleKeysTable extends DdlChange { - private static final String TABLE = "deprecated_rule_keys"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToDeprecatedRuleKeysTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java deleted file mode 100644 index 17d2433839becb3a50f5979da3e2e05ce47d68f4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable extends DropIndexChange { - private static final String TABLE_NAME = "deprecated_rule_keys"; - private static final String INDEX_NAME = "rule_id_deprecated_rule_keys"; - - public DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java deleted file mode 100644 index 16ffbf582911d4c0dbdb904e468b698b3786ae22..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfDeprecatedRuleKeysTable extends DdlChange { - - public DropRuleIdColumnOfDeprecatedRuleKeysTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "deprecated_rule_keys", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java deleted file mode 100644 index cf3e6e9ccca7c4a219002ef9a6746cd6544c099c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeDeprecatedRuleKeysRuleUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "deprecated_rule_keys"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeDeprecatedRuleKeysRuleUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java deleted file mode 100644 index b2e884989d8cb58a2846b640096217662e7ba59f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.version.v84.util.OrphanData; - -public class PopulateDeprecatedRuleKeysRuleUuidColumn extends DataChange { - - public PopulateDeprecatedRuleKeysRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select drk.rule_id, ru.uuid " + - "from deprecated_rule_keys drk " + - "join rules ru on drk.rule_id = ru.id " + - "where drk.rule_uuid is null"); - massUpdate.update("update deprecated_rule_keys set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - - OrphanData.delete(context, "deprecated_rule_keys", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/package-info.java deleted file mode 100644 index 1d193c90b78fcfda219aa4d30420c1d5b427bc26..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTable.java deleted file mode 100644 index eb81531f173b876f1d3e4f14ad2ecd11c2b10fee..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTable.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexesToIssuesTable extends DdlChange { - private static final String TABLE = "issues"; - - public AddIndexesToIssuesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists("issues_assignee")) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("issues_assignee") - .addColumn("assignee") - .build()); - } - if (!indexExists("issues_component_uuid")) { - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("issues_component_uuid") - .addColumn("component_uuid") - .build()); - } - if (!indexExists("issues_creation_date")) { - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("issues_creation_date") - .addColumn("issue_creation_date") - .build()); - } - if (!indexExists("issues_kee")) { - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("issues_kee") - .setUnique(true) - .addColumn("kee") - .build()); - } - if (!indexExists("issues_project_uuid")) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("issues_project_uuid") - .addColumn("project_uuid") - .build()); - } - if (!indexExists("issues_resolution")) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("issues_resolution") - .addColumn("resolution") - .build()); - } - if (!indexExists("issues_updated_at")) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("issues_updated_at") - .addColumn("updated_at") - .build()); - } - if (!indexExists("issues_rule_uuid")) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("issues_rule_uuid") - .addColumn("rule_uuid") - .build()); - } - } - - private boolean indexExists(String name) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE, name, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTable.java deleted file mode 100644 index c27256172ee206ee672a49ce39842960f75c26d1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTable.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.CreateTableAsBuilder; -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.DecimalColumnDef.newDecimalColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.IntegerColumnDef.newIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.TinyIntColumnDef.newTinyIntColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class CopyIssuesTable extends DdlChange { - public CopyIssuesTable(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - CreateTableAsBuilder builder = new CreateTableAsBuilder(getDialect(), "issues_copy", "issues") - // this will cause the following changes: - // * Drop ID and RULE_ID - // * Add RULE_UUID with values in RULE_ID casted to varchar - .addColumn(newVarcharColumnDefBuilder().setColumnName("kee").setLimit(50).setIsNullable(false).build()) - .addColumnWithCast(newVarcharColumnDefBuilder().setColumnName("rule_uuid").setLimit(40).build(), "rule_id") - .addColumn(newVarcharColumnDefBuilder().setColumnName("severity").setLimit(10).build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("manual_severity").setIsNullable(false).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("message").setLimit(4000).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("line").build()) - .addColumn(newDecimalColumnDefBuilder().setColumnName("gap").build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("status").setLimit(20).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("resolution").setLimit(20).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("checksum").setLimit(1000).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("reporter").setLimit(255).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("assignee").setLimit(255).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("author_login").setLimit(255).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("action_plan_key").setLimit(50).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("issue_attributes").setLimit(4000).build()) - .addColumn(newIntegerColumnDefBuilder().setColumnName("effort").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_creation_date").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_update_date").build()) - .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_close_date").build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("tags").setLimit(4000).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(50).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("project_uuid").setLimit(50).build()) - .addColumn(newBlobColumnDefBuilder().setColumnName("locations").build()) - .addColumn(newTinyIntColumnDefBuilder().setColumnName("issue_type").build()) - .addColumn(newBooleanColumnDefBuilder().setColumnName("from_hotspot").build()); - - context.execute(builder.build()); - /* - "KEE VARCHAR(50) NOT NULL", - "RULE_UUID VARCHAR(40)", - "SEVERITY VARCHAR(10)", - "MANUAL_SEVERITY BOOLEAN NOT NULL", - "MESSAGE VARCHAR(4000)", - "LINE INTEGER", - "GAP DOUBLE", - "STATUS VARCHAR(20)", - "RESOLUTION VARCHAR(20)", - "CHECKSUM VARCHAR(1000)", - "REPORTER VARCHAR(255)", - "ASSIGNEE VARCHAR(255)", - "AUTHOR_LOGIN VARCHAR(255)", - "ACTION_PLAN_KEY VARCHAR(50)", - "ISSUE_ATTRIBUTES VARCHAR(4000)", - "EFFORT INTEGER", - "CREATED_AT BIGINT", - "UPDATED_AT BIGINT", - "ISSUE_CREATION_DATE BIGINT", - "ISSUE_UPDATE_DATE BIGINT", - "ISSUE_CLOSE_DATE BIGINT", - "TAGS VARCHAR(4000)", - "COMPONENT_UUID VARCHAR(50)", - "PROJECT_UUID VARCHAR(50)", - "LOCATIONS BLOB", - "ISSUE_TYPE TINYINT", - "FROM_HOTSPOT BOOLEAN" - */ - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTable.java deleted file mode 100644 index ecfb7ec98978690dc51b694862d010a0daba6b45..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTable.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIssuesTable extends DdlChange { - public DropIssuesTable(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new DropTableBuilder(getDialect(), "issues").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssues.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssues.java deleted file mode 100644 index b9d183553435483e388f60acc3ee33c3ded76a38..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssues.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.RenameTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class RenameIssuesCopyToIssues extends DdlChange { - public RenameIssuesCopyToIssues(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new RenameTableBuilder(getDialect()) - .setName("issues_copy") - .setNewName("issues") - .setAutoGeneratedId(false) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/package-info.java deleted file mode 100644 index e4a21dc2a13dc850c827044864ec332a7ea388da..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/package-info.java deleted file mode 100644 index e3f9ec903634ed96eeeb1ec910fd69c7e57feb7e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rules; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java deleted file mode 100644 index 5116d05cb0663b2f0d68f1503b432358807d3fc5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable extends DdlChange { - - public AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("rules_metadata", "rule_uuid", "organization_uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java deleted file mode 100644 index f173483d117bf04f4f38374ef7db479ce5a9d5e6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToRulesMetadataTable extends DdlChange { - private static final String TABLE = "rules_metadata"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToRulesMetadataTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java deleted file mode 100644 index 4931a70aeb82b0b5c0aabed14f727d5b6626b548..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfRulesMetadataTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfRulesMetadataTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("rules_metadata", "rule_id", false)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java deleted file mode 100644 index 3974d4303650bf8ae5160837f2149c55fd8ad545..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfRulesMetadataTable extends DdlChange { - - public DropRuleIdColumnOfRulesMetadataTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "rules_metadata", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java deleted file mode 100644 index b036030edd8bfc541c42a0aa2d34e11459cdc4a2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeRulesMetadataRuleUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "rules_metadata"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeRulesMetadataRuleUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java deleted file mode 100644 index 3a85c4bff2640c28e8b9a5b20d75f457344c99cc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesMetadataRuleUuidColumn extends DataChange { - - public PopulateRulesMetadataRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select rm.rule_id, ru.uuid " + - "from rules_metadata rm " + - "join rules ru on rm.rule_id = ru.id " + - "where rm.rule_uuid is null"); - massUpdate.update("update rules_metadata set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select rule_id, organization_uuid from rules_metadata where rule_uuid is null"); - massUpdate.update("delete from rules_metadata where rule_id = ? and organization_uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setLong(1, row.getLong(1)); - update.setString(2, row.getString(2)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/package-info.java deleted file mode 100644 index f60025e1462eb62965be5b9b9fc8152877e57b07..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTable.java deleted file mode 100644 index b094469b4fa367e17c950bd61b657bb685af6d13..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTable.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexesToRulesParametersTable extends DdlChange { - private static final String TABLE = "rules_parameters"; - private static final String RULE_UUID_INDEX = "rules_parameters_rule_uuid"; - private static final String RULE_UUID_NAME_UNIQUE_INDEX = "rules_parameters_unique"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final VarcharColumnDef nameColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("name") - .setLimit(128) - .setIsNullable(false) - .build(); - - public AddIndexesToRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexDoesNotExist(RULE_UUID_INDEX)) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(RULE_UUID_INDEX) - .addColumn(uuidColumnDefinition) - .build()); - } - - if (indexDoesNotExist(RULE_UUID_NAME_UNIQUE_INDEX)) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(RULE_UUID_NAME_UNIQUE_INDEX) - .addColumn(uuidColumnDefinition) - .addColumn(nameColumnDefinition) - .setUnique(true) - .build()); - } - } - - private boolean indexDoesNotExist(String index) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return !DatabaseUtils.indexExistsIgnoreCase(TABLE, index, connection); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java deleted file mode 100644 index ee78d18ab6982821acdbb155a22c912c708ca0b1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToRulesParametersTable extends DdlChange { - private static final String TABLE = "rules_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java deleted file mode 100644 index d2ae614de981e35e920e6848086b7b46a03df9a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Optional; -import java.util.function.Consumer; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexesOnRuleIdColumnOfRulesParametersTable extends DdlChange { - private static final String TABLE_NAME = "rules_parameters"; - - public DropIndexesOnRuleIdColumnOfRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - Consumer dropIndex = idx -> context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(idx) - .build()); - - findExistingIndexName("rules_parameters_rule_id").ifPresent(dropIndex); - findExistingIndexName("rules_parameters_unique").ifPresent(dropIndex); - } - - private Optional findExistingIndexName(String indexName) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.findExistingIndex(connection, TABLE_NAME, indexName); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java deleted file mode 100644 index 2554edfbce624435d831ff466760da496de62d7b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfRulesParametersTable extends DdlChange { - - public DropRuleIdColumnOfRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "rules_parameters", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java deleted file mode 100644 index 61dc356ac8822fd1e0cd8b245faac71cc7e99267..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeRulesParametersRuleUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "rules_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeRulesParametersRuleUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java deleted file mode 100644 index f2b32a0e51979b2545e61b24759b1de2fed31480..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesParametersRuleUuidColumn extends DataChange { - - public PopulateRulesParametersRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - populateUuids(context); - removeOrphans(context); - } - - private void populateUuids(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select rp.rule_id, ru.uuid " + - "from rules_parameters rp " + - "join rules ru on rp.rule_id = ru.id " + - "where rp.rule_uuid is null"); - massUpdate.update("update rules_parameters set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - } - - private void removeOrphans(DataChange.Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from rules_parameters where rule_uuid is null"); - massUpdate.update("delete from rules_parameters where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/package-info.java deleted file mode 100644 index 55aa445f6127430728fc47ff851bcfc69dd8b367..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java deleted file mode 100644 index 531c42bdaa19825fa112036f450151142f4ec8f1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfRulesParametersTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("rules_parameters", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParameters.java deleted file mode 100644 index 9698987c1aae02c3b0e75d4a66fe8dc9f49544f0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParameters.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToRulesParameters extends AddUuidColumnToTable { - private static final String TABLE_NAME = "rules_parameters"; - - public AddUuidColumnToRulesParameters(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTable.java deleted file mode 100644 index 092ee39430b5d672419bf2686e2d9448b6584d01..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfRulesParametersTable extends DropIdColumn { - private static final String TABLE_NAME = "rules_parameters"; - - public DropIdColumnOfRulesParametersTable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java deleted file mode 100644 index a4e8bcef827130555fb916aae3bd27fa4d01e2f4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfRulesParametersTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "rules_parameters"; - - public DropPrimaryKeyOnIdColumnOfRulesParametersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java deleted file mode 100644 index 8cb96ebfb14a593edf66d7ca9cfa85e110e76ff2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeRulesParametersUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE_NAME = "rules_parameters"; - - public MakeRulesParametersUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuid.java deleted file mode 100644 index d41e944349d98c0c7f23a6dfcbdeff535532fed5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesParametersUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateRulesParametersUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from rules_parameters where uuid is null"); - massUpdate.update("update rules_parameters set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java deleted file mode 100644 index f1c1af814d4ad3143eef5f8257bdfeb5eaf38213..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRulesParameterUuidColumnToActiveRuleParameters extends DdlChange { - private static final String TABLE = "active_rule_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rules_parameter_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRulesParameterUuidColumnToActiveRuleParameters(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java deleted file mode 100644 index 7bc26731865d457c06ae817d2d5c3bec9e2f18d6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRulesParameterIdColumnOfActiveRuleParametersTable extends DdlChange { - - public DropRulesParameterIdColumnOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "active_rule_parameters", "rules_parameter_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java deleted file mode 100644 index 320169c18936e88f163bcece57e16a883a854ccc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeActiveRuleParametersRulesParameterUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "active_rule_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rules_parameter_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeActiveRuleParametersRulesParameterUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java deleted file mode 100644 index b3d24475b02113d48547c588e920ae7e1f4e558d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRuleParametersRulesParameterUuid extends DataChange { - - public PopulateActiveRuleParametersRulesParameterUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select arp.uuid, rp.uuid " + - "from active_rule_parameters arp " + - "join rules_parameters rp on arp.rules_parameter_id = rp.id " + - "where arp.rules_parameter_uuid is null"); - massUpdate.update("update active_rule_parameters set rules_parameter_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from active_rule_parameters where rules_parameter_uuid is null"); - massUpdate.update("delete from active_rule_parameters where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/package-info.java deleted file mode 100644 index 0233ec0345c7d0e217f9855d0b79e0cd4d37170d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/package-info.java deleted file mode 100644 index b4f98fbd6e3448ff127ccde551d81535546ba378..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java deleted file mode 100644 index 4b29b47f02dc9ee0684fb7e84e40207f27d64ae3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfRulesProfilesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfRulesProfilesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("rules_profiles", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTable.java deleted file mode 100644 index b13ce1cb8bf94c4d402e342f38ef5a76972cdb9f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToRulesProfilesTable extends AddUuidColumnToTable { - private static final String TABLE = "rules_profiles"; - - public AddUuidColumnToRulesProfilesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTable.java deleted file mode 100644 index ad272197943f9a05b2d772b04febec8bafa27295..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfRulesProfilesTable extends DropIdColumn { - - private static final String TABLE_NAME = "rules_profiles"; - - public DropIdColumnOfRulesProfilesTable(Database db) { - super(db, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java deleted file mode 100644 index e39b12c8b2a0595a6f8622f28f05dbaabd014c1c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropKeeColumnOfRulesProfilesTable extends DdlChange { - - private Database db; - - public DropKeeColumnOfRulesProfilesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "rules_profiles", "kee").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java deleted file mode 100644 index ae0080af1ec60b5443e23789f3550f5be0d666ba..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfRulesProfilesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "rules_profiles"; - - public DropPrimaryKeyOnIdColumnOfRulesProfilesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java deleted file mode 100644 index 5de1b6bf93e99217ad508f2b9056194abc7f4867..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropUniqueIndexOnKeeColumnOfRulesProfilesTable extends DropIndexChange { - private static final String TABLE_NAME = "rules_profiles"; - private static final String INDEX_NAME = "uniq_qprof_key"; - - public DropUniqueIndexOnKeeColumnOfRulesProfilesTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java deleted file mode 100644 index a9c3edee677a96cf742e38a133e7119331de8aab..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeRulesProfilesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE_NAME = "rules_profiles"; - - public MakeRulesProfilesUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuid.java deleted file mode 100644 index c375e55a8680b5e0a4a26fcec4ba9e46c70b168f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesProfilesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateRulesProfilesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from rules_profiles where uuid is null"); - massUpdate.update("update rules_profiles set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java deleted file mode 100644 index 6e803cd6b0c86dc6b99cd30324c020b51559bd4b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddProfileUuidColumnToActiveRulesTable extends DdlChange { - private static final String TABLE = "active_rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("profile_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddProfileUuidColumnToActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java deleted file mode 100644 index ec3e23b01c547bc47ff3c53c6f3eb72f57d18f9d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.IntegerColumnDef; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable extends DdlChange { - private static final String TABLE_NAME = "active_rules"; - private static final String INDEX_NAME = "uniq_profile_rule_ids"; - - public AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("profile_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("rule_id") - .setIsNullable(false) - .build()) - .build()); - } - - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java deleted file mode 100644 index b42054032b12f6d72c0d85c82626ddee6e21d1e4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropProfileIdColumnOfActiveRulesTable extends DdlChange { - - private Database db; - - public DropProfileIdColumnOfActiveRulesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "active_rules", "profile_id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java deleted file mode 100644 index 4a773ddab7e5bfba8538fa12777df0becbc3146a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropUniqueIndexOnProfileIdColumnOfActiveRulesTable extends DropIndexChange { - private static final String TABLE_NAME = "active_rules"; - private static final String INDEX_NAME = "uniq_profile_rule_ids"; - - public DropUniqueIndexOnProfileIdColumnOfActiveRulesTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java deleted file mode 100644 index b68b2f5b687c1918a1bb60a4abd5563862370f85..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeActiveRulesProfileUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "active_rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("profile_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeActiveRulesProfileUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java deleted file mode 100644 index abd499995248ad035ffa3d74ff5acf342b074fa8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRulesProfileUuid extends DataChange { - - public PopulateActiveRulesProfileUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ar.uuid, rp.uuid " + - "from active_rules ar " + - "join rules_profiles rp on ar.profile_id = rp.id " + - "where ar.profile_uuid is null"); - massUpdate.update("update active_rules set profile_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from active_rules where profile_uuid is null"); - massUpdate.update("delete from active_rules where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/package-info.java deleted file mode 100644 index 8c33f05526426e353c61f1df15cdb83e2e496552..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java deleted file mode 100644 index 509633a74a827bc30ea2708b23ed43e3d86f03e6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.orgqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateOrgQProfilesRulesProfileUuid extends DataChange { - - public PopulateOrgQProfilesRulesProfileUuid(Database db) { - super(db); - } - - @Override - protected void execute(DataChange.Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select oqp.uuid, rp.uuid " + - "from org_qprofiles oqp " + - "join rules_profiles rp on oqp.rules_profile_uuid = rp.kee"); - massUpdate.update("update org_qprofiles set rules_profile_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/package-info.java deleted file mode 100644 index e907cf41914b07f2197eddd629a6bf427e631b99..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.orgqprofiles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/package-info.java deleted file mode 100644 index 2548004076565de078523c13bc6b4b616fb84e5e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java deleted file mode 100644 index af1c9d9d5b37dd85e1c7447107a0f188965f9482..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.qprofilechanges; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQProfileChangesRulesProfileUuid extends DataChange { - - public PopulateQProfileChangesRulesProfileUuid(Database db) { - super(db); - } - - @Override - protected void execute(DataChange.Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select qpc.kee, rp.uuid " + - "from qprofile_changes qpc " + - "join rules_profiles rp on qpc.rules_profile_uuid = rp.kee"); - massUpdate.update("update qprofile_changes set rules_profile_uuid = ? where kee = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/package-info.java deleted file mode 100644 index cd0f3d9fd16286d1c00dc255037f1833efb12960..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.qprofilechanges; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/package-info.java deleted file mode 100644 index 56baf605405501ecf352101abd692f8360c087c1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java deleted file mode 100644 index 8782ac9d85e901cbc32f645f8a30e0791491a6d3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfSnapshotsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfSnapshotsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("snapshots", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropIdColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropIdColumnOfSnapshotsTable.java deleted file mode 100644 index aad5190eed1b2f1de3d5c175dc73b640b88e7cdc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropIdColumnOfSnapshotsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfSnapshotsTable extends DropIdColumn { - private static final String TABLE = "snapshots"; - - public DropIdColumnOfSnapshotsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java deleted file mode 100644 index 7cded5f7ab0ab0eae8634e8f61c59d88482326a1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfSnapshotsTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfSnapshotsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("snapshots", "id", true)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/package-info.java deleted file mode 100644 index b035563e3eb5147c8081f04952e099a476a567d5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/package-info.java deleted file mode 100644 index 4b336e03ac3d8ed0fe3ee83b404a0a9d87f0cc08..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.snapshots; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java deleted file mode 100644 index f4f5bbdc8f50335074d432f5ff2afad51f19edf6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfUserRolesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("user_roles", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTable.java deleted file mode 100644 index ffcf055d092374d19a10232b87dc2a3f28f858d9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToUserRolesTable extends AddUuidColumnToTable { - private static final String TABLE = "user_roles"; - - public AddUuidColumnToUserRolesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTable.java deleted file mode 100644 index f69c611b984ef74258273d490fcaa78a24918915..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTable.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfUserRolesTable extends DropIdColumn { - public DropIdColumnOfUserRolesTable(Database db) { - super(db, "user_roles"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java deleted file mode 100644 index 3d6958fe761a41168854b0f742082cba497c21f0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfUserRolesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "user_roles"; - - public DropPrimaryKeyOnIdColumnOfUserRolesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullable.java deleted file mode 100644 index 4d13bb2530fd69a6126f75b0c3acff3cf62b8a26..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeUserRolesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "user_roles"; - - public MakeUserRolesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuid.java deleted file mode 100644 index c851dd7e15da8309b7c46ba5180385de8fef21c6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.userroles; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateUserRolesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateUserRolesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from user_roles where uuid is null"); - massUpdate.update("update user_roles set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/package-info.java deleted file mode 100644 index fdbc4784ca48fa6c725943dd0241546e65bc24e3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.userroles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java deleted file mode 100644 index a3508db6ab74992725037195e2852e7fc5e78097..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfUsersTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("users", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTable.java deleted file mode 100644 index dd8d96f061662ab3757916f261df607c0dbc41bf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfUsersTable extends DropIdColumn { - - private static final String TABLE_NAME = "users"; - - public DropIdColumnOfUsersTable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java deleted file mode 100644 index 40a3b1576a269742f236b785e5a4a514d9f1c730..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfUsersTable extends DropPrimaryKeyOnIdColumn { - - private static final String TABLE_NAME = "users"; - - public DropPrimaryKeyOnIdColumnOfUsersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTable.java deleted file mode 100644 index fce3d7bf8e9f523f8a9d884de612a8e0e8daf9f3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropUniqueIndexOnUuidColumnOfUsersTable extends DropIndexChange { - - private static final String TABLE_NAME = "users"; - private static final String INDEX_NAME = "users_uuid"; - - public DropUniqueIndexOnUuidColumnOfUsersTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java deleted file mode 100644 index 8e866a2119e870f0d9afc56e9e8af0be1cfd033a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.USER_UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnUserUuidOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "index_groups_users_user_uuid"; - - public AddIndexOnUserUuidOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(USER_UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java deleted file mode 100644 index a665f54051a762f8d674520673a26c9c94f7be3a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "groups_users_unique"; - - public AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .setUnique(true) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java deleted file mode 100644 index c6020f40a2b0fdea34a59ecb004b7a77acfbe568..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToGroupsUsers extends AddUserUuidColumnToTable { - public AddUserUuidColumnToGroupsUsers(Database db) { - super(db, "groups_users"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java deleted file mode 100644 index a6ccfb30df131e79f84977b261396b14e436c845..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnUserIdOfGroupsUsersTable extends DropIndexChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "index_groups_users_on_user_id"; - - public DropIndexOnUserIdOfGroupsUsersTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java deleted file mode 100644 index 7002321966ccb6aff1eb1516511e1287be52c25e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable extends DropIndexChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "groups_users_unique"; - - public DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java deleted file mode 100644 index d2d36cb7c53392666d7ba6bf4a7d2517c6818e60..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfGroupsUsersTable extends DdlChange { - public DropUserIdColumnOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "groups_users", "user_id").build()); - } -} - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java deleted file mode 100644 index 8b459d911fead36affd38c6d3b921ea6a0ea4aad..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.USER_UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeGroupsUsersUserUuidColumnNotNullable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(USER_UUID_SIZE) - .build(); - - public MakeGroupsUsersUserUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java deleted file mode 100644 index b773357af722eed623d63e90761456c3ef2fadde..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupsUsersUserUuid extends DataChange { - - public PopulateGroupsUsersUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select gu.group_uuid, gu.user_id, u.uuid " + - "from groups_users gu " + - "join users u on gu.user_id = u.id where gu.user_uuid is null"); - - massUpdate.update("update groups_users set user_uuid = ? where group_uuid = ? and user_id = ?"); - - massUpdate.execute((row, update) -> { - String groupUuid = row.getString(1); - long userId = row.getLong(2); - String userUuid = row.getString(3); - update.setString(1, userUuid); - update.setString(2, groupUuid); - update.setLong(3, userId); - return true; - }); - - remoteOrphanEntries(context); - } - - private static void remoteOrphanEntries(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select group_uuid, user_id from groups_users where user_uuid is null"); - massUpdate.update("delete from groups_users where group_uuid = ? and user_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - update.setLong(2, row.getLong(2)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/package-info.java deleted file mode 100644 index fbf586dcf32c527ff7b6cf3f4c37f9e28f0af81e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java deleted file mode 100644 index 1d2b4f3891203197b1595fc1e43d67083ff0728b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnUserUuidOfOrganizationMembersTable extends DdlChange { - private static final String TABLE_NAME = "organization_members"; - private static final String INDEX_NAME = "org_members_user_uuid"; - - public AddIndexOnUserUuidOfOrganizationMembersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java deleted file mode 100644 index 839ee055ded0c08c0f2d6467984174dc006d234a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable extends DdlChange { - - public AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("organization_members", "user_uuid", "organization_uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java deleted file mode 100644 index 9627f96a89acd02cf8297df220573e15c39576fb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToOrganizationMembers extends AddUserUuidColumnToTable { - public AddUserUuidColumnToOrganizationMembers(Database db) { - super(db, "organization_members"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java deleted file mode 100644 index 451a2d7aef0e8f871f69b9e826c7099de3298a16..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnUserIdOfOrganizationMembersTable extends DropIndexChange { - private static final String TABLE_NAME = "organization_members"; - private static final String INDEX_NAME = "ix_org_members_on_user_id"; - - public DropIndexOnUserIdOfOrganizationMembersTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java deleted file mode 100644 index e653784ae7b52e52b093fa44ec2dc562b4912a09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable extends DdlChange { - private static final String TABLE_NAME = "organization_members"; - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, "user_id", false)); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java deleted file mode 100644 index 7ff3a545100a55bf9670ce190d7308436de8658a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfOrganizationMembersTable extends DdlChange { - public DropUserIdColumnOfOrganizationMembersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "organization_members", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java deleted file mode 100644 index cfc34382daa54aa5d9aad3a63a831e310b7706db..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.MakeUserUuidColumnNotNullable; - -public class MakeOrganizationMembersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { - private static final String TABLE_NAME = "organization_members"; - - public MakeOrganizationMembersUserUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java deleted file mode 100644 index 5de8a55e396404476ac4b4796a7a898fcc3e23ae..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateOrganizationMembersUserUuid extends DataChange { - - public PopulateOrganizationMembersUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select om.user_id, om.organization_uuid, u.uuid " + - "from organization_members om " + - "join users u on om.user_id = u.id where om.user_uuid is null"); - - massUpdate.update("update organization_members set user_uuid = ? where organization_uuid = ? and user_id = ?"); - - massUpdate.execute((row, update, index) -> { - long userId = row.getLong(1); - String organizationUuid = row.getString(2); - String userUuid = row.getString(3); - - update.setString(1, userUuid); - update.setString(2, organizationUuid); - update.setLong(3, userId); - return true; - }); - - MassUpdate.Handler removeOrphanHandler = (row, update) -> { - update.setString(1, row.getString(1)); - update.setLong(2, row.getLong(2)); - - return true; - }; - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select organization_uuid, user_id from organization_members where user_uuid is null"); - massUpdate.update("delete from organization_members where organization_uuid = ? and user_id = ?"); - - massUpdate.execute(removeOrphanHandler); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/package-info.java deleted file mode 100644 index 565f183495e91c9eb474201374fba18e1e5cf424..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/package-info.java deleted file mode 100644 index 5f85fc2cb3ee5e8081bda025c00a21d0f4fb9b05..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users.fk; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java deleted file mode 100644 index 1571a79064257fee7765313650b7b98c2603c322..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToPermTemplatesUsers extends AddUserUuidColumnToTable { - - public AddUserUuidColumnToPermTemplatesUsers(Database db) { - super(db, "perm_templates_users"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index dc32e790d99043fbf577c666e832eed645c55380..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfPermTemplatesUsersTable extends DdlChange { - public DropUserIdColumnOfPermTemplatesUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_users", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java deleted file mode 100644 index b6e1639e0d776e2fb5f5a71b9ba804eccf165cbd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.MakeUserUuidColumnNotNullable; - -public class MakePermTemplatesUsersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { - private static final String TABLE_NAME = "perm_templates_users"; - - public MakePermTemplatesUsersUserUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java deleted file mode 100644 index fe835116347dfe9ff1930b9fe3410d6a9641a59c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesUsersUserUuid extends DataChange { - - public PopulatePermTemplatesUsersUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptu.uuid, u.uuid " + - "from perm_templates_users ptu " + - "join users u on ptu.user_id = u.id where ptu.user_uuid is null"); - - massUpdate.update("update perm_templates_users set user_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update, index) -> { - String permTemplatesUuid = row.getString(1); - String userUuid = row.getString(2); - - update.setString(1, userUuid); - update.setString(2, permTemplatesUuid); - return true; - }); - - massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from perm_templates_users where user_uuid is null"); - massUpdate.update("delete from perm_templates_users where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/package-info.java deleted file mode 100644 index 700fe3c5415f6f7334bec985f595fae48eb0d263..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java deleted file mode 100644 index fbe5c41889e22065d9bee66d3bbadc5c150df157..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToPropertiesUsers extends AddUserUuidColumnToTable { - - public AddUserUuidColumnToPropertiesUsers(Database db) { - super(db, "properties"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTable.java deleted file mode 100644 index 824b95634b46c2e0d9f013e7ec7e12fcd91e85b6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfPropertiesTable extends DdlChange { - public DropUserIdColumnOfPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "properties", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuid.java deleted file mode 100644 index 87d148cb8a3994603828281d032a8e9603754fa3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuid.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePropertiesUserUuid extends DataChange { - - public PopulatePropertiesUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - populateUserUuid(context); - removeRowWithNonExistentUser(context); - } - - private static void populateUserUuid(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select p.uuid, u.uuid " + - "from properties p " + - "join users u on p.user_id = u.id where p.user_uuid is null"); - - massUpdate.update("update properties set user_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update, index) -> { - String propertiesUuid = row.getString(1); - String userUuid = row.getString(2); - - update.setString(1, userUuid); - update.setString(2, propertiesUuid); - return true; - }); - } - - private static void removeRowWithNonExistentUser(Context context) throws SQLException { - context.prepareUpsert("delete from properties where user_uuid is null and user_id is not null") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/package-info.java deleted file mode 100644 index 4fa499ca67b436ce6b00cd852a82e9e30a88c8af..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java deleted file mode 100644 index bc2508834b104690602c02117e6600c84b9822b5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable extends DdlChange { - private static final String TABLE_NAME = "qprofile_edit_users"; - private static final String INDEX_NAME = "qprofile_edit_users_unique"; - - public AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("qprofile_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java deleted file mode 100644 index 5f25d812839942f24d55dc97a1b9c102d43f2208..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToQProfileEditUsers extends AddUserUuidColumnToTable { - - public AddUserUuidColumnToQProfileEditUsers(Database db) { - super(db, "qprofile_edit_users"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java deleted file mode 100644 index 7fb8fff8fdff8ba1e5bb5e9e6a3720a204866930..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable extends DropIndexChange { - private static final String TABLE_NAME = "qprofile_edit_users"; - private static final String INDEX_NAME = "qprofile_edit_users_unique"; - - public DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java deleted file mode 100644 index 35828422dbd2685320dd5e2c90939b977a205158..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfQProfileEditUsersTable extends DdlChange { - public DropUserIdColumnOfQProfileEditUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "qprofile_edit_users", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java deleted file mode 100644 index e1c8b10f913838c0bc59d9be78b48404825be552..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.MakeUserUuidColumnNotNullable; - -public class MakeQProfileEditUsersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { - private static final String TABLE_NAME = "qprofile_edit_users"; - - public MakeQProfileEditUsersUserUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java deleted file mode 100644 index 59d6daf798fc5d06448f1e88e500b5c301f3d628..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.version.v84.util.OrphanData; - -public class PopulateQProfileEditUsersUserUuid extends DataChange { - - public PopulateQProfileEditUsersUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select qeu.uuid, u.uuid " + - "from qprofile_edit_users qeu " + - "join users u on qeu.user_id = u.id where qeu.user_uuid is null"); - - massUpdate.update("update qprofile_edit_users set user_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update, index) -> { - String permTemplatesUuid = row.getString(1); - String userUuid = row.getString(2); - - update.setString(1, userUuid); - update.setString(2, permTemplatesUuid); - return true; - }); - - OrphanData.delete(context, "qprofile_edit_users", "user_uuid"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/package-info.java deleted file mode 100644 index 6a61f34e15a41497d1d28b827a577f6ce4287196..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java deleted file mode 100644 index 41ddf949af4b15f755c03cb044023073969cd8a9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnUserUuidOfUserRolesTable extends DdlChange { - private static final String TABLE_NAME = "user_roles"; - private static final String INDEX_NAME = "user_roles_user"; - - public AddIndexOnUserUuidOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRoles.java deleted file mode 100644 index a41f3b9cbb518fcb17f6651c09a4932bd9e067b4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRoles.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToUserRoles extends AddUserUuidColumnToTable { - - public AddUserUuidColumnToUserRoles(Database db) { - super(db, "user_roles"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java deleted file mode 100644 index d71fdab7ff0aea710ef463fe23a413accbca324f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropIndexOnUserIdOfUserRolesTable extends DropIndexChange { - private static final String TABLE_NAME = "user_roles"; - private static final String INDEX_NAME = "user_roles_user"; - - public DropIndexOnUserIdOfUserRolesTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java deleted file mode 100644 index 96680ef921dacae46de0b9d09c1fc8f72f89ea65..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfUserRolesTable extends DdlChange { - public DropUserIdColumnOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "user_roles", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuid.java deleted file mode 100644 index 02e8027c8d77c72634944325c25c423170faff7e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateUserRolesUserUuid extends DataChange { - - public PopulateUserRolesUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ur.uuid, u.uuid " + - "from user_roles ur " + - "join users u on ur.user_id = u.id where ur.user_uuid is null"); - - massUpdate.update("update user_roles set user_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update, index) -> { - String userRolesUuid = row.getString(1); - String userUuid = row.getString(2); - - update.setString(1, userUuid); - update.setString(2, userRolesUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/package-info.java deleted file mode 100644 index 0f43b1c29fe68da71f66c2cdd0a388818e680bd4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/AddUserUuidColumnToTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/AddUserUuidColumnToTable.java deleted file mode 100644 index 4f10a75cde55d76c6464ded5168471cfa3e72a14..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/AddUserUuidColumnToTable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.util; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUserUuidColumnToTable extends DdlChange { - private final String tableName; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.USER_UUID_SIZE) - .build(); - - public AddUserUuidColumnToTable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), tableName) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/MakeUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/MakeUserUuidColumnNotNullable.java deleted file mode 100644 index 033192451767f0d51916b5f48e7a935ae485790b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/MakeUserUuidColumnNotNullable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.util; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeUserUuidColumnNotNullable extends DdlChange { - private final String tableName; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.USER_UUID_SIZE) - .build(); - - public MakeUserUuidColumnNotNullable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), tableName) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/package-info.java deleted file mode 100644 index b56469fbd253591145d0c4ded8ed724d726bbb8c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users.fk.util; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/package-info.java deleted file mode 100644 index e398d3d793b4be1f4466f88c8fae9766589ebee3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.users; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java deleted file mode 100644 index 617979d1569641060b1aa7b44742a7389c6f5623..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidColumnOfUserTokensTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfUserTokensTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("user_tokens", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokens.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokens.java deleted file mode 100644 index 85ab5142a7e2c25366f49424655135c48026d69c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokens.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; - -public class AddUuidColumnToUserTokens extends AddUuidColumnToTable { - private static final String TABLE = "user_tokens"; - - public AddUuidColumnToUserTokens(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTable.java deleted file mode 100644 index e9cf5751b4733f6de4dea7c38f3c71a21abc1600..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; - -public class DropIdColumnOfUserTokensTable extends DropIdColumn { - private static final String TABLE = "user_tokens"; - - public DropIdColumnOfUserTokensTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java deleted file mode 100644 index 0fd1c80892cc2bf0726cfeec25c9705ce1397d67..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; - -public class DropPrimaryKeyOnIdColumnOfUserTokensTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "user_tokens"; - - public DropPrimaryKeyOnIdColumnOfUserTokensTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullable.java deleted file mode 100644 index 34998b746482d8a9a364e8170e6bf0e7942edf0d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; - -public class MakeUserTokensUuidNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "user_tokens"; - - public MakeUserTokensUuidNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuid.java deleted file mode 100644 index af25317433c3b4d82f0ca325b3d17d596c853e2a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateUserTokensUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateUserTokensUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from user_tokens where uuid is null"); - massUpdate.update("update user_tokens set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/package-info.java deleted file mode 100644 index ed22b263aeadca94af2d32fdc6de6846fdf3b674..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/OrphanData.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/OrphanData.java deleted file mode 100644 index d71611ba25f7c554110e175ad22ab8f5c5257c02..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/OrphanData.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.util; - -import java.sql.SQLException; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class OrphanData { - private OrphanData() { - // static only - } - /** - * Deletes from a table entries that contain a null foreign key. - * Primary key of the table must be 'uuid' - */ - public static void delete(DataChange.Context context, String table, String foreignKeyColumn) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from " + table + " where " + foreignKeyColumn + " is null"); - massUpdate.update("delete from " + table + " where " + " uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/package-info.java deleted file mode 100644 index 4709a5d2f2a7dda1ec42bdefdabd59588613e05a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v84.util; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTable.java deleted file mode 100644 index 7c506d95616c09e06f3ad47aaebfbe2571791d1b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTable.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnIssueKeyForIssueChangesTable extends DdlChange { - - private static final String TABLE_NAME = "issue_changes"; - private static final String INDEX_NAME = "issue_changes_issue_key"; - - public AddIndexOnIssueKeyForIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("issue_key") - .setIsNullable(false) - .setLimit(UUID_VARCHAR_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTable.java deleted file mode 100644 index c025806e1c227a648c719207e6e2c96700a1098e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTable.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_VARCHAR_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnKeeForIssueChangesTable extends DdlChange { - - private static final String TABLE_NAME = "issue_changes"; - private static final String INDEX_NAME = "issue_changes_kee"; - - public AddIndexOnKeeForIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("kee") - .setIsNullable(true) - .setLimit(UUID_VARCHAR_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTable.java deleted file mode 100644 index ac9762abb35cbbe991b8bb3a8d4dbc5ea04d427b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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; - -public class AddIndexOnMessageTypeColumnOfCeTaskMessageTable extends DdlChange { - private static final String TABLE = "ce_task_message"; - - public AddIndexOnMessageTypeColumnOfCeTaskMessageTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("ctm_message_type") - .addColumn("message_type") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTable.java deleted file mode 100644 index 1d58bbc1628819a9a243f4ee65f8f3932e6b6b9d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTable.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnProjectUuidOnIssueChangesTable extends DdlChange { - private static final String TABLE_NAME = "issue_changes"; - private static final String INDEX_NAME = "issue_changes_project_uuid"; - - public AddIndexOnProjectUuidOnIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(true) - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTable.java deleted file mode 100644 index f1dcee734691879b1b907c00676efbfba85560d9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTable.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 AddMessageTypeColumnToCeTaskMessageTable extends DdlChange { - private static final String TABLE = "ce_task_message"; - - private static final VarcharColumnDef MESSAGE_TYPE = newVarcharColumnDefBuilder() - .setColumnName("message_type") - .setIsNullable(true) - .setLimit(255) - .build(); - - public AddMessageTypeColumnToCeTaskMessageTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(MESSAGE_TYPE) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTable.java deleted file mode 100644 index 37feefda2a8d65b07984bcfdb73c3df7e95d9f2b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyOnUuidForIssueChangesTable extends DdlChange { - - private static final String TABLE = "issue_changes"; - - public AddPrimaryKeyOnUuidForIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - if (!DatabaseUtils.indexExistsIgnoreCase(TABLE, "issue_changes_project_uuid", connection)) { - context.execute(new AddPrimaryKeyBuilder(TABLE, "uuid").build()); - } - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddTypeToPlugins.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddTypeToPlugins.java deleted file mode 100644 index f1cb6420da821a552ff7b146d60a8912ab65461d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddTypeToPlugins.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 AddTypeToPlugins extends DdlChange { - private static final String TABLE_NAME = "plugins"; - private static final String COLUMN_NAME = "type"; - - public AddTypeToPlugins(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME).addColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setLimit(10) - .setIsNullable(true) - .setColumnName(COLUMN_NAME) - .build()).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullable.java deleted file mode 100644 index 2f92d596f31ea8a8aa1cb9abefe087f4d4b8f7d7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 AlterTypeInPluginNotNullable extends DdlChange { - private static final String TABLE_NAME = "plugins"; - private static final String COLUMN_NAME = "type"; - - public AlterTypeInPluginNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME).updateColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setLimit(10) - .setIsNullable(false) - .setColumnName(COLUMN_NAME) - .build()).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTable.java deleted file mode 100644 index 6fd09ceaab26257ecdf662aa13efc6725da798ec..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTable.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.db.dialect.MsSql; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class CreateTmpIssueChangesTable extends DdlChange { - - public CreateTmpIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - if (DatabaseUtils.tableColumnExists(connection, "issue_changes", "project_uuid")) { - // This migration might already have been done in v84 (#3476) if using SQ >= 8.7. - return; - } - String query; - if (getDatabase().getDialect().getId().equals(MsSql.ID)) { - query = "SELECT ic.uuid, ic.kee, ic.issue_key, ic.user_login, ic.change_type, " + - "ic.change_data, ic.created_at, ic.updated_at, ic.issue_change_creation_date, i.project_uuid " + - "INTO tmp_issue_changes " + - "FROM issue_changes AS ic inner join issues i on i.kee = ic.issue_key"; - } else { - query = "create table tmp_issue_changes " + - "(uuid, kee, issue_key, user_login, change_type, change_data, created_at, updated_at, issue_change_creation_date, project_uuid)" + - "as (" + - "SELECT ic.uuid, ic.kee, ic.issue_key, ic.user_login, ic.change_type, ic.change_data, ic.created_at, ic.updated_at, ic.issue_change_creation_date, i.project_uuid " + - "FROM issue_changes ic " + - "inner join issues i on i.kee = ic.issue_key " + - ")"; - } - - context.execute(query); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/CreateUserDismissedMessagesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/CreateUserDismissedMessagesTable.java deleted file mode 100644 index 75fb793403b9dddb82c77e48feb1fcfa658de116..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/CreateUserDismissedMessagesTable.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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.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 CreateUserDismissedMessagesTable extends DdlChange { - - private static final String TABLE_NAME = "user_dismissed_messages"; - - 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(VarcharColumnDef.USER_UUID_SIZE) - .build(); - - private static final VarcharColumnDef PROJECT_UUID = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setLimit(UUID_SIZE) - .build(); - - private static final VarcharColumnDef MESSAGE_TYPE = newVarcharColumnDefBuilder() - .setColumnName("message_type") - .setIsNullable(false) - .setLimit(255) - .build(); - - private static final BigIntegerColumnDef CREATED_AT = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - public CreateUserDismissedMessagesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), TABLE_NAME) - .addPkColumn(UUID_COLUMN) - .addColumn(USER_UUID_COLUMN) - .addColumn(PROJECT_UUID) - .addColumn(MESSAGE_TYPE) - .addColumn(CREATED_AT) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("uniq_user_dismissed_messages") - .setUnique(true) - .addColumn(USER_UUID_COLUMN) - .addColumn(PROJECT_UUID) - .addColumn(MESSAGE_TYPE) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("udm_project_uuid") - .addColumn(PROJECT_UUID) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("udm_message_type") - .addColumn(MESSAGE_TYPE) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DbVersion85.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DbVersion85.java deleted file mode 100644 index 01fcb2a77a0cdc2cd6204500cebca7314a8d4ea1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DbVersion85.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion85 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(4000, "Delete 'project_alm_settings' orphans", DeleteProjectAlmSettingsOrphans.class) - .add(4001, "Drop 'period', 'value_warning' columns from 'quality_gates_conditions' table", DropPeriodAndValueWarningColumnsFromQualityGateConditionsTable.class) - .add(4002, "Drop 'project_alm_bindings' table", DropProjectAlmBindings.class) - .add(4003, "Drop unused variation values columns in 'project_measures' table", DropUnusedVariationsInProjectMeasures.class) - .add(4004, "Drop unused periods in 'snapshots' table", DropUnusedPeriodsInSnapshots.class) - .add(4005, "Drop orphan favorites from 'properties' table", DropOrphanFavoritesFromProperties.class) - - .add(4006, "create 'tmp_issue_changes' table", CreateTmpIssueChangesTable.class) - .add(4007, "drop 'issue_changes' table", DropIssueChangesTable.class) - .add(4008, "rename 'tmp_issue_changes' table to 'issue_changes'", RenameTmpIssueChangesToIssueChanges.class) - .add(4009, "Make 'issueKey' not nullable for 'issue_changes' table", MakeIssueKeyNotNullOnIssueChangesTable.class) - .add(4010, "Make 'uuid' not nullable for 'issue_changes' table", MakeUuidNotNullOnIssueChangesTable.class) - .add(4011, "Make 'project_uuid' not nullable for 'issue_changes' table", MakeProjectUuidNotNullOnIssueChangesTable.class) - .add(4012, "add PK table to 'issue_changes'", AddPrimaryKeyOnUuidForIssueChangesTable.class) - .add(4013, "add index on 'issue_key' for table 'issue_changes'", AddIndexOnIssueKeyForIssueChangesTable.class) - .add(4014, "add index on 'kee' for table 'issue_changes'", AddIndexOnKeeForIssueChangesTable.class) - .add(4015, "add index on 'project_uuid' for table 'issue_changes'", AddIndexOnProjectUuidOnIssueChangesTable.class) - - .add(4016, "Add 'type' column to 'plugins' table", AddTypeToPlugins.class) - .add(4017, "Populate 'type' column in 'plugins' table", PopulateTypeInPlugins.class) - .add(4018, "Alter 'type' column in 'plugins' to not nullable", AlterTypeInPluginNotNullable.class) - .add(4019, "Add 'message_type' column to 'ce_task_message' table", AddMessageTypeColumnToCeTaskMessageTable.class) - .add(4020, "Populate 'message_type' column of 'ce_task_message' table", PopulateMessageTypeColumnOfCeTaskMessageTable.class) - .add(4021, "Make 'message_type' column not nullable for `ce_task_message` table", MakeMessageTypeColumnNotNullableOnCeTaskMessageTable.class) - .add(4022, "Add index on 'message_type' column of `ce_task_message` table", AddIndexOnMessageTypeColumnOfCeTaskMessageTable.class) - .add(4023, "Create 'user_dismissed_messages' table", CreateUserDismissedMessagesTable.class) - .add(4024, "Populate 'branch_type' in 'project_branches'", FillProjectBranchesBranchType.class) - .add(4025, "Make 'branch_type' in 'project_branches' not nullable", MakeProjectBranchesBranchTypeNotNullable.class) - .add(4026, "Drop column 'key_type' in table 'project_branches'", DropProjectBranchesKeyType.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphans.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphans.java deleted file mode 100644 index 2f107ec6c61860b7fc3d3f8d5a2f4c74579ecc2a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphans.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 DeleteProjectAlmSettingsOrphans extends DataChange { - - public DeleteProjectAlmSettingsOrphans(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select pas.uuid from project_alm_settings pas left join " - + "projects p on pas.project_uuid = p.uuid where p.uuid is null"); - massUpdate.update("delete from project_alm_settings where uuid = ?"); - - massUpdate.execute((row, update) -> { - String notExistingProjectUuid = row.getString(1); - update.setString(1, notExistingProjectUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTable.java deleted file mode 100644 index 22aab062fb41deb50554b5db7605cd6a13b7fe92..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIssueChangesTable extends DdlChange { - public DropIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - if (DatabaseUtils.tableExists("tmp_issue_changes", connection)) { - context.execute(new DropTableBuilder(getDialect(), "issue_changes").build()); - } - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromProperties.java deleted file mode 100644 index d8959db8009446d15ecf4775a64bfa463dc34f4b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromProperties.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 DropOrphanFavoritesFromProperties extends DataChange { - - public DropOrphanFavoritesFromProperties(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from properties where prop_key = ? and component_uuid is null") - .setString(1, "favourite"); - massUpdate.update("delete from properties where uuid = ?"); - - massUpdate.execute((row, update) -> { - String propertyUuid = row.getString(1); - update.setString(1, propertyUuid); - return true; - }); - - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTable.java deleted file mode 100644 index 37a551cf9b142869699f0198f77852a0c8444940..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 DropPeriodAndValueWarningColumnsFromQualityGateConditionsTable extends DdlChange { - - public DropPeriodAndValueWarningColumnsFromQualityGateConditionsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "quality_gate_conditions", "value_warning", "period").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindings.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindings.java deleted file mode 100644 index d6c9a02b76f5febdda5d47805fcee97eb5ccc927..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindings.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 DropProjectAlmBindings extends DdlChange { - private static final String TABLE_NAME = "project_alm_bindings"; - - public DropProjectAlmBindings(Database db) { - super(db); - } - - @Override public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("project_alm_bindings_alm_repo").build()); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("project_alm_bindings_project").build()); - context.execute(new DropTableBuilder(getDialect(), TABLE_NAME).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyType.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyType.java deleted file mode 100644 index 62ed921e284726110730d4683e32a56ffc7574c2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyType.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropProjectBranchesKeyType extends DdlChange { - private static final String TABLE_NAME = "project_branches"; - - public DropProjectBranchesKeyType(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("project_branches_kee_key_type").build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "key_type").build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setUnique(true) - .setName("uniq_project_branches") - .addColumn("branch_type") - .addColumn("project_uuid") - .addColumn("kee") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedIndexes.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedIndexes.java deleted file mode 100644 index cb1da7d5de7205e371d97979bf10ef1f1cfb0f79..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedIndexes.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 DropUnusedIndexes extends DdlChange { - public DropUnusedIndexes(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - // duplicated by its PK - context.execute(new DropIndexBuilder(getDialect()).setTable("events").setName("events_uuid").build()); - // duplicated by its PK - context.execute(new DropIndexBuilder(getDialect()).setTable("ce_activity").setName("ce_activity_uuid").build()); - // no query filtering or ordering by users_updated_at - context.execute(new DropIndexBuilder(getDialect()).setTable("file_sources").setName("file_sources_updated_at").build()); - // no query filtering or ordering by users_updated_at - context.execute(new DropIndexBuilder(getDialect()).setTable("users").setName("users_updated_at").build()); - // not used - context.execute(new DropIndexBuilder(getDialect()).setTable("alm_app_installs").setName("alm_app_installs_external_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshots.java deleted file mode 100644 index 1f6d780374c821d101dff3a2d25cefe627e0b16f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshots.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -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 org.sonar.server.platform.db.migration.sql.DropMsSQLDefaultConstraintsBuilder; - -public class DropUnusedPeriodsInSnapshots extends DdlChange { - private static final String TABLE_NAME = "snapshots"; - private static final String[] COLUMNS = {"period2_mode", "period2_param", "period2_date", - "period3_mode", "period3_param", "period3_date", "period4_mode", "period4_param", "period4_date", "period5_mode", - "period5_param", "period5_date"}; - private final Database db; - - public DropUnusedPeriodsInSnapshots(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - if (MsSql.ID.equals(db.getDialect().getId())) { - context.execute(new DropMsSQLDefaultConstraintsBuilder(db).setTable(TABLE_NAME).setColumns(COLUMNS).build()); - } - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, COLUMNS).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasures.java deleted file mode 100644 index 1c42f6f47f18d8dcb585424c04dd085fba2bdb31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasures.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -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 org.sonar.server.platform.db.migration.sql.DropMsSQLDefaultConstraintsBuilder; - -public class DropUnusedVariationsInProjectMeasures extends DdlChange { - private static final String TABLE_NAME = "project_measures"; - private static final String[] COLUMNS = {"variation_value_2", "variation_value_3", "variation_value_4", "variation_value_5"}; - private final Database db; - - public DropUnusedVariationsInProjectMeasures(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - if (MsSql.ID.equals(db.getDialect().getId())) { - context.execute(new DropMsSQLDefaultConstraintsBuilder(db).setTable(TABLE_NAME).setColumns(COLUMNS).build()); - } - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, COLUMNS).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchType.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchType.java deleted file mode 100644 index 6a4123140cadb7f34996ddb2bb4a44c735f24cdc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchType.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 FillProjectBranchesBranchType extends DataChange { - public FillProjectBranchesBranchType(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid, key_type from project_branches where branch_type is null"); - massUpdate.update("update project_branches set branch_type = ? where uuid = ?"); - massUpdate.execute((row, update) -> { - String uuid = row.getString(1); - String type = row.getString(2); - - update.setString(1, type); - update.setString(2, uuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTable.java deleted file mode 100644 index 50c44faae16231bac141f172cf503ba935ee5581..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 MakeIssueKeyNotNullOnIssueChangesTable extends DdlChange { - - private static final String TABLE = "issue_changes"; - - private static final VarcharColumnDef columnDefinition = newVarcharColumnDefBuilder() - .setColumnName("issue_key") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE) - .build(); - - public MakeIssueKeyNotNullOnIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(columnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTable.java deleted file mode 100644 index dec4912ae170bd4e3cfa7113cd9fe29aa460cfa0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTable.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 MakeMessageTypeColumnNotNullableOnCeTaskMessageTable extends DdlChange { - private static final VarcharColumnDef MESSAGE_TYPE = newVarcharColumnDefBuilder() - .setColumnName("message_type") - .setIsNullable(false) - .setLimit(255) - .build(); - - public MakeMessageTypeColumnNotNullableOnCeTaskMessageTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "ce_task_message") - .updateColumn(MESSAGE_TYPE) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullable.java deleted file mode 100644 index 354e357ee8595b9324fe110ef2fb93cf863de3cd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 MakeProjectBranchesBranchTypeNotNullable extends DdlChange { - public MakeProjectBranchesBranchTypeNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), "project_branches") - .updateColumn(newVarcharColumnDefBuilder() - .setLimit(12) - .setIsNullable(false) - .setColumnName("branch_type") - .build()).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectUuidNotNullOnIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectUuidNotNullOnIssueChangesTable.java deleted file mode 100644 index 74f864c62a7fc8bffd4247484da48acc404ce8e8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectUuidNotNullOnIssueChangesTable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 MakeProjectUuidNotNullOnIssueChangesTable extends DdlChange { - - private static final String TABLE = "issue_changes"; - - private static final VarcharColumnDef columnDefinition = newVarcharColumnDefBuilder() - .setColumnName("project_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE) - .build(); - - public MakeProjectUuidNotNullOnIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(columnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTable.java deleted file mode 100644 index 8abedf9be78a120a225e4dc0f9a6b302014c6fbf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 MakeUuidNotNullOnIssueChangesTable extends DdlChange { - - private static final String TABLE = "issue_changes"; - - private static final VarcharColumnDef columnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeUuidNotNullOnIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(columnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCount.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCount.java deleted file mode 100644 index 29fe68c39ba96208e9dcc9db730bce504bfc3d8f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCount.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.apache.commons.lang.StringUtils; -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 PopulateFileSourceLineCount extends DataChange { - static final int LINE_COUNT_NOT_POPULATED = -1; - private static final String NEW_LINE = "\n"; - - public PopulateFileSourceLineCount(Database database) { - super(database); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid, line_hashes from file_sources where line_count = ?").setInt(1, LINE_COUNT_NOT_POPULATED); - massUpdate.update("update file_sources set line_count = ? where uuid = ?"); - massUpdate.rowPluralName("line counts of file sources"); - massUpdate.execute(PopulateFileSourceLineCount::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - String rowUuid = row.getString(1); - String rawData = row.getNullableString(2); - - int lineCount = rawData == null ? 0 : (StringUtils.countMatches(rawData, NEW_LINE) + 1); - update.setInt(1, lineCount); - update.setString(2, rowUuid); - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTable.java deleted file mode 100644 index 0173404b19bc0b45eee6c612384a0994b74c103d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 PopulateMessageTypeColumnOfCeTaskMessageTable extends DataChange { - public PopulateMessageTypeColumnOfCeTaskMessageTable(Database db) { - super(db); - } - - @Override - protected void execute(DataChange.Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select ctm.uuid from ce_task_message ctm where ctm.message_type is null"); - massUpdate.update("update ce_task_message set message_type = ? where uuid = ?"); - massUpdate.execute((row, update) -> { - update.setString(1, "GENERIC"); - 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/v85/PopulateTypeInPlugins.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/PopulateTypeInPlugins.java deleted file mode 100644 index 6c8e89185259ba012c1447c7ba2ab41f93440981..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/PopulateTypeInPlugins.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class PopulateTypeInPlugins extends DataChange { - public PopulateTypeInPlugins(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("update plugins set type = 'EXTERNAL' where type is null") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChanges.java deleted file mode 100644 index 2800416a523fea81e19ffa465080a25928ec2708..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChanges.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.RenameTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class RenameTmpIssueChangesToIssueChanges extends DdlChange { - - public RenameTmpIssueChangesToIssueChanges(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - if (DatabaseUtils.tableExists("tmp_issue_changes", connection)) { - context.execute(new RenameTableBuilder(getDialect()) - .setName("tmp_issue_changes").setNewName("issue_changes") - .setAutoGeneratedId(false) - .build()); - } - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/package-info.java deleted file mode 100644 index 431939eb6936ef74ae854729af0aaa901f3573f1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v85; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjs.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjs.java deleted file mode 100644 index 3062e309c46affa7a36b615170e13534a1fa5a2e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjs.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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; - -public class AddIndexToApplicationBranchProjs extends DdlChange { - private static final String TABLE = "app_branch_project_branch"; - - public AddIndexToApplicationBranchProjs(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("uniq_app_branch_proj") - .addColumn("application_branch_uuid") - .addColumn("project_branch_uuid") - .setUnique(true) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("idx_abpb_app_uuid") - .addColumn("application_uuid") - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("idx_abpb_app_branch_uuid") - .addColumn("application_branch_uuid") - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("idx_abpb_proj_uuid") - .addColumn("project_uuid") - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("idx_abpb_proj_branch_uuid") - .addColumn("project_branch_uuid") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjects.java deleted file mode 100644 index a75f6a7c27df3e1839daa12b015f095f41178958..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjects.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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; - -public class AddIndexToApplicationProjects extends DdlChange { - private static final String TABLE = "app_projects"; - - public AddIndexToApplicationProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("uniq_app_projects") - .addColumn("application_uuid") - .addColumn("project_uuid") - .setUnique(true) - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("idx_app_proj_application_uuid") - .addColumn("application_uuid") - .build()); - - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName("idx_app_proj_project_uuid") - .addColumn("project_uuid") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjs.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjs.java deleted file mode 100644 index 334488717daa6bd092696c6f8f8195195232232a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjs.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPkToApplicationBranchProjs extends DdlChange { - private static final String TABLE = "app_branch_project_branch"; - - public AddPkToApplicationBranchProjs(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder(TABLE, "uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjects.java deleted file mode 100644 index b3137c8b55f03ba9bfa7f7d9c3d0fd70abab3157..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjects.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPkToApplicationProjects extends DdlChange { - private static final String TABLE = "app_projects"; - - public AddPkToApplicationProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder(TABLE, "uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java deleted file mode 100644 index 36bd5f5c39fb99d441daaeed867fa4c48b830d18..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddPrimaryKeyToDefaultQProfiles extends DdlChange { - public AddPrimaryKeyToDefaultQProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("default_qprofiles", "language").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsers.java deleted file mode 100644 index d5710a3c2b10cda4338acfc53f89074ccc952027..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsers.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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; - -import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddResetPasswordColumnToUsers extends DdlChange { - private static final String TABLE = "users"; - private static final String NEW_COLUMN = "reset_password"; - - public AddResetPasswordColumnToUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - BooleanColumnDef column = newBooleanColumnDefBuilder() - .setColumnName(NEW_COLUMN) - .setIsNullable(true) - .build(); - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(column) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTable.java deleted file mode 100644 index 2a5c2d0332e48e7cce159197a0bc3ba16b7d8696..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 AddUniqueIndexOnNameColumnOfGroupsTable extends DdlChange { - private static final String TABLE_NAME = "groups"; - private static final String INDEX_NAME = "uniq_groups_name"; - - public AddUniqueIndexOnNameColumnOfGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(new VarcharColumnDef.Builder() - .setColumnName("name") - .setIgnoreOracleUnit(true) - .setLimit(500) - .setIsNullable(false) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/CreateApplicationBranchProjs.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/CreateApplicationBranchProjs.java deleted file mode 100644 index 25fab321e9ae97c1d4f59f4d985f90eff824d19c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/CreateApplicationBranchProjs.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.sonar.core.util.Uuids; -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 CreateApplicationBranchProjs extends DdlChange { - public CreateApplicationBranchProjs(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), "app_branch_project_branch") - .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setIsNullable(false).setLimit(Uuids.MAX_LENGTH).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("application_uuid").setIsNullable(false).setLimit(Uuids.MAX_LENGTH).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("application_branch_uuid").setIsNullable(false).setLimit(Uuids.MAX_LENGTH).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("project_uuid").setIsNullable(false).setLimit(Uuids.MAX_LENGTH).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("project_branch_uuid").setIsNullable(false).setLimit(Uuids.MAX_LENGTH).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/v86/CreateApplicationProjectsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/CreateApplicationProjectsTable.java deleted file mode 100644 index 8caf18cba3a972491d2bd1917a066a836e788ec4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/CreateApplicationProjectsTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.sonar.core.util.Uuids; -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 CreateApplicationProjectsTable extends DdlChange { - public CreateApplicationProjectsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new CreateTableBuilder(getDialect(), "app_projects") - .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setIsNullable(false).setLimit(Uuids.MAX_LENGTH).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("application_uuid").setIsNullable(false).setLimit(Uuids.MAX_LENGTH).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("project_uuid").setIsNullable(false).setLimit(Uuids.MAX_LENGTH).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/v86/DbVersion86.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java deleted file mode 100644 index 2200f10a57cc684bd65ab4570b080bd17985594e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion86 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(4100, "Drop QPROFILES_ORG_UUID index from 'quality_profile' table", DropOrganizationUuidIndexFromQualityProfileTable.class) - .add(4101, "Drop organization_uuid from 'quality_profile' table", DropOrganizationFromQualityProfileTable.class) - .add(4102, "Drop primary key of table 'default_qprofiles'", DropDefaultQProfilesPk.class) - .add(4103, "Drop organization_uuid from 'default_qprofiles' table", DropOrganizationFromDefaultQProfiles.class) - .add(4104, "Add primary key to the table 'default_qprofiles", AddPrimaryKeyToDefaultQProfiles.class) - .add(4105, "Drop 'organization_uuid' in 'rules_metadata'", DropOrganizationInRulesMetadata.class) - .add(4106, "Update 'change_data' column of 'qprofile_changes' table to use ruleUuid", UpdateChangeDataOfQProfileChanges.class) - .add(4107, "Drop 'organization_uuid' in 'users'", DropOrganizationInUsers.class) - .add(4108, "Drop 'organization_uuid' in 'user_roles'", DropOrganizationInUserRoles.class) - .add(4109, "Drop 'organization_uuid' in 'group_roles'", DropOrganizationInGroupRoles.class) - .add(4110, "Drop 'organization_uuid' in 'permission_templates'", DropOrganizationInPermissionTemplates.class) - .add(4111, "Drop 'organization_uuid' in 'groups'", DropOrganizationInGroups.class) - .add(4112, "Make 'name' column in 'groups' table not nullable", MakeNameColumnInGroupsTableNotNullable.class) - .add(4113, "Make 'name' column in 'groups' table unique", AddUniqueIndexOnNameColumnOfGroupsTable.class) - .add(4114, "Move default permission templates to internal properties", MoveDefaultTemplatesToInternalProperties.class) - .add(4115, "Set 'sonar.forceAuthentication' to false for upgraded instances", SetForceAuthenticationSettings.class) - - .add(4116, "Create table 'app_projects'", CreateApplicationProjectsTable.class) - .add(4117, "Create primary key for 'app_projects'", AddPkToApplicationProjects.class) - .add(4118, "Create index for 'app_projects'", AddIndexToApplicationProjects.class) - - .add(4119, "Create table 'app_branch_project_branch'", CreateApplicationBranchProjs.class) - .add(4120, "Create primary key for 'app_branch_project_branch'", AddPkToApplicationBranchProjs.class) - .add(4121, "Create index for 'app_branch_project_branch'", AddIndexToApplicationBranchProjs.class) - - .add(4122, "Migrate view definitions from xml to db", MigrateApplicationDefinitionsFromXmlToDb.class) - - .add(4123, "Add 'reset_password' column to 'users' table", AddResetPasswordColumnToUsers.class) - .add(4124, "Populate 'reset_password' column with default value", PopulateResetPasswordDefaultValue.class) - .add(4125, "Make 'reset_password' column in 'users' table not nullable", MakeResetPasswordColumnNotNull.class) - - .add(4126, "Secure gitlab secret parameters", SecureGitlabSecretParameters.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java deleted file mode 100644 index 3e83f7efbf1547d9381fd9593fd5e0d665524659..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropDefaultQProfilesPk extends DdlChange { - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - private static final String TABLE_NAME = "default_qprofiles"; - private static final String COLUMN_NAME = "language"; - - public DropDefaultQProfilesPk(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, COLUMN_NAME, false)); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfiles.java deleted file mode 100644 index 1f04e18b3dff182899bd542f7b44a5133f317a1b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfiles.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 DropOrganizationFromDefaultQProfiles extends DdlChange { - public DropOrganizationFromDefaultQProfiles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "default_qprofiles", "organization_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTable.java deleted file mode 100644 index c8c1cefa00f3db9a5bdf1d987be54dae9f0b4a72..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 DropOrganizationFromQualityProfileTable extends DdlChange { - - public DropOrganizationFromQualityProfileTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "org_qprofiles", "organization_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRoles.java deleted file mode 100644 index 4133a64d53048f53267c34b6a049ea45547db2ae..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRoles.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropOrganizationInGroupRoles extends DdlChange { - - private static final String TABLE_NAME = "group_roles"; - - public DropOrganizationInGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute( - new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("uniq_group_roles") - .build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName("uniq_group_roles") - .addColumn("group_uuid") - .addColumn("component_uuid") - .addColumn("role") - .setUnique(true) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroups.java deleted file mode 100644 index 9c660c425cdcd77971e6b7ccdb14482ab4826702..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroups.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 DropOrganizationInGroups extends DdlChange { - - private static final String TABLE_NAME = "groups"; - - public DropOrganizationInGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplates.java deleted file mode 100644 index 79ee99aab9d59ea808663537c15d48516d6f28df..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplates.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 DropOrganizationInPermissionTemplates extends DdlChange { - - private static final String TABLE_NAME = "permission_templates"; - - public DropOrganizationInPermissionTemplates(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java deleted file mode 100644 index 9aec063466d37e83b8b9d16192bd5049b0687245..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import java.util.Arrays; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropOrganizationInRulesMetadata extends DdlChange { - private static final String TABLE_NAME = "rules_metadata"; - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropOrganizationInRulesMetadata(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, Arrays.asList("rule_uuid", "organization_uuid"), false)); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - context.execute(new AddPrimaryKeyBuilder(TABLE_NAME, "rule_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRoles.java deleted file mode 100644 index f40fd2cf28fbba7a3ce12a499f4f440a75adadd3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRoles.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 DropOrganizationInUserRoles extends DdlChange { - - private static final String TABLE_NAME = "user_roles"; - - public DropOrganizationInUserRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsers.java deleted file mode 100644 index 0bd9137118847299d8a763d749ea9a9da49bca73..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsers.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 DropOrganizationInUsers extends DdlChange { - - private static final String TABLE_NAME = "users"; - - public DropOrganizationInUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTable.java deleted file mode 100644 index e11e9c7ab39f0c46c0410b8d70c773afac17a971..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DropIndexChange; - -public class DropOrganizationUuidIndexFromQualityProfileTable extends DropIndexChange { - private static final String TABLE_NAME = "org_qprofiles"; - private static final String INDEX_NAME = "qprofiles_org_uuid"; - - public DropOrganizationUuidIndexFromQualityProfileTable(Database db) { - super(db, INDEX_NAME, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullable.java deleted file mode 100644 index 09592caee5dbdabd50d515f24ca364ddc3235ad5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 MakeNameColumnInGroupsTableNotNullable extends DdlChange { - private static final String TABLE = "groups"; - - private static final VarcharColumnDef columnDefinition = newVarcharColumnDefBuilder() - .setColumnName("name") - .setIsNullable(false) - .setIgnoreOracleUnit(true) - .setLimit(500) - .build(); - - public MakeNameColumnInGroupsTableNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(columnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNull.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNull.java deleted file mode 100644 index 744bb1ea34916d9f99cecbceab2b30ba5de60cbd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNull.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 MakeResetPasswordColumnNotNull extends DdlChange { - private static final String TABLE = "users"; - private static final String RESET_PASSWORD_COLUMN_NAME = "reset_password"; - - private static final BooleanColumnDef columnDefinition = newBooleanColumnDefBuilder() - .setColumnName(RESET_PASSWORD_COLUMN_NAME) - .setIsNullable(false) - .build(); - - public MakeResetPasswordColumnNotNull(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(columnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDb.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDb.java deleted file mode 100644 index 2dce4e79808a0960083f91cf3c07260ce6aff8cb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDb.java +++ /dev/null @@ -1,743 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.sql.SQLException; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.xml.XMLConstants; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.transform.sax.SAXSource; -import javax.xml.validation.SchemaFactory; -import org.apache.commons.lang.StringUtils; -import org.codehaus.staxmate.SMInputFactory; -import org.codehaus.staxmate.in.SMHierarchicCursor; -import org.codehaus.staxmate.in.SMInputCursor; -import org.sonar.api.resources.Qualifiers; -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; -import org.sonar.server.platform.db.migration.step.Upsert; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.helpers.DefaultHandler; - -import static java.lang.String.format; -import static java.nio.charset.StandardCharsets.UTF_8; -import static javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING; -import static org.apache.commons.io.IOUtils.toInputStream; -import static org.apache.commons.lang.StringEscapeUtils.escapeXml; -import static org.apache.commons.lang.StringUtils.trim; - -public class MigrateApplicationDefinitionsFromXmlToDb extends DataChange { - static final int TEXT_VALUE_MAX_LENGTH = 4000; - private static final String SELECT_APPLICATION_UUID_BY_KEY = "select uuid from projects where kee = ? and qualifier = 'APP'"; - private static final String SELECT_PROJECTS_BY_KEYS = "select kee,uuid from projects where kee in (%s) and qualifier = 'TRK'"; - private static final String SELECT_PROJECTS_BY_APP = "select project_uuid from app_projects where application_uuid = ?"; - private static final String UPDATE_INTERNAL_PROP_TEXT_VALUE = "update internal_properties set text_value = ?, clob_value = NULL where kee = ?"; - private static final String UPDATE_INTERNAL_PROP_CLOB_VALUE = "update internal_properties set clob_value = ?, text_value = NULL where kee = ?"; - private static final String VIEWS_DEF_KEY = "views.def"; - - private final UuidFactory uuidFactory; - private final System2 system; - - public MigrateApplicationDefinitionsFromXmlToDb(Database db, UuidFactory uuidFactory, System2 system) { - super(db); - - this.uuidFactory = uuidFactory; - this.system = system; - } - - @Override - protected void execute(Context context) throws SQLException { - String xml = getViewsDefinition(context); - // skip migration if `views.def` does not exist in the db - if (xml == null) { - return; - } - - try { - Map defs = ViewXml.parse(xml); - List applications = defs.values() - .stream() - .filter(v -> Qualifiers.APP.equals(v.getQualifier())) - .collect(Collectors.toList()); - for (ViewXml.ViewDef app : applications) { - insertApplication(context, app); - } - cleanUpViewsDefinitionsXml(context, defs.values()); - } catch (Exception e) { - throw new IllegalStateException("Failed to migrate views definitions property.", e); - } - - } - - private void insertApplication(Context context, ViewXml.ViewDef app) throws SQLException { - long now = system.now(); - String applicationUuid = context.prepareSelect(SELECT_APPLICATION_UUID_BY_KEY) - .setString(1, app.getKey()) - .get(r -> r.getString(1)); - - // skip migration if: - // - application only exists in xml and not in the db. It will be removed from the xml at later stage of the migration. - // - application contains no projects- it's already in a valid db state - Set uniqueProjects = new HashSet<>(app.getProjects()); - if (applicationUuid == null || uniqueProjects.isEmpty()) { - return; - } - - List alreadyAddedProjects = context.prepareSelect(SELECT_PROJECTS_BY_APP).setString(1, applicationUuid) - .list(r -> r.getString(1)); - - String queryParam = uniqueProjects.stream().map(uuid -> "'" + uuid + "'").collect(Collectors.joining(",")); - Map projectUuidsByKeys = context.prepareSelect(format(SELECT_PROJECTS_BY_KEYS, queryParam)) - .list(r -> new AbstractMap.SimpleEntry<>(r.getString(1), r.getString(2))) - .stream() - .filter(project -> !alreadyAddedProjects.contains(project.getValue())) - .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); - - if (!projectUuidsByKeys.isEmpty()) { - insertApplicationProjects(context, app, applicationUuid, projectUuidsByKeys, uniqueProjects, now); - } - if (!app.getApplicationBranches().isEmpty()) { - insertApplicationBranchesProjects(context, app, applicationUuid, projectUuidsByKeys, now); - } - } - - private void insertApplicationProjects(Context context, ViewXml.ViewDef app, String applicationUuid, - Map projectUuidsByKeys, Set uniqueProjects, long createdTime) throws SQLException { - Upsert insertApplicationProjectsQuery = context.prepareUpsert("insert into " + - "app_projects(uuid, application_uuid, project_uuid, created_at) " + - "values (?, ?, ?, ?)"); - for (String projectKey : uniqueProjects) { - String applicationProjectUuid = uuidFactory.create(); - String projectUuid = projectUuidsByKeys.get(projectKey); - - // ignore project if it does not exist anymore - if (projectUuid == null) { - continue; - } - - insertApplicationProjectsQuery - .setString(1, applicationProjectUuid) - .setString(2, applicationUuid) - .setString(3, projectUuid) - .setLong(4, createdTime) - .addBatch(); - } - - insertApplicationProjectsQuery.execute().commit(); - } - - private void insertApplicationBranchesProjects(Context context, ViewXml.ViewDef app, String applicationUuid, - Map projectUuidsByKeys, long createdTime) throws SQLException { - Map appBranchUuidByKey = context.prepareSelect("select kee,uuid from project_branches where project_uuid = ?") - .setString(1, applicationUuid) - .list(r -> new AbstractMap.SimpleEntry<>(r.getString(1), r.getString(2))) - .stream() - .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); - - Upsert insertApplicationsBranchProjectsQuery = context.prepareUpsert("insert into " + - "app_branch_project_branch(uuid, application_uuid, application_branch_uuid, project_uuid, project_branch_uuid, created_at) " + - "values (?, ?, ?, ?, ?, ?)"); - boolean insert = false; - for (ViewXml.ApplicationBranchDef branch : app.getApplicationBranches()) { - String applicationBranchUuid = appBranchUuidByKey.get(branch.getKey()); - // ignore application branch if it does not exist in the DB anymore - if (applicationBranchUuid == null) { - continue; - } - - if (insertApplicationBranchProjects(context, branch, applicationUuid, applicationBranchUuid, projectUuidsByKeys, createdTime, - insertApplicationsBranchProjectsQuery)) { - insert = true; - } - } - - if (insert) { - insertApplicationsBranchProjectsQuery.execute().commit(); - } - } - - private boolean insertApplicationBranchProjects(Context context, ViewXml.ApplicationBranchDef branch, String applicationUuid, - String applicationBranchUuid, Map projectUuidsByKeys, long createdTime, - Upsert insertApplicationsBranchProjectsQuery) throws SQLException { - - boolean insert = false; - for (ViewXml.ApplicationProjectDef appProjDef : branch.getProjects()) { - String projectUuid = projectUuidsByKeys.get(appProjDef.getKey()); - - // ignore projects that do not exist in the DB anymore - if (projectUuid != null) { - String projectBranchUuid = context.prepareSelect("select uuid from project_branches where project_uuid = ? and kee = ?") - .setString(1, projectUuid) - .setString(2, appProjDef.getBranch()) - .get(r -> r.getString(1)); - - // ignore project branches that do not exist in the DB anymore - if (projectBranchUuid != null) { - String applicationBranchProjectUuid = uuidFactory.create(); - insertApplicationsBranchProjectsQuery - .setString(1, applicationBranchProjectUuid) - .setString(2, applicationUuid) - .setString(3, applicationBranchUuid) - .setString(4, projectUuid) - .setString(5, projectBranchUuid) - .setLong(6, createdTime) - .addBatch(); - insert = true; - } - } - } - - return insert; - } - - @CheckForNull - private static String getViewsDefinition(DataChange.Context context) throws SQLException { - Select select = context.prepareSelect("select text_value,clob_value from internal_properties where kee=?"); - select.setString(1, VIEWS_DEF_KEY); - return select.get(row -> { - String v = row.getString(1); - if (v != null) { - return v; - } else { - return row.getString(2); - } - }); - } - - private static void cleanUpViewsDefinitionsXml(Context context, Collection definitions) throws SQLException, IOException { - definitions = definitions.stream() - .filter(d -> !"APP".equals(d.getQualifier())) - .collect(Collectors.toList()); - - StringWriter output = new StringWriter(); - new ViewXml.ViewDefinitionsSerializer().write(definitions, output); - String value = output.toString(); - String statement = UPDATE_INTERNAL_PROP_TEXT_VALUE; - if (mustBeStoredInClob(value)) { - statement = UPDATE_INTERNAL_PROP_CLOB_VALUE; - } - - context.prepareUpsert(statement) - .setString(1, output.toString()) - .setString(2, VIEWS_DEF_KEY) - .execute() - .commit(); - } - - private static boolean mustBeStoredInClob(String value) { - return value.length() > TEXT_VALUE_MAX_LENGTH; - } - - private static class ViewXml { - static final String SCHEMA_VIEWS = "/static/views.xsd"; - static final String VIEWS_HEADER_BARE = ""; - static final Pattern VIEWS_HEADER_BARE_PATTERN = Pattern.compile(VIEWS_HEADER_BARE); - static final String VIEWS_HEADER_FQ = "" - + ""; - - private ViewXml() { - // nothing to do here - } - - private static Map parse(String xml) throws ParserConfigurationException, SAXException, IOException, XMLStreamException { - if (StringUtils.isEmpty(xml)) { - return new LinkedHashMap<>(0); - } - - List views; - validate(xml); - SMInputFactory inputFactory = initStax(); - SMHierarchicCursor rootC = inputFactory.rootElementCursor(new StringReader(xml)); - rootC.advance(); // - SMInputCursor cursor = rootC.childElementCursor(); - views = parseViewDefinitions(cursor); - - Map result = new LinkedHashMap<>(views.size()); - for (ViewDef def : views) { - result.put(def.getKey(), def); - } - - return result; - } - - private static void validate(String xml) throws IOException, SAXException, ParserConfigurationException { - // Replace bare, namespace unaware header with fully qualified header (with schema declaration) - String fullyQualifiedXml = VIEWS_HEADER_BARE_PATTERN.matcher(xml).replaceFirst(VIEWS_HEADER_FQ); - try (InputStream xsd = MigrateApplicationDefinitionsFromXmlToDb.class.getResourceAsStream(SCHEMA_VIEWS)) { - InputSource viewsDefinition = new InputSource(new InputStreamReader(toInputStream(fullyQualifiedXml, UTF_8), UTF_8)); - - SchemaFactory saxSchemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - saxSchemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); - saxSchemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - parserFactory.setFeature(FEATURE_SECURE_PROCESSING, true); - parserFactory.setNamespaceAware(true); - parserFactory.setSchema(saxSchemaFactory.newSchema(new SAXSource(new InputSource(xsd)))); - - SAXParser saxParser = parserFactory.newSAXParser(); - saxParser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - saxParser.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); - saxParser.parse(viewsDefinition, new ViewsValidator()); - } - } - - private static List parseViewDefinitions(SMInputCursor viewsCursor) throws XMLStreamException { - List views = new ArrayList<>(); - while (viewsCursor.getNext() != null) { - ViewDef viewDef = new ViewDef(); - viewDef.setKey(viewsCursor.getAttrValue("key")); - viewDef.setDef(Boolean.parseBoolean(viewsCursor.getAttrValue("def"))); - viewDef.setParent(viewsCursor.getAttrValue("parent")); - viewDef.setRoot(viewsCursor.getAttrValue("root")); - SMInputCursor viewCursor = viewsCursor.childElementCursor(); - while (viewCursor.getNext() != null) { - String nodeName = viewCursor.getLocalName(); - parseChildElement(viewDef, viewCursor, nodeName); - } - views.add(viewDef); - } - return views; - } - - private static void parseChildElement(ViewDef viewDef, SMInputCursor viewCursor, String nodeName) throws XMLStreamException { - if (StringUtils.equals(nodeName, "name")) { - viewDef.setName(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "desc")) { - viewDef.setDesc(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "regexp")) { - viewDef.setRegexp(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "language")) { - viewDef.setLanguage(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "tag_key")) { - viewDef.setTagKey(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "tag_value")) { - viewDef.setTagValue(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "p")) { - viewDef.addProject(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "vw-ref")) { - viewDef.addReference(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "qualifier")) { - viewDef.setQualifier(trim(viewCursor.collectDescendantText())); - } else if (StringUtils.equals(nodeName, "branch")) { - parseBranch(viewDef, viewCursor); - } else if (StringUtils.equals(nodeName, "tagsAssociation")) { - parseTagsAssociation(viewDef, viewCursor); - } - } - - private static void parseBranch(ViewDef def, SMInputCursor viewCursor) throws XMLStreamException { - List projects = new ArrayList<>(); - String key = viewCursor.getAttrValue("key"); - SMInputCursor projectCursor = viewCursor.childElementCursor(); - while (projectCursor.getNext() != null) { - if (Objects.equals(projectCursor.getLocalName(), "p")) { - String branch = projectCursor.getAttrValue("branch"); - String projectKey = trim(projectCursor.collectDescendantText()); - projects.add(new ApplicationProjectDef().setKey(projectKey).setBranch(branch)); - } - } - def.getApplicationBranches().add(new ApplicationBranchDef() - .setKey(key) - .setProjects(projects)); - } - - private static void parseTagsAssociation(ViewDef def, SMInputCursor viewCursor) throws XMLStreamException { - SMInputCursor projectCursor = viewCursor.childElementCursor(); - while (projectCursor.getNext() != null) { - def.addTagAssociation(trim(projectCursor.collectDescendantText())); - } - } - - private static SMInputFactory initStax() { - XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); - xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); - xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); - // just so it won't try to load DTD in if there's DOCTYPE - xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); - xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE); - return new SMInputFactory(xmlFactory); - } - - private static class ViewDef { - String key = null; - - String parent = null; - - String root = null; - - boolean def = false; - - List p = new ArrayList<>(); - - List vwRef = new ArrayList<>(); - - String name = null; - - String desc = null; - - String regexp = null; - - String language = null; - - String tagKey = null; - - String tagValue = null; - - String qualifier = null; - - List applicationBranches = new ArrayList<>(); - - Set tagsAssociation = new TreeSet<>(); - - public String getKey() { - return key; - } - - public String getParent() { - return parent; - } - - @CheckForNull - public String getRoot() { - return root; - } - - public boolean isDef() { - return def; - } - - public List getProjects() { - return p; - } - - public List getReferences() { - return vwRef; - } - - public String getName() { - return name; - } - - public String getDesc() { - return desc; - } - - @CheckForNull - public String getRegexp() { - return regexp; - } - - @CheckForNull - public String getLanguage() { - return language; - } - - @CheckForNull - public String getTagKey() { - return tagKey; - } - - @CheckForNull - public String getTagValue() { - return tagValue; - } - - @CheckForNull - public String getQualifier() { - return qualifier; - } - - public List getApplicationBranches() { - return applicationBranches; - } - - public Set getTagsAssociation() { - return tagsAssociation; - } - - public ViewDef setKey(String key) { - this.key = key; - return this; - } - - public ViewDef setParent(String parent) { - this.parent = parent; - return this; - } - - public ViewDef setRoot(@Nullable String root) { - this.root = root; - return this; - } - - public ViewDef setDef(boolean def) { - this.def = def; - return this; - } - - public ViewDef setProjects(List projects) { - this.p = projects; - return this; - } - - public ViewDef addProject(String project) { - this.p.add(project); - return this; - } - - public ViewDef removeProject(String project) { - this.p.remove(project); - return this; - } - - public ViewDef setName(String name) { - this.name = name; - return this; - } - - public ViewDef setDesc(@Nullable String desc) { - this.desc = desc; - return this; - } - - public ViewDef setRegexp(@Nullable String regexp) { - this.regexp = regexp; - return this; - } - - public ViewDef setLanguage(@Nullable String language) { - this.language = language; - return this; - } - - public ViewDef setTagKey(@Nullable String tagKey) { - this.tagKey = tagKey; - return this; - } - - public ViewDef setTagValue(@Nullable String tagValue) { - this.tagValue = tagValue; - return this; - } - - public ViewDef addReference(String reference) { - this.vwRef.add(reference); - return this; - } - - public ViewDef removeReference(String reference) { - this.vwRef.remove(reference); - return this; - } - - public ViewDef setReferences(List vwRef) { - this.vwRef = vwRef; - return this; - } - - public ViewDef setQualifier(@Nullable String qualifier) { - this.qualifier = qualifier; - return this; - } - - public ViewDef setApplicationBranches(List branches) { - this.applicationBranches = branches; - return this; - } - - public ViewDef addTagAssociation(String tag) { - this.tagsAssociation.add(tag); - return this; - } - - public ViewDef setTagsAssociation(Set tagsAssociation) { - this.tagsAssociation = tagsAssociation; - return this; - } - } - - private static class ApplicationProjectDef { - private String key = null; - private String branch = null; - - public String getKey() { - return key; - } - - public ApplicationProjectDef setKey(String key) { - this.key = key; - return this; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public ApplicationProjectDef setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - } - - private static class ApplicationBranchDef { - - private String key = null; - private List p = new ArrayList<>(); - - public String getKey() { - return key; - } - - public ApplicationBranchDef setKey(String key) { - this.key = key; - return this; - } - - public List getProjects() { - return p; - } - - public ApplicationBranchDef setProjects(List p) { - this.p = p; - return this; - } - } - - private static final class ViewsValidator extends DefaultHandler { - @Override - public void error(SAXParseException exception) throws SAXException { - throw exception; - } - - @Override - public void warning(SAXParseException exception) throws SAXException { - throw exception; - } - - @Override - public void fatalError(SAXParseException exception) throws SAXException { - throw exception; - } - } - - static class ViewDefinitionsSerializer { - - public void write(Collection definitions, Writer writer) throws IOException { - writer.append(VIEWS_HEADER_BARE); - - for (ViewDef def : definitions) { - writer.append(""); - - writer.append(""); - writeOptionalElements(writer, def); - - for (String project : def.getProjects()) { - writer.append("

").append(project).append("

"); - } - for (String ref : def.getReferences()) { - writer.append(""); - } - writeTagsAssociation(writer, def); - writer.append(""); - } - - writer.append("
"); - } - - private static void writeOptionalElements(Writer writer, ViewDef def) throws IOException { - String description = def.getDesc(); - if (description != null) { - writer.append(""); - } - String regexp = def.getRegexp(); - if (regexp != null) { - writer.append(""); - } - String language = def.getLanguage(); - if (language != null) { - writer.append(""); - } - String customMeasureKey = def.getTagKey(); - if (customMeasureKey != null) { - writer.append(""); - } - String customMeasureValue = def.getTagValue(); - if (customMeasureValue != null) { - writer.append(""); - } - String qualifier = def.getQualifier(); - if (qualifier != null) { - writer.append(""); - } - } - - private static void writeTagsAssociation(Writer writer, ViewDef definition) throws IOException { - Set tagsAssociation = definition.getTagsAssociation(); - if (tagsAssociation.isEmpty()) { - return; - } - writer.append(""); - for (String tag : tagsAssociation) { - writer.append("").append(tag).append(""); - } - writer.append(""); - } - - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalProperties.java deleted file mode 100644 index 056ffb1b6fbc64fe3b8f3ce2c2018db619255509..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalProperties.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import java.util.Optional; -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.Select; -import org.sonar.server.platform.db.migration.step.Upsert; - -public class MoveDefaultTemplatesToInternalProperties extends DataChange { - - private final System2 system2; - - public MoveDefaultTemplatesToInternalProperties(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - OrganizationDefaultTemplates organizationDefaultTemplates = context - .prepareSelect("select org.default_perm_template_project, org.default_perm_template_port, org.default_perm_template_app from organizations org " + - "where org.kee = 'default-organization'") - .get(OrganizationDefaultTemplates::new); - if (organizationDefaultTemplates == null) { - throw new IllegalStateException("Default organization is missing"); - } - Upsert updateInternalProperties = context.prepareUpsert("insert into internal_properties (kee, text_value, is_empty, created_at) values (?, ?, ?, ?)"); - - Optional defaultPermissionTemplateForProject = organizationDefaultTemplates.getDefaultPermissionTemplateForProject(); - if (defaultPermissionTemplateForProject.isPresent()) { - insertInInternalProperties(context, updateInternalProperties, "defaultTemplate.prj", defaultPermissionTemplateForProject.get()); - } else { - // If default permission templates are missing, they will be added during the startup task "RegisterPermissionTemplates" - return; - } - - organizationDefaultTemplates.getDefaultPermissionTemplateForPortfolio() - .ifPresent( - defaultPermissionTemplate -> insertInInternalProperties(context, updateInternalProperties, "defaultTemplate.port", defaultPermissionTemplate)); - organizationDefaultTemplates.getDefaultPermissionTemplateForApplication() - .ifPresent( - defaultPermissionTemplate -> insertInInternalProperties(context, updateInternalProperties, "defaultTemplate.app", defaultPermissionTemplate)); - } - - private void insertInInternalProperties(Context context, Upsert updateInternalProperties, String key, String value) { - try { - Integer isInternalPropertyAlreadyExists = context.prepareSelect("select count(1) from internal_properties ip where ip.kee = ?") - .setString(1, key) - .get(row -> row.getInt(1)); - if (isInternalPropertyAlreadyExists != null && isInternalPropertyAlreadyExists > 0) { - return; - } - updateInternalProperties - .setString(1, key) - .setString(2, value) - .setBoolean(3, false) - .setLong(4, system2.now()) - .execute() - .commit(); - } catch (SQLException throwables) { - throw new IllegalStateException(throwables); - } - } - - private static class OrganizationDefaultTemplates { - private final String defaultPermissionTemplateForProject; - private final String defaultPermissionTemplateForPortfolio; - private final String defaultPermissionTemplateForApplication; - - OrganizationDefaultTemplates(Select.Row row) throws SQLException { - this.defaultPermissionTemplateForProject = row.getNullableString(1); - this.defaultPermissionTemplateForPortfolio = row.getNullableString(2); - this.defaultPermissionTemplateForApplication = row.getNullableString(3); - } - - Optional getDefaultPermissionTemplateForProject() { - return Optional.ofNullable(defaultPermissionTemplateForProject); - } - - Optional getDefaultPermissionTemplateForPortfolio() { - return Optional.ofNullable(defaultPermissionTemplateForPortfolio); - } - - Optional getDefaultPermissionTemplateForApplication() { - return Optional.ofNullable(defaultPermissionTemplateForApplication); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValue.java deleted file mode 100644 index d7302b57ad6cc97206534acc1ed5aa64a268d31f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValue.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 PopulateResetPasswordDefaultValue extends DataChange { - - private final System2 system2; - - public PopulateResetPasswordDefaultValue(Database db, System2 system2) { - super(db); - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from users where reset_password is null"); - massUpdate.update("update users set reset_password = ?, updated_at = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setBoolean(1, false) - .setLong(2, system2.now()) - .setString(3, row.getString(1)); - return true; - }); - - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParameters.java deleted file mode 100644 index 8e6d6cbd55388f9760d3048145e63e9ce506099b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParameters.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class SecureGitlabSecretParameters extends DataChange { - - public SecureGitlabSecretParameters(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - updateToSecured(context, "sonar.auth.gitlab.applicationId"); - updateToSecured(context, "sonar.auth.gitlab.secret"); - } - - private static void updateToSecured(Context context, String property) throws SQLException { - context.prepareUpsert("update properties set prop_key = ? where prop_key = ?") - .setString(1, property + ".secured") - .setString(2, property) - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettings.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettings.java deleted file mode 100644 index 5624c75a4209ef0b53bb4e108c48b2b856774b5e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettings.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import java.util.Optional; -import org.sonar.api.config.internal.Settings; -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 SetForceAuthenticationSettings extends DataChange { - private static final String PROPERTY_NAME_FORCE_AUTHENTICATION = "sonar.forceAuthentication"; - private System2 system2; - private UuidFactory uuidFactory; - private Settings settings; - - public SetForceAuthenticationSettings(Database db, System2 system2, UuidFactory uuidFactory, Settings settings) { - super(db); - this.system2 = system2; - this.uuidFactory = uuidFactory; - this.settings = settings; - } - - @Override - protected void execute(Context context) throws SQLException { - Select select = context.prepareSelect("select p.text_value from properties p where p.prop_key = ?") - .setString(1, PROPERTY_NAME_FORCE_AUTHENTICATION); - String value = select.get(row -> row.getString(1)); - - if (value == null) { - Optional forceAuthenticationSettings = settings.getRawString(PROPERTY_NAME_FORCE_AUTHENTICATION); - - context.prepareUpsert("INSERT INTO properties" - + "(prop_key, is_empty, text_value, created_at, uuid) " - + "VALUES(?, ?, ?, ?, ?)") - .setString(1, PROPERTY_NAME_FORCE_AUTHENTICATION) - .setBoolean(2, false) - .setString(3, forceAuthenticationSettings.orElse("false")) - .setLong(4, system2.now()) - .setString(5, uuidFactory.create()) - .execute() - .commit(); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChanges.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChanges.java deleted file mode 100644 index d5c3a69b3dc4ec375d2abd19ebbc1707d7835c25..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChanges.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -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 UpdateChangeDataOfQProfileChanges extends DataChange { - - public UpdateChangeDataOfQProfileChanges(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select qpc.kee, qpc.change_data " - + "from qprofile_changes qpc where qpc.change_data like '%ruleId=%'"); - - massUpdate.update("update qprofile_changes " - + "set change_data = replace(change_data, 'ruleId', 'ruleUuid') where kee = ?"); - - 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/v86/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/package-info.java deleted file mode 100644 index 08a9d010efec227195fa937ad0832eb2f85d78f7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public 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.v86; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTable.java deleted file mode 100644 index 2392273d4dfddbc4b301ff40ab4edb44e6f03fe5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTable.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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; - -import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; - -public class AddMonorepoColumnToProjectAlmSettingsTable extends DdlChange { - - private static final String TABLE = "project_alm_settings"; - - private static final BooleanColumnDef MONOREPO = newBooleanColumnDefBuilder() - .setColumnName("monorepo") - .setIsNullable(true) - .build(); - - public AddMonorepoColumnToProjectAlmSettingsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(MONOREPO) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DbVersion87.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DbVersion87.java deleted file mode 100644 index 700e6606dc0d447f06ca659e17a42577b9a8c4c6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DbVersion87.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion87 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(4200, "Move default project visibility to global properties", MoveDefaultProjectVisibilityToGlobalProperties.class) - .add(4201, "Move default quality gate to global properties", MoveDefaultQualityGateToGlobalProperties.class) - - .add(4202, "Drop organization_uuid in table 'components'", DropOrganizationInComponents.class) - .add(4203, "Drop organization_uuid in table 'projects'", DropOrganizationInProjects.class) - .add(4204, "Drop organizations in table 'webhooks'", DropOrganizationInWebhooks.class) - - .add(4205, "Drop table 'org_quality_gates'", DropOrgQualityGatesTable.class) - .add(4206, "Drop table 'organization_alm_bindings'", DropOrganizationAlmBindingsTable.class) - .add(4207, "Drop table 'alm_app_installs'", DropAlmAppInstallsTable.class) - .add(4208, "Drop table 'organizations'", DropOrganizationsTable.class) - .add(4209, "Drop table 'organization_members'", DropOrgMembersTable.class) - - .add(4210, "Add column 'monorepo' to table 'project_alm_settings'", AddMonorepoColumnToProjectAlmSettingsTable.class) - .add(4211, "Populate column 'monorepo' to false in table 'project_alm_settings'", PopulateMonorepoColumnToProjectAlmSettingsTable.class) - .add(4212, "Make column 'monorepo' in table 'project_alm_settings' not Nullable", MakeMonorepoColumnInProjectAlmSettingsTableNotNullable.class) - - .add(4213, "Drop column 'description' in table 'project_measures'", DropDescriptionInProjectMeasures.class) - - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTable.java deleted file mode 100644 index 897ced7fe9e34e7712149ccb52c6897684c4d46d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTable.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropAlmAppInstallsTable extends DdlChange { - private static final String TABLE_NAME = "alm_app_installs"; - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropAlmAppInstallsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, "uuid", false)); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("alm_app_installs_owner").build()); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("alm_app_installs_install").build()); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("alm_app_installs_external_id").build()); - context.execute(new DropTableBuilder(getDialect(), TABLE_NAME).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasures.java deleted file mode 100644 index 898f4132352d061ea49e6330bf523164c342f8a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasures.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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 DropDescriptionInProjectMeasures extends DdlChange { - private static final String TABLE_NAME = "project_measures"; - - public DropDescriptionInProjectMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "description").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTable.java deleted file mode 100644 index 64e704b60f3d8e28c1783aa9550054e78c4b6191..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import java.util.Arrays; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropOrgMembersTable extends DdlChange { - private static final String TABLE_NAME = "organization_members"; - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropOrgMembersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, Arrays.asList("user_uuid", "organization_uuid"), false)); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("org_members_user_uuid").build()); - context.execute(new DropTableBuilder(getDialect(), TABLE_NAME).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTable.java deleted file mode 100644 index a79642ca6d7b20dc173bddb724201f77d6528477..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropOrgQualityGatesTable extends DdlChange { - private static final String TABLE_NAME = "org_quality_gates"; - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropOrgQualityGatesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, "uuid", false)); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("uniq_org_quality_gates").build()); - context.execute(new DropTableBuilder(getDialect(), TABLE_NAME).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTable.java deleted file mode 100644 index 93ae0ed51533fa69922d65f5673ebd8e54a2273f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropOrganizationAlmBindingsTable extends DdlChange { - private static final String TABLE_NAME = "organization_alm_bindings"; - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropOrganizationAlmBindingsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, "uuid", false)); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("org_alm_bindings_org").build()); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("org_alm_bindings_install").build()); - context.execute(new DropTableBuilder(getDialect(), TABLE_NAME).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInComponents.java deleted file mode 100644 index 13b98529bc0f0b449034a277eb16fb77509fe8e3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInComponents.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropOrganizationInComponents extends DdlChange { - private static final String TABLE_NAME = "components"; - - public DropOrganizationInComponents(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("projects_organization").build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjects.java deleted file mode 100644 index c4960bca58ef3502e428990358451e92310d7eca..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjects.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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 DropOrganizationInProjects extends DdlChange { - private static final String TABLE_NAME = "projects"; - - public DropOrganizationInProjects(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooks.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooks.java deleted file mode 100644 index f310d3a9362f71743bc5d9eececc33773204e2bd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooks.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropOrganizationInWebhooks extends DdlChange { - private static final String TABLE_NAME = "webhooks"; - - public DropOrganizationInWebhooks(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("organization_webhook").build()); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("project_webhook").build()); - context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); - - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTable.java deleted file mode 100644 index cb57286c7b94c2223b238c8bc930978d78c54d96..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.sql.DropTableBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropOrganizationsTable extends DdlChange { - private static final String TABLE_NAME = "organizations"; - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropOrganizationsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, "uuid", false)); - context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("organization_key").build()); - context.execute(new DropTableBuilder(getDialect(), TABLE_NAME).build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullable.java deleted file mode 100644 index 416c467bc58e45a5a37d22483e7fd9df6a3d53c0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullable.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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 MakeMonorepoColumnInProjectAlmSettingsTableNotNullable extends DdlChange { - private static final String TABLE = "project_alm_settings"; - - private static final BooleanColumnDef MONOREPO = newBooleanColumnDefBuilder() - .setColumnName("monorepo") - .setIsNullable(false) - .build(); - - public MakeMonorepoColumnInProjectAlmSettingsTableNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(MONOREPO) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalProperties.java deleted file mode 100644 index e3dbc7a74088d8e6f913d55b5efbd9a893229263..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalProperties.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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; - -public class MoveDefaultProjectVisibilityToGlobalProperties extends DataChange { - - private final UuidFactory uuidFactory; - private final System2 system2; - - public MoveDefaultProjectVisibilityToGlobalProperties(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - Boolean newProjectPrivate = context.prepareSelect("select new_project_private from organizations where kee = ?") - .setString(1, "default-organization") - .get(row -> row.getNullableBoolean(1)); - - if (newProjectPrivate == null) { - throw new IllegalStateException("Default organization is missing"); - } else { - context.prepareUpsert("insert into properties (uuid, prop_key, is_empty, text_value, created_at) values (?, ?, ?, ?, ?)") - .setString(1, uuidFactory.create()) - .setString(2, "projects.default.visibility") - .setBoolean(3, false) - .setString(4, Boolean.TRUE.equals(newProjectPrivate) ? "private" : "public") - .setLong(5, system2.now()) - .execute() - .commit(); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalProperties.java deleted file mode 100644 index 3d4949cf4298f4d53e11eebe43c01d236720bd63..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalProperties.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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; - -public class MoveDefaultQualityGateToGlobalProperties extends DataChange { - - private final UuidFactory uuidFactory; - private final System2 system2; - - public MoveDefaultQualityGateToGlobalProperties(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - public void execute(Context context) throws SQLException { - String defaultQualityGate = context.prepareSelect("select default_quality_gate_uuid from organizations where kee = ?") - .setString(1, "default-organization") - .get(row -> row.getString(1)); - - if (defaultQualityGate == null) { - throw new IllegalStateException("Default organization is missing"); - } else { - context.prepareUpsert("insert into properties (uuid, prop_key, is_empty, text_value, created_at) values (?, ?, ?, ?, ?)") - .setString(1, uuidFactory.create()) - .setString(2, "qualitygate.default") - .setBoolean(3, false) - .setString(4, defaultQualityGate) - .setLong(5, system2.now()) - .execute() - .commit(); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTable.java deleted file mode 100644 index e7c0b1f5465cebb4ebaa1539ea2f8596451646b8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -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 PopulateMonorepoColumnToProjectAlmSettingsTable extends DataChange { - public PopulateMonorepoColumnToProjectAlmSettingsTable(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select uuid from project_alm_settings where monorepo is null"); - massUpdate.update("update project_alm_settings set monorepo = ? where uuid = ?"); - massUpdate.execute((row, update) -> { - update.setBoolean(1, false); - 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/v88/AddLastSonarlintConnectionToUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v88/AddLastSonarlintConnectionToUsers.java deleted file mode 100644 index 773117dfa7d27353cdefea33b3573e7a6a9f9c0d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v88/AddLastSonarlintConnectionToUsers.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v88; - -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.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddLastSonarlintConnectionToUsers extends DdlChange { - public AddLastSonarlintConnectionToUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), "users") - .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder().setColumnName("last_sonarlint_connection").setIsNullable(true).build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v88/DbVersion88.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v88/DbVersion88.java deleted file mode 100644 index 2c19ad0804383cd179b2298912ddb3f3769312d8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v88/DbVersion88.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v88; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion88 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(4300, "Add 'last_sonarlint_connection' to 'users", AddLastSonarlintConnectionToUsers.class) - ; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTable.java deleted file mode 100644 index 835685e6518f65a37811d43cd6f6d7a3d9825eb6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTable.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnWebhookUuidInWebhookDeliveriesTable extends DdlChange { - private static final String TABLE_NAME = "webhook_deliveries"; - private static final String INDEX_NAME = "idx_wbhk_dlvrs_wbhk_uuid"; - - public AddIndexOnWebhookUuidInWebhookDeliveriesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists(INDEX_NAME)) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn("webhook_uuid") - .build()); - } - } - - private boolean indexExists(String index) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, index, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTable.java deleted file mode 100644 index 4730a5adda2ff75d325db8b336ff68963d4fe95a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTable.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndicesToNewCodePeriodTable extends DdlChange { - private static final String TABLE_NAME = "new_code_periods"; - private static final String TYPE_INDEX_NAME = "idx_ncp_type"; - private static final String VALUE_INDEX_NAME = "idx_ncp_value"; - - public AddIndicesToNewCodePeriodTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists(TYPE_INDEX_NAME)) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(TYPE_INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("type") - .setIsNullable(false) - .setLimit(30) - .build()) - .build()); - } - - if (!indexExists(VALUE_INDEX_NAME)) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(VALUE_INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("value") - .setIsNullable(true) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists(String index) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, index, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTable.java deleted file mode 100644 index 69f5bda74febbdd0984796c6a6f03daa716db0dd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTable.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddMainBranchProjectUuidIndexToComponentTable extends DdlChange { - - private static final String TABLE_NAME = "components"; - private static final String INDEX_NAME = "idx_main_branch_prj_uuid"; - - public AddMainBranchProjectUuidIndexToComponentTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("main_branch_project_uuid") - .setIsNullable(false) - .setLimit(50) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExistsIgnoreCase(TABLE_NAME, INDEX_NAME, connection); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/DbVersion89.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/DbVersion89.java deleted file mode 100644 index ee063aa159447b6590c8c8a87c04cc36a548f133..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/DbVersion89.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; -import org.sonar.server.platform.db.migration.version.DbVersion; - -public class DbVersion89 implements DbVersion { - - @Override - public void addSteps(MigrationStepRegistry registry) { - registry - .add(4400, "Add indices on columns 'type' and 'value' to 'new_code_periods' table", AddIndicesToNewCodePeriodTable.class) - .add(4402, "Add Index on column 'main_branch_project_uuid' to 'components' table", AddMainBranchProjectUuidIndexToComponentTable.class) - .add(4403, "Drop Github endpoint on project level setting", DropGithubEndpointOnProjectLevelSetting.class) - .add(4404, "Increase size of 'value' column in 'new_code_periods' table ", IncreaseSizeOfValueColumnInNewCodePeriodsTable.class) - .add(4405, "Add index on column 'webhook_uuid' to 'webhook_deliveries' table", AddIndexOnWebhookUuidInWebhookDeliveriesTable.class); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSetting.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSetting.java deleted file mode 100644 index a0310d7205c2243dcbc9c4e7d46c734eaa43ad68..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSetting.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; - -public class DropGithubEndpointOnProjectLevelSetting extends DataChange { - - public DropGithubEndpointOnProjectLevelSetting(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - context.prepareUpsert("delete from properties where prop_key='sonar.pullrequest.github.endpoint' and component_uuid is not null") - .execute() - .commit(); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTable.java deleted file mode 100644 index 59814056f310a90d4e04563a766612a90d8a23f2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -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 IncreaseSizeOfValueColumnInNewCodePeriodsTable extends DdlChange { - private static final String TABLE_NAME = "new_code_periods"; - - public IncreaseSizeOfValueColumnInNewCodePeriodsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(newVarcharColumnDefBuilder() - .setColumnName("value") - .setLimit(255) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/util/NetworkInterfaceProvider.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/util/NetworkInterfaceProvider.java deleted file mode 100644 index e3df6bd68d119d84341e0a313c3cc2ea6ca586db..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v89/util/NetworkInterfaceProvider.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89.util; - -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -public class NetworkInterfaceProvider { - - public List getNetworkInterfaceAddresses() throws SocketException { - return Collections.list(NetworkInterface.getNetworkInterfaces()) - .stream() - .flatMap(ni -> Collections.list(ni.getInetAddresses()).stream()) - .collect(Collectors.toList()); - } -} 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 16680366bfdcb6ab49670e7ee458cd971624a21a..dded08044a2361c7990cd2431141c1e8a4c4f0c4 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 @@ -25,7 +25,7 @@ import org.sonar.core.platform.ComponentContainer; import static org.assertj.core.api.Assertions.assertThat; public class MigrationConfigurationModuleTest { - private MigrationConfigurationModule underTest = new MigrationConfigurationModule(); + private final MigrationConfigurationModule underTest = new MigrationConfigurationModule(); @Test public void verify_component_count() { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/CreateNewCodePeriodTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/CreateNewCodePeriodTableTest.java deleted file mode 100644 index f26425e6a7a6dccc0d7ddfc68ad56615d589f099..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/CreateNewCodePeriodTableTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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.BIGINT; -import static java.sql.Types.VARCHAR; - -public class CreateNewCodePeriodTableTest { - private static final String TABLE_NAME = "new_code_periods"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateNewCodePeriodTable underTest = new CreateNewCodePeriodTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_new_code_periods", "uuid"); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_new_code_periods", "project_uuid", "branch_uuid"); - - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "project_uuid", VARCHAR, 40, true); - dbTester.assertColumnDefinition(TABLE_NAME, "branch_uuid", VARCHAR, 40, true); - dbTester.assertColumnDefinition(TABLE_NAME, "type", VARCHAR, 30, false); - dbTester.assertColumnDefinition(TABLE_NAME, "value", VARCHAR, 40, true); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", BIGINT, 20, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, 20, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/CreateProjectQualityGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/CreateProjectQualityGatesTableTest.java deleted file mode 100644 index 870c7dc8fb9293c61d081d36f046e47ad00602aa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/CreateProjectQualityGatesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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 CreateProjectQualityGatesTableTest { - private static final String TABLE_NAME = "project_qgates"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateProjectQualityGatesTable underTest = new CreateProjectQualityGatesTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_project_qgates", "project_uuid"); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_project_qgates", "project_uuid", "quality_gate_uuid"); - - dbTester.assertColumnDefinition(TABLE_NAME, "project_uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "quality_gate_uuid", VARCHAR, 40, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/DbVersion80Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/DbVersion80Test.java deleted file mode 100644 index ac624c64d2af7e684df698d6016564e10a39998c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/DbVersion80Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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 DbVersion80Test { - private DbVersion underTest = new DbVersion80(); - - @Test - public void migrationNumber_starts_at_3000() { - verifyMinimumMigrationNumber(underTest, 3000); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 10); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUniqueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUniqueTest.java deleted file mode 100644 index 498982fd51c42ad7932d6ee503ff54bb750c4738..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUniqueTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class MakeDeprecatedRuleKeysRuleIdIndexNonUniqueTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeDeprecatedRuleKeysRuleIdIndexNonUniqueTest.class, "deprecated_rule_keys.sql"); - - private MakeDeprecatedRuleKeysRuleIdIndexNonUnique underTest = new MakeDeprecatedRuleKeysRuleIdIndexNonUnique(db.database()); - - @Test - public void execute_makes_index_non_unique() throws SQLException { - db.assertUniqueIndex("deprecated_rule_keys", "rule_id_deprecated_rule_keys", "rule_id"); - - underTest.execute(); - - db.assertIndex("deprecated_rule_keys", "rule_id_deprecated_rule_keys", "rule_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullableTest.java deleted file mode 100644 index fed7d9dc145314b4f91576dfcd858a1b5fdf09c9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullableTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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 MakeOrganizationsGuardedNullableTest { - - private static final String TABLE_NAME = "organizations"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MakeOrganizationsGuardedNullable.class, "organizations.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationsGuardedNullable underTest = new MakeOrganizationsGuardedNullable(dbTester.database()); - - @Test - public void column_is_made_nullable() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition(TABLE_NAME, "guarded", BOOLEAN, null, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java deleted file mode 100644 index d8d7dd2521ad8668f1531fa5f80b5af0ac67d3b5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import java.time.LocalDate; -import java.time.ZoneId; -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.api.resources.Scopes; -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 PopulateNewCodePeriodTableTest { - private static final String NEW_CODE_PERIODS_TABLE_NAME = "new_code_periods"; - private static final String PROJECT_BRANCHES_TABLE_NAME = "project_branches"; - private static final int NUMBER_OF_PROJECT_BRANCHES_TO_INSERT = 10; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateNewCodePeriodTableTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateNewCodePeriodTable underTest = new PopulateNewCodePeriodTable(dbTester.database(), UuidFactoryImpl.INSTANCE, System2.INSTANCE); - - @Test - public void copy_manual_baseline_analysis_to_new_code_period_table() throws SQLException { - for (long i = 0; i < NUMBER_OF_PROJECT_BRANCHES_TO_INSERT; i++) { - insertMainBranch(i, true); - } - - underTest.execute(); - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(10); - - for (int i = 0; i < NUMBER_OF_PROJECT_BRANCHES_TO_INSERT; i++) { - assertNewCodePeriod(i, "pb-uuid-" + i, "pb-uuid-" + i, "SPECIFIC_ANALYSIS", "mba-uuid" + i); - } - - //should not fail if executed twice - underTest.execute(); - } - - @Test - public void do_nothing_if_cant_find_matching_analysis() throws SQLException { - insertMainBranch(0, false); - insertMainBranch(1, false); - - insertProperty(0, "2.0"); - insertProperty(0, "2019-04-05"); - - underTest.execute(); - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isZero(); - } - - @Test - public void do_nothing_if_cant_migrate_global_property() throws SQLException { - insertProperty(null, "2.0"); - - underTest.execute(); - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isZero(); - } - - @Test - public void migrate_project_property_set_to_previous_version() throws SQLException { - insertMainBranch(0, true); - insertMainBranch(1, false); - // no property defined for it - insertMainBranch(2, false); - - // doesn't get copied since there is a manual baseline taking precedence - insertProperty(0, "20"); - insertProperty(1, "previous_version"); - // doesn't exist - insertProperty(3, "previous_version"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(2); - assertNewCodePeriod(0, "pb-uuid-" + 0, "pb-uuid-" + 0, "SPECIFIC_ANALYSIS", "mba-uuid" + 0); - assertNewCodePeriod(1, "pb-uuid-" + 1, null, "PREVIOUS_VERSION", null); - } - - @Test - public void migrate_project_property_set_to_number_of_days() throws SQLException { - insertMainBranch(0, false); - insertBranch(0, 1, false); - insertProperty(1, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(1); - assertNewCodePeriod(0, "pb-uuid-" + 0, "pb-uuid-" + 1, "NUMBER_OF_DAYS", "20"); - } - - @Test - public void migrate_branch_property_set_to_number_of_days() throws SQLException { - insertMainBranch(0, false); - insertProperty(0, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(1); - assertNewCodePeriod(0, "pb-uuid-" + 0, null, "NUMBER_OF_DAYS", "20"); - } - - @Test - public void migrate_global_property_set_to_number_of_days() throws SQLException { - insertProperty(null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(1); - assertNewCodePeriod(0, null, null, "NUMBER_OF_DAYS", "20"); - } - - - @Test - public void migrate_project_property_set_to_version() throws SQLException { - insertMainBranch(0, false); - insertProperty(0, "2.0"); - - insertVersionEvent(0, 10L, "1.0"); - insertVersionEvent(0, 20L, "2.0"); - insertVersionEvent(0, 30L, "3.0"); - insertVersionEvent(0, 40L, "2.0"); - insertVersionEvent(0, 50L, "3.0"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(1); - // we don't support specific analysis for projects, so we set it for the branch - assertNewCodePeriod(0, "pb-uuid-" + 0, "pb-uuid-" + 0, "SPECIFIC_ANALYSIS", "analysis-40"); - } - - @Test - public void migrate_project_property_set_to_date() throws SQLException { - insertMainBranch(0, false); - insertProperty(0, "2019-04-05"); - - long reference = LocalDate.parse("2019-04-05").atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); - insertSnapshot(100, 0, reference - 100); - insertSnapshot(200, 0, reference + 100); - insertSnapshot(300, 0, reference + 200); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(1); - // we don't support specific analysis for projects, so we set it for the branch - assertNewCodePeriod(0, "pb-uuid-" + 0, "pb-uuid-" + 0, "SPECIFIC_ANALYSIS", "snapshot-200"); - } - - private void assertNewCodePeriod(int row, @Nullable String projectUuid, @Nullable String branchUuid, String type, @Nullable String value) { - Optional> r = dbTester.select("SELECT PROJECT_UUID, BRANCH_UUID, TYPE, VALUE FROM " + NEW_CODE_PERIODS_TABLE_NAME) - .stream() - .skip(row) - .findFirst(); - - assertThat(r).isPresent(); - - assertThat(r.get().get("PROJECT_UUID")).isEqualTo(projectUuid); - assertThat(r.get().get("BRANCH_UUID")).isEqualTo(branchUuid); - assertThat(r.get().get("TYPE")).isEqualTo(type); - assertThat(r.get().get("VALUE")).isEqualTo(value); - } - - private void insertBranch(long mainBranchUid, long uid, boolean withBaseLine) { - String manualBaseline = withBaseLine ? "mba-uuid" + uid : null; - - String mainBranchProjectUuid = mainBranchUid == uid ? null : "pb-uuid-" + mainBranchUid; - insertComponent(uid, "pb-uuid-" + uid, mainBranchProjectUuid); - - dbTester.executeInsert( - PROJECT_BRANCHES_TABLE_NAME, - "UUID", "pb-uuid-" + uid, - "PROJECT_UUID", "pb-uuid-" + mainBranchUid, - "KEE", "pb-key-" + uid, - "KEY_TYPE", "TSR", - "BRANCH_TYPE", "BRANCH", - "MERGE_BRANCH_UUID", "mb-uuid-" + mainBranchUid, - "MANUAL_BASELINE_ANALYSIS_UUID", manualBaseline, - "CREATED_AT", System2.INSTANCE.now(), - "UPDATED_AT", System2.INSTANCE.now() - ); - } - - private void insertSnapshot(int uid, int branchUid, long creationDate) { - dbTester.executeInsert( - "SNAPSHOTS", - "UUID", "snapshot-" + uid, - "COMPONENT_UUID", "pb-uuid-" + branchUid, - "STATUS", "P", - "CREATED_AT", creationDate - ); - } - - private void insertProperty(@Nullable Integer uid, String value) { - dbTester.executeInsert( - "PROPERTIES", - "PROP_KEY", "sonar.leak.period", - "RESOURCE_ID", uid, - "USER_ID", null, - "IS_EMPTY", false, - "TEXT_VALUE", value, - "CLOB_VALUE", null, - "CREATED_AT", System2.INSTANCE.now() - ); - } - - private void insertComponent(long id, String uuid, @Nullable String mainBranchProjectUuid) { - dbTester.executeInsert( - "projects", - "ID", valueOf(id), - "UUID", uuid, - "ROOT_UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", mainBranchProjectUuid, - "SCOPE", Scopes.PROJECT, - "QUALIFIER", "TRK", - "NAME", "name-" + id); - } - - private void insertVersionEvent(long id, long createdAt, String version) { - dbTester.executeInsert( - "events", - "ANALYSIS_UUID", "analysis-" + createdAt, - "NAME", version, - "COMPONENT_UUID", "pb-uuid-" + id, - "CATEGORY", "Version", - "CREATED_AT", createdAt); - } - - private void insertMainBranch(long uid, boolean withBaseLine) { - insertBranch(uid, uid, withBaseLine); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateProjectQualityGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateProjectQualityGatesTableTest.java deleted file mode 100644 index 85f77a1d5b5cbc0c6b8439a119a0a3d23e352366..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateProjectQualityGatesTableTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import java.time.Instant; -import java.util.List; -import java.util.Random; -import java.util.stream.Collectors; -import org.junit.Assert; -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 PopulateProjectQualityGatesTableTest { - private static final String PROJECTS_TABLE_NAME = "projects"; - private static final String QUALITY_GATES_TABLE_NAME = "quality_gates"; - private static final String PROPERTIES_TABLE_NAME = "properties"; - private static final int NUMBER_OF_PROJECTS_TO_INSERT = 5; - - private final Random random = new Random(); - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateProjectQualityGatesTableTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateProjectQualityGatesTable underTest = new PopulateProjectQualityGatesTable(dbTester.database()); - - @Test - public void copy_quality_gates_properties_to_project_qgate_table() throws SQLException { - long firstQualityGateId = insertQualityGate("qg1"); - long secondQualityGateId = insertQualityGate("qg2"); - - for (long i = 1; i <= NUMBER_OF_PROJECTS_TO_INSERT; i++) { - long projectId = insertComponent("p" + i); - long qualityGateId = random.nextBoolean() ? firstQualityGateId : secondQualityGateId; - insertQualityGateProperty(projectId, qualityGateId); - } - - underTest.execute(); - - List qualityGates = getQualityGates(); - Assert.assertEquals(NUMBER_OF_PROJECTS_TO_INSERT, qualityGates.size()); - - //must not delete properties - int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - Assert.assertEquals(5, propertiesCount); - - //should not fail if executed twice - underTest.execute(); - } - - private long insertQualityGate(String qualityGateUuid) { - dbTester.executeInsert( - QUALITY_GATES_TABLE_NAME, - "UUID", qualityGateUuid, - "NAME", "name_" + qualityGateUuid, - "IS_BUILT_IN", valueOf(true) - ); - return (long) dbTester.selectFirst("select id as \"ID\" from quality_gates where uuid='" + qualityGateUuid + "'").get("ID"); - } - - private long insertComponent(String uuid) { - dbTester.executeInsert( - PROJECTS_TABLE_NAME, - "ORGANIZATION_UUID", "org_" + uuid, - "SCOPE", "PRJ", - "QUALIFIER", "TRK", - "UUID", uuid, - "UUID_PATH", "path_" + uuid, - "ROOT_UUID", "root_" + uuid, - "PROJECT_UUID", uuid, - "PRIVATE", valueOf(false)); - return (long) dbTester.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID"); - } - - private void insertQualityGateProperty(Long projectId, Long qualityGateId) { - dbTester.executeInsert(PROPERTIES_TABLE_NAME, - "prop_key", "sonar.qualitygate", - "resource_id", projectId, - "is_empty", false, - "text_value", Long.toString(qualityGateId), - "created_at", Instant.now().toEpochMilli()); - } - - private List getQualityGates() { - return dbTester.select("select pqg.project_uuid, pqg.quality_gate_uuid from project_qgates pqg " + - "join projects p on pqg.project_uuid = p.uuid " + - "join quality_gates qg on pqg.quality_gate_uuid = qg.uuid") - .stream() - .map(row -> { - String projectUuid = String.valueOf(row.get("PROJECT_UUID")); - String qualityGateUuid = String.valueOf(row.get("QUALITY_GATE_UUID")); - return new ProjectQualityGate(projectUuid, qualityGateUuid); - }) - .collect(Collectors.toList()); - } - - private static class ProjectQualityGate { - final String projectUuid; - final String qualityGateUuid; - - private ProjectQualityGate(String projectUuid, String qualityGateUuid) { - this.projectUuid = projectUuid; - this.qualityGateUuid = qualityGateUuid; - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTableTest.java deleted file mode 100644 index 35fcbc2cc64bc5452e01a1e8e77d6244fd4bf799..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTableTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import java.time.Instant; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - - -public class RemoveDefaultQualityGateFromPropertiesTableTest { - private static final String PROPERTIES_TABLE_NAME = "properties"; - private static final int TOTAL_NUMBER_OF_PROPERTIES = 10; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveDefaultQualityGateFromPropertiesTableTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private final RemoveDefaultQualityGateFromPropertiesTable underTest = new RemoveDefaultQualityGateFromPropertiesTable(dbTester.database()); - - @Test - public void remove_default_quality_gate_property() throws SQLException { - for (long i = 1; i <= TOTAL_NUMBER_OF_PROPERTIES; i++) { - insertQualityGateProperty(i, String.valueOf(i + 100)); - } - - int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - Assert.assertEquals(TOTAL_NUMBER_OF_PROPERTIES, propertiesCount); - - underTest.execute(); - - //should delete properties - propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - Assert.assertEquals(0, propertiesCount); - - //should not fail if executed twice - underTest.execute(); - } - - private void insertQualityGateProperty(Long projectId, String qualityGateUuid) { - dbTester.executeInsert(PROPERTIES_TABLE_NAME, - "prop_key", "sonar.qualitygate", - "resource_id", projectId, - "is_empty", false, - "text_value", qualityGateUuid, - "created_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveGitHubLoginGenerationStrategyPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveGitHubLoginGenerationStrategyPropertyTest.java deleted file mode 100644 index d26cedce0c4682441956ebb14685c05c78c13326..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveGitHubLoginGenerationStrategyPropertyTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import java.time.Instant; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class RemoveGitHubLoginGenerationStrategyPropertyTest { - private static final String PROPERTIES_TABLE_NAME = "properties"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveGitHubLoginGenerationStrategyPropertyTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RemoveGitHubLoginGenerationStrategyProperty underTest = new RemoveGitHubLoginGenerationStrategyProperty(dbTester.database()); - - @Test - public void remove_github_login_strategy_property() throws SQLException { - insertGitHubLoginStrategy(); - - int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - Assert.assertEquals(1, propertiesCount); - - underTest.execute(); - - //should delete properties - propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - Assert.assertEquals(0, propertiesCount); - - //should not fail if executed twice - underTest.execute(); - } - - private void insertGitHubLoginStrategy() { - dbTester.executeInsert(PROPERTIES_TABLE_NAME, - "prop_key", "sonar.auth.github.loginStrategy", - "is_empty", false, - "text_value", "Unique", - "created_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveLeakPeriodPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveLeakPeriodPropertiesTest.java deleted file mode 100644 index cbda87658dd143aac588ac12f8ba345f7f23d63c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RemoveLeakPeriodPropertiesTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -import java.sql.SQLException; -import java.time.Instant; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class RemoveLeakPeriodPropertiesTest { - private static final String PROPERTIES_TABLE_NAME = "properties"; - private static final int TOTAL_NUMBER_OF_PROPERTIES = 10; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveLeakPeriodPropertiesTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RemoveLeakPeriodProperties underTest = new RemoveLeakPeriodProperties(dbTester.database()); - - @Test - public void remove_default_quality_gate_property() throws SQLException { - for (long i = 1; i <= TOTAL_NUMBER_OF_PROPERTIES; i++) { - insertQualityGateProperty(i, String.valueOf(i + 100)); - } - - int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - Assert.assertEquals(TOTAL_NUMBER_OF_PROPERTIES, propertiesCount); - - underTest.execute(); - - //should delete properties - propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - Assert.assertEquals(0, propertiesCount); - - //should not fail if executed twice - underTest.execute(); - } - - private void insertQualityGateProperty(Long projectId, String qualityGateUuid) { - dbTester.executeInsert(PROPERTIES_TABLE_NAME, - "prop_key", "sonar.leak.period", - "resource_id", projectId, - "is_empty", false, - "text_value", qualityGateUuid, - "created_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RenameAnalysisPropertiesSnapshotUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RenameAnalysisPropertiesSnapshotUuidTest.java deleted file mode 100644 index ccc0eff8ef5d509647e069646d65456febb1d8fd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/RenameAnalysisPropertiesSnapshotUuidTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v80; - -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 RenameAnalysisPropertiesSnapshotUuidTest { - - private static final String TABLE_NAME = "analysis_properties"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RenameAnalysisPropertiesSnapshotUuidTest.class, "analysis_properties.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameAnalysisPropertiesSnapshotUuid underTest = new RenameAnalysisPropertiesSnapshotUuid(dbTester.database()); - - @Test - public void execute_renames_column_snapshot_uuid_and_recreate_index_snapshot_uuid_with_a_new_name() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition(TABLE_NAME, "analysis_uuid", Types.VARCHAR, 40, false); - dbTester.assertIndex(TABLE_NAME, "analysis_properties_analysis", "analysis_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/v81/AddExcludeBranchFromPurgeColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest.java deleted file mode 100644 index c65849013f57d63b6d6101c7616816ccd8bc7894..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -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.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddExcludeBranchFromPurgeColumnTest { - - private static final String TABLE = "project_branches"; - - private static final String PROJECT_1_UUID = "1a724f54-c2a4-4d36-b59c-61026f178613"; - private static final String PROJECT_2_UUID = "cc69ccb8-434a-489b-abd6-6a80371f64ff"; - - private static final String MAIN_BRANCH_1 = "8a9789c8-7aee-4aa6-9cb7-407137935ac3"; - private static final String LONG_BRANCH_1 = "69fdfc19-491c-4ed9-bcac-ef04e0f6cdc6"; - private static final String SHORT_BRANCH_1 = "f7a6d247-1790-40f8-8591-a0cc39d05ecb"; - private static final String PR_1 = "d65466bf-271c-4f9f-ac7a-72add44848c0"; - - private static final String MAIN_BRANCH_2 = "cdadf128-7bdb-4589-982d-62445d46ae1b"; - private static final String LONG_BRANCH_2 = "60bf6fa8-3ecc-4ba6-ad8d-991ea7c7f9cb"; - private static final String SHORT_BRANCH_2 = "ce5632ed-462e-4384-98b6-1773a7bbfe53"; - private static final String PR_2 = "5897f7d0-d34f-4558-b9c5-a7eb7a5c4b69"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddExcludeBranchFromPurgeColumnTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddExcludeBranchFromPurgeColumn underTest = new AddExcludeBranchFromPurgeColumn(dbTester.database()); - - @Before - public void setup() { - insertBranch(MAIN_BRANCH_1, PROJECT_1_UUID, "master", "BRANCH", "LONG"); - insertBranch(LONG_BRANCH_1, PROJECT_1_UUID, "release-1", "BRANCH", "LONG"); - insertBranch(SHORT_BRANCH_1, PROJECT_1_UUID, "feature/foo", "BRANCH", "SHORT"); - insertBranch(PR_1, PROJECT_1_UUID, "feature/feature-1", "PULL_REQUEST", "PULL_REQUEST"); - - insertBranch(MAIN_BRANCH_2, PROJECT_2_UUID, "trunk", "BRANCH", "LONG"); - insertBranch(LONG_BRANCH_2, PROJECT_2_UUID, "branch-1", "BRANCH", "LONG"); - insertBranch(SHORT_BRANCH_2, PROJECT_2_UUID, "feature/bar", "BRANCH", "SHORT"); - insertBranch(PR_2, PROJECT_2_UUID, "feature/feature-2", "PULL_REQUEST", "PULL_REQUEST"); - } - - @Test - public void execute_migration() throws SQLException { - underTest.execute(); - - verifyMigrationResult(); - } - - private void verifyMigrationResult() { - assertThat(dbTester.countSql("select count(*) from " + TABLE + " where exclude_from_purge = true")).isZero(); - assertThat(dbTester.countSql("select count(*) from " + TABLE + " where exclude_from_purge = false")).isEqualTo(8); - } - - private void insertBranch(String uuid, String projectUuid, String key, String keyType, String branchType) { - dbTester.executeInsert( - TABLE, - "UUID", uuid, - "PROJECT_UUID", projectUuid, - "KEE", key, - "BRANCH_TYPE", branchType, - "KEY_TYPE", keyType, - "MERGE_BRANCH_UUID", null, - "CREATED_AT", System2.INSTANCE.now(), - "UPDATED_AT", System2.INSTANCE.now()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/CreateAlmSettingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/CreateAlmSettingsTableTest.java deleted file mode 100644 index b3b35119bc629b528e1315341ab5388986f5fd27..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/CreateAlmSettingsTableTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.BIGINT; -import static java.sql.Types.VARCHAR; - -public class CreateAlmSettingsTableTest { - - private static final String TABLE_NAME = "alm_settings"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateAlmSettingsTable underTest = new CreateAlmSettingsTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_alm_settings", "uuid"); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_alm_settings", "kee"); - - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "kee", VARCHAR, 200, false); - dbTester.assertColumnDefinition(TABLE_NAME, "alm_id", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "url", VARCHAR, 2000, true); - dbTester.assertColumnDefinition(TABLE_NAME, "app_id", VARCHAR, 80, true); - dbTester.assertColumnDefinition(TABLE_NAME, "private_key", VARCHAR, 2000, true); - dbTester.assertColumnDefinition(TABLE_NAME, "pat", VARCHAR, 2000, true); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", BIGINT, 20, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, 20, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/CreateProjectAlmSettingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/CreateProjectAlmSettingsTableTest.java deleted file mode 100644 index 9e0558772a7794d8adfe7046db9ee65558c26478..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/CreateProjectAlmSettingsTableTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.BIGINT; -import static java.sql.Types.VARCHAR; - -public class CreateProjectAlmSettingsTableTest { - private static final String TABLE_NAME = "project_alm_settings"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateProjectAlmSettingsTable underTest = new CreateProjectAlmSettingsTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_project_alm_settings", "uuid"); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_project_alm_settings", "project_uuid"); - dbTester.assertIndex(TABLE_NAME, "project_alm_settings_alm", "alm_setting_uuid"); - - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "alm_setting_uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "project_uuid", VARCHAR, 50, false); - dbTester.assertColumnDefinition(TABLE_NAME, "alm_repo", VARCHAR, 256, true); - dbTester.assertColumnDefinition(TABLE_NAME, "alm_slug", VARCHAR, 256, true); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", BIGINT, 20, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, 20, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java deleted file mode 100644 index 39e5c9ce3ca251819f34bc6f691bbdd512891732..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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 DbVersion81Test { - - private DbVersion underTest = new DbVersion81(); - - @Test - public void migrationNumber_starts_at_3000() { - verifyMinimumMigrationNumber(underTest, 3100); - } - - @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/v81/DeleteSonarPullRequestProviderPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DeleteSonarPullRequestProviderPropertyTest.java deleted file mode 100644 index 85b4e3b9f0c881ab46b263998e6f785ebc3dc2d3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DeleteSonarPullRequestProviderPropertyTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.util.stream.Collectors.toSet; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteSonarPullRequestProviderPropertyTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteSonarPullRequestProviderPropertyTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DataChange underTest = new DeleteSonarPullRequestProviderProperty(db.database()); - - @Test - public void delete_provider_property() throws SQLException { - insertProperty("sonar.pullrequest.provider", null); - insertProperty("sonar.pullrequest.provider", 1); - insertProperty("sonar.pullrequest.provider", 2); - - underTest.execute(); - - assertNoProperties(); - } - - @Test - public void do_not_delete_other_property() throws SQLException { - insertProperty("sonar.pullrequest.provider", null); - insertProperty("sonar.other.property", null); - - underTest.execute(); - - assertPropertyKeys("sonar.other.property"); - } - - @Test - public void do_nothing_when_no_property() throws SQLException { - underTest.execute(); - - assertNoProperties(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProperty("sonar.pullrequest.provider", null); - - underTest.execute(); - underTest.execute(); - - assertNoProperties(); - } - - private void assertPropertyKeys(String... expectedKeys) { - assertThat(db.select("SELECT prop_key FROM properties") - .stream() - .map(map -> map.get("PROP_KEY")) - .collect(toSet())) - .containsExactlyInAnyOrder(expectedKeys); - } - - private void assertNoProperties() { - assertPropertyKeys(); - } - - private void insertProperty(String key, @Nullable Integer projectId) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", key, - "RESOURCE_ID", projectId, - "USER_ID", null, - "IS_EMPTY", false, - "TEXT_VALUE", "AnyValue", - "CLOB_VALUE", null, - "CREATED_AT", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateAzureAlmSettingsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateAzureAlmSettingsTest.java deleted file mode 100644 index 7286d8b8c8ed8bd075e2a6fc474ab0fcb7c89afa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateAzureAlmSettingsTest.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.util.stream.Collectors.toList; -import static java.util.stream.Collectors.toSet; -import static org.apache.commons.lang.math.RandomUtils.nextInt; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class MigrateAzureAlmSettingsTest { - - 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); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateAzureAlmSettingsTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DataChange underTest = new MigrateAzureAlmSettings(db.database(), uuidFactory, system2); - - @Test - public void migrate_settings_when_project_provider_is_set_to_azure_and_global_provider_is_set_to_something_else() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId1); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId2); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "12345", NOW, NOW)); - String almSettingUuid = selectAlmSettingUuid("Azure DevOps"); - assertProjectAlmSettings( - tuple("PROJECT_1", almSettingUuid, NOW, NOW), - tuple("PROJECT_2", almSettingUuid, NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "Bitbucket Server", null), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId1), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId2)); - } - - @Test - public void migrate_settings_when_token_is_global_and_provider_is_per_project() throws SQLException { - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "12345", NOW, NOW)); - String almSettingUuid = selectAlmSettingUuid("Azure DevOps"); - assertProjectAlmSettings( - tuple("PROJECT_1", almSettingUuid, NOW, NOW), - tuple("PROJECT_2", almSettingUuid, NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId1), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId2)); - } - - @Test - public void migrate_settings_when_provider_is_global() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId2); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "12345", NOW, NOW)); - String almSettingUuid = selectAlmSettingUuid("Azure DevOps"); - assertProjectAlmSettings( - tuple("PROJECT_1", almSettingUuid, NOW, NOW), - tuple("PROJECT_2", almSettingUuid, NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId2)); - } - - @Test - public void create_one_alm_setting_for_each_token_found() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - insertProperty("sonar.pullrequest.vsts.token.secured", "100", null); - long projectId1 = insertProject("PROJECT_1"); - // No token defined on project 1 -> use global token - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.vsts.token.secured", "200", projectId2); - long projectId3 = insertProject("PROJECT_3"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId3); - insertProperty("sonar.pullrequest.vsts.token.secured", "300", projectId3); - - underTest.execute(); - - assertAlmSettings( - tuple("azure_devops", "Azure DevOps", "100", NOW, NOW), - tuple("azure_devops", "Azure DevOps 1", "200", NOW, NOW), - tuple("azure_devops", "Azure DevOps 2", "300", NOW, NOW)); - assertProjectAlmSettings( - tuple("PROJECT_1", selectAlmSettingUuid("Azure DevOps"), NOW, NOW), - tuple("PROJECT_2", selectAlmSettingUuid("Azure DevOps 1"), NOW, NOW), - tuple("PROJECT_3", selectAlmSettingUuid("Azure DevOps 2"), NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId1), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId3)); - } - - @Test - public void ignore_when_project_is_missing_token() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - long projectId1 = insertProject("PROJECT_1"); - // No token in project 1 - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId2); - insertProperty("sonar.pullrequest.vsts.token.secured", "200", projectId2); - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "200", NOW, NOW)); - assertProjectAlmSettings( - tuple("PROJECT_2", selectAlmSettingUuid("Azure DevOps"), NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId1), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId2)); - } - - @Test - public void use_existing_alm_setting() throws SQLException { - db.executeInsert("alm_settings", - "uuid", "ABCD", - "alm_id", "azure_devops", - "kee", "Azure DevOps", - "pat", "12345", - "created_at", PAST, - "updated_at", PAST); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId1); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", projectId1); - - underTest.execute(); - - assertProjectAlmSettings(tuple("PROJECT_1", "ABCD", NOW, NOW)); - assertProperties(tuple("sonar.pullrequest.provider", "Azure DevOps", projectId1)); - } - - @Test - public void delete_azure_settings_when_project_provider_is_not_set_to_azure() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - // Project provider is set to something else - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", projectId1); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", projectId1); - - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "12345", NOW, NOW)); - assertNoProjectAlmSettings(); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "Bitbucket Server", projectId1)); - } - - @Test - public void ignore_none_azure_project_settings() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Bitbucket", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Bitbucket", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "12345", NOW, NOW)); - assertNoProjectAlmSettings(); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "Bitbucket", projectId1), - tuple("sonar.pullrequest.provider", "Bitbucket", projectId2)); - } - - @Test - public void ignore_azure_setting_when_project_provider_is_not_azure() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Bitbucket", projectId1); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", projectId1); - - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "12345", NOW, NOW)); - assertNoProjectAlmSettings(); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "Bitbucket", projectId1)); - } - - @Test - public void do_not_create_project_settings_when_only_global_provider_is_set() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", null); - insertProject("PROJECT_1"); - insertProject("PROJECT_2"); - - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "12345", NOW, NOW)); - assertNoProjectAlmSettings(); - assertProperties(tuple("sonar.pullrequest.provider", "Azure DevOps", null)); - } - - @Test - public void do_not_create_project_settings_when_missing_some_properties() throws SQLException { - long projectId1 = insertProject("PROJECT_1"); - // No provider - insertProperty("sonar.pullrequest.vsts.token.secured", "12345", projectId1); - - underTest.execute(); - - assertAlmSettings(tuple("azure_devops", "Azure DevOps", "12345", NOW, NOW)); - assertNoProjectAlmSettings(); - assertNoProperties(); - } - - @Test - public void do_nothing_when_no_alm_properties() throws SQLException { - insertProperty("sonar.other.property", "Something", null); - - underTest.execute(); - - assertNoAlmSettings(); - assertNoProjectAlmSettings(); - assertProperties(tuple("sonar.other.property", "Something", null)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId1); - insertProperty("sonar.pullrequest.vsts.token.secured", "100", projectId1); - underTest.execute(); - - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Azure DevOps", projectId2); - insertProperty("sonar.pullrequest.vsts.token.secured", "200", projectId2); - underTest.execute(); - - assertAlmSettings( - tuple("azure_devops", "Azure DevOps", "100", NOW, NOW), - tuple("azure_devops", "Azure DevOps 2", "200", NOW, NOW)); - assertProjectAlmSettings( - tuple("PROJECT_1", selectAlmSettingUuid("Azure DevOps"), NOW, NOW), - tuple("PROJECT_2", selectAlmSettingUuid("Azure DevOps 2"), NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId1), - tuple("sonar.pullrequest.provider", "Azure DevOps", projectId2)); - } - - private void assertAlmSettings(Tuple... expectedTuples) { - assertThat(db.select("SELECT alm_id, kee, pat, created_at, updated_at FROM alm_settings") - .stream() - .map(map -> new Tuple(map.get("ALM_ID"), map.get("KEE"), map.get("PAT"), map.get("CREATED_AT"), - map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoAlmSettings() { - assertAlmSettings(); - } - - private void assertProjectAlmSettings(Tuple... expectedTuples) { - assertThat(db.select("SELECT project_uuid, alm_setting_uuid, created_at, updated_at FROM project_alm_settings") - .stream() - .map(map -> new Tuple(map.get("PROJECT_UUID"), map.get("ALM_SETTING_UUID"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoProjectAlmSettings() { - assertProjectAlmSettings(); - } - - private void assertProperties(Tuple... expectedTuples) { - assertThat(db.select("SELECT prop_key, text_value, resource_id FROM properties") - .stream() - .map(map -> new Tuple(map.get("PROP_KEY"), map.get("TEXT_VALUE"), map.get("RESOURCE_ID"))) - .collect(toSet())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoProperties() { - assertProperties(); - } - - private String selectAlmSettingUuid(String almSettingKey) { - return (String) db.selectFirst("select uuid from alm_settings where kee='" + almSettingKey + "'").get("UUID"); - } - - private void insertProperty(String key, String value, @Nullable Long projectId) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", key, - "RESOURCE_ID", projectId, - "USER_ID", null, - "IS_EMPTY", false, - "TEXT_VALUE", value, - "CLOB_VALUE", null, - "CREATED_AT", System2.INSTANCE.now()); - } - - private long insertProject(String uuid) { - int id = nextInt(); - db.executeInsert("PROJECTS", - "ID", id, - "ORGANIZATION_UUID", "default", - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", null, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", "PRJ", - "QUALIFIER", "TRK"); - return id; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettingsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettingsTest.java deleted file mode 100644 index 5e3dedbfe7ba1348f294d7a306e9bda985ac33c5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettingsTest.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.util.stream.Collectors.toList; -import static java.util.stream.Collectors.toSet; -import static org.apache.commons.lang.math.RandomUtils.nextInt; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class MigrateBitbucketAlmSettingsTest { - - 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); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateBitbucketAlmSettingsTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DataChange underTest = new MigrateBitbucketAlmSettings(db.database(), uuidFactory, system2); - - @Test - public void migrate_settings_when_global_provider_is_set_to_bitbucket() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", null); - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - insertProperty("sonar.pullrequest.bitbucketserver.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository1", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug1", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository2", projectId2); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug2", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("bitbucket", "Bitbucket Server", "https://enterprise.com", "12345", NOW, NOW)); - String almSettingUuid = selectAlmSettingUuid("Bitbucket Server"); - assertProjectAlmSettings( - tuple("PROJECT_1", almSettingUuid, "Repository1", "Slug1", NOW, NOW), - tuple("PROJECT_2", almSettingUuid, "Repository2", "Slug2", NOW, NOW)); - assertProperties(tuple("sonar.pullrequest.provider", "Bitbucket Server", null)); - } - - @Test - public void migrate_settings_when_project_provider_is_set_to_bitbucket_and_global_provider_is_set_to_something_else() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - insertProperty("sonar.pullrequest.bitbucketserver.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository1", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug1", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", projectId2); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository2", projectId2); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug2", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("bitbucket", "Bitbucket Server", "https://enterprise.com", "12345", NOW, NOW)); - String almSettingUuid = selectAlmSettingUuid("Bitbucket Server"); - assertProjectAlmSettings( - tuple("PROJECT_1", almSettingUuid, "Repository1", "Slug1", NOW, NOW), - tuple("PROJECT_2", almSettingUuid, "Repository2", "Slug2", NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "Bitbucket Server", projectId1), - tuple("sonar.pullrequest.provider", "Bitbucket Server", projectId2)); - } - - @Test - public void delete_bitbucket_settings_when_project_provider_is_not_set_to_bitbucket() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", null); - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - insertProperty("sonar.pullrequest.bitbucketserver.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - // Project provider is set to something else - insertProperty("sonar.pullrequest.provider", "Azure", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository1", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug1", projectId1); - - underTest.execute(); - - assertNoProjectAlmSettings(); - assertProperties( - tuple("sonar.pullrequest.provider", "Bitbucket Server", null), - tuple("sonar.pullrequest.provider", "Azure", projectId1)); - } - - @Test - public void ignore_none_bitbucket_project_settings() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", null); - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - insertProperty("sonar.pullrequest.bitbucketserver.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Azure", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Azure", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("bitbucket", "Bitbucket Server", "https://enterprise.com", "12345", NOW, NOW)); - assertNoProjectAlmSettings(); - assertProperties( - tuple("sonar.pullrequest.provider", "Bitbucket Server", null), - tuple("sonar.pullrequest.provider", "Azure", projectId1), - tuple("sonar.pullrequest.provider", "Azure", projectId2)); - } - - @Test - public void use_existing_alm_setting() throws SQLException { - db.executeInsert("alm_settings", - "uuid", "ABCD", - "alm_id", "bitbucket", - "kee", "Bitbucket Server", - "url", "https://enterprise.com", - "pat", "12345", - "created_at", PAST, - "updated_at", PAST); - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", null); - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - insertProperty("sonar.pullrequest.bitbucketserver.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository1", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug1", projectId1); - - underTest.execute(); - - assertProjectAlmSettings(tuple("PROJECT_1", "ABCD", "Repository1", "Slug1", NOW, NOW)); - assertProperties(tuple("sonar.pullrequest.provider", "Bitbucket Server", null)); - } - - @Test - public void do_not_create_alm_settings_when_missing_some_global_properties() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", null); - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - // No token - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository1", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug1", projectId1); - - underTest.execute(); - - assertNoAlmSettings(); - assertNoProjectAlmSettings(); - assertProperties(tuple("sonar.pullrequest.provider", "Bitbucket Server", null)); - } - - @Test - public void do_not_create_project_alm_settings_when_missing_some_project_properties() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", null); - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - insertProperty("sonar.pullrequest.bitbucketserver.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - // No project - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug1", projectId1); - long projectId2 = insertProject("PROJECT_2"); - // No repository - insertProperty("sonar.pullrequest.bitbucketserver.project", "Project1", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("bitbucket", "Bitbucket Server", "https://enterprise.com", "12345", NOW, NOW)); - assertNoProjectAlmSettings(); - assertProperties(tuple("sonar.pullrequest.provider", "Bitbucket Server", null)); - } - - @Test - public void do_nothing_when_no_alm_properties() throws SQLException { - insertProperty("sonar.other.property", "Something", null); - - underTest.execute(); - - assertNoAlmSettings(); - assertNoProjectAlmSettings(); - assertProperties(tuple("sonar.other.property", "Something", null)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", null); - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - insertProperty("sonar.pullrequest.bitbucketserver.token.secured", "12345", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Bitbucket Server", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository1", projectId1); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug1", projectId1); - underTest.execute(); - - // Global settings have been removed, let's re-create them - insertProperty("sonar.pullrequest.bitbucketserver.serverUrl", "https://enterprise.com", null); - insertProperty("sonar.pullrequest.bitbucketserver.token.secured", "12345", null); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.bitbucketserver.project", "Repository2", projectId2); - insertProperty("sonar.pullrequest.bitbucketserver.repository", "Slug2", projectId2); - underTest.execute(); - - assertAlmSettings(tuple("bitbucket", "Bitbucket Server", "https://enterprise.com", "12345", NOW, NOW)); - String almSettingUuid = selectAlmSettingUuid("Bitbucket Server"); - assertProperties( - tuple("sonar.pullrequest.provider", "Bitbucket Server", null), - tuple("sonar.pullrequest.provider", "Bitbucket Server", projectId1)); - } - - private void assertAlmSettings(Tuple... expectedTuples) { - assertThat(db.select("SELECT alm_id, kee, url, pat, created_at, updated_at FROM alm_settings") - .stream() - .map(map -> new Tuple(map.get("ALM_ID"), map.get("KEE"), map.get("URL"), map.get("PAT"), map.get("CREATED_AT"), - map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoAlmSettings() { - assertAlmSettings(); - } - - private void assertProjectAlmSettings(Tuple... expectedTuples) { - assertThat(db.select("SELECT project_uuid, alm_setting_uuid, alm_repo, alm_slug, created_at, updated_at FROM project_alm_settings") - .stream() - .map(map -> new Tuple(map.get("PROJECT_UUID"), map.get("ALM_SETTING_UUID"), map.get("ALM_REPO"), map.get("ALM_SLUG"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoProjectAlmSettings() { - assertProjectAlmSettings(); - } - - private void assertProperties(Tuple... expectedTuples) { - assertThat(db.select("SELECT prop_key, text_value, resource_id FROM properties") - .stream() - .map(map -> new Tuple(map.get("PROP_KEY"), map.get("TEXT_VALUE"), map.get("RESOURCE_ID"))) - .collect(toSet())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoProperties() { - assertProperties(); - } - - private String selectAlmSettingUuid(String almSettingKey) { - return (String) db.selectFirst("select uuid from alm_settings where kee='" + almSettingKey + "'").get("UUID"); - } - - private void insertProperty(String key, String value, @Nullable Long projectId) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", key, - "RESOURCE_ID", projectId, - "USER_ID", null, - "IS_EMPTY", false, - "TEXT_VALUE", value, - "CLOB_VALUE", null, - "CREATED_AT", System2.INSTANCE.now()); - } - - private long insertProject(String uuid) { - int id = nextInt(); - db.executeInsert("PROJECTS", - "ID", id, - "ORGANIZATION_UUID", "default", - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", uuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", "PRJ", - "QUALIFIER", "PRJ"); - return id; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest.java deleted file mode 100644 index bda17e5abc6ea159c451d2361ce5bf236cdcc911..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.utils.System2; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrateDefaultBranchesToKeepSettingTest { - - private static final String PROPS_TABLE = "properties"; - private static final String PATTERN_1 = "(branch|release|llb)-.*"; - private static final String PATTERN_2 = "(branch|llb)-.*"; - private static final String PATTERN_3 = "llb-.*"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MigrateDefaultBranchesToKeepSettingTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrateDefaultBranchesToKeepSetting underTest = new MigrateDefaultBranchesToKeepSetting(dbTester.database(), System2.INSTANCE); - - @Test - public void migrate_overridden_old_setting() throws SQLException { - setupOverriddenSetting(); - - underTest.execute(); - - verifyMigrationOfOverriddenSetting(); - } - - @Test - public void migration_of_overridden_setting_is_re_entrant() throws SQLException { - setupOverriddenSetting(); - - underTest.execute(); - underTest.execute(); - - verifyMigrationOfOverriddenSetting(); - } - - @Test - public void migrate_default_old_setting_on_fresh_install() throws SQLException { - setupDefaultSetting(); - - underTest.execute(); - - verifyMigrationOfDefaultSetting("master,develop,trunk"); - } - - @Test - public void migrate_default_old_setting_on_existing_install() throws SQLException { - setupDefaultSetting(); - insertProject(); - - underTest.execute(); - - verifyMigrationOfDefaultSetting("master,develop,trunk,branch-.*,release-.*"); - } - - @Test - public void migration_of_default_old_setting_is_re_entrant() throws SQLException { - setupDefaultSetting(); - - underTest.execute(); - underTest.execute(); - - verifyMigrationOfDefaultSetting("master,develop,trunk"); - } - - private void setupOverriddenSetting() { - insertProperty(1, "some.key", "some.value", 1001L); - insertProperty(2, "sonar.branch.longLivedBranches.regex", PATTERN_1, 1001L); - insertProperty(3, "some.other.key", "some.other.value", 1001L); - insertProperty(4, "sonar.branch.longLivedBranches.regex", PATTERN_2, 1002L); - insertProperty(5, "some.other.key", "some.other.value", null); - insertProperty(6, "sonar.branch.longLivedBranches.regex", PATTERN_3, null); - } - - private void setupDefaultSetting() { - insertProperty(1, "some.key", "some.value", 1001L); - insertProperty(3, "some.other.key", "some.other.value", 1001L); - insertProperty(5, "some.other.key", "some.other.value", null); - } - - private void verifyMigrationOfOverriddenSetting() { - assertThat(dbTester.countRowsOfTable(PROPS_TABLE)).isEqualTo(9); - assertThat(dbTester.countSql("select count(*) from " + PROPS_TABLE + " where prop_key = 'sonar.branch.longLivedBranches.regex'")).isEqualTo(3); - assertThat(dbTester.countSql("select count(*) from " + PROPS_TABLE + " where prop_key = 'sonar.dbcleaner.branchesToKeepWhenInactive'")).isEqualTo(3); - assertThat(dbTester.select("select resource_id, text_value from " + PROPS_TABLE + " where prop_key = 'sonar.dbcleaner.branchesToKeepWhenInactive'") - .stream() - .map(e -> new Tuple(e.get("TEXT_VALUE"), e.get("RESOURCE_ID"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder( - new Tuple(PATTERN_1, 1001L), - new Tuple(PATTERN_2, 1002L), - new Tuple(PATTERN_3, null)); - } - - private void verifyMigrationOfDefaultSetting(String expectedValue) { - assertThat(dbTester.countRowsOfTable(PROPS_TABLE)).isEqualTo(4); - assertThat(dbTester.countSql("select count(*) from " + PROPS_TABLE + " where prop_key = 'sonar.branch.longLivedBranches.regex'")).isZero(); - assertThat(dbTester.countSql("select count(*) from " + PROPS_TABLE + " where prop_key = 'sonar.dbcleaner.branchesToKeepWhenInactive'")).isEqualTo(1); - assertThat(dbTester.select("select resource_id, text_value from " + PROPS_TABLE + " where prop_key = 'sonar.dbcleaner.branchesToKeepWhenInactive'") - .stream() - .map(e -> new Tuple(e.get("TEXT_VALUE"), e.get("RESOURCE_ID"))) - .collect(Collectors.toList())) - .containsExactly(new Tuple(expectedValue, null)); - } - - private void insertProperty(int id, String key, String value, @Nullable Long resourceId) { - dbTester.executeInsert( - PROPS_TABLE, - "ID", id, - "PROP_KEY", key, - "RESOURCE_ID", resourceId, - "USER_ID", null, - "IS_EMPTY", false, - "TEXT_VALUE", value, - "CLOB_VALUE", null, - "CREATED_AT", System2.INSTANCE.now()); - } - - private void insertProject() { - String uuid = Uuids.createFast(); - dbTester.executeInsert("PROJECTS", - "ORGANIZATION_UUID", "default-org", - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "main_branch_project_uuid", uuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", "true", - "qualifier", "TRK", - "scope", "PRJ"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDeprecatedGithubPrivateKeyToNewKeyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDeprecatedGithubPrivateKeyToNewKeyTest.java deleted file mode 100644 index 424e9e35edec50b161b65f0ef2ff642ab22883cb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDeprecatedGithubPrivateKeyToNewKeyTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.util.Base64; -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 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 MigrateDeprecatedGithubPrivateKeyToNewKeyTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateDeprecatedGithubPrivateKeyToNewKeyTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DataChange underTest = new MigrateDeprecatedGithubPrivateKeyToNewKey(db.database()); - - @Test - public void migrate_and_decode_old_property_to_new_one() throws SQLException { - String privateKey = ""; - insertProperty("sonar.alm.github.app.privateKey.secured", Base64.getEncoder().encodeToString(privateKey.getBytes())); - - underTest.execute(); - - assertProperties(tuple("sonar.alm.github.app.privateKeyContent.secured", privateKey)); - } - - @Test - public void do_nothing_when_only_new_property() throws SQLException { - String privateKey = ""; - insertProperty("sonar.alm.github.app.privateKeyContent.secured", privateKey); - - underTest.execute(); - - assertProperties(tuple("sonar.alm.github.app.privateKeyContent.secured", privateKey)); - } - - @Test - public void remove_old_property_when_both_new_one_and_old_one_exist() throws SQLException { - String privateKey = ""; - insertProperty("sonar.alm.github.app.privateKey.secured", Base64.getEncoder().encodeToString(privateKey.getBytes())); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", privateKey); - - underTest.execute(); - - assertProperties(tuple("sonar.alm.github.app.privateKeyContent.secured", privateKey)); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - String privateKey = ""; - insertProperty("sonar.alm.github.app.privateKey.secured", Base64.getEncoder().encodeToString(privateKey.getBytes())); - - underTest.execute(); - underTest.execute(); - - assertProperties(tuple("sonar.alm.github.app.privateKeyContent.secured", privateKey)); - } - - private void assertProperties(Tuple... tuples) { - assertThat(db.select("SELECT prop_key, text_value FROM properties") - .stream() - .map(map -> new Tuple(map.get("PROP_KEY"), map.get("TEXT_VALUE"))) - .collect(toList())) - .containsExactlyInAnyOrder(tuples); - } - - private void insertProperty(String key, String value) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", key, - "RESOURCE_ID", null, - "USER_ID", null, - "IS_EMPTY", false, - "TEXT_VALUE", value, - "CLOB_VALUE", null, - "CREATED_AT", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateGithubAlmSettingsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateGithubAlmSettingsTest.java deleted file mode 100644 index 309f7312c907bd51fa55ef5db55d36e1011d5de4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateGithubAlmSettingsTest.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -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.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.util.stream.Collectors.toList; -import static java.util.stream.Collectors.toSet; -import static org.apache.commons.lang.math.RandomUtils.nextInt; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class MigrateGithubAlmSettingsTest { - - 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); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateGithubAlmSettingsTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DataChange underTest = new MigrateGithubAlmSettings(db.database(), uuidFactory, system2); - - @Test - public void migrate_settings_when_global_provider_is_set_to_github() throws SQLException { - insertProperty("sonar.pullrequest.provider", "GitHub", null); - insertProperty("sonar.pullrequest.github.endpoint", "https://enterprise.github.com", null); - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.github.repository", "Repository1", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.github.repository", "Repository2", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("github", "GitHub", "https://enterprise.github.com", "12345", "", NOW, NOW)); - String gitHubAlmSettingUuid = selectAlmSettingUuid("GitHub"); - assertProjectAlmSettings( - tuple("PROJECT_1", gitHubAlmSettingUuid, "Repository1", NOW, NOW), - tuple("PROJECT_2", gitHubAlmSettingUuid, "Repository2", NOW, NOW)); - assertProperties(tuple("sonar.pullrequest.provider", "GitHub", null)); - } - - @Test - public void migrate_settings_when_project_provider_is_set_to_github_and_global_provider_is_set_to_something_else() throws SQLException { - insertProperty("sonar.pullrequest.provider", "Azure DevOps", null); - insertProperty("sonar.pullrequest.github.endpoint", "https://enterprise.github.com", null); - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "GitHub", projectId1); - insertProperty("sonar.pullrequest.github.repository", "Repository1", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "GitHub", projectId2); - insertProperty("sonar.pullrequest.github.repository", "Repository2", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("github", "GitHub", "https://enterprise.github.com", "12345", "", NOW, NOW)); - String gitHubAlmSettingUuid = selectAlmSettingUuid("GitHub"); - assertProjectAlmSettings( - tuple("PROJECT_1", gitHubAlmSettingUuid, "Repository1", NOW, NOW), - tuple("PROJECT_2", gitHubAlmSettingUuid, "Repository2", NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "Azure DevOps", null), - tuple("sonar.pullrequest.provider", "GitHub", projectId1), - tuple("sonar.pullrequest.provider", "GitHub", projectId2)); - } - - @Test - public void delete_github_settings_when_project_provider_is_not_set_to_github() throws SQLException { - insertProperty("sonar.pullrequest.provider", "GitHub", null); - insertProperty("sonar.pullrequest.github.endpoint", "https://enterprise.github.com", null); - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId1 = insertProject("PROJECT_1"); - // Project provider is set to something else - insertProperty("sonar.pullrequest.provider", "Azure", projectId1); - insertProperty("sonar.pullrequest.github.repository", "Repository1", projectId1); - - underTest.execute(); - - assertNoProjectAlmSettings(); - assertProperties( - tuple("sonar.pullrequest.provider", "GitHub", null), - tuple("sonar.pullrequest.provider", "Azure", projectId1)); - } - - @Test - public void use_existing_alm_setting() throws SQLException { - db.executeInsert("alm_settings", - "uuid", "ABCD", - "alm_id", "github", - "kee", "GitHub", - "url", "https://enterprise.github.com", - "app_id", "12345", - "private_key", "", - "created_at", PAST, - "updated_at", PAST); - insertProperty("sonar.pullrequest.provider", "GitHub", null); - insertProperty("sonar.pullrequest.github.endpoint", "https://enterprise.github.com", null); - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.github.repository", "Repository1", projectId1); - - underTest.execute(); - - assertProjectAlmSettings(tuple("PROJECT_1", "ABCD", "Repository1", NOW, NOW)); - assertProperties(tuple("sonar.pullrequest.provider", "GitHub", null)); - } - - @Test - public void ignore_none_github_project_settings() throws SQLException { - insertProperty("sonar.pullrequest.provider", "GitHub", null); - insertProperty("sonar.pullrequest.github.endpoint", "https://enterprise.github.com", null); - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "Bitbucket", projectId1); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.provider", "Bitbucket", projectId2); - - underTest.execute(); - - assertAlmSettings(tuple("github", "GitHub", "https://enterprise.github.com", "12345", "", NOW, NOW)); - assertNoProjectAlmSettings(); - assertProperties( - tuple("sonar.pullrequest.provider", "GitHub", null), - tuple("sonar.pullrequest.provider", "Bitbucket", projectId1), - tuple("sonar.pullrequest.provider", "Bitbucket", projectId2)); - } - - @Test - public void do_not_create_alm_settings_when_missing_some_global_properties() throws SQLException { - insertProperty("sonar.pullrequest.provider", "GitHub", null); - // No endpoint - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.github.repository", "Repository1", projectId1); - - underTest.execute(); - - assertNoAlmSettings(); - assertNoProjectAlmSettings(); - assertProperties(tuple("sonar.pullrequest.provider", "GitHub", null)); - } - - @Test - public void do_not_create_project_alm_settings_when_missing_some_project_properties() throws SQLException { - insertProperty("sonar.pullrequest.provider", "GitHub", null); - insertProperty("sonar.pullrequest.github.endpoint", "https://enterprise.github.com", null); - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId1 = insertProject("PROJECT_1"); - // No repository - insertProperty("sonar.pullrequest.provider", "GitHub", projectId1); - - underTest.execute(); - - assertAlmSettings(tuple("github", "GitHub", "https://enterprise.github.com", "12345", "", NOW, NOW)); - assertNoProjectAlmSettings(); - assertProperties( - tuple("sonar.pullrequest.provider", "GitHub", null), - tuple("sonar.pullrequest.provider", "GitHub", projectId1)); - } - - @Test - public void do_nothing_when_no_alm_properties() throws SQLException { - insertProperty("sonar.other.property", "Something", null); - - underTest.execute(); - - assertNoAlmSettings(); - assertNoProjectAlmSettings(); - assertProperties(tuple("sonar.other.property", "Something", null)); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProperty("sonar.pullrequest.provider", "GitHub", null); - insertProperty("sonar.pullrequest.github.endpoint", "https://enterprise.github.com", null); - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId1 = insertProject("PROJECT_1"); - insertProperty("sonar.pullrequest.provider", "GitHub", projectId1); - insertProperty("sonar.pullrequest.github.repository", "Repository1", projectId1); - underTest.execute(); - - // Global settings have been removed, let's re-create them - insertProperty("sonar.pullrequest.github.endpoint", "https://enterprise.github.com", null); - insertProperty("sonar.alm.github.app.id", "12345", null); - insertProperty("sonar.alm.github.app.privateKeyContent.secured", "", null); - long projectId2 = insertProject("PROJECT_2"); - insertProperty("sonar.pullrequest.github.repository", "Repository2", projectId2); - underTest.execute(); - - assertAlmSettings(tuple("github", "GitHub", "https://enterprise.github.com", "12345", "", NOW, NOW)); - assertProperties( - tuple("sonar.pullrequest.provider", "GitHub", null), - tuple("sonar.pullrequest.provider", "GitHub", projectId1)); - } - - private void assertAlmSettings(Tuple... expectedTuples) { - assertThat(db.select("SELECT alm_id, kee, url, app_id, private_key, created_at, updated_at FROM alm_settings") - .stream() - .map(map -> new Tuple(map.get("ALM_ID"), map.get("KEE"), map.get("URL"), map.get("APP_ID"), map.get("PRIVATE_KEY"), map.get("CREATED_AT"), - map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoAlmSettings() { - assertAlmSettings(); - } - - private void assertProjectAlmSettings(Tuple... expectedTuples) { - assertThat(db.select("SELECT project_uuid, alm_setting_uuid, alm_repo, created_at, updated_at FROM project_alm_settings") - .stream() - .map(map -> new Tuple(map.get("PROJECT_UUID"), map.get("ALM_SETTING_UUID"), map.get("ALM_REPO"), map.get("CREATED_AT"), map.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoProjectAlmSettings() { - assertProjectAlmSettings(); - } - - private void assertProperties(Tuple... expectedTuples) { - assertThat(db.select("SELECT prop_key, text_value, resource_id FROM properties") - .stream() - .map(map -> new Tuple(map.get("PROP_KEY"), map.get("TEXT_VALUE"), map.get("RESOURCE_ID"))) - .collect(toSet())) - .containsExactlyInAnyOrder(expectedTuples); - } - - private void assertNoProperties() { - assertProperties(); - } - - private String selectAlmSettingUuid(String almSettingKey) { - return (String) db.selectFirst("select uuid from alm_settings where kee='" + almSettingKey + "'").get("UUID"); - } - - private void insertProperty(String key, String value, @Nullable Long projectId) { - db.executeInsert( - "PROPERTIES", - "PROP_KEY", key, - "RESOURCE_ID", projectId, - "USER_ID", null, - "IS_EMPTY", false, - "TEXT_VALUE", value, - "CLOB_VALUE", null, - "CREATED_AT", System2.INSTANCE.now()); - } - - private long insertProject(String uuid) { - int id = nextInt(); - db.executeInsert("PROJECTS", - "ID", id, - "ORGANIZATION_UUID", "default", - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", uuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", "PRJ", - "QUALIFIER", "PRJ"); - return id; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest.java deleted file mode 100644 index 6329d2b241860b8ca9b63989c70efb149f929160..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.junit.Before; -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.sonar.server.platform.db.migration.version.v81.MigrateSlbsAndLlbsToCommonTypeInCeTasks.TABLE; - -public class MigrateSlbsAndLlbsToCommonTypeInCeTasksTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MigrateSlbsAndLlbsToCommonTypeInCeTasksTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrateSlbsAndLlbsToCommonTypeInCeTasks underTest = new MigrateSlbsAndLlbsToCommonTypeInCeTasks(dbTester.database()); - - @Before - public void setup() { - insertCeTaskCharacteristic("char-uuid-1", "task-uuid-1", "branchType", "LONG"); - insertCeTaskCharacteristic("char-uuid-2", "task-uuid-1", "branch", "foobar"); - insertCeTaskCharacteristic("char-uuid-3", "task-uuid-1", "someKey", "someValue"); - - insertCeTaskCharacteristic("char-uuid-21", "task-uuid-2", "branchType", "SHORT"); - insertCeTaskCharacteristic("char-uuid-22", "task-uuid-2", "branch", "feature/1"); - insertCeTaskCharacteristic("char-uuid-23", "task-uuid-2", "someKey", "anotherValue"); - - insertCeTaskCharacteristic("char-uuid-31", "task-uuid-3", "pullRequest", "1"); - insertCeTaskCharacteristic("char-uuid-32", "task-uuid-3", "someKey", "yetAnotherValue"); - - assertThat(dbTester.countRowsOfTable(TABLE)).isEqualTo(8); - } - - @Test - public void execute() throws SQLException { - underTest.execute(); - - verifyMigrationResult(); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - verifyMigrationResult(); - } - - private void verifyMigrationResult() { - assertThat(dbTester.countRowsOfTable(TABLE)).isEqualTo(8); - assertThat(dbTester.countSql("select count(*) from " + TABLE + " where kee = 'branchType' and text_value in ('LONG', 'SHORT')")).isZero(); - assertThat(dbTester.select("select uuid from " + TABLE + " where kee = 'branchType' and text_value = 'BRANCH'") - .stream() - .map(e -> e.get("UUID")) - .collect(Collectors.toSet())).containsExactlyInAnyOrder("char-uuid-1", "char-uuid-21"); - } - - private void insertCeTaskCharacteristic(String uuid, String taskUuid, String key, String value) { - dbTester.executeInsert( - TABLE, - "UUID", uuid, - "TASK_UUID", taskUuid, - "KEE", key, - "TEXT_VALUE", value); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest.java deleted file mode 100644 index ff2a1afceb50c49718c063785b1fd350b0b7daf8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.util.stream.Collectors; -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.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrateSlbsAndLlbsToCommonTypeTest { - - private static final String BRANCHES_TABLE = "project_branches"; - private static final String MAIN_BRANCH_1 = "825644c3-06b2-44b5-833e-13169a5379ad"; - private static final String MAIN_BRANCH_2 = "47a53ace-0297-4a4e-bcab-07a65e3eeac4"; - private static final String PR_1 = "ad85f2ee-7271-407a-b9f7-b0a80343e001"; - private static final String LLB_1 = "08905714-2bfd-48a6-b19d-7801bc4d1ca4"; - private static final String SLB_1 = "a2020607-4134-45f9-87ea-2cdaa84bf386"; - private static final String PR_2 = "834eba05-e4f7-4214-bfec-c7823e101487"; - private static final String LLB_2 = "fea036fe-e830-4d87-85ee-7aaa21729019"; - private static final String SLB_2 = "20166755-953e-4b8e-8c1d-67d812e42418"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MigrateSlbsAndLlbsToCommonTypeTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrateSlbsAndLlbsToCommonType underTest = new MigrateSlbsAndLlbsToCommonType(dbTester.database(), System2.INSTANCE); - - @Before - public void setup() { - insertMainBranch(MAIN_BRANCH_1); - insertBranch(MAIN_BRANCH_1, PR_1, "PULL_REQUEST"); - insertBranch(MAIN_BRANCH_1, LLB_1, "LONG"); - insertBranch(MAIN_BRANCH_1, SLB_1, "SHORT"); - - insertMainBranch(MAIN_BRANCH_2); - insertBranch(MAIN_BRANCH_1, PR_2, "PULL_REQUEST"); - insertBranch(MAIN_BRANCH_1, LLB_2, "LONG"); - insertBranch(MAIN_BRANCH_1, SLB_2, "SHORT"); - } - - @Test - public void execute() throws SQLException { - underTest.execute(); - - verifyMigrationResult(); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - verifyMigrationResult(); - } - - private void verifyMigrationResult() { - assertThat(dbTester.countRowsOfTable(BRANCHES_TABLE)).isEqualTo(8); - assertThat(dbTester.countSql("select count(*) from project_branches where branch_type = 'LONG' or branch_type = 'SHORT'")).isZero(); - assertThat(dbTester.select("select uuid from " + BRANCHES_TABLE + " where branch_type = 'BRANCH'") - .stream() - .map(e -> e.get("UUID")) - .collect(Collectors.toSet())).containsExactlyInAnyOrder(MAIN_BRANCH_1, MAIN_BRANCH_2, SLB_1, SLB_2, LLB_1, LLB_2); - assertThat(dbTester.select("select uuid from " + BRANCHES_TABLE + " where branch_type = 'PULL_REQUEST'") - .stream() - .map(e -> e.get("UUID")) - .collect(Collectors.toSet())).containsExactlyInAnyOrder(PR_1, PR_2); - } - - private void insertBranch(String mainBranchUuid, String uuid, String type) { - dbTester.executeInsert( - BRANCHES_TABLE, - "UUID", uuid, - "PROJECT_UUID", mainBranchUuid, - "KEE", "pb-key-" + uuid, - "KEY_TYPE", "TSR", - "BRANCH_TYPE", type, - "MERGE_BRANCH_UUID", "mb-uuid-" + mainBranchUuid, - "MANUAL_BASELINE_ANALYSIS_UUID", null, - "CREATED_AT", System2.INSTANCE.now(), - "UPDATED_AT", System2.INSTANCE.now()); - } - - private void insertMainBranch(String mainBranchUuid) { - insertBranch(mainBranchUuid, mainBranchUuid, "LONG"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/PopulateExcludeBranchFromPurgeColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/PopulateExcludeBranchFromPurgeColumnTest.java deleted file mode 100644 index 5e8cecdda101a694a4e67c1ceff2d811d7632d26..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/PopulateExcludeBranchFromPurgeColumnTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.util.stream.Collectors; -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.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateExcludeBranchFromPurgeColumnTest { - - private static final String TABLE = "PROJECT_BRANCHES"; - - private static final String PROJECT_1_UUID = "1a724f54-c2a4-4d36-b59c-61026f178613"; - private static final String PROJECT_2_UUID = "cc69ccb8-434a-489b-abd6-6a80371f64ff"; - - private static final String MAIN_BRANCH_1 = "8a9789c8-7aee-4aa6-9cb7-407137935ac3"; - private static final String LONG_BRANCH_1 = "69fdfc19-491c-4ed9-bcac-ef04e0f6cdc6"; - private static final String SHORT_BRANCH_1 = "f7a6d247-1790-40f8-8591-a0cc39d05ecb"; - private static final String PR_1 = "d65466bf-271c-4f9f-ac7a-72add44848c0"; - - private static final String MAIN_BRANCH_2 = "cdadf128-7bdb-4589-982d-62445d46ae1b"; - private static final String LONG_BRANCH_2 = "60bf6fa8-3ecc-4ba6-ad8d-991ea7c7f9cb"; - private static final String SHORT_BRANCH_2 = "ce5632ed-462e-4384-98b6-1773a7bbfe53"; - private static final String PR_2 = "5897f7d0-d34f-4558-b9c5-a7eb7a5c4b69"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateExcludeBranchFromPurgeColumnTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateExcludeBranchFromPurgeColumn underTest = new PopulateExcludeBranchFromPurgeColumn(dbTester.database(), System2.INSTANCE); - - @Before - public void setup() { - insertBranch(MAIN_BRANCH_1, PROJECT_1_UUID, "master", "BRANCH", "LONG"); - insertBranch(LONG_BRANCH_1, PROJECT_1_UUID, "release-1", "BRANCH", "LONG"); - insertBranch(SHORT_BRANCH_1, PROJECT_1_UUID, "feature/foo", "BRANCH", "SHORT"); - insertBranch(PR_1, PROJECT_1_UUID, "feature/feature-1", "PULL_REQUEST", "PULL_REQUEST"); - - insertBranch(MAIN_BRANCH_2, PROJECT_2_UUID, "trunk", "BRANCH", "LONG"); - insertBranch(LONG_BRANCH_2, PROJECT_2_UUID, "branch-1", "BRANCH", "LONG"); - insertBranch(SHORT_BRANCH_2, PROJECT_2_UUID, "feature/bar", "BRANCH", "SHORT"); - insertBranch(PR_2, PROJECT_2_UUID, "feature/feature-2", "PULL_REQUEST", "PULL_REQUEST"); - } - - @Test - public void execute_migration() throws SQLException { - underTest.execute(); - - verifyMigrationResult(); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - verifyMigrationResult(); - } - - private void verifyMigrationResult() { - assertThat(dbTester.select("select UUID from " + TABLE + " where EXCLUDE_FROM_PURGE = true") - .stream() - .map(e -> e.get("UUID")) - .collect(Collectors.toList())).containsExactlyInAnyOrder(MAIN_BRANCH_1, LONG_BRANCH_1, MAIN_BRANCH_2, LONG_BRANCH_2); - assertThat(dbTester.select("select UUID from " + TABLE + " where EXCLUDE_FROM_PURGE = false") - .stream() - .map(e -> e.get("UUID")) - .collect(Collectors.toList())).containsExactlyInAnyOrder(SHORT_BRANCH_1, SHORT_BRANCH_2, PR_1, PR_2); - } - - private void insertBranch(String uuid, String projectUuid, String key, String keyType, String branchType) { - dbTester.executeInsert( - TABLE, - "UUID", uuid, - "PROJECT_UUID", projectUuid, - "KEE", key, - "BRANCH_TYPE", branchType, - "KEY_TYPE", keyType, - "MERGE_BRANCH_UUID", null, - "CREATED_AT", System2.INSTANCE.now(), - "UPDATED_AT", System2.INSTANCE.now()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java deleted file mode 100644 index 0e0ab5042dd0068dfa23014731cfae0286f603fb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.time.Instant; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.junit.Assert.assertEquals; - -public class RemoveLLBRegexSettingTest { - - private static final String PROPERTIES_TABLE_NAME = "properties"; - private static final int TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES = 10; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveLLBRegexSettingTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RemoveLLBRegexSetting underTest = new RemoveLLBRegexSetting(dbTester.database()); - - @Before - public void setup() { - insertProperty(null, "xyz"); - for (long i = 1; i <= TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES; i++) { - insertProperty(i, format("xyz-%s", i)); - } - - int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - assertEquals(TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES + 1, propertiesCount); - } - - @Test - public void remove_llb_regex_property() throws SQLException { - underTest.execute(); - - verifyResult(); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - verifyResult(); - } - - private void verifyResult() { - int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); - assertEquals(0, propertiesCount); - } - - private void insertProperty(@Nullable Long projectId, String propertyValue) { - dbTester.executeInsert(PROPERTIES_TABLE_NAME, - "prop_key", "sonar.branch.longLivedBranches.regex", - "resource_id", projectId, - "is_empty", false, - "text_value", propertyValue, - "created_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest.java deleted file mode 100644 index ec90307152d94db80f897f92e54469b11b3983c4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.time.Instant; -import java.util.Random; -import java.util.UUID; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.junit.Assert.assertEquals; - -public class RemoveNewsboxDismissHotspotsPropertyTest { - - private static final String USER_PROPERTIES_TABLE_NAME = "user_properties"; - private static final int TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES = 10; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveNewsboxDismissHotspotsPropertyTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private Random random = new Random(); - - private RemoveNewsboxDismissHotspotsProperty underTest = new RemoveNewsboxDismissHotspotsProperty(dbTester.database()); - - @Before - public void setup() { - insertUserProperty("some-user-uuid", "some-property", random.nextBoolean()); - - for (int i = 1; i <= TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES; i++) { - insertUserProperty(format("user-uuid-%s", i), "newsbox.dismiss.hotspots", random.nextBoolean()); - } - - int propertiesCount = dbTester.countRowsOfTable(USER_PROPERTIES_TABLE_NAME); - assertEquals(TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES + 1, propertiesCount); - } - - @Test - public void remove_newsbox_dismiss_hotspot_property() throws SQLException { - underTest.execute(); - - verifyResult(); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - verifyResult(); - } - - private void verifyResult() { - int hotspotDismissPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee = 'newsbox.dismiss.hotspots'"); - assertEquals(0, hotspotDismissPropertiesCount); - int otherPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee != 'newsbox.dismiss.hotspots'"); - assertEquals(1, otherPropertiesCount); - } - - private void insertUserProperty(String userUuid, String key, boolean value) { - dbTester.executeInsert(USER_PROPERTIES_TABLE_NAME, - "uuid", UUID.randomUUID().toString(), - "kee", key, - "user_uuid", userUuid, - "text_value", value, - "created_at", Instant.now().toEpochMilli(), - "updated_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest.java deleted file mode 100644 index 1ed2de495fad8bc105e2aab8f8a180539a0c2052..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v81; - -import java.sql.SQLException; -import java.time.Instant; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.sonar.server.platform.db.migration.version.v81.RenameDaysBeforeDeletingInactiveSLBSetting.NEW_PROPERTY_NAME; -import static org.sonar.server.platform.db.migration.version.v81.RenameDaysBeforeDeletingInactiveSLBSetting.OLD_PROPERTY_NAME; -import static org.sonar.server.platform.db.migration.version.v81.RenameDaysBeforeDeletingInactiveSLBSetting.TABLE; - -public class RenameDaysBeforeDeletingInactiveSLBSettingTest { - - private static final int TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES = 10; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RenameDaysBeforeDeletingInactiveSLBSettingTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameDaysBeforeDeletingInactiveSLBSetting underTest = new RenameDaysBeforeDeletingInactiveSLBSetting(dbTester.database()); - - @Before - public void setup() { - insertProperty(null, OLD_PROPERTY_NAME, "xyz"); - insertProperty(null, "sonar.unrelated.global.property", "xyz"); - for (long i = 1; i <= TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES; i++) { - insertProperty(i, OLD_PROPERTY_NAME, format("xyz-%s", i)); - insertProperty(i, "sonar.unrelated.project.property", format("xyz-%s", i)); - } - - int propertiesCount = dbTester.countRowsOfTable(TABLE); - assertEquals(2 * TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES + 2, propertiesCount); - } - - @Test - public void migrates_old_prop_key_to_new_prop_key() throws SQLException { - underTest.execute(); - - verifyResult(); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - verifyResult(); - } - - private void verifyResult() { - int propertiesCount = dbTester.countRowsOfTable(TABLE); - assertEquals(2 * TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES + 2, propertiesCount); - - int numberOfPropsWithNewName = dbTester.countSql("select count(*) from " + TABLE + " where prop_key = '" + NEW_PROPERTY_NAME + "'"); - int numberOfPropsWithOldName = dbTester.countSql("select count(*) from " + TABLE + " where prop_key = '" + OLD_PROPERTY_NAME + "'"); - assertThat(numberOfPropsWithNewName).isEqualTo(TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES + 1); - assertThat(numberOfPropsWithOldName).isZero(); - } - - private void insertProperty(@Nullable Long projectId, String propertyKey, String propertyValue) { - dbTester.executeInsert(TABLE, - "prop_key", propertyKey, - "resource_id", projectId, - "is_empty", false, - "text_value", propertyValue, - "created_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/AddIndexOnSlugOfProjectAlmSettingsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/AddIndexOnSlugOfProjectAlmSettingsTest.java deleted file mode 100644 index 1c671b3a13fbe9e8351c47f1e063e005f902b6a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/AddIndexOnSlugOfProjectAlmSettingsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class AddIndexOnSlugOfProjectAlmSettingsTest { - - private static final String TABLE_NAME = "project_alm_settings"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnSlugOfProjectAlmSettingsTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIndexOnSlugOfProjectAlmSettings underTest = new AddIndexOnSlugOfProjectAlmSettings(dbTester.database()); - - @Test - public void index_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertIndex(TABLE_NAME, "project_alm_settings_slug", "alm_slug"); - - // script should not fail if executed twice - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/CreateAlmPATsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/CreateAlmPATsTableTest.java deleted file mode 100644 index 57207aea101643bc64d2324d0b071423bb4dd442..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/CreateAlmPATsTableTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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.BIGINT; -import static java.sql.Types.VARCHAR; - -public class CreateAlmPATsTableTest { - - private static final String TABLE_NAME = "alm_pats"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateAlmPatsTable underTest = new CreateAlmPatsTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_alm_pats", "uuid"); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_alm_pats", "user_uuid", "alm_setting_uuid"); - - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "pat", VARCHAR, 2000, false); - dbTester.assertColumnDefinition(TABLE_NAME, "user_uuid", VARCHAR, 256, false); - dbTester.assertColumnDefinition(TABLE_NAME, "alm_setting_uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", BIGINT, 20, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, 20, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/CreateProjectsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/CreateProjectsTableTest.java deleted file mode 100644 index 1c9915dc3d4c76070b53b88258b00a47618ce84b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/CreateProjectsTableTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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.BIGINT; -import static java.sql.Types.BOOLEAN; -import static java.sql.Types.VARCHAR; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; - -public class CreateProjectsTableTest { - private static final String TABLE_NAME = "projects"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateProjectsTable underTest = new CreateProjectsTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_new_projects", "uuid"); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_projects_kee", "kee"); - - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, UUID_SIZE, false); - dbTester.assertColumnDefinition(TABLE_NAME, "kee", VARCHAR, 400, false); - dbTester.assertColumnDefinition(TABLE_NAME, "organization_uuid", VARCHAR, UUID_SIZE, false); - dbTester.assertColumnDefinition(TABLE_NAME, "name", VARCHAR, 2000, true); - dbTester.assertColumnDefinition(TABLE_NAME, "description", VARCHAR, 2000, true); - dbTester.assertColumnDefinition(TABLE_NAME, "private", BOOLEAN, null, false); - dbTester.assertColumnDefinition(TABLE_NAME, "tags", VARCHAR, 500, true); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, null, true); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", BIGINT, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82Test.java deleted file mode 100644 index 2cd1a41b83ef13be7e3fcc9271d5322140e61cc1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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 DbVersion82Test { - - private DbVersion underTest = new DbVersion82(); - - @Test - public void migrationNumber_starts_at_3200() { - verifyMinimumMigrationNumber(underTest, 3200); - } - - @Test - public void verify_migration_count() { - verifyMigrationCount(underTest, 12); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetricsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetricsTest.java deleted file mode 100644 index 391d458f15b68649efefb729c2616f71a0b6f50e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetricsTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static com.google.common.primitives.Longs.asList; -import static java.lang.String.format; -import static java.util.Collections.singletonList; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteQgateConditionsUsingSecurityHotspotMetricsTest { - - private static final String TABLE_QUALITY_GATE_CONDITIONS = "quality_gate_conditions"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteQgateConditionsUsingSecurityHotspotMetricsTest.class, "schema.sql"); - - private DataChange underTest = new DeleteQgateConditionsUsingSecurityHotspotMetrics(db.database()); - - @Test - public void remove_conditions_on_security_hotspots() throws SQLException { - long securityHotspotsMetric = insertMetric("security_hotspots"); - insertQualityGateCondition(securityHotspotsMetric); - long newSecurityHotspotsMetric = insertMetric("new_security_hotspots"); - insertQualityGateCondition(newSecurityHotspotsMetric); - long nclocMetric = insertMetric("ncloc"); - long conditionOnNcloc = insertQualityGateCondition(nclocMetric); - - underTest.execute(); - - verifyConditionIds(singletonList(conditionOnNcloc)); - } - - @Test - public void do_not_remove_any_condition_when_no_security_hotspot_metrics() throws SQLException { - long nclocMetric = insertMetric("ncloc"); - long conditionOnNcloc = insertQualityGateCondition(nclocMetric); - long issuesMetric = insertMetric("issues"); - long conditionOnIssues = insertQualityGateCondition(issuesMetric); - - underTest.execute(); - - verifyConditionIds(asList(conditionOnNcloc, conditionOnIssues)); - } - - @Test - public void do_nothing_when_no_condition() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isZero(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long securityHotspotsMetric = insertMetric("security_hotspots"); - insertQualityGateCondition(securityHotspotsMetric); - long newSecurityHotspotsMetric = insertMetric("new_security_hotspots"); - insertQualityGateCondition(newSecurityHotspotsMetric); - long otherMetric = insertMetric("ncloc"); - 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/v82/DeleteSecurityReviewRatingLiveMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest.java deleted file mode 100644 index 3e9e602087d771f3c5cf6d9df96e30f441c57388..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import java.util.UUID; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.apache.commons.lang.math.RandomUtils.nextInt; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteSecurityReviewRatingLiveMeasuresTest { - private static final String LIVE_MEASURES_TABLE_NAME = "LIVE_MEASURES"; - - private static final int SECURITY_REVIEW_RATING_METRIC_ID = 200; - private static final String SECURITY_REVIEW_RATING_METRIC_KEY = "security_review_rating"; - private static final int SECURITY_REVIEW_RATING_EFFORT_METRIC_ID = 201; - private static final String SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY = "security_review_rating_effort"; - - private static final int OTHER_METRIC_ID_1 = 1; - private static final int OTHER_METRIC_ID_2 = 2; - private static final int OTHER_METRIC_MEASURES_COUNT = 20; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteSecurityReviewRatingLiveMeasuresTest.class, "schema.sql"); - - private final DataChange underTest = new DeleteSecurityReviewRatingLiveMeasures(db.database()); - - @Before - public void before() { - insertMetric(OTHER_METRIC_ID_1, "another metric#1"); - insertMetric(OTHER_METRIC_ID_2, "another metric#2"); - } - - @Test - public void not_fail_if_metrics_not_defined() throws SQLException { - String projectUuid = insertComponent("TRK"); - insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, projectUuid, projectUuid); - - underTest.execute(); - - assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(1); - } - - @Test - public void not_fail_if_security_review_rating_effort_metric_not_found() throws SQLException { - insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); - - String applicationUuid = insertComponent("TRK"); - - insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid, applicationUuid); - - generateOtherMetricsLiveMeasures(applicationUuid); - - underTest.execute(); - - assertSecurityReviewRatingLiveMeasuresDeleted(); - - assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); - - // should not fail if called twice - underTest.execute(); - } - - @Test - public void remove_security_rating_review_from_live_measures_projects() throws SQLException { - insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); - insertMetric(SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - - String applicationUuid = insertComponent("TRK"); - - insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid, applicationUuid); - - generateOtherMetricsLiveMeasures(applicationUuid); - - underTest.execute(); - - assertSecurityReviewRatingLiveMeasuresDeleted(); - - assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); - - // should not fail if called twice - underTest.execute(); - } - - @Test - public void remove_security_rating_review_from_live_measures_for_portfolios() throws SQLException { - insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); - insertMetric(SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - - String portfolioUuid = insertComponent("VW"); - String subPortfolioUuid = insertComponent("SVW"); - - insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, portfolioUuid, portfolioUuid); - insertLiveMeasure("uuid-2", SECURITY_REVIEW_RATING_METRIC_ID, subPortfolioUuid, subPortfolioUuid); - - insertLiveMeasure("uuid-3", SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, portfolioUuid, portfolioUuid); - insertLiveMeasure("uuid-4", SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, subPortfolioUuid, subPortfolioUuid); - - generateOtherMetricsLiveMeasures(portfolioUuid); - - underTest.execute(); - - assertSecurityReviewRatingLiveMeasuresDeleted(); - - assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); - - // should not fail if called twice - underTest.execute(); - } - - @Test - public void remove_security_rating_review_from_live_measures_applications() throws SQLException { - insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); - insertMetric(SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - - String applicationUuid = insertComponent("APP"); - - insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid, applicationUuid); - - generateOtherMetricsLiveMeasures(applicationUuid); - - underTest.execute(); - - assertSecurityReviewRatingLiveMeasuresDeleted(); - - assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); - - // should not fail if called twice - underTest.execute(); - } - - @Test - public void not_fail_if_empty_tables() throws SQLException { - insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); - - underTest.execute(); - - assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isZero(); - } - - private void generateOtherMetricsLiveMeasures(String componentUuid) { - IntStream.range(0, OTHER_METRIC_MEASURES_COUNT) - .peek(i -> insertLiveMeasure("uuid-other-" + i, i, componentUuid, getRandomUuid())) - .boxed() - .collect(Collectors.toList()); - } - - private void assertSecurityReviewRatingLiveMeasuresDeleted() { - assertThat(db.countSql("select count(uuid) from LIVE_MEASURES where metric_id = " + SECURITY_REVIEW_RATING_METRIC_ID)) - .isZero(); - } - - private String getRandomUuid() { - return UUID.randomUUID().toString(); - } - - private void insertLiveMeasure(String uuid, int metricId, String projectUuid, String componentUuid) { - db.executeInsert("LIVE_MEASURES", - "UUID", uuid, - "PROJECT_UUID", projectUuid, - "COMPONENT_UUID", componentUuid, - "METRIC_ID", metricId, - "CREATED_AT", System.currentTimeMillis(), - "UPDATED_AT", System.currentTimeMillis()); - } - - private void insertMetric(int id, String name) { - db.executeInsert("METRICS", - "ID", id, - "NAME", name, - "DIRECTION", 0, - "QUALITATIVE", true); - } - - private String insertComponent(String qualifier) { - int id = nextInt(); - String uuid = getRandomUuid(); - db.executeInsert("COMPONENTS", - "ID", id, - "UUID", uuid, - "ORGANIZATION_UUID", "default", - "PROJECT_UUID", uuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", "PRJ", - "QUALIFIER", qualifier); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java deleted file mode 100644 index 56367eaf20e7d7106506ce6fcc331b8a6c0da1f9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.issue.Issue.STATUSES; - -public class DropSecurityHotSpotsInReviewStatusTest { - - private final static String ISSUES_TABLE_NAME = "issues"; - private final static int NUMBER_OF_ISSUES_IN_REVIEW = 3; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropSecurityHotSpotsInReviewStatusTest.class, "schema.sql"); - - private final System2 system2 = System2.INSTANCE; - - private final DataChange underTest = new DropSecurityHotSpotsInReviewStatus(db.database(), system2); - - @Test - public void should_change_IN_REVIEW_statuses_only() throws SQLException { - - Map statuses = IntStream.range(0, STATUSES.size()) - .boxed() - .collect(Collectors.toMap(Function.identity(), STATUSES::get)); - - statuses.forEach(this::insertIssue); - - int startIndex = STATUSES.size(); - int endIndex = startIndex + NUMBER_OF_ISSUES_IN_REVIEW; - IntStream.range(startIndex, endIndex).forEach(value -> insertIssue(value, "IN_REVIEW")); - - underTest.execute(); - - IntStream.range(startIndex, endIndex).forEach(this::assertIssueChanged); - - statuses.forEach(this::assertIssueNotChanged); - - // should not fail if executed twice - underTest.execute(); - } - - @Test - public void should_not_fail_if_no_issues() throws SQLException { - underTest.execute(); - assertThat(db.countRowsOfTable("issues")).isZero(); - } - - private void assertIssueChanged(int issueId) { - List> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId)); - assertThat(row).hasSize(1); - assertThat(row.get(0)) - .containsEntry("STATUS", "TO_REVIEW"); - - List> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" + - " from issue_changes where issue_key = '%s'", "issue-key-" + issueId)); - assertThat(changelogRows).hasSize(1); - - Map changelogRow = changelogRows.get(0); - assertThat(changelogRow) - .containsEntry("CHANGE_TYPE", "diff") - .containsEntry("CHANGE_DATA", "status=IN_REVIEW|TO_REVIEW"); - - assertThat(changelogRow.get("CREATED_AT")).isNotNull(); - assertThat(changelogRow.get("UPDATED_AT")).isNotNull(); - assertThat(changelogRow.get("ISSUE_CHANGE_CREATION_DATE")).isNotNull(); - } - - private void assertIssueNotChanged(int issueId, String expectedStatus) { - List> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId)); - assertThat(row).hasSize(1); - assertThat(row.get(0)) - .containsEntry("STATUS", expectedStatus); - - List> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" + - " from issue_changes where issue_key = '%s'", "issue-key-" + issueId)); - assertThat(changelogRows).isEmpty(); - } - - private void insertIssue(int issueId, String status) { - db.executeInsert(ISSUES_TABLE_NAME, - "kee", "issue-key-" + issueId, - "status", status, - "manual_severity", false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTableTest.java deleted file mode 100644 index 75be0e05e24f8e5259f5727732422137d19ec41a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTableTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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.v82.DropTagsColumnFromComponentsTable.COLUMNS_TO_DROP; -import static org.sonar.server.platform.db.migration.version.v82.DropTagsColumnFromComponentsTable.TABLE; - -public class DropTagsColumnFromComponentsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTagsColumnFromComponentsTableTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DropTagsColumnFromComponentsTable underTest = new DropTagsColumnFromComponentsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - for (String column : COLUMNS_TO_DROP) { - db.assertColumnDoesNotExist(TABLE, column); - } - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - for (String column : COLUMNS_TO_DROP) { - db.assertColumnDoesNotExist(TABLE, column); - } - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest.java deleted file mode 100644 index 7c1de3e3401209f136b47446f80ca173259d6ad9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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.Random; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.sonar.api.issue.Issue; -import org.sonar.api.rules.RuleType; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.issue.Issue.STATUS_OPEN; -import static org.sonar.api.issue.Issue.STATUS_TO_REVIEW; -import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT; - -@RunWith(DataProviderRunner.class) -public class EnsureHotspotDefaultStatusIsToReviewTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(EnsureHotspotDefaultStatusIsToReviewTest.class, "issues.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private Random random = new Random(); - - private EnsureHotspotDefaultStatusIsToReview underTest = new EnsureHotspotDefaultStatusIsToReview(db.database()); - - @Test - public void does_not_fail_if_table_is_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("issues")).isZero(); - } - - @Test - public void changes_OPEN_security_hotspot_to_TO_REVIEW_whatever_resolution() throws SQLException { - insertIssue("Kee_none", SECURITY_HOTSPOT, STATUS_OPEN, null); - Issue.RESOLUTIONS.forEach(resolution -> insertIssue("Kee_" + resolution, SECURITY_HOTSPOT, STATUS_OPEN, resolution)); - - underTest.execute(); - - assertThat(db.select("select distinct STATUS from issues").stream().map(t -> t.get("STATUS"))) - .containsExactly(STATUS_TO_REVIEW); - } - - @Test - @UseDataProvider("allStatusesButOpen") - public void changes_non_OPEN_security_hotspot_to_TO_REVIEW_whatever_resolution(String status) throws SQLException { - insertIssue("Kee_none", SECURITY_HOTSPOT, status, null); - Issue.RESOLUTIONS.forEach(resolution -> insertIssue("Kee_" + resolution, SECURITY_HOTSPOT, status, resolution)); - - underTest.execute(); - - assertThat(db.select("select distinct STATUS from issues").stream().map(t -> t.get("STATUS"))) - .containsExactly(status); - } - - @DataProvider - public static Object[][] allStatusesButOpen() { - return Issue.STATUSES.stream() - .filter(t -> !STATUS_OPEN.equals(t)) - .map(t -> new Object[] {t}) - .toArray(Object[][]::new); - } - - @Test - @UseDataProvider("allRuleTypeButHotspot") - public void does_not_change_OPEN_issues_to_TO_REVIEW_whatever_resolution(RuleType ruleType) throws SQLException { - insertIssue("Kee_none", ruleType, STATUS_OPEN, null); - Issue.RESOLUTIONS.forEach(resolution -> insertIssue("Kee_" + resolution, ruleType, STATUS_OPEN, resolution)); - - underTest.execute(); - - assertThat(db.select("select distinct STATUS from issues").stream().map(t -> t.get("STATUS"))) - .containsExactly(STATUS_OPEN); - } - - @DataProvider - public static Object[][] allRuleTypeButHotspot() { - return Arrays.stream(RuleType.values()) - .filter(t -> t != SECURITY_HOTSPOT) - .map(t -> new Object[] {t}) - .toArray(Object[][]::new); - } - - private void insertIssue(String kee, RuleType ruleType, String status, @Nullable String resolution) { - db.executeInsert( - "ISSUES", - "KEE", kee, - "MANUAL_SEVERITY", random.nextBoolean(), - "ISSUE_TYPE", ruleType.getDbConstant(), - "STATUS", status, - "RESOLUTION", resolution); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java deleted file mode 100644 index 678e837ffa6c6508d6f32f077b770c5a6b143dd7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.rules.RuleType.BUG; -import static org.sonar.api.rules.RuleType.CODE_SMELL; -import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT; -import static org.sonar.api.rules.RuleType.VULNERABILITY; - -public class MigrateManualVulnerabilitiesToSecurityHotSpotsTest { - - private final static String ISSUES_TABLE_NAME = "issues"; - private final static int TOTAL_NUMBER_OF_ISSUES = 9; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateManualVulnerabilitiesToSecurityHotSpotsTest.class, "schema.sql"); - - private final System2 system2 = System2.INSTANCE; - - private final DataChange underTest = new MigrateManualVulnerabilitiesToSecurityHotSpots(db.database(), system2); - - @Test - public void should_migrate_manual_vulnerabilities_only() throws SQLException { - Random random = new Random(); - List range = IntStream.range(0, TOTAL_NUMBER_OF_ISSUES).boxed() - .collect(Collectors.toCollection(ArrayList::new)); - Collections.shuffle(range); - - insertIssue(range.get(0), CODE_SMELL.getDbConstant(), random.nextBoolean()); - insertIssue(range.get(1), BUG.getDbConstant(), random.nextBoolean()); - insertIssue(range.get(2), VULNERABILITY.getDbConstant(), false); - insertIssue(range.get(3), SECURITY_HOTSPOT.getDbConstant(), random.nextBoolean()); - insertIssue(range.get(4), -1, random.nextBoolean()); - - insertIssue(range.get(5), VULNERABILITY.getDbConstant(), true); - insertIssue(range.get(6), VULNERABILITY.getDbConstant(), true); - insertIssue(range.get(7), VULNERABILITY.getDbConstant(), true); - insertIssue(range.get(8), VULNERABILITY.getDbConstant(), true); - - underTest.execute(); - - assertIssueNotChanged(range.get(0), CODE_SMELL.getDbConstant()); - assertIssueNotChanged(range.get(1), BUG.getDbConstant()); - assertIssueNotChanged(range.get(2), VULNERABILITY.getDbConstant()); - assertIssueNotChanged(range.get(3), SECURITY_HOTSPOT.getDbConstant()); - assertIssueNotChanged(range.get(4), -1); - - assertIssueChanged(range.get(5)); - assertIssueChanged(range.get(6)); - assertIssueChanged(range.get(7)); - assertIssueChanged(range.get(8)); - - // should not fail if executed twice - underTest.execute(); - } - - @Test - public void should_not_fail_if_no_issues() throws SQLException { - underTest.execute(); - assertThat(db.countRowsOfTable("issues")).isZero(); - } - - private void assertIssueChanged(int issueId) { - List> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId)); - assertThat(row).hasSize(1); - assertThat(row.get(0)) - .containsEntry("STATUS", "TO_REVIEW"); - - List> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" + - " from issue_changes where issue_key = '%s'", "issue-key-" + issueId)); - assertThat(changelogRows).hasSize(1); - - Map changelogRow = changelogRows.get(0); - assertThat(changelogRow) - .containsEntry("CHANGE_TYPE", "diff") - .containsEntry("CHANGE_DATA", "type=VULNERABILITY|SECURITY_HOTSPOT,status=OPEN|TO_REVIEW"); - - assertThat(changelogRow.get("CREATED_AT")).isNotNull(); - assertThat(changelogRow.get("UPDATED_AT")).isNotNull(); - assertThat(changelogRow.get("ISSUE_CHANGE_CREATION_DATE")).isNotNull(); - } - - private void assertIssueNotChanged(int issueId, int expectedType) { - List> row = db.select(String.format("select issue_type, status from issues where kee = '%s'", "issue-key-" + issueId)); - assertThat(row).hasSize(1); - - Map issueData = row.get(0); - assertThat(issueData.get("STATUS")) - .isNull(); - assertThat(issueData) - .containsEntry("ISSUE_TYPE", expectedType); - - List> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" + - " from issue_changes where issue_key = '%s'", "issue-key-" + issueId)); - assertThat(changelogRows).isEmpty(); - } - - private void insertIssue(int issueId, int issueType, boolean fromHotspot) { - db.executeInsert(ISSUES_TABLE_NAME, - "kee", "issue-key-" + issueId, - "issue_type", issueType, - "from_hotspot", fromHotspot, - "manual_severity", false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTableTest.java deleted file mode 100644 index 0bdc458992c1fb2ded837b3468449ee127b65b5c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTableTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -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.Before; -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 org.sonar.server.platform.db.migration.step.DataChange; - -import static org.apache.commons.lang.math.RandomUtils.nextInt; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateProjectsTableTest { - - private static final String TABLE_COMPONENTS = "components"; - private static final String TABLE_PROJECTS = "projects"; - 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); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectsTableTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DataChange underTest = new PopulateProjectsTable(db.database(), system2); - - @Before - public void setup() { - insertComponent("uuid-1", "PRJ", "TRK", null); - insertComponent("uuid-2", "PRJ", "VW", null); - insertComponent("uuid-3", "PRJ", "SVW", null); - insertComponent("uuid-4", "PRJ", "APP", null); - insertComponent("uuid-5", "PRJ", "TRK", null); - insertComponent("uuid-6", "FIL", "FIL", null); - insertComponent("uuid-5-branch", "PRJ", "TRK", "uuid-5"); - } - - @Test - public void migrate() throws SQLException { - underTest.execute(); - - verifyMigrationResult(); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - verifyMigrationResult(); - } - - private void verifyMigrationResult() { - assertThat(db.countRowsOfTable(TABLE_COMPONENTS)).isEqualTo(7); - assertThat(db.countRowsOfTable(TABLE_PROJECTS)).isEqualTo(3); - - assertThat(db.select("select UUID, KEE, QUALIFIER, ORGANIZATION_UUID, NAME, DESCRIPTION, PRIVATE, TAGS, CREATED_AT, UPDATED_AT from " + TABLE_PROJECTS) - .stream() - .map(e -> new Tuple( - e.get("UUID"), - e.get("KEE"), - e.get("QUALIFIER"), - e.get("ORGANIZATION_UUID"), - e.get("NAME"), - e.get("DESCRIPTION"), - e.get("PRIVATE"), - e.get("TAGS"), - e.get("CREATED_AT"), - e.get("UPDATED_AT"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder( - new Tuple("uuid-1", "uuid-1-key", "TRK", "default", "uuid-1-name", "uuid-1-description", false, "uuid-1-tags", PAST, 50_000_000_000L), - new Tuple("uuid-5", "uuid-5-key", "TRK", "default", "uuid-5-name", "uuid-5-description", false, "uuid-5-tags", PAST, 50_000_000_000L), - new Tuple("uuid-4", "uuid-4-key", "APP", "default", "uuid-4-name", "uuid-4-description", false, "uuid-4-tags", PAST, 50_000_000_000L)); - } - - private void insertComponent(String uuid, String scope, String qualifier, @Nullable String mainBranchProjectUuid) { - int id = nextInt(); - db.executeInsert("COMPONENTS", - "ID", id, - "NAME", uuid + "-name", - "DESCRIPTION", uuid + "-description", - "ORGANIZATION_UUID", "default", - "TAGS", uuid + "-tags", - "CREATED_AT", new Date(PAST), - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", mainBranchProjectUuid, - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", scope, - "QUALIFIER", qualifier); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest.java deleted file mode 100644 index d952da29c7a3b018b1783220a61140655f7c8e21..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import java.time.Instant; -import java.util.Random; -import java.util.UUID; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.lang.String.format; -import static org.junit.Assert.assertEquals; - -public class RemoveNewsboxDismissHotspotsPropertyTest { - - private static final String USER_PROPERTIES_TABLE_NAME = "user_properties"; - private static final int TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES = 10; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveNewsboxDismissHotspotsPropertyTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private Random random = new Random(); - - private RemoveNewsboxDismissHotspotsProperty underTest = new RemoveNewsboxDismissHotspotsProperty(dbTester.database()); - - @Before - public void setup() { - insertUserProperty("some-user-uuid", "some-property", random.nextBoolean()); - - for (int i = 1; i <= TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES; i++) { - insertUserProperty(format("user-uuid-%s", i), "newsbox.dismiss.hotspots", random.nextBoolean()); - } - - int propertiesCount = dbTester.countRowsOfTable(USER_PROPERTIES_TABLE_NAME); - assertEquals(TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES + 1, propertiesCount); - } - - @Test - public void remove_newsbox_dismiss_hotspot_property() throws SQLException { - underTest.execute(); - - verifyResult(); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - verifyResult(); - } - - private void verifyResult() { - int hotspotDismissPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee = 'newsbox.dismiss.hotspots'"); - assertEquals(0, hotspotDismissPropertiesCount); - int otherPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee != 'newsbox.dismiss.hotspots'"); - assertEquals(1, otherPropertiesCount); - } - - private void insertUserProperty(String userUuid, String key, boolean value) { - dbTester.executeInsert(USER_PROPERTIES_TABLE_NAME, - "uuid", UUID.randomUUID().toString(), - "kee", key, - "user_uuid", userUuid, - "text_value", value, - "created_at", Instant.now().toEpochMilli(), - "updated_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponentsTest.java deleted file mode 100644 index 8602186a18be69cbf7a3e86327c7c9b02249b350..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponentsTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v82; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class RenameProjectsTableToComponentsTest { - private static final String OLD_TABLE_NAME = "projects"; - private static final String NEW_TABLE_NAME = "components"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RenameProjectsTableToComponentsTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private RenameProjectsTableToComponents underTest = new RenameProjectsTableToComponents(dbTester.database()); - - @Test - public void table_has_been_renamed() throws SQLException { - underTest.execute(); - - dbTester.assertTableDoesNotExist(OLD_TABLE_NAME); - - dbTester.assertTableExists(NEW_TABLE_NAME); - dbTester.assertPrimaryKey(NEW_TABLE_NAME, "pk_projects", "id"); - - dbTester.assertIndex(NEW_TABLE_NAME, "PROJECTS_ORGANIZATION", "organization_uuid"); - dbTester.assertUniqueIndex(NEW_TABLE_NAME, "PROJECTS_KEE", "kee"); - dbTester.assertIndex(NEW_TABLE_NAME, "PROJECTS_ROOT_UUID", "root_uuid"); - dbTester.assertUniqueIndex(NEW_TABLE_NAME, "PROJECTS_UUID", "uuid"); - dbTester.assertIndex(NEW_TABLE_NAME, "PROJECTS_PROJECT_UUID", "project_uuid"); - dbTester.assertIndex(NEW_TABLE_NAME, "PROJECTS_MODULE_UUID", "module_uuid"); - dbTester.assertIndex(NEW_TABLE_NAME, "PROJECTS_QUALIFIER", "qualifier"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/AddSummaryEnabledColumnToAlmSettingsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/AddSummaryEnabledColumnToAlmSettingsTest.java deleted file mode 100644 index 3afab81354c87b693faae302e0d60039879ea7a1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/AddSummaryEnabledColumnToAlmSettingsTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.sql.Types.BOOLEAN; -import static org.assertj.core.api.Assertions.assertThat; - -public class AddSummaryEnabledColumnToAlmSettingsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddSummaryEnabledColumnToAlmSettingsTest.class, "schema.sql"); - - private DdlChange underTest = new AddSummaryEnabledColumnToAlmSettings(db.database()); - - @Before - public void setup() { - insertProjectAlmSetting("1"); - insertProjectAlmSetting("2"); - insertProjectAlmSetting("3"); - insertProjectAlmSetting("4"); - insertProjectAlmSetting("5"); - } - - @Test - public void should_add_summary_comment_enabled_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_alm_settings", "summary_comment_enabled", BOOLEAN, null, true); - - assertThat(db.countSql("select count(uuid) from project_alm_settings where summary_comment_enabled is null")) - .isEqualTo(5); - } - - private void insertProjectAlmSetting(String uuid) { - db.executeInsert("PROJECT_ALM_SETTINGS", - "UUID", uuid, - "ALM_SETTING_UUID", uuid + "-name", - "PROJECT_UUID", uuid + "-description", - "UPDATED_AT", System2.INSTANCE.now(), - "CREATED_AT", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83Test.java deleted file mode 100644 index 7305a852b83129bb5cd1a083079ef8921b79aeaa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83; - -import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion83Test { - - private DbVersion underTest = new DbVersion83(); - - @Test - public void migrationNumber_starts_at_3300() { - verifyMinimumMigrationNumber(underTest, 3300); - } - - @Test - public void verify_migration_count() { - verifyMigrationNotEmpty(underTest); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java deleted file mode 100644 index c34f9cd998681f0f7c9b3e01be9deac15e599442..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83; - -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.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; - -import static java.sql.Types.INTEGER; -import static org.sonar.server.platform.db.migration.version.v83.DropIdFromComponentsTable.COLUMN_NAME; -import static org.sonar.server.platform.db.migration.version.v83.DropIdFromComponentsTable.TABLE_NAME; - -public class DropIdFromComponentsTableTest { - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIdFromComponentsTableTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(dbTester.database(), new DbPrimaryKeyConstraintFinder(dbTester.database())); - private final DropIdFromComponentsTable underTest = new DropIdFromComponentsTable(dbTester.database(), dropPrimaryKeySqlGenerator); - - @Test - public void column_has_been_dropped() throws SQLException { - dbTester.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, INTEGER, null, false); - underTest.execute(); - dbTester.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest.java deleted file mode 100644 index 3d7217bc538459381404d281d1d3441501428b28..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateSummaryCommentEnabledColumnForGitHubTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateSummaryCommentEnabledColumnForGitHubTest.class, "schema.sql"); - - private final System2 system = System2.INSTANCE; - - private final DataChange underTest = new PopulateSummaryCommentEnabledColumnForGitHub(db.database(), system); - - @Test - public void does_not_fail_if_alm_settings_are_empty() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(uuid) from project_alm_settings where summary_comment_enabled is null")) - .isZero(); - - // re-entrant migration - underTest.execute(); - } - - @Test - public void does_not_set_comment_summary_enabled_flag_for_alms_other_than_github() throws SQLException { - insertAlmSetting("alm-bitbucket", "bitbucket"); - insertAlmSetting("alm-azure", "azure"); - insertAlmSetting("alm-gitlab", "gitlab"); - - insertProjectAlmSetting("project-alm-1", "alm-bitbucket"); - insertProjectAlmSetting("project-alm-2", "alm-bitbucket"); - insertProjectAlmSetting("project-alm-3", "alm-azure"); - insertProjectAlmSetting("project-alm-4", "alm-azure"); - insertProjectAlmSetting("project-alm-5", "alm-azure"); - insertProjectAlmSetting("project-alm-6", "alm-gitlab"); - - underTest.execute(); - - verifySummaryColumnForProjectAlmSettings(null, "project-alm-1", "project-alm-2", "project-alm-3", - "project-alm-4", "project-alm-5", "project-alm-6"); - } - - @Test - public void set_comment_summary_enabled_flag_to_true_for_github_alm_only() throws SQLException { - insertAlmSetting("alm-github", "github"); - insertAlmSetting("alm-azure", "azure"); - insertAlmSetting("alm-gitlab", "gitlab"); - - insertProjectAlmSetting("project-alm-1", "alm-bitbucket"); - insertProjectAlmSetting("project-alm-2", "alm-bitbucket"); - insertProjectAlmSetting("project-alm-3", "alm-github"); - insertProjectAlmSetting("project-alm-4", "alm-github"); - insertProjectAlmSetting("project-alm-5", "alm-github"); - insertProjectAlmSetting("project-alm-6", "alm-github"); - insertProjectAlmSetting("project-alm-7", "alm-gitlab"); - - underTest.execute(); - - verifySummaryColumnForProjectAlmSettings(null, "project-alm-1", "project-alm-2", "project-alm-7"); - verifySummaryColumnForProjectAlmSettings(true, "project-alm-3", "project-alm-4", "project-alm-5", "project-alm-6"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertAlmSetting("alm-github", "github"); - insertAlmSetting("alm-azure", "azure"); - insertAlmSetting("alm-gitlab", "gitlab"); - - insertProjectAlmSetting("project-alm-1", "alm-bitbucket"); - insertProjectAlmSetting("project-alm-2", "alm-github"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifySummaryColumnForProjectAlmSettings(null, "project-alm-1"); - verifySummaryColumnForProjectAlmSettings(true, "project-alm-2"); - } - - private void verifySummaryColumnForProjectAlmSettings(@Nullable Boolean expectedSummarColumnValue, String... projectUuids) { - assertThat(db.select("select uuid, summary_comment_enabled from project_alm_settings") - .stream() - .filter(rowColumns -> Objects.equals(expectedSummarColumnValue, getBooleanValue(rowColumns.get("SUMMARY_COMMENT_ENABLED")))) - .map(row -> row.get("UUID")) - .collect(Collectors.toList())) - .containsExactly(projectUuids); - } - - private Boolean getBooleanValue(@Nullable Object value) { - return value == null ? null : Boolean.parseBoolean(value.toString()); - } - - private void insertProjectAlmSetting(String uuid, String almSettingsUuid) { - db.executeInsert("PROJECT_ALM_SETTINGS", - "UUID", uuid, - "ALM_SETTING_UUID", almSettingsUuid, - "PROJECT_UUID", uuid + "-description", - "UPDATED_AT", system.now(), - "CREATED_AT", system.now()); - } - - private void insertAlmSetting(String uuid, String almId) { - db.executeInsert("ALM_SETTINGS", - "UUID", uuid, - "ALM_ID", almId, - "KEE", uuid + "-key", - "UPDATED_AT", system.now(), - "CREATED_AT", system.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRolesTest.java deleted file mode 100644 index 5343f90048f9c83083c4b464b13e93febd37f4ac..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRolesTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddComponentUuidColumnToGroupRolesTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddComponentUuidColumnToGroupRolesTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddComponentUuidColumnToGroupRoles underTest = new AddComponentUuidColumnToGroupRoles(dbTester.database()); - - @Test - public void column_has_been_created() throws SQLException { - underTest.execute(); - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertColumnDefinition(TABLE_NAME, "component_uuid", VARCHAR, 40, true); - dbTester.assertIndex(TABLE_NAME, "group_roles_component_uuid", "component_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTableTest.java deleted file mode 100644 index d6ba640f1a1b1f0fedfc8e352134cea2343802bc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.INTEGER; - -public class DropResourceIdFromGroupRolesTableTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropResourceIdFromGroupRolesTableTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DropResourceIdFromGroupRolesTable underTest = new DropResourceIdFromGroupRolesTable(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - dbTester.assertColumnDefinition(TABLE_NAME, "resource_id", INTEGER, null, true); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_id", "resource_id", "role"); - dbTester.assertIndex(TABLE_NAME, "group_roles_resource", "resource_id"); - - underTest.execute(); - dbTester.assertColumnDoesNotExist(TABLE_NAME, "resource_id"); - dbTester.assertIndexDoesNotExist(TABLE_NAME, "group_roles_resource"); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_id", "component_uuid", "role"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRolesTest.java deleted file mode 100644 index b0e9037aca2cf25bc1ef8ddb004fd0afd4312e13..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRolesTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import java.util.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.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrateResourceIdToUuidInGroupRolesTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MigrateResourceIdToUuidInGroupRolesTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrateResourceIdToUuidInGroupRoles underTest = new MigrateResourceIdToUuidInGroupRoles(dbTester.database()); - private int id = 1; - - @Test - public void data_has_been_migrated() throws SQLException { - insertComponent(1, "uuid1"); - insertRole(1); - insertRole(2); - insertRole(null); - - underTest.execute(); - assertThat(dbTester.select("select ID, RESOURCE_ID, COMPONENT_UUID, GROUP_ID from " + TABLE_NAME).stream() - .map(e -> new Tuple(e.get("ID"), e.get("RESOURCE_ID"), e.get("COMPONENT_UUID"), e.get("GROUP_ID"))) - .collect(Collectors.toList())).containsExactlyInAnyOrder( - new Tuple(1L, 1L, "uuid1", 1L), - new Tuple(3L, null, null, 1L)); - - // reentrant - underTest.execute(); - } - - private void insertRole(@Nullable Integer resourceId) { - dbTester.executeInsert(TABLE_NAME, - "id", id++, - "organization_uuid", "org", - "group_id", 1, - "resource_id", resourceId, - "role", "role"); - } - - private void insertComponent(int id, String uuid) { - dbTester.executeInsert("COMPONENTS", - "ID", id, - "NAME", uuid + "-name", - "DESCRIPTION", uuid + "-description", - "ORGANIZATION_UUID", "default", - "CREATED_AT", new Date(1000L), - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", "project_uuid", - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", "TRK", - "QUALIFIER", "PRJ"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToPropertiesTest.java deleted file mode 100644 index d8dbfec110709c0cc9c88535eb4cd36509410aa8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToPropertiesTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddComponentUuidColumnToPropertiesTest { - private static final String TABLE_NAME = "properties"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddComponentUuidColumnToPropertiesTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddComponentUuidColumnToProperties underTest = new AddComponentUuidColumnToProperties(dbTester.database()); - - @Test - public void column_has_been_created() throws SQLException { - underTest.execute(); - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertColumnDefinition(TABLE_NAME, "component_uuid", VARCHAR, 40, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTableTest.java deleted file mode 100644 index df6f25a6c236b37bdc6a9faea88591d13cff0622..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTableTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.BIGINT; - -public class DropResourceIdFromPropertiesTableTest { - private static final String TABLE_NAME = "properties"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropResourceIdFromPropertiesTableTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DropResourceIdFromPropertiesTable underTest = new DropResourceIdFromPropertiesTable(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - dbTester.assertColumnDefinition(TABLE_NAME, "resource_id", BIGINT, null, true); - underTest.execute(); - dbTester.assertColumnDoesNotExist(TABLE_NAME, "resource_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInPropertiesTest.java deleted file mode 100644 index 63216816e25224d5003f38adf62d5fc6a2a6e48f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInPropertiesTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import java.util.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.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrateResourceIdToUuidInPropertiesTest { - private static final String TABLE_NAME = "properties"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MigrateResourceIdToUuidInPropertiesTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrateResourceIdToUuidInProperties underTest = new MigrateResourceIdToUuidInProperties(dbTester.database()); - private int id = 1; - - @Test - public void data_has_been_migrated() throws SQLException { - insertComponent(1, "uuid1"); - insertProperty(1); - insertProperty(2); - insertProperty(null); - - underTest.execute(); - assertThat(dbTester.select("select ID, RESOURCE_ID, COMPONENT_UUID, PROP_KEY, TEXT_VALUE from " + TABLE_NAME).stream() - .map(e -> new Tuple(e.get("ID"), e.get("RESOURCE_ID"), e.get("COMPONENT_UUID"), e.get("PROP_KEY"), e.get("TEXT_VALUE"))) - .collect(Collectors.toList())).containsExactlyInAnyOrder( - new Tuple(1L, 1L, "uuid1", "key", "value"), - new Tuple(3L, null, null, "key", "value")); - - // reentrant - underTest.execute(); - } - - private void insertProperty(@Nullable Integer resourceId) { - dbTester.executeInsert(TABLE_NAME, - "id", id++, - "prop_key", "key", - "resource_id", resourceId, - "is_empty", false, - "text_value", "value", - "created_at", 1000L); - } - - private void insertComponent(int id, String uuid) { - dbTester.executeInsert("COMPONENTS", - "ID", id, - "NAME", uuid + "-name", - "DESCRIPTION", uuid + "-description", - "ORGANIZATION_UUID", "default", - "CREATED_AT", new Date(1000L), - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", "project_uuid", - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", "TRK", - "QUALIFIER", "PRJ"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRolesTest.java deleted file mode 100644 index 6d0722f0527e2aafe91708f7fff5b2bb55967184..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRolesTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.VARCHAR; - -public class AddComponentUuidColumnToUserRolesTest { - private static final String TABLE_NAME = "user_roles"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddComponentUuidColumnToUserRolesTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddComponentUuidColumnToUserRoles underTest = new AddComponentUuidColumnToUserRoles(dbTester.database()); - - @Test - public void column_has_been_created() throws SQLException { - underTest.execute(); - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertColumnDefinition(TABLE_NAME, "component_uuid", VARCHAR, 40, true); - dbTester.assertIndex(TABLE_NAME, "user_roles_component_uuid", "component_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropResourceIdFromUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropResourceIdFromUserRolesTableTest.java deleted file mode 100644 index eff5695ecd1111631a172ab586677ca51035f3d6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropResourceIdFromUserRolesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.INTEGER; - -public class DropResourceIdFromUserRolesTableTest { - private static final String TABLE_NAME = "user_roles"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropResourceIdFromUserRolesTableTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private DropResourceIdFromUserRolesTable underTest = new DropResourceIdFromUserRolesTable(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - dbTester.assertColumnDefinition(TABLE_NAME, "resource_id", INTEGER, null, true); - dbTester.assertIndex(TABLE_NAME, "user_roles_resource", "resource_id"); - - underTest.execute(); - dbTester.assertColumnDoesNotExist(TABLE_NAME, "resource_id"); - dbTester.assertIndexDoesNotExist(TABLE_NAME, "user_roles_resource"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRolesTest.java deleted file mode 100644 index e2c31bcfee041f47b635623887a59dd07898c701..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRolesTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import java.sql.SQLException; -import 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.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrateResourceIdToUuidInUserRolesTest { - private static final String TABLE_NAME = "user_roles"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(MigrateResourceIdToUuidInUserRolesTest.class, "schema.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrateResourceIdToUuidInUserRoles underTest = new MigrateResourceIdToUuidInUserRoles(dbTester.database()); - private int id = 1; - - @Test - public void data_has_been_migrated() throws SQLException { - insertComponent(1, "uuid1"); - insertRole(1); - insertRole(2); - insertRole(null); - - underTest.execute(); - assertThat(dbTester.select("select ID, RESOURCE_ID, COMPONENT_UUID, USER_ID from " + TABLE_NAME).stream() - .map(e -> new Tuple(e.get("ID"), e.get("RESOURCE_ID"), e.get("COMPONENT_UUID"), e.get("USER_ID"))) - .collect(Collectors.toList())).containsExactlyInAnyOrder( - new Tuple(1L, 1L, "uuid1", 1L), - new Tuple(3L, null, null, 1L)); - - // reentrant - underTest.execute(); - } - - private void insertRole(@Nullable Integer resourceId) { - dbTester.executeInsert(TABLE_NAME, - "id", id++, - "organization_uuid", "org", - "user_id", 1, - "resource_id", resourceId, - "role", "role"); - } - - private void insertComponent(int id, String uuid) { - dbTester.executeInsert("COMPONENTS", - "ID", id, - "NAME", uuid + "-name", - "DESCRIPTION", uuid + "-description", - "ORGANIZATION_UUID", "default", - "CREATED_AT", new Date(1000L), - "KEE", uuid + "-key", - "UUID", uuid, - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", "project_uuid", - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", "TRK", - "QUALIFIER", "PRJ"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSyncTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSyncTest.java deleted file mode 100644 index cc5b451ad253755400377fd34c815fb93c9ef39b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSyncTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddProjectBranchesNeedIssueSyncTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddProjectBranchesNeedIssueSyncTest.class, "schema.sql"); - - private DdlChange underTest = new AddProjectBranchesNeedIssueSync(db.database()); - - @Before - public void setup() { - insertProjectBranches("uuid-1"); - insertProjectBranches("uuid-2"); - insertProjectBranches("uuid-3"); - } - - @Test - public void add_need_issue_sync_column_to_project_branches() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_branches", "need_issue_sync", Types.BOOLEAN, null, true); - - assertThat(db.countSql("select count(uuid) from project_branches")) - .isEqualTo(3); - } - - private void insertProjectBranches(String uuid) { - db.executeInsert("project_branches", - "uuid", uuid, - "project_uuid", "name", - "kee", uuid, - "key_type", "KEY_TYPE", - "created_at", System.currentTimeMillis(), - "updated_at", System.currentTimeMillis(), - "exclude_from_purge", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/CreateSamlMessageIdsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/CreateSamlMessageIdsTableTest.java deleted file mode 100644 index 12f2c4cb616397149a3fbfe6f7a3130523ff25e7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/CreateSamlMessageIdsTableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import 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.BIGINT; -import static java.sql.Types.VARCHAR; - -public class CreateSamlMessageIdsTableTest { - - private static final String TABLE_NAME = "saml_message_ids"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateSamlMessageIdsTable underTest = new CreateSamlMessageIdsTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_saml_message_ids", "uuid"); - dbTester.assertUniqueIndex(TABLE_NAME, "saml_message_ids_unique", "message_id"); - - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "message_id", VARCHAR, 255, false); - dbTester.assertColumnDefinition(TABLE_NAME, "expiration_date", BIGINT, 20, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, 20, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/CreateSessionTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/CreateSessionTokensTableTest.java deleted file mode 100644 index db53874c35a84b06fb1ad459ff6554902a88a322..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/CreateSessionTokensTableTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import 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.BIGINT; -import static java.sql.Types.VARCHAR; - -public class CreateSessionTokensTableTest { - - private static final String TABLE_NAME = "session_tokens"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateSessionTokensTable underTest = new CreateSessionTokensTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_session_tokens", "uuid"); - dbTester.assertIndex(TABLE_NAME, "session_tokens_user_uuid", "user_uuid"); - - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "user_uuid", VARCHAR, 255, false); - dbTester.assertColumnDefinition(TABLE_NAME, "expiration_date", BIGINT, 20, false); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", BIGINT, 20, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, 20, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84Test.java deleted file mode 100644 index 45043396fa5561bc8d5c7903a55dac039b2fae2e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion84Test { - - private DbVersion underTest = new DbVersion84(); - - @Test - public void migrationNumber_starts_at_3400() { - verifyMinimumMigrationNumber(underTest, 3400); - } - - @Test - public void verify_migration_count() { - verifyMigrationNotEmpty(underTest); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/MakeProjectBranchesNeedIssueSyncNonNullTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/MakeProjectBranchesNeedIssueSyncNonNullTest.java deleted file mode 100644 index 9beee77bf2092377ba17cc6a69bc5558aa52c0fe..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/MakeProjectBranchesNeedIssueSyncNonNullTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.BOOLEAN; - -public class MakeProjectBranchesNeedIssueSyncNonNullTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectBranchesNeedIssueSyncNonNullTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectBranchesNeedIssueSyncNonNull(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_branches", "need_issue_sync", BOOLEAN, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/PopulateProjectBranchesNeedIssueSyncTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/PopulateProjectBranchesNeedIssueSyncTest.java deleted file mode 100644 index 2b11a02ce919fc69227ffbec9fbc9fc5e5e11ac1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/PopulateProjectBranchesNeedIssueSyncTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateProjectBranchesNeedIssueSyncTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectBranchesNeedIssueSyncTest.class, "schema.sql"); - - private DataChange underTest = new PopulateProjectBranchesNeedIssueSync(db.database()); - - @Test - public void populate_need_issue_sync() throws SQLException { - insertProjectBranches("uuid-1"); - insertProjectBranches("uuid-2"); - insertProjectBranches("uuid-3"); - - underTest.execute(); - - verifyNeedIssueSyncIsNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProjectBranches("uuid-1"); - insertProjectBranches("uuid-2"); - insertProjectBranches("uuid-3"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyNeedIssueSyncIsNotNull(); - } - - private void verifyNeedIssueSyncIsNotNull() { - assertThat(db.select("select need_issue_sync from project_branches where need_issue_sync is null")).isEmpty(); - } - - private void insertProjectBranches(String uuid) { - db.executeInsert("project_branches", - "uuid", uuid, - "project_uuid", "name", - "kee", uuid, - "key_type", "KEY_TYPE", - "created_at", System.currentTimeMillis(), - "updated_at", System.currentTimeMillis(), - "exclude_from_purge", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest.java deleted file mode 100644 index 26074f4ccb35d103711a66b27da5c80043c9319f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84; - -import java.sql.SQLException; -import java.time.Instant; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.DIRECTORY; -import static org.sonar.api.resources.Qualifiers.FILE; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; - -public class RemoveFilesFavouritesFromPropertiesTest { - - private static final String PROPERTIES_TABLE_NAME = "properties"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveFilesFavouritesFromPropertiesTest.class, "schema.sql"); - - private final DataChange underTest = new RemoveFilesFavouritesFromProperties(dbTester.database()); - - private static final String APPLICATION_UUID_1 = Uuids.createFast(); - private static final String PROJECT_UUID_2 = Uuids.createFast(); - private static final String FILE_UUID_3 = Uuids.createFast(); - private static final String DIRECTORY_UUID_4 = Uuids.createFast(); - private static final String UNIT_TEST_FILE_UUID_5 = Uuids.createFast(); - - private static final String USER_UUID_1 = "1"; - private static final String USER_UUID_2 = "2"; - - @Before - public void setup() { - insertComponent(APPLICATION_UUID_1, APP); - insertComponent(PROJECT_UUID_2, PROJECT); - insertComponent(FILE_UUID_3, FILE); - insertComponent(DIRECTORY_UUID_4, DIRECTORY); - insertComponent(UNIT_TEST_FILE_UUID_5, UNIT_TEST_FILE); - - insertProperty("1", USER_UUID_1, APPLICATION_UUID_1, "test"); - insertProperty("2", USER_UUID_2, PROJECT_UUID_2, "test2"); - insertProperty("3", USER_UUID_2, null, "test3"); - } - - @Test - public void migrate() throws SQLException { - insertProperty("4", USER_UUID_1, APPLICATION_UUID_1, "favourite"); - // properties to remove - insertProperty("5", USER_UUID_1, FILE_UUID_3, "favourite"); - insertProperty("6", USER_UUID_2, FILE_UUID_3, "favourite"); - insertProperty("7", USER_UUID_2, DIRECTORY_UUID_4, "favourite"); - insertProperty("8", USER_UUID_2, UNIT_TEST_FILE_UUID_5, "favourite"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isEqualTo(4); - assertThat(dbTester.select("select uuid from properties").stream().map(columns -> columns.get("UUID"))) - .containsOnly("1", "2", "3", "4"); - } - - @Test - public void properties_table_empty() throws SQLException { - dbTester.executeUpdateSql("delete from properties"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isZero(); - } - - @Test - public void does_not_remove_properties_with_key_other_than_favourite() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isEqualTo(3L); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - insertProperty("4", USER_UUID_1, APPLICATION_UUID_1, "favourite"); - // properties to remove - insertProperty("5", USER_UUID_1, FILE_UUID_3, "favourite"); - insertProperty("6", USER_UUID_2, FILE_UUID_3, "favourite"); - - underTest.execute(); - - insertProperty("7", USER_UUID_2, DIRECTORY_UUID_4, "favourite"); - insertProperty("8", USER_UUID_2, UNIT_TEST_FILE_UUID_5, "favourite"); - - // re-entrant - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isEqualTo(4); - assertThat(dbTester.select("select uuid from properties").stream().map(columns -> columns.get("UUID"))) - .containsOnly("1", "2", "3", "4"); - } - - private void insertComponent(String uuid, String qualifier) { - dbTester.executeInsert("COMPONENTS", - "UUID", uuid, - "NAME", uuid + "-name", - "DESCRIPTION", uuid + "-description", - "ORGANIZATION_UUID", "default", - "KEE", uuid + "-key", - "PROJECT_UUID", uuid, - "MAIN_BRANCH_PROJECT_UUID", "project_uuid", - "UUID_PATH", ".", - "ROOT_UUID", uuid, - "PRIVATE", Boolean.toString(false), - "SCOPE", "TRK", - "QUALIFIER", qualifier); - } - - private void insertProperty(String id, String userUuid, @Nullable String componentUuid, String propKey) { - dbTester.executeInsert(PROPERTIES_TABLE_NAME, - "uuid", id, - "user_uuid", userUuid, - "component_uuid", componentUuid, - "prop_key", propKey, - "is_empty", true, - "created_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index f15270d80ae49e4b948e13125347eb1b901138d1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("active_rule_parameters", "pk_active_rule_parameters", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java deleted file mode 100644 index e6a0c8cc41fd58cb747eef161ea67fb3be8fe124..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToActiveRuleParametersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToActiveRuleParametersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToActiveRuleParametersTable(db.database()); - - @Before - public void setup() { - insertActiveRuleParameter(1L); - insertActiveRuleParameter(2L); - insertActiveRuleParameter(3L); - } - - @Test - public void add_uuid_column_to_active_rule_parameters() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from active_rule_parameters")) - .isEqualTo(3); - } - - private void insertActiveRuleParameter(Long id) { - db.executeInsert("active_rule_parameters", - "id", id, - "active_rule_id", id + 2, - "rules_parameter_id", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index 38cd164e08ca912e0550624d04d8a81e5d9190dd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfActiveRuleParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rule_parameters", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index c30ebc2258448a234e4eaa114c2340a32eedd284..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest { - - private static final String TABLE_NAME = "active_rule_parameters"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java deleted file mode 100644 index acb1c4f63c2b652a96c6f1861f16c31f4f9d3224..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRuleParametersUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRuleParametersUuidColumnNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest.java deleted file mode 100644 index 4a8fc8a38975daacc8fe3683964de6938cd1467d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateActiveRuleParametersUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateActiveRuleParametersUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertActiveRuleParameter(1L); - insertActiveRuleParameter(2L); - insertActiveRuleParameter(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertActiveRuleParameter(1L); - insertActiveRuleParameter(2L); - insertActiveRuleParameter(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from active_rule_parameters") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertActiveRuleParameter(Long id) { - db.executeInsert("active_rule_parameters", - "id", id, - "active_rule_id", id + 2, - "rules_parameter_id", id + 3); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java deleted file mode 100644 index de735db7f59d1fa4656c79bbfc3331b3727caf36..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddActiveRuleUuidColumnToActiveRuleParametersTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddActiveRuleUuidColumnToActiveRuleParametersTest.class, "schema.sql"); - private DdlChange underTest = new AddActiveRuleUuidColumnToActiveRuleParameters(db.database()); - - @Before - public void setup() { - insertActiveRuleParameter(1L); - insertActiveRuleParameter(2L); - insertActiveRuleParameter(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "active_rule_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("active_rule_parameters")) - .isEqualTo(3); - } - - private void insertActiveRuleParameter(Long id) { - db.executeInsert("active_rule_parameters", - "uuid", "uuid" + id, - "rules_parameter_id", id, - "value", "value" + id, - "active_rule_id", id + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java deleted file mode 100644 index 2c2e6df5e7dcfcf93c5fe7079fd1d6b87db4f18d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnActiveRuleUuidOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("active_rule_parameters", "arp_active_rule_uuid", "active_rule_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("active_rule_parameters", "arp_active_rule_uuid", "active_rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java deleted file mode 100644 index 9c8c6e8cb04789265437ef134758178c94450f0e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("active_rules", "pk_active_rules", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest.java deleted file mode 100644 index 75c7d5ab3a897ce2a698b675376d3aea194fc55d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToActiveRulesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToActiveRulesTableTest.class, "schema.sql"); - private DdlChange underTest = new AddUuidColumnToActiveRulesTable(db.database()); - - @Before - public void setup() { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("active_rules")) - .isEqualTo(3); - } - - private void insertActiveRule(Long id) { - db.executeInsert("active_rules", - "id", id, - "profile_id", id + 1, - "rule_id", id + 2, - "failure_level", id + 3); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index 8a6cf76a0b6c786b537cbf99519d347a0d26fb13..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropActiveRuleIdColumnOfActiveRuleParametersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropActiveRuleIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropActiveRuleIdColumnOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("active_rule_parameters", "active_rule_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist("active_rule_parameters", "active_rule_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 3f934a41ee9074f08f387a0983a268637b2d580e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rules", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java deleted file mode 100644 index 9a41f103ea8d7a3feabc595ddb71c970dc74c2f7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnActiveRuleIdOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("active_rule_parameters"); - db.assertIndex("active_rule_parameters", "ix_arp_on_active_rule_id", "active_rule_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("active_rule_parameters", "ix_arp_on_active_rule_id"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("active_rule_parameters", "ix_arp_on_active_rule_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index f33d82dd7b585b47a75d991533e61381fd12450e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfActiveRulesTableTest { - - private static final String TABLE_NAME = "active_rules"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfActiveRulesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java deleted file mode 100644 index 6a8d8bed27b3ca7187291a73a074a6b4d48cd148..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRuleParametersActiveRuleUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersActiveRuleUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRuleParametersActiveRuleUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "active_rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest.java deleted file mode 100644 index 64a58e03e10e0e4dc184af6b6c524e0c108a24b5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRulesUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRulesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java deleted file mode 100644 index ace74cd9467915462d02b51eea4eaab7a43badd1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateActiveRuleParametersActiveRuleUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersActiveRuleUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateActiveRuleParametersActiveRuleUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - insertActiveRuleParameter(4L, 1L); - insertActiveRuleParameter(5L, 2L); - insertActiveRuleParameter(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1", "value4"), - tuple("uuid5", 2L, "uuid2", "value5"), - tuple("uuid6", 3L, "uuid3", "value6") - ); - } - - @Test - public void delete_orphan_rows() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - insertActiveRuleParameter(4L, 10L); - insertActiveRuleParameter(5L, 2L); - insertActiveRuleParameter(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid5", 2L, "uuid2", "value5"), - tuple("uuid6", 3L, "uuid3", "value6") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - insertActiveRuleParameter(4L, 1L); - insertActiveRuleParameter(5L, 2L); - insertActiveRuleParameter(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1", "value4"), - tuple("uuid5", 2L, "uuid2", "value5"), - tuple("uuid6", 3L, "uuid3", "value6") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, active_rule_id, active_rule_uuid, value from active_rule_parameters"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("ACTIVE_RULE_ID"), m -> m.get("ACTIVE_RULE_UUID"), m -> m.get("VALUE")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertActiveRule(Long id) { - db.executeInsert("active_rules", - "uuid", "uuid" + id, - "id", id, - "profile_id", id + 1, - "rule_id", id + 2, - "failure_level", id + 3); - } - - private void insertActiveRuleParameter(Long id, Long activeRuleId) { - db.executeInsert("active_rule_parameters", - "uuid", "uuid" + id, - "rules_parameter_id", id, - "value", "value" + id, - "active_rule_id", activeRuleId); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest.java deleted file mode 100644 index 0e7dc98b8a93413c75494c24f1d748a9164656ef..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.activerules; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateActiveRulesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateActiveRulesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from active_rules") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertActiveRule(Long id) { - db.executeInsert("active_rules", - "id", id, - "profile_id", id + 1, - "rule_id", id + 2, - "failure_level", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumnsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumnsTest.java deleted file mode 100644 index 0465b15ecb2ad0fbb9dbb2c7d8a3cb58956b57f5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumnsTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.alm; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddClientIdAndClientSecretColumnsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddClientIdAndClientSecretColumnsTest.class, "schema.sql"); - - private MigrationStep underTest = new AddClientIdAndClientSecretColumns(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("alm_settings", "client_id", Types.VARCHAR, 80, true); - db.assertColumnDefinition("alm_settings", "client_secret", Types.VARCHAR, 80, true); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java deleted file mode 100644 index 2bafea052706527998ea5a7fe5c2e7e706ffe358..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.ceactivity; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfCeActivityTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfCeActivityTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("ce_activity", "pk_ce_activity", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest.java deleted file mode 100644 index 99a18bf168bc15f4d9202555f5d1d6902531b4ea..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.ceactivity; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfCeActivityTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfCeActivityTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfCeActivityTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("ce_activity", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java deleted file mode 100644 index 09b11b665d6ebe4643515b5ae9ec0a85e647fdb4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.ceactivity; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfCeActivityTableTest { - - private static final String TABLE_NAME = "ce_activity"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeActivityTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeActivityTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java deleted file mode 100644 index 4c933d8a3c0189fd6489a25f99625ff426ad2ffb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfCeQueueTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfCeQueueTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("ce_queue", "pk_ce_queue", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest.java deleted file mode 100644 index 613859626d3d4283fad2ca8595a9af346ce61ff1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfCeQueueTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfCeQueueTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfCeQueueTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("ce_queue", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java deleted file mode 100644 index 4f17918162b4d31a5a2ee5588f7991f6d2377d7b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfCeQueueTableTest { - - private static final String TABLE_NAME = "ce_queue"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeQueueTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeQueueTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java deleted file mode 100644 index ea36f81e9783a3be8bc57ca234ad8b1713fa9cff..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.cequeue; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUniqueIndexOnUuidColumnOfCeQueueTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfCeQueueTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUniqueIndexOnUuidColumnOfCeQueueTable(db.database()); - - @Test - public void execute_drop_index() throws SQLException { - db.assertUniqueIndex("ce_queue", "ce_queue_uuid", "uuid"); - - underTest.execute(); - - db.assertIndexDoesNotExist("ce_queue", "ce_queue_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java deleted file mode 100644 index d3b45824e14b1ce3820d2d22cb03d545bdb22202..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("duplications_index", "pk_duplications_index", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java deleted file mode 100644 index 5cd015260fe5370c941909e6c857d2d46d053b41..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidToDuplicationsIndexTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToDuplicationsIndexTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidToDuplicationsIndexTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertDuplicationsIndex(1L); - insertDuplicationsIndex(2L); - insertDuplicationsIndex(3L); - } - - @Test - public void add_uuid_column_to_duplications_index() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("duplications_index", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("duplications_index")) - .isEqualTo(3); - } - - private void insertDuplicationsIndex(Long id) { - db.executeInsert("duplications_index", - "id", id, - "hash", uuidFactory.create(), - "index_in_file", id + 1, - "start_line", id + 2, - "end_line", id + 3, - "component_uuid", uuidFactory.create(), - "analysis_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java deleted file mode 100644 index a2d6f28b02167032e8249732fce00ec89adbd27f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfDuplicationsIndexTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfDuplicationsIndexTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfDuplicationsIndexTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("duplications_index", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java deleted file mode 100644 index aeaf762def7316c62a7b590570f28767abf22924..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest { - - private static final String TABLE_NAME = "duplications_index"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java deleted file mode 100644 index 6219a7bc66f748584b708c7531b064843bbd3892..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeDuplicationsIndexUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeDuplicationsIndexUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeDuplicationsIndexUuidColumnNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("duplications_index", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest.java deleted file mode 100644 index e63d198192582ff8520cf06fb16b79d8ec8645e4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateDuplicationsIndexUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateDuplicationsIndexUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateDuplicationsIndexUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertDuplicationsIndex(1L); - insertDuplicationsIndex(2L); - insertDuplicationsIndex(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertDuplicationsIndex(1L); - insertDuplicationsIndex(2L); - insertDuplicationsIndex(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from duplications_index") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertDuplicationsIndex(Long id) { - db.executeInsert("duplications_index", - "id", id, - "hash", uuidFactory.create(), - "index_in_file", id + 1, - "start_line", id + 2, - "end_line", id + 3, - "component_uuid", uuidFactory.create(), - "analysis_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java deleted file mode 100644 index 8a157c8c6737e0ef7a2529397bf131ff2556714a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.events; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfEventsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfEventsTableTest.class, "schema.sql"); - - private AddPrimaryKeyOnUuidColumnOfEventsTable underTest = new AddPrimaryKeyOnUuidColumnOfEventsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("events", "pk_events", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest.java deleted file mode 100644 index c9a2372ec2527e54624777ead9431daa376abc57..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.events; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfEventsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfEventsTableTest.class, "schema.sql"); - - private DropIdColumnOfEventsTable underTest = new DropIdColumnOfEventsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("events", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java deleted file mode 100644 index acd069c82c96d819a3621577734561da3260d89a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.events; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfEventsTableTest { - - private static final String TABLE_NAME = "events"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfEventsTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DropPrimaryKeyOnIdColumnOfEventsTable underTest = new DropPrimaryKeyOnIdColumnOfEventsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java deleted file mode 100644 index f5adedc96e329f9a32c70134508d8529bef88b49..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfFileSourcesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("file_sources", "pk_file_sources", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest.java deleted file mode 100644 index 224b02bfe4a8ec14b7862fc3950bfbc4e42fcbdf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToFileSourcesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToFileSourcesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToFileSourcesTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertFileSources(1L); - insertFileSources(2L); - insertFileSources(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("file_sources", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("file_sources")) - .isEqualTo(3); - } - - private void insertFileSources(Long id) { - db.executeInsert("file_sources", - "id", id, - "project_uuid", uuidFactory.create(), - "file_uuid", uuidFactory.create(), - "line_count", id + 1, - "created_at", id + 2, - "updated_at", id + 3); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest.java deleted file mode 100644 index 2890a12a8157dfe5a5c172ada5760479f2453f42..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfFileSourcesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfFileSourcesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfFileSourcesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("file_sources", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java deleted file mode 100644 index d859424ac431c75e5dd7b78d2a618933c66e123e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfFileSourcesTableTest { - - private static final String TABLE_NAME = "file_sources"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfFileSourcesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest.java deleted file mode 100644 index 3ff9e98b8f5085d1d97289f09e638f8df889e598..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeFileSourcesUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeFileSourcesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeFileSourcesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("file_sources", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest.java deleted file mode 100644 index 858daee347a69a95e20a07766edf9258d57ea4ce..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.filesources; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateFileSourcesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateFileSourcesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateFileSourcesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertFileSources(1L); - insertFileSources(2L); - insertFileSources(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertFileSources(1L); - insertFileSources(2L); - insertFileSources(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from file_sources") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertFileSources(Long id) { - db.executeInsert("file_sources", - "id", id, - "project_uuid", uuidFactory.create(), - "file_uuid", uuidFactory.create(), - "line_count", id + 1, - "created_at", id + 2, - "updated_at", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java deleted file mode 100644 index 873381d68eb0e1b3f0e2c50567a12992ce2f92e5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.class, "schema.sql"); - - private AddPrimaryKeyOnUuidColumnOfGroupRolesTable underTest = new AddPrimaryKeyOnUuidColumnOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("group_roles", "pk_group_roles", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest.java deleted file mode 100644 index a0bdce7916a39bd78aa291e83800e0e957501488..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToGroupRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToGroupRolesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToGroupRolesTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertGroupRoles(1L); - insertGroupRoles(2L); - insertGroupRoles(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("group_roles", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("group_roles")) - .isEqualTo(3); - } - - private void insertGroupRoles(Long id) { - db.executeInsert("group_roles", - "id", id, - "organization_uuid", uuidFactory.create(), - "group_id", id + 1, - "role", id + 2, - "component_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest.java deleted file mode 100644 index 840ba1d80f234e910ba1ee2565d9cf789f849e49..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfGroupRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfGroupRolesTableTest.class, "schema.sql"); - - private DropIdColumnOfGroupRolesTable underTest = new DropIdColumnOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("group_roles", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java deleted file mode 100644 index 65e279e04c3d7c0af14cd24811c9bf42ba2d66c7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfGroupRolesTableTest { - - private static final String TABLE_NAME = "group_roles"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DropPrimaryKeyOnIdColumnOfGroupRolesTable underTest = new DropPrimaryKeyOnIdColumnOfGroupRolesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java deleted file mode 100644 index 7e8641d3d2e89b62c983e6a228e003323e8f1a69..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeGroupRolesUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupRolesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeGroupRolesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("group_roles", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest.java deleted file mode 100644 index b5317e1a3df34d422ab699590fb1dfb54c6638af..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.grouproles; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateGroupRolesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupRolesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateGroupRolesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertGroupRoles(1L); - insertGroupRoles(2L); - insertGroupRoles(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroupRoles(1L); - insertGroupRoles(2L); - insertGroupRoles(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from group_roles") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertGroupRoles(Long id) { - db.executeInsert("group_roles", - "id", id, - "uuid", uuidFactory.create(), - "organization_uuid", uuidFactory.create(), - "group_id", id + 1, - "role", id + 2, - "component_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java deleted file mode 100644 index 6bc959300985bdd2a374412a673f92e378a2059d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("groups", "pk_groups", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest.java deleted file mode 100644 index 1b09889ec3de3c04f63b0a19a5a07441a1714d5c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToGroupsTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToGroupsTableTest.class, "schema.sql"); - private DdlChange underTest = new AddUuidColumnToGroupsTable(db.database()); - - @Before - public void setup() { - insertGroups(1L); - insertGroups(2L); - insertGroups(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("groups")) - .isEqualTo(3); - } - - private void insertGroups(Long id) { - db.executeInsert("groups", - "id", id, - "organization_uuid", "org" + id, - "name", "name" + id); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest.java deleted file mode 100644 index ac61ae1def133f66ded4518b28d004de4520de26..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("groups", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java deleted file mode 100644 index 99723e8f69255da086fbbcfc13b3dbc6347b8a5b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfGroupsTableTest { - - private static final String TABLE_NAME = "groups"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfGroupsTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfGroupsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest.java deleted file mode 100644 index a61e9da240c46bb5ebad7a25dfdb6004e02640e6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeGroupsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeGroupsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest.java deleted file mode 100644 index f541540434cad640f0ee271e45659a6bf8fdb416..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateGroupsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateGroupsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertGroups(1L); - insertGroups(2L); - insertGroups(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroups(1L); - insertGroups(2L); - insertGroups(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from groups") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertGroups(Long id) { - db.executeInsert("groups", - "id", id, - "organization_uuid", "org" + id, - "name", "name" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java deleted file mode 100644 index 495c3071073e3de47a67ee517b4dbbcc88a9782d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddGroupUuidColumnToGroupRolesTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToGroupRolesTest.class, "schema.sql"); - private DdlChange underTest = new AddGroupUuidColumnToGroupRoles(db.database()); - - @Before - public void setup() { - insertGroupRole(1L); - insertGroupRole(2L); - insertGroupRole(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertGroupRole(Long id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", id + 1, - "role", "role" + id, - "organization_uuid", "org" + id - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java deleted file mode 100644 index 5b65cd7a8d4d52212027627a0d6569b9410f125a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnGroupUuidOfGroupRolesTableTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfGroupRolesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnGroupUuidOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_uuid", - "component_uuid", "role"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_uuid", - "component_uuid", "role"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java deleted file mode 100644 index 009b7bebea0e8b566c3a8cac72fb34fcb3d6f6d7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropGroupIdColumnOfGroupRolesTableTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfGroupRolesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropGroupIdColumnOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, true); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java deleted file mode 100644 index 303b6f332f3702a99f9682ea04308cda29144bc5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnGroupIdOfGroupRolesTableTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfGroupRolesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnGroupIdOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_id", - "component_uuid", "role"); - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "uniq_group_roles"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "uniq_group_roles"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest.java deleted file mode 100644 index 42b29de2537c970e95b00400f4ad93adde1032b9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateGroupRolesGroupUuidTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupRolesGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateGroupRolesGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupRole(4L, 1L); - insertGroupRole(5L, 2L); - insertGroupRole(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_orphan_rows() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupRole(4L, 1L); - insertGroupRole(5L, 2L); - insertGroupRole(6L, 10L); - insertGroupRole(7L, null); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid7", null, null) - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupRole(4L, 1L); - insertGroupRole(5L, 2L); - insertGroupRole(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id, - "name", "name" + id); - } - - private void insertGroupRole(Long id, Long groupId) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", groupId, - "role", "role" + id, - "organization_uuid", "org" + id - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java deleted file mode 100644 index e0be9603b6ac246e129c1182e4210f4d9bc0f731..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddGroupUuidColumnToGroupsUsersTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToGroupsUsersTest.class, "schema.sql"); - private DdlChange underTest = new AddGroupUuidColumnToGroupsUsers(db.database()); - - @Before - public void setup() { - insertGroupsUser(1L); - insertGroupsUser(2L); - insertGroupsUser(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertGroupsUser(Long id) { - db.executeInsert(TABLE_NAME, - "user_id", id, - "group_id", id + 1 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java deleted file mode 100644 index a8b86141a5448f08c1afcc0145dc25322fda7f96..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnGroupUuidOfGroupsUsersTableTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfGroupsUsersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnGroupUuidOfGroupsUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_NAME, "index_groups_users_group_uuid", "group_uuid"); - db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_uuid", "user_id"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex(TABLE_NAME, "index_groups_users_group_uuid", "group_uuid"); - db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_uuid", "user_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java deleted file mode 100644 index 2467e0df2c095fbbfa23047eacdda25e3a901e6c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropGroupIdColumnOfGroupsUsersTableTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfGroupsUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropGroupIdColumnOfGroupsUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "group_id", Types.BIGINT, null, true); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java deleted file mode 100644 index 0d7f36e5cfdf8f420535aeccddb189d0255aa9f5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnGroupIdOfGroupsUsersTableTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfGroupsUsersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnGroupIdOfGroupsUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertIndex(TABLE_NAME, "index_groups_users_on_group_id", "group_id"); - db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_id", "user_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "index_groups_users_on_group_id"); - db.assertIndexDoesNotExist(TABLE_NAME, "groups_users_unique"); - - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "index_groups_users_on_group_id"); - db.assertIndexDoesNotExist(TABLE_NAME, "groups_users_unique"); - - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java deleted file mode 100644 index 0a9739a87d486980b2b7fea1c166ca64a7b0c047..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeGroupsUsersGroupUuidNotNullableTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUsersGroupUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeGroupsUsersGroupUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java deleted file mode 100644 index 4df6e5a050c89efa33d8e1a6e43cb86de705cbcf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateGroupsUsersGroupUuidTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUsersGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateGroupsUsersGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupsUser(4L, 1L); - insertGroupsUser(5L, 2L); - insertGroupsUser(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple(1L, "uuid1"), - tuple(2L, "uuid2"), - tuple(3L, "uuid3") - ); - } - - @Test - public void delete_orphan_rows() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupsUser(4L, 1L); - insertGroupsUser(5L, 2L); - insertGroupsUser(6L, 10L); - insertGroupsUser(7L, null); - - underTest.execute(); - - assertThatTableContains( - tuple(1L, "uuid1"), - tuple(2L, "uuid2"), - tuple(null, null) - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupsUser(4L, 1L); - insertGroupsUser(5L, 2L); - insertGroupsUser(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple( 1L, "uuid1"), - tuple(2L, "uuid2"), - tuple(3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select group_id, group_uuid from " + TABLE_NAME); - assertThat(select).extracting( m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id); - } - - private void insertGroupsUser(Long id, Long group) { - db.executeInsert(TABLE_NAME, - "user_id", id, - "group_id", group - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java deleted file mode 100644 index c044edc3bfd87fa0a4b23ed256a62935952736a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.organizations; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddDefaultGroupUuidColumnToOrganizationsTest { - private static final String TABLE_NAME = "organizations"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddDefaultGroupUuidColumnToOrganizationsTest.class, "schema.sql"); - private DdlChange underTest = new AddDefaultGroupUuidColumnToOrganizations(db.database()); - - @Before - public void setup() { - insertOrganization(1L); - insertOrganization(2L); - insertOrganization(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "default_group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertOrganization(Long id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "kee", "kee" + id, - "name", "name" + id, - "default_quality_gate_uuid", "default_quality_gate_uuid" + id, - "new_project_private", true, - "subscription", "subscription" + id, - "created_at", id + 1, - "updated_at", id + 2 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java deleted file mode 100644 index 2fa7598cb471ecbf9babdfd85035f4d5552291d6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.organizations; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropDefaultGroupIdColumnOfOrganizationsTableTest { - private static final String TABLE_NAME = "organizations"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropDefaultGroupIdColumnOfOrganizationsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropDefaultGroupIdColumnOfOrganizationsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "default_group_id", Types.INTEGER, null, true); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "default_group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java deleted file mode 100644 index 45b71d1820100c54bd302bfc8aec6f360f077c47..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.organizations; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateOrganizationsDefaultGroupUuidTest { - private static final String TABLE_NAME = "organizations"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationsDefaultGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateOrganizationsDefaultGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertOrganization(4L, 1L); - insertOrganization(5L, 2L); - insertOrganization(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_orphan_rows() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertOrganization(4L, 1L); - insertOrganization(5L, 2L); - insertOrganization(6L, 10L); - insertOrganization(7L, null); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid7", null, null) - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertOrganization(4L, 1L); - insertOrganization(5L, 2L); - insertOrganization(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, default_group_id, default_group_uuid from " + TABLE_NAME); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("DEFAULT_GROUP_ID"), m -> m.get("DEFAULT_GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id); - } - - private void insertOrganization(Long id, Long groupId) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "kee", "kee" + id, - "name", "name" + id, - "default_group_id", groupId, - "default_quality_gate_uuid", "default_quality_gate_uuid" + id, - "new_project_private", true, - "subscription", "subscription" + id, - "created_at", id + 1, - "updated_at", id + 2 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java deleted file mode 100644 index c89cb74aa75d9861bbc48f38106304103dd83c5a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddGroupUuidColumnToPermTemplatesGroupsTest { - private static final String TABLE_NAME = "perm_templates_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToPermTemplatesGroupsTest.class, "schema.sql"); - private DdlChange underTest = new AddGroupUuidColumnToPermTemplatesGroups(db.database()); - - @Before - public void setup() { - insertPermTemplatesGroup(1L); - insertPermTemplatesGroup(2L); - insertPermTemplatesGroup(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertPermTemplatesGroup(Long id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", id + 1, - "permission_reference", "permission_reference" + id, - "template_id", id + 2 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index 26863c6b892fd1acb8d7ff543c0b4867c769b975..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropGroupIdColumnOfPermTemplatesGroupsTableTest { - private static final String TABLE_NAME = "perm_templates_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropGroupIdColumnOfPermTemplatesGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, true); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java deleted file mode 100644 index 0dacab28d3389cd99fbf99630ecfff3bdc1b3203..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulatePermTemplatesGroupsGroupUuidTest { - private static final String TABLE_NAME = "perm_templates_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulatePermTemplatesGroupsGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertPermTemplatesGroup(4L, 1L); - insertPermTemplatesGroup(5L, 2L); - insertPermTemplatesGroup(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_orphan_rows() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertPermTemplatesGroup(4L, 1L); - insertPermTemplatesGroup(5L, 2L); - insertPermTemplatesGroup(6L, 10L); - insertPermTemplatesGroup(7L, null); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid7", null, null) - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertPermTemplatesGroup(4L, 1L); - insertPermTemplatesGroup(5L, 2L); - insertPermTemplatesGroup(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id); - } - - private void insertPermTemplatesGroup(Long id, Long groupId) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", groupId, - "permission_reference", "permission_reference" + id, - "template_id", id + 2 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java deleted file mode 100644 index 4d18844342c4606e67f645844e29633c4ed8b1d0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddGroupUuidColumnToQProfileEditGroupsTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToQProfileEditGroupsTest.class, "schema.sql"); - private DdlChange underTest = new AddGroupUuidColumnToQProfileEditGroups(db.database()); - - @Before - public void setup() { - insertQProfileEditGroup(1L); - insertQProfileEditGroup(2L); - insertQProfileEditGroup(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertQProfileEditGroup(Long id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", id + 1, - "qprofile_uuid", "qprofile_uuid" + id, - "created_at", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java deleted file mode 100644 index 5946abc9696deabdb3bff27e69af8118702356bc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnGroupUuidOfQProfileEditGroupsTableTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnGroupUuidOfQProfileEditGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_uuid", "qprofile_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_uuid", "qprofile_uuid"); - - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java deleted file mode 100644 index 1f43331afc0bb77bb5d71eb0df9e35bcfcfc7e77..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropGroupIdColumnOfQProfileEditGroupsTableTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfQProfileEditGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropGroupIdColumnOfQProfileEditGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java deleted file mode 100644 index 165ed7d3ae2e55a544b9d32113359c4ba7ea4534..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnGroupIdOfQProfileEditGroupsTableTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfQProfileEditGroupsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnGroupIdOfQProfileEditGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_id", "qprofile_uuid"); - - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "qprofile_edit_groups_unique"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "qprofile_edit_groups_unique"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java deleted file mode 100644 index 38723a7d88486a1fc32d7cb1face6c11f312b04e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQProfileEditGroupsGroupUuidNotNullableTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQProfileEditGroupsGroupUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQProfileEditGroupsGroupUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java deleted file mode 100644 index 3fdf198d9db776b58c94e01b12de7d3e8ff73e2f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateQProfileEditGroupsGroupUuidTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileEditGroupsGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQProfileEditGroupsGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertQProfileEditGroup(4L, 1L); - insertQProfileEditGroup(5L, 2L); - insertQProfileEditGroup(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_orphan_rows() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertQProfileEditGroup(4L, 1L); - insertQProfileEditGroup(5L, 2L); - insertQProfileEditGroup(6L, 10L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertQProfileEditGroup(4L, 1L); - insertQProfileEditGroup(5L, 2L); - insertQProfileEditGroup(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id); - } - - private void insertQProfileEditGroup(Long id, Long groupId) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", groupId, - "qprofile_uuid", "qprofile_uuid" + id, - "created_at", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTableTest.java deleted file mode 100644 index bd5adae39ebfe5e0a9bbc17e7258553bbc954200..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnIssueKeyOfIssueChangesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnIssueKeyOfIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnIssueKeyOfIssueChangesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("issue_changes", "issue_changes_issue_key", "issue_key"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("issue_changes", "issue_changes_issue_key", "issue_key"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTableTest.java deleted file mode 100644 index a989dd6db37ddabb0652168ebd4b555f8fbd1ee5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnKeeOfIssueChangesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnKeeOfIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnKeeOfIssueChangesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("issue_changes", "issue_changes_kee", "kee"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("issue_changes", "issue_changes_kee", "kee"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java deleted file mode 100644 index f6f1399c5aac5eb49a48be6aac4e812cc83a9843..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfIssueChangesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("issue_changes", "pk_issue_changes", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTableTest.java deleted file mode 100644 index bf5f0a68e24ccd47a699ebc9260208b3df27a1ea..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTableTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.JDBCType; -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class CopyIssueChangesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CopyIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new CopyIssueChangesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("issue_changes"); - db.assertTableDoesNotExist("issue_changes_copy"); - - underTest.execute(); - db.assertTableExists("issue_changes"); - db.assertTableExists("issue_changes_copy"); - db.assertColumnDefinition("issue_changes_copy", "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition("issue_changes_copy", "issue_key", Types.VARCHAR, 50, false); - db.assertColumnDefinition("issue_changes_copy", "updated_at", Types.BIGINT, null, true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTableTest.java deleted file mode 100644 index 7f184f25b7b87a68ca6755ba973beaf5bf8b633f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIssueChangesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIssueChangesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("issue_changes"); - underTest.execute(); - db.assertTableDoesNotExist("issue_changes"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - db.assertTableExists("issue_changes"); - - underTest.execute(); - - // re-entrant - underTest.execute(); - db.assertTableDoesNotExist("issue_changes"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChangesTest.java deleted file mode 100644 index 31d1ca20438a0715292833a62dbacc4ae5e5764f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChangesTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class RenameIssueChangesCopyToIssueChangesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RenameIssueChangesCopyToIssueChangesTest.class, "schema.sql"); - - private MigrationStep underTest = new RenameIssueChangesCopyToIssueChanges(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("issue_changes_copy"); - db.assertTableDoesNotExist("issue_changes"); - - underTest.execute(); - db.assertTableExists("issue_changes"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java deleted file mode 100644 index 3ceb4a9386ab19fbc7e5f77e908646ba66b08cc1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnKeeColumnOfIssuesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnKeeColumnOfIssuesTableTest.class, "schema.sql"); - - private AddPrimaryKeyOnKeeColumnOfIssuesTable underTest = new AddPrimaryKeyOnKeeColumnOfIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("issues", "pk_issues", "kee"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java deleted file mode 100644 index 9436d07759530bb4ec529cdb481c8fce581f0abf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfManualMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("manual_measures", "pk_manual_measures", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest.java deleted file mode 100644 index f2c9f1f658a519e7cc6231fda771a7d5ac409115..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidToManualMeasuresTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToManualMeasuresTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToManualMeasures(db.database()); - - @Before - public void setup() { - insertManualMeasure(1L); - insertManualMeasure(2L); - insertManualMeasure(3L); - } - - @Test - public void add_uuid_column_to_manual_measures() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from manual_measures")) - .isEqualTo(3); - } - - private void insertManualMeasure(Long id) { - db.executeInsert("manual_measures", - "id", id, - "metric_id", id + 100, - "component_uuid", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java deleted file mode 100644 index b61ac018b78c87452870a20f6efa6775d566af2b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfManualMeasuresTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfManualMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfManualMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("manual_measures", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java deleted file mode 100644 index c670d997839000848be6b1ec288e0dae8d8f54ce..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest { - - private static final String TABLE_NAME = "manual_measures"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfManualMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java deleted file mode 100644 index 1df9d6c99f033cda5e6cf217632874fddb7b8c06..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeManualMeasuresUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeManualMeasuresUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeManualMeasuresUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest.java deleted file mode 100644 index b0a3b8fa845bf252d7f164916fb28d9039bd9806..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.manualmeasures; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateManualMeasuresUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateManualMeasuresUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateManualMeasureUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids_and_created_at() throws SQLException { - insertManualMeasure(1L); - insertManualMeasure(2L); - insertManualMeasure(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertManualMeasure(1L); - insertManualMeasure(2L); - insertManualMeasure(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from manual_measures") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertManualMeasure(Long id) { - db.executeInsert("manual_measures", - "id", id, - "metric_id", id + 100, - "component_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java deleted file mode 100644 index 8d57fc49048a2486dcaf046836b4e6dcc1c8be5f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfMetricsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfMetricsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfMetricsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("metrics", "pk_metrics", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest.java deleted file mode 100644 index 69f44705827e57ebae34bc8520d8240afb5bc356..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToMetricsTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToMetricsTableTest.class, "schema.sql"); - private DdlChange underTest = new AddUuidColumnToMetricsTable(db.database()); - - @Before - public void setup() { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("metrics", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("metrics")) - .isEqualTo(3); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "name", "name" + id); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest.java deleted file mode 100644 index aa847b3d6e60f5d4e66c18293e2665f8da34dba1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfMetricsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfMetricsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfMetricsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("metrics", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java deleted file mode 100644 index ba2cc6188d289f0fe5870c720584bf47528ca694..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfMetricsTableTest { - - private static final String TABLE_NAME = "metrics"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfMetricsTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfMetricsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest.java deleted file mode 100644 index 509430e3b8dc7961e1b3a7e2f722d38ca3de53e6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeMetricsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeMetricsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeMetricsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("metrics", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java deleted file mode 100644 index 0402e044817157c7036c4ce7ebad3cc36df59d62..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnMetricUuidOfLiveMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnMetricUuidOfLiveMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnMetricUuidOfLiveMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("live_measures", "live_measures_component", "component_uuid", "metric_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex("live_measures", "live_measures_component", "component_uuid", "metric_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTableTest.java deleted file mode 100644 index f6a915f30c1b0955891c4c5919f34dd157ca1add..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnProjectUuidOfLiveMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnProjectUuidOfLiveMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnProjectUuidOfLiveMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("live_measures", "live_measures_project", "project_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("live_measures", "live_measures_project", "project_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTableTest.java deleted file mode 100644 index 9ec7ee1100687181375ec305607a31fa22b0b2af..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTableTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.rules.issues.CopyIssuesTable; - -public class CopyLiveMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CopyLiveMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new CopyLiveMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("live_measures"); - db.assertTableDoesNotExist("live_measures_copy"); - - underTest.execute(); - db.assertTableExists("live_measures"); - db.assertTableExists("live_measures_copy"); - db.assertColumnDefinition("live_measures_copy", "uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition("live_measures_copy", "metric_uuid", Types.VARCHAR, 40, false); - db.assertColumnDefinition("live_measures_copy", "measure_data", Types.BLOB, null, true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTableTest.java deleted file mode 100644 index 51badc71971e198e23edd12ca02747f376ccd414..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.rules.issues.DropIssuesTable; - -public class DropLiveMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropLiveMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropLiveMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("live_measures"); - underTest.execute(); - db.assertTableDoesNotExist("live_measures"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - db.assertTableExists("live_measures"); - - underTest.execute(); - - // re-entrant - underTest.execute(); - db.assertTableDoesNotExist("live_measures"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasuresTest.java deleted file mode 100644 index daf43b89e929be0a34703d01275a4907ac52d96a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasuresTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.rules.issues.RenameIssuesCopyToIssues; - -public class RenameLiveMeasuresCopyToLiveMeasuresTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RenameLiveMeasuresCopyToLiveMeasuresTest.class, "schema.sql"); - - private MigrationStep underTest = new RenameLiveMeasuresCopyToLiveMeasures(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("live_measures_copy"); - db.assertTableDoesNotExist("live_measures"); - - underTest.execute(); - db.assertTableDoesNotExist("live_measures_copy"); - db.assertTableExists("live_measures"); - - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java deleted file mode 100644 index d4ee2da552e41e79e032b76c8b52c315d67d6bd5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMetricUuidColumnToManualMeasuresTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToManualMeasuresTest.class, "schema.sql"); - private DdlChange underTest = new AddMetricUuidColumnToManualMeasures(db.database()); - - @Before - public void setup() { - insertManualMeasure(1L); - insertManualMeasure(2L); - insertManualMeasure(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "metric_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("manual_measures")) - .isEqualTo(3); - } - - private void insertManualMeasure(Long id) { - db.executeInsert("manual_measures", - "uuid", "uuid" + id, - "metric_id", id + 1, - "component_uuid", "component" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java deleted file mode 100644 index 6af0fac340b462aa2485b8e1b5f7c0c1dfd20228..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropMetricIdColumnOfManualMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfManualMeasuresTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropMetricIdColumnOfManualMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("manual_measures", "metric_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist("manual_measures", "metric_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java deleted file mode 100644 index 4a727a9cb5cae6096ebb8573d56b09d6e42ce9e1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeManualMeasuresMetricUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeManualMeasuresMetricUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeManualMeasuresMetricUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "metric_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java deleted file mode 100644 index d97d9ed2ccb5da9f509a6d33389a34eacc9c94fe..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateManualMeasuresMetricUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateManualMeasuresMetricUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateManualMeasuresMetricUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertManualMeasure(4L, 1L); - insertManualMeasure(5L, 2L); - insertManualMeasure(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_orphan_rows() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertManualMeasure(4L, 10L); - insertManualMeasure(5L, 2L); - insertManualMeasure(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertManualMeasure(4L, 1L); - insertManualMeasure(5L, 2L); - insertManualMeasure(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, metric_id, metric_uuid from manual_measures"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "uuid", "uuid" + id, - "name", "name" + id); - } - - private void insertManualMeasure(Long id, Long metricId) { - db.executeInsert("manual_measures", - "uuid", "uuid" + id, - "metric_id", metricId, - "component_uuid", "component" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTableTest.java deleted file mode 100644 index 073c6b20a7176f044e8c86d65ba4b1a4d89c9c24..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java deleted file mode 100644 index 47482eabfe45d7becaaba26889d07ba1cc09da1b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnMetricUuidOfProjectMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnMetricUuidOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnMetricUuidOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("project_measures", "project_measures_metric", "metric_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("project_measures", "project_measures_metric", "metric_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java deleted file mode 100644 index 1f177343668104bd9a0b9b0951f1ce2fb2c8d656..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMetricUuidColumnToProjectMeasuresTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToProjectMeasuresTest.class, "schema.sql"); - private DdlChange underTest = new AddMetricUuidColumnToProjectMeasures(db.database()); - - @Before - public void setup() { - insertProjectMeasure(1L); - insertProjectMeasure(2L); - insertProjectMeasure(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_measures", "metric_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("project_measures")) - .isEqualTo(3); - } - - private void insertProjectMeasure(Long id) { - db.executeInsert("project_measures", - "uuid", "uuid" + id, - "metric_id", id + 1, - "component_uuid", "component" + id, - "analysis_uuid", "analysis" + id + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasuresTest.java deleted file mode 100644 index b332e8b3eb605f0cc1854ded775c7dbbd9c26eca..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasuresTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import 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.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.lang.String.format; -import static java.util.Collections.singletonList; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; - -public class DeleteSecurityReviewRatingProjectMeasuresTest { - private static final String PROJECT_MEASURES_TABLE = "project_measures"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteSecurityReviewRatingProjectMeasuresTest.class, "schema.sql"); - - private DataChange underTest = new DeleteSecurityReviewRatingProjectMeasures(db.database()); - - @Test - public void removes_project_measure_for_review_rating_and_review_rating_effort_metrics() throws SQLException { - String codeSmellMetric = insertMetric(1L, "security_review_rating"); - insertProjectMeasure(codeSmellMetric); - String reviewRatingEffort = insertMetric(2L, "security_review_rating_effort"); - insertProjectMeasure(reviewRatingEffort); - String anotherMetric = insertMetric(3L, "another_metric"); - String anotherMetricProjectMeasure = insertProjectMeasure(anotherMetric); - - underTest.execute(); - verifyProjectMeasureIds(singletonList(anotherMetricProjectMeasure)); - } - - - private String insertMetric(Long id, String key) { - db.executeInsert("metrics", - "id", id, - "uuid", id, - "name", key); - - return (String) db.selectFirst(format("select uuid as \"uuid\" from metrics where name='%s'", key)).get("uuid"); - } - - private String insertProjectMeasure(String metricUuid) { - double projectMeasureUUid = RandomUtils.nextDouble(); - Map values = new HashMap<>(ImmutableMap.of("uuid", projectMeasureUUid, "metric_uuid", metricUuid, - "analysis_uuid", "analysis_uuid", "component_uuid", "component_uuid")); - db.executeInsert(PROJECT_MEASURES_TABLE, values); - String sql = format("select uuid as \"uuid\" from %s where metric_uuid='%s'", PROJECT_MEASURES_TABLE, metricUuid); - return (String) db - .selectFirst(sql) - .get("uuid"); - } - - private void verifyProjectMeasureIds(List expectedProjectMeasureIds) { - List> results = db.select("select uuid from " + PROJECT_MEASURES_TABLE); - assertThat(results.stream() - .map(map -> (String) map.get("UUID")) - .collect(toList())) - .containsExactlyInAnyOrderElementsOf(expectedProjectMeasureIds); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java deleted file mode 100644 index 4dcd074520dc19b17ab4ceafdc4b65f79215be1e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnMetricIdOfProjectMeasuresTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnMetricIdOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnMetricIdOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("project_measures"); - db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("project_measures", "measures_analysis_metric"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("project_measures", "measures_analysis_metric"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java deleted file mode 100644 index a28faf260c54518d208ce4b27fb460c33f94836e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropMetricIdColumnOfProjectMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropMetricIdColumnOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("project_measures", "metric_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist("project_measures", "metric_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java deleted file mode 100644 index c4a7cfca9320a27d8bc2e474b6143bb3e9620e63..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeProjectMeasuresMetricUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectMeasuresMetricUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectMeasuresMetricUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_measures", "metric_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java deleted file mode 100644 index e3839decdcf0cf80f92c9a2903d1590a88a25bb1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateProjectMeasuresMetricUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectMeasuresMetricUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateProjectMeasuresMetricUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertProjectMeasure(4L, 1L); - insertProjectMeasure(5L, 2L); - insertProjectMeasure(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_orphan_entries() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertProjectMeasure(4L, 10L); - insertProjectMeasure(5L, 2L); - insertProjectMeasure(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertProjectMeasure(4L, 1L); - insertProjectMeasure(5L, 2L); - insertProjectMeasure(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, metric_id, metric_uuid from project_measures"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "uuid", "uuid" + id, - "name", "name" + id); - } - - private void insertProjectMeasure(Long id, Long metricId) { - db.executeInsert("project_measures", - "uuid", "uuid" + id, - "metric_id", metricId, - "component_uuid", "component" + id, - "analysis_uuid", "analysis" + id + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java deleted file mode 100644 index 62bf2b9e229c712f4c0ce61378dbc70a0fd75049..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMetricUuidColumnToQualityGateConditionsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToQualityGateConditionsTest.class, "schema.sql"); - private DdlChange underTest = new AddMetricUuidColumnToQualityGateConditions(db.database()); - - @Before - public void setup() { - insertQualityGateConditions(1L); - insertQualityGateConditions(2L); - insertQualityGateConditions(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "metric_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("quality_gate_conditions")) - .isEqualTo(3); - } - - private void insertQualityGateConditions(Long id) { - db.executeInsert("quality_gate_conditions", - "uuid", "uuid" + id, - "metric_id", id + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java deleted file mode 100644 index 2671359c75fc03a4b6dcc390e08e5131c8e35c91..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropMetricIdColumnOfQualityGateConditionsTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropMetricIdColumnOfQualityGateConditionsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("quality_gate_conditions", "metric_id", Types.INTEGER, null, true); - underTest.execute(); - db.assertColumnDoesNotExist("quality_gate_conditions", "metric_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java deleted file mode 100644 index 566dfaac01389236a1ff8ebcd69a33fa349c6232..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQualityGateConditionsMetricUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityGateConditionsMetricUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQualityGateConditionsMetricUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "metric_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java deleted file mode 100644 index 46038327758b86d94c529b4b8b75cb46ab105fa4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateQualityGateConditionsMetricUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQualityGateConditionsMetricUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQualityGateConditionsMetricUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertQualityGateConditions(4L, 1L); - insertQualityGateConditions(5L, 2L); - insertQualityGateConditions(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_entries_with_null_id() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertQualityGateConditions(4L, null); - insertQualityGateConditions(5L, 2L); - insertQualityGateConditions(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_rows_with_orphan_ids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertQualityGateConditions(4L, 10L); - insertQualityGateConditions(5L, 2L); - insertQualityGateConditions(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertQualityGateConditions(4L, 1L); - insertQualityGateConditions(5L, 2L); - insertQualityGateConditions(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, metric_id, metric_uuid from quality_gate_conditions"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "uuid", "uuid" + id, - "name", "name" + id); - } - - private void insertQualityGateConditions(Long id, Long metricId) { - db.executeInsert("quality_gate_conditions", - "uuid", "uuid" + id, - "metric_id", metricId); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java deleted file mode 100644 index 2bd6ce623729e99a4637909b7da4774f20f53594..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfNotificationTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfNotificationTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfNotificationTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("notifications", "pk_notifications", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java deleted file mode 100644 index 4c73d29d9c0f526f1ce80f875b57774525e388bf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.sql.SQLException; -import java.sql.Types; -import org.apache.commons.io.IOUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.SonarException; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.sql.Types.BIGINT; -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidAndCreatedAtColumnsToNotificationTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidAndCreatedAtColumnsToNotificationTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidAndCreatedAtColumnsToNotification(db.database()); - - @Before - public void setup() { - insertNotification(1L, "data1"); - insertNotification(2L, "data2"); - insertNotification(3L, "data3"); - } - - @Test - public void add_uuid_and_created_at_columns_to_notification() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("notifications", "uuid", Types.VARCHAR, 40, true); - db.assertColumnDefinition("notifications", "created_at", BIGINT, null, true); - - assertThat(db.countSql("select count(id) from notifications")) - .isEqualTo(3); - } - - private void insertNotification(Long id, String data) { - - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - try { - ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); - objectOutputStream.writeObject(data); - objectOutputStream.close(); - byte[] byteArray = byteArrayOutputStream.toByteArray(); - - db.executeInsert("notifications", - "id", id, - "data", byteArray); - - } catch (IOException e) { - throw new SonarException("Unable to write notification", e); - - } finally { - IOUtils.closeQuietly(byteArrayOutputStream); - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest.java deleted file mode 100644 index 50a3afcefdc7ef32c14c93a44892cc119704c9ad..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfNotificationTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfNotificationTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfNotificationTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("notifications", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java deleted file mode 100644 index aa332a489a577dc2ea4fc0623649fe0813d3c3b5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfNotificationTableTest { - - private static final String TABLE_NAME = "notifications"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfNotificationTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfNotificationTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java deleted file mode 100644 index a7882f951a98a712226b9f1bcc65aa9eab6ca459..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; - -public class MakeNotificationUuidAndCreatedAtColumnsNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeNotificationUuidAndCreatedAtColumnsNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("notifications", "uuid", VARCHAR, null, false); - db.assertColumnDefinition("notifications", "created_at", BIGINT, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest.java deleted file mode 100644 index e53dbb59f943e283f6f14d16a65debe0daefdcfd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.notifications; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateNotificationUuidAndCreatedAtTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateNotificationUuidAndCreatedAtTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private System2 system2 = mock(System2.class); - private DataChange underTest = new PopulateNotificationUuidAndCreatedAt(db.database(), uuidFactory, system2); - - @Before - public void before() { - // exactly one week before now + 1ms, so that ID are exactly equals to timestamp in the tests - when(system2.now()).thenReturn((1000 * 60 * 60 * 24 * 7) + 1L); - } - - @Test - public void populate_uuids_and_created_at() throws IOException, SQLException { - insertNotification(1L, "data1"); - insertNotification(2L, "data2"); - insertNotification(3L, "data3"); - - underTest.execute(); - - verifyUuidsAreNotNull(); - verifyCreatedAt(); - } - - @Test - public void migration_is_reentrant() throws IOException, SQLException { - insertNotification(1L, "data1"); - insertNotification(2L, "data2"); - insertNotification(3L, "data3"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - verifyCreatedAt(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from notifications") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void verifyCreatedAt() { - assertThat(db.select("select id, created_at from notifications") - .stream() - .filter(row -> !row.get("CREATED_AT").equals(row.get("ID"))) - .collect(Collectors.toList())).isEmpty(); - - } - - private void insertNotification(Long id, String data) throws IOException { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); - objectOutputStream.writeObject(data); - objectOutputStream.close(); - byte[] byteArray = byteArrayOutputStream.toByteArray(); - - db.executeInsert("notifications", - "id", id, - "data", byteArray); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java deleted file mode 100644 index d5eccbc92fcf1b1151f16fc43fd7db4b07e88944..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("permission_templates", "pk_permission_templates", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java deleted file mode 100644 index 5ef047320c1cd0e9b97fa90898d8069ffd818f10..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPermissionTemplatesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermissionTemplatesTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToPermissionTemplates(db.database()); - - @Before - public void setup() { - insertPermissionTemplate(1L); - insertPermissionTemplate(2L); - insertPermissionTemplate(3L); - } - - @Test - public void add_uuid_column_to_permission_templates() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("permission_templates", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from permission_templates")) - .isEqualTo(3); - } - - private void insertPermissionTemplate(Long id) { - db.executeInsert("permission_templates", - "id", id, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java deleted file mode 100644 index e30b60a1c86766a2c5cb026c7b3a1d30077fdda2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPermissionTemplatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfPermissionTemplatesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("permission_templates", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java deleted file mode 100644 index 7aec2ba6cae26a186c2c7133c27a16d0567a7d9f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropKeeColumnOfPermissionTemplatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropKeeColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropKeeColumnOfPermissionTemplatesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("permission_templates", "kee"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java deleted file mode 100644 index 66bb2ffb0cc5ce01a9d1bef36c55f0f48a104ac4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest { - - private static final String TABLE_NAME = "permission_templates"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java deleted file mode 100644 index 1b02677d63deeb7f19d53b8aded6440140ae817a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermissionTemplateUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermissionTemplateUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermissionTemplateUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("permission_templates", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest.java deleted file mode 100644 index a403cf013caf0b694cbb07134a3c374ac90b5051..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermissionTemplatesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermissionTemplatesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermissionTemplatesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertPermissionTemplate(1L); - insertPermissionTemplate(2L); - insertPermissionTemplate(3L); - insertPermissionTemplate(4L, "very_very_very_very_very_very_very_very_very_very_very_long_kee"); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertPermissionTemplate(1L); - insertPermissionTemplate(2L); - insertPermissionTemplate(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from permission_templates") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertPermissionTemplate(Long id) { - insertPermissionTemplate(id, uuidFactory.create()); - } - - private void insertPermissionTemplate(Long id, String kee) { - db.executeInsert("permission_templates", - "id", id, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", kee); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java deleted file mode 100644 index 0aeca4772892e2b0215e31bd69a1d86fb69f09d6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddTemplateUuidColumnToPermTemplatesGroupsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTemplatesGroupsTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddTemplateUuidColumnToPermTemplatesGroups(db.database()); - - @Before - public void setup() { - insertPermissionTemplateGroup("1", 4L); - insertPermissionTemplateGroup("2", 5L); - insertPermissionTemplateGroup("3", 6L); - } - - @Test - public void add_uuid_column_to_permission_templates() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_groups", "template_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_templates_groups")) - .isEqualTo(3); - } - - private void insertPermissionTemplateGroup(String uuid, Long templateId) { - db.executeInsert("perm_templates_groups", - "uuid", uuid, - "template_id", templateId, - "permission_reference", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index 57014dc1fb82a0142070fa16de9de2c399068b62..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropTemplateIdColumnOfPermTemplatesGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropTemplateIdColumnOfPermTemplatesGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_groups", "template_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java deleted file mode 100644 index 412717b7b69618615bfb09723a67d15d6f9eded8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesGroupsTemplateUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_groups", "template_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java deleted file mode 100644 index f431ac663c654c2f807b1c1568f3325bee709542..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesGroupsTemplateUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsTemplateUuidColumnTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTemplatesGroupsTemplateUuidColumn(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermissionTemplateGroup("4", permissionTemplateId_1); - insertPermissionTemplateGroup("5", permissionTemplateId_2); - insertPermissionTemplateGroup("6", permissionTemplateId_3); - - underTest.execute(); - - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - @Test - public void delete_orphan_rows() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermissionTemplateGroup("4", permissionTemplateId_1); - insertPermissionTemplateGroup("5", permissionTemplateId_2); - insertPermissionTemplateGroup("6", permissionTemplateId_3); - - underTest.execute(); - - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermissionTemplateGroup("4", permissionTemplateId_1); - insertPermissionTemplateGroup("5", permissionTemplateId_2); - insertPermissionTemplateGroup("6", 10L); - assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(3); - - underTest.execute(); - - assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(2); - } - - private void assertThatPermissionTemplateGroupTemplateUuidIsEqualTo(String permissionTemplateGroupUuid, String expectedUuid) { - assertThat(db.select("select template_uuid from perm_templates_groups where uuid = '" + permissionTemplateGroupUuid + "'") - .stream() - .map(row -> row.get("TEMPLATE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertPermissionTemplateGroup(String uuid, Long templateId) { - db.executeInsert("perm_templates_groups", - "uuid", uuid, - "template_id", templateId, - "permission_reference", uuidFactory.create()); - } - - private void insertPermissionTemplate(Long id, String uuid) { - db.executeInsert("permission_templates", - "id", id, - "uuid", uuid, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java deleted file mode 100644 index f3eecbc7c328ef4342af0e6cdec12c96fb02bf2c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddTemplateUuidColumnToPermTemplatesUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTemplatesUsersTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddTemplateUuidColumnToPermTemplatesUsers(db.database()); - - @Before - public void setup() { - insertPermTemplatesUsers("1"); - insertPermTemplatesUsers("2"); - insertPermTemplatesUsers("3"); - } - - @Test - public void add_uuid_column_to_permission_templates() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "template_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_templates_users")) - .isEqualTo(3); - } - - private void insertPermTemplatesUsers(String uuid) { - db.executeInsert("perm_templates_users", - "uuid", uuid, - "user_id", 100, - "template_id", 200, - "permission_reference", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 7b9eebd9eb2b6e988a135642c0a081da11777618..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropTemplateIdColumnOfPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropTemplateIdColumnOfPermTemplatesUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_users", "template_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java deleted file mode 100644 index 7824258f14ef34446ea3fc1be6c2333d86059129..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesUsersTemplateUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesUsersTemplateUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "template_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java deleted file mode 100644 index 96adb67286b0f0516c9ef95fff52c7ef5dcade3a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesUsersTemplateUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersTemplateUuidColumnTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTemplatesUsersTemplateUuidColumn(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTemplatesUsers("4", permissionTemplateId_1); - insertPermTemplatesUsers("5", permissionTemplateId_2); - insertPermTemplatesUsers("6", permissionTemplateId_3); - - underTest.execute(); - - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - @Test - public void delete_orphan_rows() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTemplatesUsers("4", permissionTemplateId_1); - insertPermTemplatesUsers("5", permissionTemplateId_2); - insertPermTemplatesUsers("6", 10L); - - assertThat(db.countRowsOfTable("perm_templates_users")).isEqualTo(3); - - underTest.execute(); - - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThat(db.countRowsOfTable("perm_templates_users")).isEqualTo(2); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTemplatesUsers("4", permissionTemplateId_1); - insertPermTemplatesUsers("5", permissionTemplateId_2); - insertPermTemplatesUsers("6", permissionTemplateId_3); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - private void assertThatPermTemplatesUsersTemplateUuidIsEqualTo(String permTemplatesUsersUuid, String expectedUuid) { - assertThat(db.select("select template_uuid from perm_templates_users where uuid = '" + permTemplatesUsersUuid + "'") - .stream() - .map(row -> row.get("TEMPLATE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertPermTemplatesUsers(String uuid, Long templateId) { - db.executeInsert("perm_templates_users", - "uuid", uuid, - "user_id", 100, - "template_id", templateId, - "permission_reference", uuidFactory.create()); - } - - private void insertPermissionTemplate(Long id, String uuid) { - db.executeInsert("permission_templates", - "id", id, - "uuid", uuid, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java deleted file mode 100644 index 735929bc794440c62760307ffa29c5c3d1e6e24a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddTemplateUuidColumnToPermTplCharacteristicsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTplCharacteristicsTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddTemplateUuidColumnToPermTplCharacteristics(db.database()); - - @Before - public void setup() { - insertPermTplCharacteristics("1"); - insertPermTplCharacteristics("2"); - insertPermTplCharacteristics("3"); - } - - @Test - public void add_uuid_column_to_perm_tpl_characteristics() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_tpl_characteristics", "template_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_tpl_characteristics")) - .isEqualTo(3); - } - - private void insertPermTplCharacteristics(String uuid) { - db.executeInsert("perm_tpl_characteristics", - "uuid", uuid, - "template_id", 100, - "permission_key", uuidFactory.create(), - "with_project_creator", false, - "created_at", System.currentTimeMillis(), - "updated_at", System.currentTimeMillis()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index a26d62c8a5f956c20d86f285159572a5ed56fe5a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("perm_tpl_characteristics", "uniq_perm_tpl_charac", "template_uuid", "permission_key"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex("perm_tpl_characteristics", "uniq_perm_tpl_charac", "template_uuid", "permission_key"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index d89a60aae96559a2b868ce56ba995f1b49d237dd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropTemplateIdColumnOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropTemplateIdColumnOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_tpl_characteristics", "template_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index 2d7f7f9f3c244f8bad169c0cfb49da4745ce726f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java deleted file mode 100644 index 0ce9ccdd9800dae37b7aabb888380bc3d1fcde33..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTplCharacteristicsTemplateUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_tpl_characteristics", "template_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java deleted file mode 100644 index 2be6b40457514322c90875d6b9e90daa1bc50de1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTplCharacteristicsTemplateUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTplCharacteristicsTemplateUuidColumnTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTplCharacteristicsTemplateUuidColumn(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTplCharacteristics("4", permissionTemplateId_1); - insertPermTplCharacteristics("5", permissionTemplateId_2); - insertPermTplCharacteristics("6", permissionTemplateId_3); - - underTest.execute(); - - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - @Test - public void delete_orphan_rows() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTplCharacteristics("4", permissionTemplateId_1); - insertPermTplCharacteristics("5", permissionTemplateId_2); - insertPermTplCharacteristics("6", 10L); - - assertThat(db.countRowsOfTable("perm_tpl_characteristics")).isEqualTo(3); - - underTest.execute(); - - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThat(db.countRowsOfTable("perm_tpl_characteristics")).isEqualTo(2); - - } - - @Test - public void migration_is_reentrant() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTplCharacteristics("4", permissionTemplateId_1); - insertPermTplCharacteristics("5", permissionTemplateId_2); - insertPermTplCharacteristics("6", permissionTemplateId_3); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - private void assertThatPermTplCharacteristicsTemplateUuidIsEqualTo(String permTplCharacteristicsUuid, String expectedUuid) { - assertThat(db.select("select template_uuid from perm_tpl_characteristics where uuid = '" + permTplCharacteristicsUuid + "'") - .stream() - .map(row -> row.get("TEMPLATE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertPermTplCharacteristics(String uuid, long templateId) { - db.executeInsert("perm_tpl_characteristics", - "uuid", uuid, - "template_id", templateId, - "permission_key", uuidFactory.create(), - "with_project_creator", false, - "created_at", System.currentTimeMillis(), - "updated_at", System.currentTimeMillis()); - } - - private void insertPermissionTemplate(Long id, String uuid) { - db.executeInsert("permission_templates", - "id", id, - "uuid", uuid, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index 1b8241f7a23ecef3220b1980fccde82023e0727d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("perm_templates_groups", "pk_perm_templates_groups", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java deleted file mode 100644 index 3a589c05549ad2648f0b4b888c5c79b14e849a85..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPermTemplatesGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToPermTemplatesGroupsTable(db.database()); - - @Before - public void setup() { - insertPermTemplatesGroups(1L); - insertPermTemplatesGroups(2L); - insertPermTemplatesGroups(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_groups", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_templates_groups")) - .isEqualTo(3); - } - - private void insertPermTemplatesGroups(Long id) { - db.executeInsert("perm_templates_groups", - "id", id, - "group_id", id + 1, - "template_id", id + 2, - "permission_reference", "ref" + id); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index ccb14836cee7b933620bcd71b96f5163ce72758b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPermTemplatesGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfPermTemplatesGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_groups", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index b429bf529ee61f5b9b1db67ae49e0edcd5c32fda..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest { - - private static final String TABLE_NAME = "perm_templates_groups"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java deleted file mode 100644 index 11e2f1da88143169cb38269e732d6d1e8553d2d1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesGroupsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesGroupsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesGroupsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_groups", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java deleted file mode 100644 index 5d352b72d4bcbffedb0ea8e2213da3873412c31e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesGroupsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTemplatesGroupsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertPermTemplatesGroups(1L); - insertPermTemplatesGroups(2L); - insertPermTemplatesGroups(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertPermTemplatesGroups(1L); - insertPermTemplatesGroups(2L); - insertPermTemplatesGroups(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from perm_templates_groups") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertPermTemplatesGroups(Long id) { - db.executeInsert("perm_templates_groups", - "id", id, - "group_id", id + 1, - "template_id", id + 2, - "permission_reference", "ref" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 93197277beb0f12d7d0c40956e8f38783f57dd57..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("perm_templates_users", "pk_perm_templates_users", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java deleted file mode 100644 index fd8713eeee68dab9087a7dcdd4eb00db3b753ef2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTemplatesUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToPermTemplatesUsersTable(db.database()); - - @Before - public void setup() { - insertPermTemplatesUsers(1L); - insertPermTemplatesUsers(2L); - insertPermTemplatesUsers(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_templates_users")) - .isEqualTo(3); - } - - private void insertPermTemplatesUsers(Long id) { - db.executeInsert("perm_templates_users", - "id", id, - "user_id", id + 1, - "template_id", id + 2, - "permission_reference", "ref" + id); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 4c406cda944733023eb742b8d4b9c2dc3dd6046f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfPermTemplatesUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_users", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 0754f744af564e12497e3e83b9d959a6bcd6ade8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest { - - private static final String TABLE_NAME = "perm_templates_users"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java deleted file mode 100644 index 7e74f21cad50faa5bbb1315c949c204cb1e87b0f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesUsersUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesUsersUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java deleted file mode 100644 index d95e19275f69d11ba2f85c7fb451bf863823ea0f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesUsersUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTemplatesUsersUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertPermTemplatesUsers(1L); - insertPermTemplatesUsers(2L); - insertPermTemplatesUsers(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertPermTemplatesUsers(1L); - insertPermTemplatesUsers(2L); - insertPermTemplatesUsers(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from perm_templates_users") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertPermTemplatesUsers(Long id) { - db.executeInsert("perm_templates_users", - "id", id, - "user_id", id + 1, - "template_id", id + 2, - "permission_reference", "ref" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index b4ee75a6189b46c388ff61a32c89d781d6089942..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("perm_tpl_characteristics", "pk_perm_tpl_characteristics", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java deleted file mode 100644 index 28b4a964daf75e87a855e8e0289f5d1b439b3905..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTplCharacteristicsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToPermTplCharacteristicsTable(db.database()); - - @Before - public void setup() { - insertPermTplCharacteristics(1L); - insertPermTplCharacteristics(2L); - insertPermTplCharacteristics(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_tpl_characteristics", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_tpl_characteristics")) - .isEqualTo(3); - } - - private void insertPermTplCharacteristics(Long id) { - db.executeInsert("perm_tpl_characteristics", - "id", id, - "template_id", id + 1, - "permission_key", "key" + id + 2, - "with_project_creator", true, - "created_at", id + 3, - "updated_at", id + 4); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index d3344418b7398413e465f108f75dfee239e87522..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_tpl_characteristics", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index 55a39f46937ae49012fdc8bc43061a62ada38bcc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest { - - private static final String TABLE_NAME = "perm_tpl_characteristics"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java deleted file mode 100644 index bf321cd18b7a82bd2eba86754f0f706d68ee167b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTplCharacteristicsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTplCharacteristicsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTplCharacteristicsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_tpl_characteristics", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java deleted file mode 100644 index fe3c75f8a8faafb0a7987319955d77e3e559b2e3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTplCharacteristicsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTplCharacteristicsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTplCharacteristicsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertPermTplCharacteristics(1L); - insertPermTplCharacteristics(2L); - insertPermTplCharacteristics(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertPermTplCharacteristics(1L); - insertPermTplCharacteristics(2L); - insertPermTplCharacteristics(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from perm_tpl_characteristics") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertPermTplCharacteristics(Long id) { - db.executeInsert("perm_tpl_characteristics", - "id", id, - "template_id", id + 1, - "permission_key", "key" + id + 2, - "with_project_creator", true, - "created_at", id + 3, - "updated_at", id + 4); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java deleted file mode 100644 index d30a0e3b6f329c25bb68952a8bba53599070bd70..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("project_measures", "pk_project_measures", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTableTest.java deleted file mode 100644 index 8caae1d8cfdc189b15e328152219adeddffd3605..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddTechIndexOnUuidOfProjectMeasuresTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddTechIndexOnUuidOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddTechIndexOnUuidOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("project_measures", "tech_index_uuid", "uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("project_measures", "tech_index_uuid", "uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest.java deleted file mode 100644 index 6655b0eac8cefc8973c80d3728f6673e805dace3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidToProjectMeasuresTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToProjectMeasuresTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToProjectMeasures(db.database()); - - @Before - public void setup() { - insertProjectMeasure(1L); - insertProjectMeasure(2L); - insertProjectMeasure(3L); - } - - @Test - public void add_uuid_column_to_project_measures() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_measures", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from project_measures")) - .isEqualTo(3); - } - - private void insertProjectMeasure(Long id) { - db.executeInsert("project_measures", - "id", id, - "metric_id", id + 100, - "analysis_uuid", uuidFactory.create(), - "component_uuid", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java deleted file mode 100644 index 41e0d8716d0ce81b058673e29251989a3b05c678..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfProjectMeasuresTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("project_measures", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java deleted file mode 100644 index 6dd3642e47c6d9292327116c6019193640f36a9a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest { - - private static final String TABLE_NAME = "project_measures"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfProjectMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTableTest.java deleted file mode 100644 index 4e182eb9bc04edde9983e18dde4b7987c84abac7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropTechIndexOnUuidOfProjectMeasuresTableTest { - - private static final String TABLE_NAME = "project_measures"; - private static final String INDEX_NAME = "tech_index_uuid"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTechIndexOnUuidOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropTechIndexOnUuidOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java deleted file mode 100644 index ff116991e2ef087f919490b9f0124815bd038468..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeProjectMeasuresUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectMeasuresUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectMeasuresUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_measures", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest.java deleted file mode 100644 index 932ed6ade5719a57d56d3edea654d38d4af77089..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectmeasures; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateProjectMeasuresUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectMeasuresUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateProjectMeasureUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertProjectMeasure(1L); - insertProjectMeasure(2L); - insertProjectMeasure(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProjectMeasure(1L); - insertProjectMeasure(2L); - insertProjectMeasure(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from project_measures") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertProjectMeasure(Long id) { - db.executeInsert("project_measures", - "id", id, - "metric_id", id + 100, - "analysis_uuid", uuidFactory.create(), - "component_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java deleted file mode 100644 index 09d1fd33be2bc7d2241d5b802d6a2d59f718656c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("project_qprofiles", "pk_project_qprofiles", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java deleted file mode 100644 index 429dc6d731aea49c7c0468abbe933dab1a29f688..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToProjectQProfilesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToProjectQProfilesTableTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToProjectQProfilesTable(db.database()); - - @Before - public void setup() { - insertProjectQProfile(1L); - insertProjectQProfile(2L); - insertProjectQProfile(3L); - } - - @Test - public void add_uuid_column_to_project_qprofiles() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_qprofiles", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from project_qprofiles")) - .isEqualTo(3); - } - - private void insertProjectQProfile(Long id) { - db.executeInsert("project_qprofiles", - "id", id, - "project_uuid", uuidFactory.create(), - "profile_key", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java deleted file mode 100644 index 5dad81854849880c7d4ce74c3de71b7b551f2480..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfProjectQProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfProjectQProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfProjectQProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("project_qprofiles", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java deleted file mode 100644 index 9f92f2447fc4d97315ddd7839136efd08b1ce950..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest { - private static final String TABLE_NAME = "project_qprofiles"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java deleted file mode 100644 index e163ae47fe0d061f010d8cb49951ad24ef086f31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeProjectQProfilesUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectQProfilesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectQProfilesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_qprofiles", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest.java deleted file mode 100644 index 79071f7cd94c488eb72c191e27d049b0269a9509..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateProjectQProfilesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectQProfilesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateProjectQProfilesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertProjectQProfile(1L); - insertProjectQProfile(2L); - insertProjectQProfile(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProjectQProfile(1L); - insertProjectQProfile(2L); - insertProjectQProfile(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from project_qprofiles") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertProjectQProfile(Long id) { - db.executeInsert("project_qprofiles", - "id", id, - "project_uuid", uuidFactory.create(), - "profile_key", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java deleted file mode 100644 index e2b7ae774ecb9c4e64ae6a45d4bcf9af84b467db..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPropertiesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfPropertiesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("properties", "pk_properties", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest.java deleted file mode 100644 index 40b08965c6cd19af2c6f66119bb76e6510e11088..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPropertiesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPropertiesTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToProperties(db.database()); - - @Before - public void setup() { - insertProperties(1L, "uuid1", "key1"); - insertProperties(2L, "uuid2", "key2"); - insertProperties(3L, "uuid3", "key3"); - } - - @Test - public void add_uuid_to_properties() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("properties", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from properties")) - .isEqualTo(3); - } - - private void insertProperties(Long id, String uuid, String propKey) { - - db.executeInsert("properties", - "id", id, - "prop_key", propKey, - "is_empty", false, - "created_at", 0); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest.java deleted file mode 100644 index 5efe0a4ad11e11311e7e0730e21eae7186576e8d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPropertiesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPropertiesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfPropertiesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("properties", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java deleted file mode 100644 index 9c748ecdd437f5a676af8da1d23533603607a0bb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfPropertiesTableTest { - - private static final String TABLE_NAME = "properties"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfPropertiesTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPropertiesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest.java deleted file mode 100644 index 9064ece35dcc5a95afeca213c1e2a93d5a4216c4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeNotificationUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeNotificationUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePropertiesUuidColumnNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("properties", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest.java deleted file mode 100644 index 1d8e724ec45606b666f5893a1c72699143803a77..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.properties; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePropertiesUuidAndCreatedAtTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePropertiesUuidAndCreatedAtTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePropertiesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertProperties(1L, "uuid1", "key1"); - insertProperties(2L, "uuid2", "key2"); - insertProperties(3L, "uuid3", "key3"); - - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProperties(1L, "uuid1", "key1"); - insertProperties(2L, "uuid2", "key2"); - insertProperties(3L, "uuid3", "key3"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from properties") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertProperties(Long id, String uuid, String propKey) { - - db.executeInsert("properties", - "id", id, - "prop_key", propKey, - "uuid", uuid, - "is_empty", false, - "created_at", 0); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java deleted file mode 100644 index 2a51a4f2f66b5c15aacea98bba1b26f1ce88945b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("quality_gate_conditions", "pk_quality_gate_conditions", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java deleted file mode 100644 index c50da55188af84f022dec9f27118101e327f2951..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToQualityGateConditionsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToQualityGateConditionsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToQualityGateConditionsTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertQualityGateCondition(1L); - insertQualityGateCondition(2L); - insertQualityGateCondition(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("quality_gate_conditions")) - .isEqualTo(3); - } - - private void insertQualityGateCondition(Long id) { - db.executeInsert("quality_gate_conditions", - "id", id, - "qgate_id", id + 1, - "period", id + 2); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java deleted file mode 100644 index 17bab2b35ba60aefdc6b56d3fd5ad241c7a2311a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfQualityGateConditionsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfQualityGateConditionsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("quality_gate_conditions", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java deleted file mode 100644 index ce1a4861f3efb4bd288e8509dece9302bf36bcd7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest { - - private static final String TABLE_NAME = "quality_gate_conditions"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java deleted file mode 100644 index ce7cc523a82b0dfc5529b092c35248cf71f6d91e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQualityGateConditionsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityGateConditionsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQualityGateConditionsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java deleted file mode 100644 index 00bb98afb7fabadfc73d97c8424e802a1c78fb27..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateQualityGateConditionsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQualityGateConditionsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateQualityGateConditionsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertQualityGateCondition(1L); - insertQualityGateCondition(2L); - insertQualityGateCondition(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertQualityGateCondition(1L); - insertQualityGateCondition(2L); - insertQualityGateCondition(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from quality_gate_conditions") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertQualityGateCondition(Long id) { - db.executeInsert("quality_gate_conditions", - "id", id, - "uuid", uuidFactory.create(), - "qgate_id", id + 1, - "period", id + 2); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java deleted file mode 100644 index ea8f96735d1f7b70a61811b36b21c3c8bf077071..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfQGatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfQGatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfQGatesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("quality_gates", "pk_quality_gates", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java deleted file mode 100644 index 88ce9731ca3b5935d0d8089f75a81dc07ce340fc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddQGateUuidColumnForQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddQGateUuidColumnForQGateConditionsTest.class, "schema.sql"); - - private MigrationStep underTest = new AddQGateUuidColumnForQGateConditions(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "qgate_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest.java deleted file mode 100644 index 0ff5a41bfa0f0ebfd556b119bd24ae3adc9892a8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfQGateTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfQGateTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfQGateTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("quality_gates", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest.java deleted file mode 100644 index f508a36ac86bdfc5ea2fefaa24770272877874fb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DropOrphansQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrphansQGateConditionsTest.class, "schema.sql"); - - private MigrationStep underTest = new DropOrphansQGateConditions(db.database()); - - @Test - public void deleteOrphanQGConditions() throws SQLException { - insertQualityGate(1L, "uuid1", "qualityGate1"); - insertQualityGateCondition("condition_uuid_1", "uuid1"); - insertQualityGateCondition("condition_uuid_2", "uuid1"); - insertQualityGateCondition("condition_uuid_3", null); - - underTest.execute(); - - verifyConditionExist("condition_uuid_1", true); - verifyConditionExist("condition_uuid_2", true); - verifyConditionExist("condition_uuid_3", false); - } - - private void verifyConditionExist(String uuid, boolean exist) { - assertThat(db.select("select count(uuid) as C from quality_gate_conditions where uuid='" + uuid + "'") - .stream() - .map(row -> (Long) row.get("C")) - .collect(Collectors.toList())).containsOnly(exist ? 1L : 0L); - } - - private void insertQualityGate(Long id, String uuid, String name) { - db.executeInsert("quality_gates", - "id", id, - "uuid", uuid, - "name", name, - "is_built_in", true); - } - - private void insertQualityGateCondition(String uuid, String qualityGateUuid) { - db.executeInsert("quality_gate_conditions", - "uuid", uuid, - "qgate_uuid", qualityGateUuid); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java deleted file mode 100644 index 684e534d2c2f8a06057df03eeb1600dde2099b47..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfQGatesTableTest { - - private static final String TABLE_NAME = "quality_gates"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfQGatesTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfQGatesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest.java deleted file mode 100644 index 9b596cd7ab4eb46bc67faff542bbf052b0ceac57..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropQGateIdColumnForQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropQGateIdColumnForQGateConditionsTest.class, "schema.sql"); - - private MigrationStep underTest = new DropQGateIdColumnForQGateConditions(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("quality_gate_conditions", "qgate_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java deleted file mode 100644 index 67a858ebfc3979d07f574d967925c12f641f7605..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUniqueIndexOnUuidColumnOfQualityGatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUniqueIndexOnUuidColumnOfQualityGatesTable(db.database()); - - @Test - public void execute_drop_index() throws SQLException { - db.assertUniqueIndex("quality_gates", "uniq_quality_gates_uuid", "uuid"); - - underTest.execute(); - - db.assertIndexDoesNotExist("quality_gates", "uniq_quality_gates_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java deleted file mode 100644 index b71a04e7f87b21f1d4096627a34b8fcd9859ea3f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQGateUuidColumnNotNullableForQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQGateUuidColumnNotNullableForQGateConditionsTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQGateUuidColumnNotNullableForQGateConditions(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "qgate_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java deleted file mode 100644 index 3053c9d8c385d596d2953e1e7695a93bb9249e5c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.qualitygates; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateQGateUuidColumnForQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQGateUuidColumnForQGateConditionsTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQGateUuidColumnForQGateConditions(db.database()); - - @Test - public void populate_qgate_uuids() throws SQLException { - insertQualityGate(1L, "uuid1", "qualityGate1"); - insertQualityGate(2L, "uuid2", "qualityGate2"); - insertQualityGate(3L, "uuid3", "qualityGate3"); - insertQualityGateCondition("condition_uuid_1", "uuid1"); - insertQualityGateCondition("condition_uuid_2", "uuid1"); - insertQualityGateCondition("condition_uuid_3", "uuid2"); - - underTest.execute(); - - verifyUuid("condition_uuid_1", "uuid1"); - verifyUuid("condition_uuid_2", "uuid1"); - verifyUuid("condition_uuid_3", "uuid2"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertQualityGate(1L, "uuid1", "qualityGate1"); - insertQualityGate(2L, "uuid2", "qualityGate2"); - insertQualityGate(3L, "uuid3", "qualityGate3"); - insertQualityGateCondition("condition_uuid_1", "uuid1"); - insertQualityGateCondition("condition_uuid_2", "uuid1"); - insertQualityGateCondition("condition_uuid_3", "uuid2"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuid("condition_uuid_1", "uuid1"); - verifyUuid("condition_uuid_2", "uuid1"); - verifyUuid("condition_uuid_3", "uuid2"); - } - - private void verifyUuid(String conditionUuid, String expectedUuid) { - assertThat(db.select("select QGATE_UUID from quality_gate_conditions where uuid='" + conditionUuid+"'") - .stream() - .map(row -> row.get("QGATE_UUID")) - .collect(Collectors.toList())).containsOnly(expectedUuid); - } - - private void insertQualityGate(Long id, String uuid, String name) { - db.executeInsert("quality_gates", - "id", id, - "uuid", uuid, - "name", name, - "is_built_in", true); - } - - private void insertQualityGateCondition(String uuid, String qualityGateUuid) { - db.executeInsert("quality_gate_conditions", - "uuid", uuid, - "qgate_uuid", qualityGateUuid); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java deleted file mode 100644 index 70b508923b378b52c1c7d6427378f583158f9e66..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("rules", "pk_rules", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java deleted file mode 100644 index 3a441735de38e06abc867c69b3d750b1e988cad4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidAndTemplateUuidColumnsToRulesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidAndTemplateUuidColumnsToRulesTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidAndTemplateUuidColumnsToRules(db.database()); - - @Before - public void setup() { - insertRule(1L); - insertRule(2L); - insertRule(3L); - insertRule(4L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(*) from rules")) - .isEqualTo(4); - } - - private void insertRule(long id) { - db.executeInsert("rules", - "id", id, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest.java deleted file mode 100644 index 93c12af97db3dbcfdafa4c0a833daa3a9bce68b9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java deleted file mode 100644 index e47a9781f5119e630c407961a29a739559a2f85e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfRulesTableTest { - private static final String TABLE_NAME = "rules"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesTableTest.class, "schema.sql"); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesTable(db.database(), - new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database()))); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertPrimaryKey(TABLE_NAME, "pk_rules", "id"); - - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest.java deleted file mode 100644 index c90e3b58291b1aecc48d65a6b4be78cfc85b760f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropTemplateIdColumnOfRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropTemplateIdColumnOfRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules", "template_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest.java deleted file mode 100644 index 6c7dfb50b6aca30b756dd805641d43179a0ee73c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest.java deleted file mode 100644 index acad73135e9cfee0023c13b3a2528686f48504a5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateRulesTemplateUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesTemplateUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateRulesTemplateUuid(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-1", 1L); - insertRule(2L, "uuid-2", 1L); - insertRule(3L, "uuid-3", null); - insertRule(4L, "uuid-4", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from rules")) - .isEqualTo(4); - assertThat(db.select("select uuid, template_id, template_uuid from rules")) - .extracting(m -> m.get("UUID"), m -> m.get("TEMPLATE_ID"), m -> m.get("TEMPLATE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-1", 1L, "uuid-1"), - tuple("uuid-2", 1L, "uuid-1"), - tuple("uuid-3", null, null), - tuple("uuid-4", 2L, "uuid-2")); - } - - private void insertRule(long id, String uuid, @Nullable Long templateId) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "template_id", templateId, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest.java deleted file mode 100644 index ddc1e485abbc5670af17d35ad09945ad1f5bcfff..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexToActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToActiveRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexToActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("active_rules", "uniq_profile_rule_uuids", "profile_uuid", "rule_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex("active_rules", "uniq_profile_rule_uuids", "profile_uuid", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java deleted file mode 100644 index 1df3853ce50d09190ab8d915c9b177d5f4c20c2f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToActiveRulesTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertActiveRule("uuid-ar-1", 1L, "uuid-profile-1"); - insertActiveRule("uuid-ar-2", 1L, "uuid-profile-2"); - insertActiveRule("uuid-ar-3", 2L, "uuid-profile-1"); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from active_rules")) - .isEqualTo(3); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertActiveRule(String uuid, long ruleId, String profileUuid) { - db.executeInsert("active_rules", - "uuid", uuid, - "rule_id", ruleId, - "profile_uuid", profileUuid, - "failure_level", 1); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 6a1a2c661bbcf2c13081ac8ab71ff67ad90c92c2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnRuleIdColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnRuleIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnRuleIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("active_rules"); - db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("active_rules", "uniq_profile_rule_ids"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("active_rules", "uniq_profile_rule_ids"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 6a1d054efb453d153e93961d549b22f619601da4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rules", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java deleted file mode 100644 index 0cdbbef53ce26bcfd259c311d9330a0436d4969a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRulesRuleUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesRuleUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRulesRuleUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java deleted file mode 100644 index 85da9ff6a7ef9a1f00ef97119d8e0f3c2d686b96..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.activerules; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateActiveRulesRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateActiveRulesRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertActiveRule("uuid-ar-1", 1L, "uuid-profile-1"); - insertActiveRule("uuid-ar-2", 1L, "uuid-profile-2"); - insertActiveRule("uuid-ar-3", 2L, "uuid-profile-1"); - // orphan FK - insertActiveRule("uuid-ar-4", 10L, "uuid-profile-1"); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from active_rules")) - .isEqualTo(3); - assertThat(db.select("select uuid, rule_id, rule_uuid from active_rules")) - .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-ar-1", 1L, "uuid-rule-1"), - tuple("uuid-ar-2", 1L, "uuid-rule-1"), - tuple("uuid-ar-3", 2L, "uuid-rule-2")); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertActiveRule(String uuid, long ruleId, String profileUuid) { - db.executeInsert("active_rules", - "uuid", uuid, - "rule_id", ruleId, - "profile_uuid", profileUuid, - "failure_level", 1); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java deleted file mode 100644 index 66ddec375560d3f18a7aa8d665fe1706749f5203..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexToDeprecatedRuleKeysTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToDeprecatedRuleKeysTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexToDeprecatedRuleKeysTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("deprecated_rule_keys", "rule_uuid_deprecated_rule_keys", "rule_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("deprecated_rule_keys", "rule_uuid_deprecated_rule_keys", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java deleted file mode 100644 index 9e8d138c70f753a5cd2e01e2b37003e484b5869a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToDeprecatedRuleKeysTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToDeprecatedRuleKeysTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToDeprecatedRuleKeysTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - - insertDeprecatedRuleKeyRow("uuid-drk-1", 1L); - insertDeprecatedRuleKeyRow("uuid-drk-2", 1L); - insertDeprecatedRuleKeyRow("uuid-drk-3", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("deprecated_rule_keys", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from deprecated_rule_keys")) - .isEqualTo(3); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertDeprecatedRuleKeyRow(String uuid, long ruleId) { - db.executeInsert("deprecated_rule_keys", - "uuid", uuid, - "rule_id", ruleId, - "old_repository_key", "old-repo-key" + uuid, - "old_rule_key", "old-rule-key" + uuid, - "created_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java deleted file mode 100644 index 75be03b559e1d999b14c9b8fc9422063569c26ef..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("deprecated_rule_keys"); - db.assertIndex("deprecated_rule_keys", "rule_id_deprecated_rule_keys", "rule_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("deprecated_rule_keys", "rule_id_deprecated_rule_keys"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("deprecated_rule_keys", "rule_id_deprecated_rule_keys"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java deleted file mode 100644 index ae08878c2859c15e1ed82967df799f2779b0f382..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfDeprecatedRuleKeysTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfDeprecatedRuleKeysTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfDeprecatedRuleKeysTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("deprecated_rule_keys", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java deleted file mode 100644 index 7d7b8dfe3d53af0a722cf00873e36752c3ef418a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeDeprecatedRuleKeysRuleUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("deprecated_rule_keys", "rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java deleted file mode 100644 index 4699f7bc21e0a540850473b89191dcfa33740675..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateDeprecatedRuleKeysRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateDeprecatedRuleKeysRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateDeprecatedRuleKeysRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertDeprecatedRuleKeyRow("uuid-drk-1", 1L); - insertDeprecatedRuleKeyRow("uuid-drk-2", 1L); - insertDeprecatedRuleKeyRow("uuid-drk-3", 2L); - // orphan FK - insertDeprecatedRuleKeyRow("uuid-drk-4", 10L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from deprecated_rule_keys")) - .isEqualTo(3); - assertThat(db.select("select uuid, rule_id, rule_uuid from deprecated_rule_keys")) - .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-drk-1", 1L, "uuid-rule-1"), - tuple("uuid-drk-2", 1L, "uuid-rule-1"), - tuple("uuid-drk-3", 2L, "uuid-rule-2")); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertDeprecatedRuleKeyRow(String uuid, long ruleId) { - db.executeInsert("deprecated_rule_keys", - "uuid", uuid, - "rule_id", ruleId, - "old_repository_key", "old-repo-key" + uuid, - "old_rule_key", "old-rule-key" + uuid, - "created_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTableTest.java deleted file mode 100644 index fdfb4998dc8cb79eb3268ee82bb883df2c974176..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexesToIssuesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexesToIssuesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexesToIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("issues", "issues_rule_uuid", "rule_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("issues", "issues_rule_uuid", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTableTest.java deleted file mode 100644 index 4cff8871b8ce4d0926418df546578a9adb6b53f2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTableTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.CopyIssueChangesTable; - -public class CopyIssuesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(CopyIssuesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new CopyIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("issues"); - db.assertTableDoesNotExist("issues_copy"); - - underTest.execute(); - db.assertTableExists("issues"); - db.assertTableExists("issues_copy"); - db.assertColumnDefinition("issues_copy", "kee", Types.VARCHAR, 50, false); - db.assertColumnDefinition("issues_copy", "message", Types.VARCHAR, 4000, true); - db.assertColumnDefinition("issues_copy", "issue_type", Types.TINYINT, null, true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTableTest.java deleted file mode 100644 index e49c7c8e0ee4ca3de0580eb7f4a58a29f8d6f792..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.DropIssueChangesTable; - -public class DropIssuesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIssuesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("issues"); - underTest.execute(); - db.assertTableDoesNotExist("issues"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - db.assertTableExists("issues"); - - underTest.execute(); - - // re-entrant - underTest.execute(); - db.assertTableDoesNotExist("issues"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssuesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssuesTest.java deleted file mode 100644 index 4255c786bc159ab326936752ffccf84e3b89efab..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssuesTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.issuechanges.RenameIssueChangesCopyToIssueChanges; - -public class RenameIssuesCopyToIssuesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(RenameIssuesCopyToIssuesTest.class, "schema.sql"); - - private MigrationStep underTest = new RenameIssuesCopyToIssues(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("issues_copy"); - db.assertTableDoesNotExist("issues"); - - underTest.execute(); - db.assertTableDoesNotExist("issues_copy"); - db.assertTableExists("issues"); - - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java deleted file mode 100644 index 84606688d038e8da2f28b8005b263c510a1f5983..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_uuid", "organization_uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java deleted file mode 100644 index 0197f1801856b3e97b16bd40f8f5cac558c5d94f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToRulesMetadataTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToRulesMetadataTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToRulesMetadataTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertRuleMetadata(1L, "org-1"); - insertRuleMetadata(1L, "org-2"); - insertRuleMetadata(2L, "org-1"); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_metadata", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from rules_metadata")) - .isEqualTo(3); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertRuleMetadata(long ruleId, String organizationUuid) { - db.executeInsert("rules_metadata", - "rule_id", ruleId, - "organization_uuid", organizationUuid, - "created_at", System2.INSTANCE.now(), - "updated_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java deleted file mode 100644 index 351dcd1c21ca6f5ff134df2130c35c677138ccaf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest { - private static final String TABLE_NAME = "rules_metadata"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.class, "schema.sql"); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesMetadataTable(db.database(), - new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database()))); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertPrimaryKey(TABLE_NAME, "pk_rules_metadata", "rule_id", "organization_uuid"); - - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java deleted file mode 100644 index 48744abe9081937c26c6354bdb5ea86b36c7a367..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfRulesMetadataTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfRulesMetadataTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfRulesMetadataTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_metadata", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java deleted file mode 100644 index 86030159b1fcedc771302a4fdc521d1e588523e4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesMetadataRuleUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesMetadataRuleUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesMetadataRuleUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_metadata", "rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java deleted file mode 100644 index 3dec490c939250afb1da8bbc9bb3035fa615b689..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateRulesMetadataRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesMetadataRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateRulesMetadataRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertRuleMetadata(1L, "org-1"); - insertRuleMetadata(1L, "org-2"); - insertRuleMetadata(2L, "org-1"); - // orphan FK - insertRuleMetadata(10L, "org-1"); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from rules_metadata")) - .isEqualTo(3); - assertThat(db.select("select rule_id, organization_uuid, rule_uuid from rules_metadata")) - .extracting(m -> m.get("RULE_ID"), m -> m.get("ORGANIZATION_UUID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple(1L, "org-1", "uuid-rule-1"), - tuple(1L, "org-2", "uuid-rule-1"), - tuple(2L, "org-1", "uuid-rule-2")); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertRuleMetadata(long ruleId, String organizationUuid) { - db.executeInsert("rules_metadata", - "rule_id", ruleId, - "organization_uuid", organizationUuid, - "created_at", System2.INSTANCE.now(), - "updated_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java deleted file mode 100644 index 84c6d588d87331b08c0252a71e957a3f4a000fe3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexesToRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexesToRulesParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexesToRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("rules_parameters", "rules_parameters_rule_uuid", "rule_uuid"); - db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_uuid", "name"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("rules_parameters", "rules_parameters_rule_uuid", "rule_uuid"); - db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_uuid", "name"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java deleted file mode 100644 index 736a1c532f757d42fb43353a88e4d34d3add5669..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToRulesParametersTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToRulesParametersTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - - insertRulesParametersEntry("uuid-rp-1", 1L); - insertRulesParametersEntry("uuid-rp-2", 1L); - insertRulesParametersEntry("uuid-rp-3", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_parameters", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from rules_parameters")) - .isEqualTo(3); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertRulesParametersEntry(String uuid, long ruleId) { - db.executeInsert("rules_parameters", - "uuid", uuid, - "rule_id", ruleId, - "name", "name-" + uuid, - "param_type", "STRING"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java deleted file mode 100644 index 4522d8fff6e69cb6c61b08c0f0ec5e73d222db38..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexesOnRuleIdColumnOfRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexesOnRuleIdColumnOfRulesParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexesOnRuleIdColumnOfRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("rules_parameters"); - db.assertIndex("rules_parameters", "rules_parameters_rule_id", "rule_id"); - db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_id", "name"); - - underTest.execute(); - - db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_rule_id"); - db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_unique"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_rule_id"); - db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_unique"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java deleted file mode 100644 index 6a5ec981b4a306295b50988af037853c07dabd61..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfRulesParametersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_parameters", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java deleted file mode 100644 index fb059f32b8c9d4a65e0f68241627623ee2118282..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesParametersRuleUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesParametersRuleUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesParametersRuleUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_parameters", "rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java deleted file mode 100644 index 9f7933c325ab501112fd36b3ec0f09da61214006..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateRulesParametersRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesParametersRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateRulesParametersRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - - insertRulesParametersEntry("uuid-rp-1", 1L); - insertRulesParametersEntry("uuid-rp-2", 1L); - insertRulesParametersEntry("uuid-rp-3", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from rules_parameters")) - .isEqualTo(3); - assertThat(db.select("select uuid, rule_id, rule_uuid from rules_parameters")) - .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-rp-1", 1L, "uuid-rule-1"), - tuple("uuid-rp-2", 1L, "uuid-rule-1"), - tuple("uuid-rp-3", 2L, "uuid-rule-2")); - } - - @Test - public void remove_orphans() throws SQLException { - insertRulesParametersEntry("uuid-rp-4", 666L); - - underTest.execute(); - - assertThat(db.countSql("select count(*) from rules_parameters")) - .isEqualTo(3); - assertThat(db.select("select uuid, rule_id, rule_uuid from rules_parameters")) - .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-rp-1", 1L, "uuid-rule-1"), - tuple("uuid-rp-2", 1L, "uuid-rule-1"), - tuple("uuid-rp-3", 2L, "uuid-rule-2")); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertRulesParametersEntry(String uuid, long ruleId) { - db.executeInsert("rules_parameters", - "uuid", uuid, - "rule_id", ruleId, - "name", "name-" + uuid, - "param_type", "STRING"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java deleted file mode 100644 index 54c62922f19ee51361326b090eff2f7777feff71..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("rules_parameters", "pk_rules_parameters", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest.java deleted file mode 100644 index d9e1b1696444345256a463e9f6cd2bd3ea2b3007..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToRulesParametersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToRulesParametersTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToRulesParameters(db.database()); - - @Before - public void setup() { - insertRuleParameter(1L); - insertRuleParameter(2L); - insertRuleParameter(3L); - } - - @Test - public void add_uuid_column_to_project_measures() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_parameters", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from rules_parameters")) - .isEqualTo(3); - } - - private void insertRuleParameter(Long id) { - db.executeInsert("rules_parameters", - "id", id, - "rule_id", id + 100, - "name", uuidFactory.create(), - "param_type", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest.java deleted file mode 100644 index a7115de314febd77c93bca0c997c7eacf930ee4a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_parameters", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java deleted file mode 100644 index 44715d556925deb6ce63dfa11ab37d873ceade52..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfRulesParametersTableTest { - - private static final String TABLE_NAME = "rules_parameters"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesParametersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java deleted file mode 100644 index aa21df4f1557daa20788383b165dfff6cc5e1cf1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesParametersUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesParametersUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesParametersUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_parameters", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest.java deleted file mode 100644 index a55ecec1c176579b3ec98ed0c6178fccd7fc5fa5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateRulesParametersUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesParametersUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateRulesParametersUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids_and_created_at() throws SQLException { - insertRuleParameter(1L); - insertRuleParameter(2L); - insertRuleParameter(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertRuleParameter(1L); - insertRuleParameter(2L); - insertRuleParameter(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from rules_parameters") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertRuleParameter(Long id) { - db.executeInsert("rules_parameters", - "id", id, - "rule_id", id + 100, - "name", uuidFactory.create(), - "param_type", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java deleted file mode 100644 index 22d5a2430c378118528de603608af8b1eeb99f5a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRulesParameterUuidColumnToActiveRuleParametersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRulesParameterUuidColumnToActiveRuleParametersTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddRulesParameterUuidColumnToActiveRuleParameters(db.database()); - - @Before - public void setup() { - insertActiveRuleParameter(uuidFactory.create(), 1L, 4L); - insertActiveRuleParameter(uuidFactory.create(), 2L, 5L); - insertActiveRuleParameter(uuidFactory.create(), 3L, 6L); - } - - @Test - public void add_rules_parameter_uuid_column_to_active_rule_parameters() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "rules_parameter_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("active_rule_parameters")) - .isEqualTo(3); - } - - private void insertActiveRuleParameter(String uuid, Long ruleId, Long rulesParameterId) { - db.executeInsert("active_rule_parameters", - "uuid", uuid, - "active_rule_id", ruleId, - "rules_parameter_id", rulesParameterId); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index dd97b9305cff77f8daa8c82ee2ab062b70ba872d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRulesParameterIdColumnOfActiveRuleParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRulesParameterIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropRulesParameterIdColumnOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rule_parameters", "rules_parameter_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java deleted file mode 100644 index ed9bac5e90a630c5917cd7c5384e5031c7c84c81..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRuleParametersRulesParameterUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "rules_parameter_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java deleted file mode 100644 index 967402a9a8d85b492f2e36e3d455b80ef8fc3257..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateActiveRuleParametersRulesParameterUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersRulesParameterUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateActiveRuleParametersRulesParameterUuid(db.database()); - - @Test - public void populate_rules_parameter_uuids() throws SQLException { - String ruleParamUuid1 = uuidFactory.create(); - long ruleParamId1 = 1L; - insertRuleParameter(ruleParamId1, ruleParamUuid1, 101L); - String activeRuleParameter11 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter12 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter13 = insertActiveRuleParameter(101L, ruleParamId1); - - String ruleParamUuid2 = uuidFactory.create(); - long ruleParamId2 = 2L; - insertRuleParameter(ruleParamId2, ruleParamUuid2, 101L); - String activeRuleParameter21 = insertActiveRuleParameter(101L, ruleParamId2); - String activeRuleParameter22 = insertActiveRuleParameter(101L, ruleParamId2); - - insertRuleParameter(3L, uuidFactory.create(), 101L); - - underTest.execute(); - - assertRulesParameterUuidsAreNotNull(); - assertThatRulesParametersUuidAreSet(ruleParamUuid1, activeRuleParameter11, activeRuleParameter12, activeRuleParameter13); - assertThatRulesParametersUuidAreSet(ruleParamUuid2, activeRuleParameter21, activeRuleParameter22); - } - - @Test - public void delete_orphan_rows() throws SQLException { - String ruleParamUuid1 = uuidFactory.create(); - long ruleParamId1 = 1L; - insertRuleParameter(ruleParamId1, ruleParamUuid1, 101L); - String activeRuleParameter11 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter12 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter13 = insertActiveRuleParameter(101L, 2L); - - underTest.execute(); - - assertRulesParameterUuidsAreNotNull(); - assertThatRulesParametersUuidAreSet(ruleParamUuid1, activeRuleParameter11, activeRuleParameter12); - } - - @Test - public void migration_is_reentrant() throws SQLException { - String ruleParamUuid1 = uuidFactory.create(); - long ruleParamId1 = 1L; - insertRuleParameter(ruleParamId1, ruleParamUuid1, 101L); - String activeRuleParameter11 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter12 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter13 = insertActiveRuleParameter(101L, ruleParamId1); - - underTest.execute(); - - String ruleParamUuid2 = uuidFactory.create(); - long ruleParamId2 = 2L; - insertRuleParameter(ruleParamId2, ruleParamUuid2, 101L); - String activeRuleParameter21 = insertActiveRuleParameter(101L, ruleParamId2); - String activeRuleParameter22 = insertActiveRuleParameter(101L, ruleParamId2); - // re-entrant - underTest.execute(); - - assertRulesParameterUuidsAreNotNull(); - assertThatRulesParametersUuidAreSet(ruleParamUuid1, activeRuleParameter11, activeRuleParameter12, activeRuleParameter13); - assertThatRulesParametersUuidAreSet(ruleParamUuid2, activeRuleParameter21, activeRuleParameter22); - } - - private void assertThatRulesParametersUuidAreSet(String ruleParameterUuid, String... activeRuleParameters) { - assertThat(db.select("select rules_parameter_uuid from active_rule_parameters where uuid in (" - + Stream.of(activeRuleParameters).map(s -> format("'%s'", s)).collect(Collectors.joining(",")) + ")") - .stream() - .map(row -> row.get("RULES_PARAMETER_UUID")) - .filter(o -> !Objects.equals(o, ruleParameterUuid)) - .collect(Collectors.toList())).isEmpty(); - } - - private void assertRulesParameterUuidsAreNotNull() { - assertThat(db.select("select rules_parameter_uuid from active_rule_parameters") - .stream() - .map(row -> row.get("RULES_PARAMETER_UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertRuleParameter(Long id, String uuid, Long ruleId) { - db.executeInsert("rules_parameters", - "id", id, - "uuid", uuid, - "rule_id", ruleId, - "name", uuidFactory.create(), - "param_type", uuidFactory.create()); - } - - private String insertActiveRuleParameter(Long ruleId, Long rulesParameterId) { - String uuid = uuidFactory.create(); - db.executeInsert("active_rule_parameters", - "uuid", uuid, - "active_rule_id", ruleId, - "rules_parameter_id", rulesParameterId); - return uuid; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java deleted file mode 100644 index 4ffa67b200814a21c234521f72e10a8bb19ad979..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfRulesProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("rules_profiles", "pk_rules_profiles", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java deleted file mode 100644 index b9a1800f1e3e7d81ff4d330ff3255c0329a1449d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToRulesProfilesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToRulesProfilesTableTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToRulesProfilesTable(db.database()); - - @Before - public void setup() { - insertRuleProfile(1L); - insertRuleProfile(2L); - insertRuleProfile(3L); - } - - @Test - public void add_uuid_column_to_rules_profiles() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_profiles", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from rules_profiles")) - .isEqualTo(3); - } - - private void insertRuleProfile(Long id) { - db.executeInsert("rules_profiles", - "id", id, - "name", "name" + id, - "kee", "kee" + id, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java deleted file mode 100644 index 045469630f6da78a74ff3da7fe6e0eca94413e4a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfRulesProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfRulesProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_profiles", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java deleted file mode 100644 index 55113b1433d412bca565560333686d490638986d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropKeeColumnOfRulesProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropKeeColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropKeeColumnOfRulesProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_profiles", "kee"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java deleted file mode 100644 index 1062c2c04eb15f69f9976f04aef8e54fb0b48405..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest { - private static final String TABLE_NAME = "rules_profiles"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfRulesProfilesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java deleted file mode 100644 index 200bc040d30edd3e44aad2ce56d53dfe47af87e5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest { - - private static final String TABLE_NAME = "rules_profiles"; - private static final String INDEX_NAME = "uniq_qprof_key"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUniqueIndexOnKeeColumnOfRulesProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - // migration is re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java deleted file mode 100644 index ccb2e006a7747ab1c8b75adf699ed958484cf169..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesProfilesUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesProfilesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesProfilesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_profiles", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest.java deleted file mode 100644 index 01c014b374c173992ad0aaf056be2fb9a02e46c1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateRulesProfilesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesProfilesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateRulesProfilesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertRuleProfile(1L); - insertRuleProfile(2L); - insertRuleProfile(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertRuleProfile(1L); - insertRuleProfile(2L); - insertRuleProfile(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from rules_profiles") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertRuleProfile(Long id) { - db.executeInsert("rules_profiles", - "id", id, - "name", "name" + id, - "kee", "kee" + id, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java deleted file mode 100644 index 4f55577f86ff77f86cfd481f0f61bec0e0adfdc8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddProfileUuidColumnToActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddProfileUuidColumnToActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddProfileUuidColumnToActiveRulesTable(db.database()); - - @Before - public void setup() { - insertActiveRule("1", 1L, 2L); - insertActiveRule("2", 3L, 4L); - insertActiveRule("3", 5L, 6L); - } - - @Test - public void add_uuid_column_to_rules_profiles() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "profile_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("active_rules")) - .isEqualTo(3); - } - - private void insertActiveRule(String uuid, long profileId, long rule_id) { - db.executeInsert("active_rules", - "uuid", uuid, - "profile_id", profileId, - "rule_id", rule_id, - "failure_level", 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java deleted file mode 100644 index 2068c133aebb48bc15e79e0895508b6839d35e0a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - - db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 1ff938ab79570a194c3eef74b978c92c99b1f48e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropProfileIdColumnOfActiveRulesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropProfileIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropProfileIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rules", "profile_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 759cbac1df1ca7c67ba8ecceb38b419f3a4124eb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUniqueIndexOnProfileIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java deleted file mode 100644 index fdd714e0d92bc2136156d30630f38e5b0deabcbc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRulesProfileUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesProfileUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRulesProfileUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "profile_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java deleted file mode 100644 index e1583a84fbb26b4209705b374d0cdc0f9e65d874..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateActiveRulesProfileUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesProfileUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateActiveRulesProfileUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3); - - insertActiveRule("4", ruleProfileId_1); - insertActiveRule("5", ruleProfileId_2); - insertActiveRule("6", ruleProfileId_3); - - underTest.execute(); - - assertThatActiveRulesProfileUuidIsEqualTo("4", ruleProfileUuid_1); - assertThatActiveRulesProfileUuidIsEqualTo("5", ruleProfileUuid_2); - assertThatActiveRulesProfileUuidIsEqualTo("6", ruleProfileUuid_3); - } - - @Test - public void delete_orphan_rows() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3); - - insertActiveRule("4", ruleProfileId_1); - insertActiveRule("5", ruleProfileId_2); - insertActiveRule("6", 10L); - - assertThat(db.countRowsOfTable("active_rules")).isEqualTo(3); - - underTest.execute(); - - assertThatActiveRulesProfileUuidIsEqualTo("4", ruleProfileUuid_1); - assertThatActiveRulesProfileUuidIsEqualTo("5", ruleProfileUuid_2); - assertThat(db.countRowsOfTable("active_rules")).isEqualTo(2); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3); - - insertActiveRule("4", ruleProfileId_1); - insertActiveRule("5", ruleProfileId_2); - insertActiveRule("6", ruleProfileId_3); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatActiveRulesProfileUuidIsEqualTo("4", ruleProfileUuid_1); - assertThatActiveRulesProfileUuidIsEqualTo("5", ruleProfileUuid_2); - assertThatActiveRulesProfileUuidIsEqualTo("6", ruleProfileUuid_3); - } - - private void assertThatActiveRulesProfileUuidIsEqualTo(String uuid, String expectedUuid) { - assertThat(db.select("select profile_uuid from active_rules where uuid = '" + uuid + "'") - .stream() - .map(row -> row.get("PROFILE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertActiveRule(String uuid, Long profileId) { - db.executeInsert("active_rules", - "uuid", uuid, - "profile_id", profileId, - "rule_id", 1, - "failure_level", 2); - } - - private void insertRuleProfile(Long id, String uuid) { - db.executeInsert("rules_profiles", - "id", id, - "uuid", uuid, - "name", "name" + id, - "kee", "kee" + id, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java deleted file mode 100644 index fd1d79e61f260516f994fb2a8d4fe889132549cd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.orgqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrgQProfilesRulesProfileUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrgQProfilesRulesProfileUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateOrgQProfilesRulesProfileUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - String ruleProfileKee_1 = "kee-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - String ruleProfileKee_2 = "kee-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - String ruleProfileKee_3 = "kee-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); - - String orgQProfileUuid_1 = "orgQProfileUuid_1"; - insertOrgQProfiles(orgQProfileUuid_1, ruleProfileKee_1); - String orgQProfileUuid_2 = "orgQProfileUuid_2"; - insertOrgQProfiles(orgQProfileUuid_2, ruleProfileKee_2); - String orgQProfileUuid_3 = "orgQProfileUuid_3"; - insertOrgQProfiles(orgQProfileUuid_3, ruleProfileKee_3); - - underTest.execute(); - - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_1, ruleProfileUuid_1); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_2, ruleProfileUuid_2); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_3, ruleProfileUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - String ruleProfileKee_1 = "kee-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - String ruleProfileKee_2 = "kee-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - String ruleProfileKee_3 = "kee-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); - - String orgQProfileUuid_1 = "orgQProfileUuid_1"; - insertOrgQProfiles(orgQProfileUuid_1, ruleProfileKee_1); - String orgQProfileUuid_2 = "orgQProfileUuid_2"; - insertOrgQProfiles(orgQProfileUuid_2, ruleProfileKee_2); - String orgQProfileUuid_3 = "orgQProfileUuid_3"; - insertOrgQProfiles(orgQProfileUuid_3, ruleProfileKee_3); - - underTest.execute(); - - long ruleProfileId_4 = 4L; - String ruleProfileUuid_4 = "uuid-4"; - String ruleProfileKee_4 = "kee-4"; - insertRuleProfile(ruleProfileId_4, ruleProfileUuid_4, ruleProfileKee_4); - - String orgQProfileUuid_4 = "orgQProfileUuid_4"; - insertOrgQProfiles(orgQProfileUuid_4, ruleProfileKee_4); - - // re-entrant - underTest.execute(); - - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_1, ruleProfileUuid_1); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_2, ruleProfileUuid_2); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_3, ruleProfileUuid_3); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_4, ruleProfileUuid_4); - } - - private void assertThatOrgQprofileRulesProfileUuidIsEqualTo(String orgQprofileUuid, String expectedUuid) { - assertThat(db.select("select rules_profile_uuid from org_qprofiles where uuid = '" + orgQprofileUuid + "'") - .stream() - .map(row -> row.get("RULES_PROFILE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertOrgQProfiles(String uuid, String rulesProfileUuid) { - db.executeInsert("org_qprofiles", - "uuid", uuid, - "organization_uuid", Uuids.createFast(), - "rules_profile_uuid", rulesProfileUuid, - "created_at", System.currentTimeMillis(), - "updated_at", System.currentTimeMillis()); - } - - private void insertRuleProfile(Long id, String uuid, String kee) { - db.executeInsert("rules_profiles", - "id", id, - "uuid", uuid, - "name", "name" + id, - "kee", kee, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java deleted file mode 100644 index a3ea54d70ff3ffd691fe6a52061cd19a7349843d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.qprofilechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateQProfileChangesRulesProfileUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileChangesRulesProfileUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQProfileChangesRulesProfileUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - String ruleProfileKee_1 = "kee-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - String ruleProfileKee_2 = "kee-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - String ruleProfileKee_3 = "kee-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); - - String qProfileChangeUuid_1 = "qProfileChangeUuid_1"; - insertQProfileChange(qProfileChangeUuid_1, ruleProfileKee_1); - String qProfileChangeUuid_2 = "qProfileChangeUuid_2"; - insertQProfileChange(qProfileChangeUuid_2, ruleProfileKee_2); - String qProfileChangeUuid_3 = "qProfileChangeUuid_3"; - insertQProfileChange(qProfileChangeUuid_3, ruleProfileKee_3); - - underTest.execute(); - - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_1, ruleProfileUuid_1); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_2, ruleProfileUuid_2); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_3, ruleProfileUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - String ruleProfileKee_1 = "kee-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - String ruleProfileKee_2 = "kee-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - String ruleProfileKee_3 = "kee-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); - - String qProfileChangeUuid_1 = "qProfileChangeUuid_1"; - insertQProfileChange(qProfileChangeUuid_1, ruleProfileKee_1); - String qProfileChangeUuid_2 = "qProfileChangeUuid_2"; - insertQProfileChange(qProfileChangeUuid_2, ruleProfileKee_2); - String qProfileChangeUuid_3 = "qProfileChangeUuid_3"; - insertQProfileChange(qProfileChangeUuid_3, ruleProfileKee_3); - - underTest.execute(); - - long ruleProfileId_4 = 4L; - String ruleProfileUuid_4 = "uuid-4"; - String ruleProfileKee_4 = "kee-4"; - insertRuleProfile(ruleProfileId_4, ruleProfileUuid_4, ruleProfileKee_4); - - String qProfileChangeUuid_4 = "qProfileChangeUuid_4"; - insertQProfileChange(qProfileChangeUuid_4, ruleProfileKee_4); - - // re-entrant - underTest.execute(); - - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_1, ruleProfileUuid_1); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_2, ruleProfileUuid_2); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_3, ruleProfileUuid_3); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_4, ruleProfileUuid_4); - } - - private void assertThatQProfileChangeRulesProfileUuidIsEqualTo(String qProfileChangeKee, String expectedUuid) { - assertThat(db.select("select rules_profile_uuid from qprofile_changes where kee = '" + qProfileChangeKee + "'") - .stream() - .map(row -> row.get("RULES_PROFILE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertQProfileChange(String kee, String rulesProfileUuid) { - db.executeInsert("qprofile_changes", - "kee", kee, - "change_type", Uuids.createFast(), - "rules_profile_uuid", rulesProfileUuid, - "created_at", System.currentTimeMillis()); - } - - private void insertRuleProfile(Long id, String uuid, String kee) { - db.executeInsert("rules_profiles", - "id", id, - "uuid", uuid, - "name", "name" + id, - "kee", kee, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java deleted file mode 100644 index fdf6723086cae01fb326083f396378ade014f9a5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.snapshots; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.AddPrimaryKeyOnUuidColumnOfSnapshotsTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.class, "schema.sql"); - - private AddPrimaryKeyOnUuidColumnOfSnapshotsTable underTest = new AddPrimaryKeyOnUuidColumnOfSnapshotsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("snapshots", "pk_snapshots", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest.java deleted file mode 100644 index ab000923e97d12edfb3c789680d7e502729bc740..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.snapshots; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropIdColumnOfSnapshotsTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfSnapshotsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfSnapshotsTableTest.class, "schema.sql"); - - private DropIdColumnOfSnapshotsTable underTest = new DropIdColumnOfSnapshotsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("snapshots", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java deleted file mode 100644 index f55068b7a4faca8a8338c42b4930025db2d04d99..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.snapshots; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable; - -public class DropPrimaryKeyOnIdColumnOfSnapshotsTableTest { - - private static final String TABLE_NAME = "snapshots"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DropPrimaryKeyOnIdColumnOfSnapshotsTable underTest = new DropPrimaryKeyOnIdColumnOfSnapshotsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java deleted file mode 100644 index 6946ae6147065b81273fcba2ddd79d458a7353be..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfUsersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("users", "pk_users", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest.java deleted file mode 100644 index 285c9307328af6b0841d9d7e3ef20aca650d7b73..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfUsersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("users", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java deleted file mode 100644 index 677b97c8f36dba0592e634534771d78a588a6695..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnIdColumnOfUsersTableTest { - private static final String TABLE_NAME = "users"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfUsersTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfUsersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java deleted file mode 100644 index 8064954ee2e781a62313b28e639e68ad3562e3a0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUuidColumnOfUsersTableTest { - private static final String TABLE_NAME = "users"; - private static final String INDEX_NAME = "users_uuid"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUniqueIndexOnUuidColumnOfUsersTable(db.database()); - - @Test - public void remove_index_if_exists() throws SQLException { - underTest.execute(); - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java deleted file mode 100644 index 7f2d0f32d152bd98ff1a049f3008d95768f346a0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnUserUuidOfGroupsUsersTableTest { - - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "index_groups_users_user_uuid"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfGroupsUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnUserUuidOfGroupsUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java deleted file mode 100644 index f30e59db094951f25f0f7de542f6a473328b721d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest { - - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "groups_users_unique"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "group_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "group_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java deleted file mode 100644 index 3d8f3800f8a02e778813fe320c474957f71d0aef..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToGroupsUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToGroupsUsersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToGroupsUsers(db.database()); - - @Before - public void setup() { - insertGroupUser(Uuids.createFast(), 1L); - insertGroupUser(Uuids.createFast(), 2L); - insertGroupUser(Uuids.createFast(), 3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups_users", "user_uuid", Types.VARCHAR, 255, true); - - assertThat(db.countSql("select count(*) from groups_users")) - .isEqualTo(3); - } - - private void insertGroupUser(String uuid, Long userId) { - db.executeInsert("groups_users", - "group_uuid", uuid, - "user_id", userId + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java deleted file mode 100644 index bc3acc4cbe3c7c16706f93c24b035868a5e57a3a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfGroupsUsersTableTest { - - private static final String TABLE_NAME = "users_groups"; - private static final String INDEX_NAME = "index_groups_users_on_user_id"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfGroupsUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new DropIndexOnUserIdOfGroupsUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java deleted file mode 100644 index b4d82b0c4e5f6ffc307455f2deaa00c214eadd74..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest { - - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "groups_users_unique"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java deleted file mode 100644 index 97d77353eaf692983e5e92e03f9e4cf9610d2974..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfGroupsUsersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfGroupsUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfGroupsUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("groups_users", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java deleted file mode 100644 index cac9667cb987dba11b289263c05af843a0386712..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeGroupsUsersUserUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUsersUserUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeGroupsUsersUserUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups_users", "user_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java deleted file mode 100644 index 49f120d2ff030aec15e09a72f7772d1c40ee605c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; - -import java.sql.SQLException; -import java.util.Objects; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateGroupsUsersUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUsersUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateGroupsUsersUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String groupUuid_1 = Uuids.createFast(); - insertGroupUser(userId_1, groupUuid_1); - String groupUuid_2 = Uuids.createFast(); - insertGroupUser(userId_2, groupUuid_2); - String groupUuid_3 = Uuids.createFast(); - insertGroupUser(userId_3, groupUuid_3); - String groupUuid_4 = Uuids.createFast(); - insertGroupUser(userId_1, groupUuid_4); - // orphan FK - String groupUuid_5 = Uuids.createFast(); - insertGroupUser(100L, groupUuid_5); - - underTest.execute(); - - assertThat(db.countRowsOfTable("groups_users")).isEqualTo(4); - assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_1, userUuid_1); - assertThatGroupsUserUserUuidIsEqualTo(userId_2, groupUuid_2, userUuid_2); - assertThatGroupsUserUserUuidIsEqualTo(userId_3, groupUuid_3, userUuid_3); - assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_4, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String groupUuid_1 = Uuids.createFast(); - insertGroupUser(userId_1, groupUuid_1); - String groupUuid_2 = Uuids.createFast(); - insertGroupUser(userId_2, groupUuid_2); - String groupUuid_3 = Uuids.createFast(); - insertGroupUser(userId_3, groupUuid_3); - - underTest.execute(); - - String groupUuid_4 = Uuids.createFast(); - insertGroupUser(userId_1, groupUuid_4); - - // re-entrant - underTest.execute(); - - assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_1, userUuid_1); - assertThatGroupsUserUserUuidIsEqualTo(userId_2, groupUuid_2, userUuid_2); - assertThatGroupsUserUserUuidIsEqualTo(userId_3, groupUuid_3, userUuid_3); - assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_4, userUuid_1); - } - - private void assertThatGroupsUserUserUuidIsEqualTo(Long userId, String groupUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from groups_users where user_id = %d and group_uuid = '%s'", userId, groupUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .filter(Objects::nonNull) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertGroupUser(Long userId, String groupUuid) { - db.executeInsert("groups_users", - "user_id", userId, - "group_uuid", groupUuid); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java deleted file mode 100644 index d6a882022a9f9d2ce1916244075ab15286361de0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnUserUuidOfOrganizationMembersTableTest { - - private static final String TABLE_NAME = "organization_members"; - private static final String INDEX_NAME = "org_members_user_uuid"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfOrganizationMembersTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnUserUuidOfOrganizationMembersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java deleted file mode 100644 index f22d41228e875a2e31a5289478b1ee0959656d81..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("organization_members", "pk_organization_members", "user_uuid", "organization_uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java deleted file mode 100644 index 23f142d4cb8e6d31c721afd9c170d73c65b245ab..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToOrganizationMembersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToOrganizationMembersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToOrganizationMembers(db.database()); - - @Before - public void setup() { - insertGroupUser(1L); - insertGroupUser(2L); - insertGroupUser(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("organization_members", "user_uuid", Types.VARCHAR, 255, true); - - assertThat(db.countSql("select count(*) from organization_members")) - .isEqualTo(3); - } - - private void insertGroupUser(Long id) { - db.executeInsert("organization_members", - "user_id", id, - "organization_uuid", "uuid-" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java deleted file mode 100644 index a5855e58af2a28ca26166c96d39b4f901ff5f92a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfOrganizationMembersTableTest { - - private static final String TABLE_NAME = "organization_members"; - private static final String INDEX_NAME = "ix_org_members_on_user_id"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfOrganizationMembersTableTest.class, "schema.sql"); - - DdlChange underTest = new DropIndexOnUserIdOfOrganizationMembersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java deleted file mode 100644 index cbc0310e1f5e2390862add88d6b2151a02e720bb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest { - private static final String TABLE_NAME = "organization_members"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final DdlChange underTest = new DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java deleted file mode 100644 index 6f53c7f19a1752ee9f5f159ebe52e52a947446bd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfOrganizationMembersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfOrganizationMembersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfOrganizationMembersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("organization_members", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java deleted file mode 100644 index 0c7f8ec3c5954c117a8ae7bb69afe56bad834a30..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeOrganizationMembersUserUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationMembersUserUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeOrganizationMembersUserUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("organization_members", "user_uuid", VARCHAR, 255, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java deleted file mode 100644 index 516dd9e0e0bb251375e020e4bda14f8112bebd22..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationMembersUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationMembersUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateOrganizationMembersUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String organizationUuid_1 = Uuids.createFast(); - insertOrganizationMember(userId_1, organizationUuid_1); - String organizationUuid_2 = Uuids.createFast(); - insertOrganizationMember(userId_2, organizationUuid_2); - String organizationUuid_3 = Uuids.createFast(); - insertOrganizationMember(userId_3, organizationUuid_3); - String organizationUuid_4 = Uuids.createFast(); - insertOrganizationMember(userId_4, organizationUuid_4); - String organizationUuid_5 = Uuids.createFast(); - insertOrganizationMember(userId_1, organizationUuid_5); - - // orphan FK - String organizationUuid_6 = Uuids.createFast(); - insertOrganizationMember(100L, organizationUuid_6); - - underTest.execute(); - - assertThat(db.countRowsOfTable("organization_members")).isEqualTo(5); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_1, userUuid_1); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_2, organizationUuid_2, userUuid_2); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_3, userUuid_3); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_4, organizationUuid_4, userUuid_4); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_5, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String organizationUuid_1 = Uuids.createFast(); - insertOrganizationMember(userId_1, organizationUuid_1); - String organizationUuid_2 = Uuids.createFast(); - insertOrganizationMember(userId_2, organizationUuid_2); - String organizationUuid_3 = Uuids.createFast(); - insertOrganizationMember(userId_3, organizationUuid_3); - - underTest.execute(); - - String organizationUuid_4 = Uuids.createFast(); - insertOrganizationMember(userId_3, organizationUuid_4); - - // re-entrant - underTest.execute(); - - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_1, userUuid_1); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_2, organizationUuid_2, userUuid_2); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_3, userUuid_3); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_4, userUuid_3); - } - - private void assertThatQProfileChangeRulesProfileUuidIsEqualTo(Long userId, String organizationUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from organization_members where user_id = %d and organization_uuid = '%s'", userId, organizationUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertOrganizationMember(Long userId, String organizationUuid) { - db.executeInsert("organization_members", - "user_id", userId, - "organization_uuid", organizationUuid); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java deleted file mode 100644 index 1e58a237c36fe3393fb10041bae0d57b50d9f3f9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToPermTemplatesUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToPermTemplatesUsersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToPermTemplatesUsers(db.database()); - - @Before - public void setup() { - insertPermTemplatesUser(Uuids.createFast(), 1L); - insertPermTemplatesUser(Uuids.createFast(), 2L); - insertPermTemplatesUser(Uuids.createFast(), 3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "user_uuid", Types.VARCHAR, 255, true); - - assertThat(db.countSql("select count(*) from perm_templates_users")) - .isEqualTo(3); - } - - private void insertPermTemplatesUser(String uuid, long userId) { - db.executeInsert("perm_templates_users", - "uuid", uuid, - "user_id", userId, - "template_id", userId + 100, - "permission_reference", Uuids.createFast()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 4fcdcb69d699057f2366efd0ddf6ad7ade4a4fd5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfPermTemplatesUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_users", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java deleted file mode 100644 index 8c6b7319d352975fca34dfa4ec18338b25c288b5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesUsersUserUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersUserUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesUsersUserUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "user_uuid", VARCHAR, 255, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java deleted file mode 100644 index ec7a482bd22fe58c0be863cda6e68467020b22aa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesUsersUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulatePermTemplatesUsersUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String permTemplatesUserUuid_1 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_1, userId_1); - String permTemplatesUserUuid_2 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_2, userId_2); - String permTemplatesUserUuid_3 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_3, userId_3); - String permTemplatesUserUuid_4 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_4, userId_4); - String permTemplatesUserUuid_5 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_5, userId_1); - - // orphan FK - String permTemplatesUserUuid_6 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_6, 100L); - - underTest.execute(); - - assertThat(db.countRowsOfTable("perm_templates_users")).isEqualTo(5); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_1, userUuid_1); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_2, userUuid_2); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_3, userUuid_3); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_4, userUuid_4); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_5, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String permTemplatesUserUuid_1 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_1, userId_1); - String permTemplatesUserUuid_2 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_2, userId_2); - String permTemplatesUserUuid_3 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_3, userId_3); - - underTest.execute(); - - String permTemplatesUserUuid_4 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_4, userId_4); - String permTemplatesUserUuid_5 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_5, userId_1); - - // re-entrant - underTest.execute(); - - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_1, userUuid_1); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_2, userUuid_2); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_3, userUuid_3); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_4, userUuid_4); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_5, userUuid_1); - } - - private void assertThatPermTemplatesUsersUserUuidIsEqualTo(String permTemplatesUserUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from perm_templates_users where uuid = '%s'", permTemplatesUserUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertPermTemplatesUser(String uuid, long userId) { - db.executeInsert("perm_templates_users", - "uuid", uuid, - "user_id", userId, - "template_id", userId + 100, - "permission_reference", Uuids.createFast()); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java deleted file mode 100644 index 02330be1f4d73368506e212f1cf1f84349e099dd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToPropertiesUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToPropertiesUsersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToPropertiesUsers(db.database()); - - @Before - public void setup() { - insertProperty(Uuids.createFast()); - insertProperty(Uuids.createFast()); - insertProperty(Uuids.createFast()); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("properties", "user_uuid", Types.VARCHAR, 255, true); - - assertThat(db.countSql("select count(*) from properties")) - .isEqualTo(3); - } - - private void insertProperty(String uuid) { - db.executeInsert("properties", - "uuid", uuid, - "prop_key", "kee-" + uuid, - "is_empty", false, - "created_at", System.currentTimeMillis()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java deleted file mode 100644 index 01fc0f79fa80e27269683560b2a67d4c26471b81..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfPropertiesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfPropertiesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfPropertiesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("properties", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest.java deleted file mode 100644 index 2550fec05cec2029b13c96700b25c0012e896ccf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.Optional; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePropertiesUserUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePropertiesUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulatePropertiesUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String propertyUuid_1 = Uuids.createFast(); - insertProperty(propertyUuid_1, userId_1); - String propertyUuid_2 = Uuids.createFast(); - insertProperty(propertyUuid_2, userId_2); - String propertyUuid_3 = Uuids.createFast(); - insertProperty(propertyUuid_3, userId_3); - String propertyUuid_4 = Uuids.createFast(); - insertProperty(propertyUuid_4, userId_4); - String propertyUuid_5 = Uuids.createFast(); - insertProperty(propertyUuid_5, null); - - underTest.execute(); - - assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_2, userUuid_2); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_3, userUuid_3); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_4, userUuid_4); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_5, null); - } - - @Test - public void should_remove_property_for_non_existent_user() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - - long userId_3 = 3L; - - String propertyUuid_1 = Uuids.createFast(); - insertProperty(propertyUuid_1, userId_1); - String propertyUuid_2 = Uuids.createFast(); - insertProperty(propertyUuid_2, userId_2); - String propertyUuid_3 = Uuids.createFast(); - insertProperty(propertyUuid_3, userId_3); - - underTest.execute(); - - assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); - assertPropertyIsRemoved(propertyUuid_2); - assertPropertyIsRemoved(propertyUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String propertyUuid_1 = Uuids.createFast(); - insertProperty(propertyUuid_1, userId_1); - String propertyUuid_2 = Uuids.createFast(); - insertProperty(propertyUuid_2, userId_2); - String propertyUuid_3 = Uuids.createFast(); - insertProperty(propertyUuid_3, userId_3); - - underTest.execute(); - - String propertyUuid_4 = Uuids.createFast(); - insertProperty(propertyUuid_4, userId_4); - String propertyUuid_5 = Uuids.createFast(); - insertProperty(propertyUuid_5, null); - - // re-entrant - underTest.execute(); - - assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_2, userUuid_2); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_3, userUuid_3); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_4, userUuid_4); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_5, null); - } - - private void assertThatPropertyUserUuidIsEqualTo(String propertyUuid, String expectedUuid) { - Optional optional = db.select(String.format("select user_uuid from properties where uuid = '%s'", propertyUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .filter(Objects::nonNull) - .findFirst(); - - if (expectedUuid != null) { - assertThat(optional).hasValue(expectedUuid); - } else { - assertThat(optional).isEmpty(); - } - - } - - private void assertPropertyIsRemoved(String propertyUuid){ - assertThat(db.select(String.format("select 1 from properties where uuid = '%s'", propertyUuid))).isEmpty(); - } - - private void insertProperty(String uuid, Long userId) { - db.executeInsert("properties", - "uuid", uuid, - "user_id", userId, - "prop_key", "kee-" + uuid, - "is_empty", false, - "created_at", System.currentTimeMillis()); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java deleted file mode 100644 index 34379d1fe3164e8b4de279ea0310fb96eaa930dc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest { - - private static final String TABLE_NAME = "qprofile_edit_users"; - private static final String INDEX_NAME = "qprofile_edit_users_unique"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "qprofile_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "qprofile_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java deleted file mode 100644 index 9bd2ffcdc92b323fd915efcea3e1437017195078..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToQProfileEditUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToQProfileEditUsersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToQProfileEditUsers(db.database()); - - @Before - public void setup() { - insertQProfileEditUser(Uuids.createFast(), 1L); - insertQProfileEditUser(Uuids.createFast(), 2L); - insertQProfileEditUser(Uuids.createFast(), 3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("qprofile_edit_users", "user_uuid", Types.VARCHAR, 255, true); - - assertThat(db.countSql("select count(*) from qprofile_edit_users")) - .isEqualTo(3); - } - - private void insertQProfileEditUser(String uuid, long userId) { - db.executeInsert("qprofile_edit_users", - "uuid", uuid, - "user_id", userId, - "qprofile_uuid", Uuids.createFast(), - "created_at", System.currentTimeMillis()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java deleted file mode 100644 index 12d4645237567965e1fb87a23b8bf61859412c31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest { - - private static final String TABLE_NAME = "qprofile_edit_users"; - private static final String INDEX_NAME = "qprofile_edit_users_unique"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java deleted file mode 100644 index 59d0093a75b84501616e504929c1ebff5cffc228..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfQProfileEditUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfQProfileEditUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfQProfileEditUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("qprofile_edit_users", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java deleted file mode 100644 index 0a92dd95c619331f42243e6e4a3bfa0c5a93c8ae..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQProfileEditUsersUserUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQProfileEditUsersUserUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQProfileEditUsersUserUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("qprofile_edit_users", "user_uuid", VARCHAR, 255, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java deleted file mode 100644 index 356c4a3c796b2f49728a363352221ad179cfd01c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateQProfileEditUsersUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileEditUsersUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQProfileEditUsersUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String qprofileEditUserUuid_1 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_1, userId_1); - String qprofileEditUserUuid_2 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_2, userId_2); - String qprofileEditUserUuid_3 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_3, userId_3); - String qprofileEditUserUuid_4 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_4, userId_4); - String qprofileEditUserUuid_5 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_5, userId_1); - - // orphan FK - String qprofileEditUserUuid_6 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_6, 100L); - - underTest.execute(); - - assertThat(db.countRowsOfTable("qprofile_edit_users")).isEqualTo(5); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_1, userUuid_1); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_2, userUuid_2); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_3, userUuid_3); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_4, userUuid_4); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_5, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String qprofileEditUserUuid_1 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_1, userId_1); - String qprofileEditUserUuid_2 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_2, userId_2); - String qprofileEditUserUuid_3 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_3, userId_3); - - underTest.execute(); - - String qprofileEditUserUuid_4 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_4, userId_4); - String qprofileEditUserUuid_5 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_5, userId_1); - - // re-entrant - underTest.execute(); - - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_1, userUuid_1); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_2, userUuid_2); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_3, userUuid_3); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_4, userUuid_4); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_5, userUuid_1); - } - - private void assertThatQProfileEditUserUserUuidIsEqualTo(String qprofileEditUserUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from qprofile_edit_users where uuid = '%s'", qprofileEditUserUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertQProfileEditUser(String uuid, long userId) { - db.executeInsert("qprofile_edit_users", - "uuid", uuid, - "user_id", userId, - "qprofile_uuid", Uuids.createFast(), - "created_at", System.currentTimeMillis()); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java deleted file mode 100644 index cada9f5113460fa5d4f65e3fa45c66cea8e5b8a8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnUserUuidOfUserRolesTableTest { - - private static final String TABLE_NAME = "user_roles"; - private static final String INDEX_NAME = "user_roles_user"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfUserRolesTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnUserUuidOfUserRolesTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java deleted file mode 100644 index a8dc62b9c93c69d9a1d7de237bddc7241881abf5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToUserRolesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToUserRolesTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToUserRoles(db.database()); - - @Before - public void setup() { - insertUserRole(Uuids.createFast(), 1L); - insertUserRole(Uuids.createFast(), 2L); - insertUserRole(Uuids.createFast(), 3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("user_roles", "user_uuid", Types.VARCHAR, 255, true); - - assertThat(db.countSql("select count(*) from user_roles")) - .isEqualTo(3); - } - - private void insertUserRole(String uuid, Long userId) { - db.executeInsert("user_roles", - "uuid", uuid, - "organization_uuid", Uuids.createFast(), - "user_id", userId, - "role", Uuids.createFast()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java deleted file mode 100644 index f1f9c717e025424487c299232f08729b5d2b588b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfUserRolesTableTest { - - private static final String TABLE_NAME = "user_roles"; - private static final String INDEX_NAME = "user_roles_user"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfUserRolesTableTest.class, "schema.sql"); - - DdlChange underTest = new DropIndexOnUserIdOfUserRolesTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java deleted file mode 100644 index 95e2ab7f910a616f2280d0ed772d4853ffb50033..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfUserRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfUserRolesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfUserRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("user_roles", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest.java deleted file mode 100644 index cbbb4107c9dee33ff00426a80b11e082cb9e7b81..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUserRolesUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUserRolesUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateUserRolesUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String userRoleUuid_1 = Uuids.createFast(); - insertUserRole(userRoleUuid_1, userId_1); - String userRoleUuid_2 = Uuids.createFast(); - insertUserRole(userRoleUuid_2, userId_2); - String userRoleUuid_3 = Uuids.createFast(); - insertUserRole(userRoleUuid_3, userId_3); - String userRoleUuid_4 = Uuids.createFast(); - insertUserRole(userRoleUuid_4, userId_4); - String userRoleUuid_5 = Uuids.createFast(); - insertUserRole(userRoleUuid_5, userId_1); - - underTest.execute(); - - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_1, userUuid_1); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_2, userUuid_2); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_3, userUuid_3); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_4, userUuid_4); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_5, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String userRoleUuid_1 = Uuids.createFast(); - insertUserRole(userRoleUuid_1, userId_1); - String userRoleUuid_2 = Uuids.createFast(); - insertUserRole(userRoleUuid_2, userId_2); - String userRoleUuid_3 = Uuids.createFast(); - insertUserRole(userRoleUuid_3, userId_3); - - underTest.execute(); - - String userRoleUuid_4 = Uuids.createFast(); - insertUserRole(userRoleUuid_4, userId_4); - String userRoleUuid_5 = Uuids.createFast(); - insertUserRole(userRoleUuid_5, userId_1); - - // re-entrant - underTest.execute(); - - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_1, userUuid_1); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_2, userUuid_2); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_3, userUuid_3); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_4, userUuid_4); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_5, userUuid_1); - } - - private void assertThatUserRoleUserUuidIsEqualTo(String userRoleUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from user_roles where uuid = '%s'", userRoleUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertUserRole(String uuid, Long userId) { - db.executeInsert("user_roles", - "uuid", uuid, - "organization_uuid", Uuids.createFast(), - "user_id", userId, - "role", Uuids.createFast()); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java deleted file mode 100644 index 6812e5d9d91c3c3807624751cf3459d8ea9e4733..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfUserTokensTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfUserTokensTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("user_tokens", "pk_user_tokens", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest.java deleted file mode 100644 index f68e164a1b80bb43a81ab7cc917f79a0c715d07e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToUserTokensTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToUserTokensTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToUserTokens(db.database()); - - @Before - public void setup() { - insertUserToken(1L, "user1", "name1", "token1"); - insertUserToken(2L, "user2", "name2", "token2"); - insertUserToken(3L, "user3", "name3", "token3"); - } - - @Test - public void add_uuid_column_to_user_tokens() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("user_tokens", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from user_tokens")) - .isEqualTo(3); - } - - private void insertUserToken(Long id, String userUuid, String name, String tokenHash) { - db.executeInsert("user_tokens", - "id", id, - "USER_UUID", userUuid, - "NAME", name, - "TOKEN_HASH", tokenHash, - "CREATED_AT", 0L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest.java deleted file mode 100644 index 88f3dfa305f1aae82c52d8f5e5ecc031a9d1ed2b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfUserTokensTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfUserTokensTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfUserTokensTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("user_tokens", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java deleted file mode 100644 index 48b4fd82831c2f0b15713654811708d9b5f93d3e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropPrimaryKeyOnIdColumnOfUserTokensTableTest { - - private static final String TABLE_NAME = "user_tokens"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfUserTokensTableTest.class, "schema.sql"); - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfUserTokensTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_re_entrant_but_fails_silently() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest.java deleted file mode 100644 index ed7d21671a5e965bdae99fb6907ba82a898fc771..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeUserTokensUuidNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeUserTokensUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeUserTokensUuidNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("user_tokens", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest.java deleted file mode 100644 index 307ae8e6ffcff71614d35b2849ef0da20efe330f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v84.usertokens; - -import java.sql.SQLException; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUserTokensUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUserTokensUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateUserTokensUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertUserToken(1L, "user1", "name1", "token1"); - insertUserToken(2L, "user2", "name2", "token2"); - insertUserToken(3L, "user3", "name3", "token3"); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertUserToken(1L, "user1", "name1", "token1"); - insertUserToken(2L, "user2", "name2", "token2"); - insertUserToken(3L, "user3", "name3", "token3"); - - underTest.execute(); - verifyUuidsAreNotNull(); - insertUserToken(4L, "user4", "name4", "token4"); - insertUserToken(5L, "user5", "name5", "token5"); - - List uuids = db.select("select uuid from user_tokens where id = 1 or id = 2 or id = 3") - .stream() - .map(row -> (String) row.get("UUID")) - .collect(Collectors.toList()); - - // re-entrant - underTest.execute(); - verifyUuidsAreNotNull(); - - // verify that uuid set during the first migration have not been updated during the second migration - assertThat(db.select("select uuid from user_tokens") - .stream() - .map(row -> (String) row.get("UUID")) - .collect(Collectors.toList())) - .containsAll(uuids); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from user_tokens") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertUserToken(Long id, String userUuid, String name, String tokenHash) { - db.executeInsert("user_tokens", - "id", id, - "USER_UUID", userUuid, - "NAME", name, - "TOKEN_HASH", tokenHash, - "CREATED_AT", 0L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTableTest.java deleted file mode 100644 index 7337bb06dd62ab127d1afeb8695a338f3bdbf1cb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import 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 AddIndexOnIssueKeyForIssueChangesTableTest { - private static final String TABLE_NAME = "issue_changes"; - private static final String INDEX_NAME = "issue_changes_issue_key"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnIssueKeyForIssueChangesTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnIssueKeyForIssueChangesTable(db.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - db.assertIndex(TABLE_NAME, INDEX_NAME, "issue_key"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - db.assertIndex(TABLE_NAME, INDEX_NAME, "issue_key"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTableTest.java deleted file mode 100644 index f4ebe62acbecba7b26f5248e5dd5250351a66635..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import 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 AddIndexOnKeeForIssueChangesTableTest { - private static final String TABLE_NAME = "issue_changes"; - private static final String INDEX_NAME = "issue_changes_kee"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnKeeForIssueChangesTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnKeeForIssueChangesTable(db.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - db.assertIndex(TABLE_NAME, INDEX_NAME, "kee"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - db.assertIndex(TABLE_NAME, INDEX_NAME, "kee"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTableTest.java deleted file mode 100644 index 37d6f8d4e7dac947d07d8d29cd351adf792257e4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import 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 AddIndexOnMessageTypeColumnOfCeTaskMessageTableTest { - private static final String TABLE_NAME = "ce_task_message"; - private static final String INDEX_NAME = "ctm_message_type"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnMessageTypeColumnOfCeTaskMessageTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnMessageTypeColumnOfCeTaskMessageTable(db.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_NAME, INDEX_NAME, "message_type"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTableTest.java deleted file mode 100644 index e47019251dcadb881bc1f8b54d920a6eaa24523d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import 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 AddIndexOnProjectUuidOnIssueChangesTableTest { - private static final String TABLE_NAME = "issue_changes"; - private static final String INDEX_NAME = "issue_changes_project_uuid"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnProjectUuidOnIssueChangesTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnProjectUuidOnIssueChangesTable(db.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - db.assertIndex(TABLE_NAME, INDEX_NAME, "project_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - db.assertIndex(TABLE_NAME, INDEX_NAME, "project_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTableTest.java deleted file mode 100644 index 1acbee3422c3b56b2aad926dfd37ea34e20ee87a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTableTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMessageTypeColumnToCeTaskMessageTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMessageTypeColumnToCeTaskMessageTableTest.class, "schema.sql"); - - private final DdlChange underTest = new AddMessageTypeColumnToCeTaskMessageTable(db.database()); - - @Before - public void setup() { - insertTaskMessage(1L, "a1"); - insertTaskMessage(2L, "a2"); - insertTaskMessage(3L, "a3"); - } - - @Test - public void add_message_type_column_to_ce_task_message_table() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_task_message", "message_type", Types.VARCHAR, 255, true); - - assertThat(db.countSql("select count(uuid) from ce_task_message")).isEqualTo(3); - } - - private void insertTaskMessage(Long id, String message) { - db.executeInsert("ce_task_message", - "uuid", "uuid-" + id, - "task_uuid", "task-uuid-" + id, - "message", message, - "created_at", System2.INSTANCE.now()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTableTest.java deleted file mode 100644 index 25f8681a9abc66c61e9ca0997c0bf0e23bdc77f4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTableTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidForIssueChangesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidForIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidForIssueChangesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("issue_changes", "pk_issue_changes", "uuid"); - } - - @Test - public void skip_if_project_uuid_index_exists() throws SQLException { - db.executeDdl("create index issue_changes_project_uuid on issue_changes ( issue_key)"); - - underTest.execute(); - - db.assertNoPrimaryKey("issue_changes"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddTypeToPluginsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddTypeToPluginsTest.java deleted file mode 100644 index 2df093b2660062311edb315e4839eb1466cd9a31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddTypeToPluginsTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddTypeToPluginsTest { - private static final String TABLE_NAME = "plugins"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddTypeToPluginsTest.class, "schema.sql"); - - private MigrationStep underTest = new AddTypeToPlugins(db.database()); - - @Test - public void add_column() throws SQLException { - addPlugin("1"); - addPlugin("2"); - underTest.execute(); - db.assertColumnDefinition(TABLE_NAME, "type", Types.VARCHAR, 10, true); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(2); - } - - private void addPlugin(String id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "kee", "kee" + id, - "base_plugin_key", "base" + id, - "file_hash", "hash" + id, - "created_at", 1L, - "updated_at", 2L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullableTest.java deleted file mode 100644 index 9c4ea9061dac8c2078c84aa35c804d63fa0ab20c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullableTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AlterTypeInPluginNotNullableTest { - private static final String TABLE_NAME = "plugins"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AlterTypeInPluginNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new AlterTypeInPluginNotNullable(db.database()); - - @Test - public void add_column() throws SQLException { - addPlugin("1"); - addPlugin("2"); - underTest.execute(); - db.assertColumnDefinition(TABLE_NAME, "type", Types.VARCHAR, 10, false); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(2); - } - - private void addPlugin(String id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "kee", "kee" + id, - "base_plugin_key", "base" + id, - "file_hash", "hash" + id, - "type", "BUNDLED", - "created_at", 1L, - "updated_at", 2L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTableTest.java deleted file mode 100644 index 96267985c853c7118f6af23cabb3590a2b6285f6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTableTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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.BIGINT; -import static java.sql.Types.CLOB; -import static java.sql.Types.VARCHAR; - -public class CreateTmpIssueChangesTableTest { - - private static final String TABLE_NAME = "tmp_issue_changes"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTmpIssueChangesTableTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTmpIssueChangesTable underTest = new CreateTmpIssueChangesTable(dbTester.database()); - - @Test - public void skip_if_project_uuid_column_exists() throws SQLException { - dbTester.executeDdl("ALTER TABLE issue_changes ADD project_uuid VARCHAR"); - - underTest.execute(); - dbTester.assertTableDoesNotExist(TABLE_NAME); - } - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, 40, true); - dbTester.assertColumnDefinition(TABLE_NAME, "kee", VARCHAR, 50, true); - dbTester.assertColumnDefinition(TABLE_NAME, "issue_key", VARCHAR, 50, true); - dbTester.assertColumnDefinition(TABLE_NAME, "user_login", VARCHAR, 255, true); - dbTester.assertColumnDefinition(TABLE_NAME, "change_type", VARCHAR, 20, true); - dbTester.assertColumnDefinition(TABLE_NAME, "change_data", CLOB, null, true); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, null, true); - dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", BIGINT, null, true); - dbTester.assertColumnDefinition(TABLE_NAME, "issue_change_creation_date", BIGINT, null, true); - dbTester.assertColumnDefinition(TABLE_NAME, "project_uuid", VARCHAR, 50, true); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/CreateUserDismissedMessagesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/CreateUserDismissedMessagesTableTest.java deleted file mode 100644 index 7c2608e1bee8c2a1d18526ddf1ad7c1d64b662c2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/CreateUserDismissedMessagesTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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 CreateUserDismissedMessagesTableTest { - private static final String TABLE_NAME = "user_dismissed_messages"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createEmpty(); - - private final CreateUserDismissedMessagesTable underTest = new CreateUserDismissedMessagesTable(dbTester.database()); - - @Test - public void table_has_been_created() throws SQLException { - underTest.execute(); - - dbTester.assertTableExists(TABLE_NAME); - dbTester.assertPrimaryKey(TABLE_NAME, "pk_user_dismissed_messages", "uuid"); - dbTester.assertColumnDefinition(TABLE_NAME, "uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "user_uuid", VARCHAR, 255, false); - dbTester.assertColumnDefinition(TABLE_NAME, "project_uuid", VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_NAME, "message_type", VARCHAR, 255, false); - dbTester.assertColumnDefinition(TABLE_NAME, "created_at", BIGINT, null, false); - dbTester.assertUniqueIndex(TABLE_NAME, "uniq_user_dismissed_messages", "user_uuid", - "project_uuid", "message_type"); - dbTester.assertIndex(TABLE_NAME, "udm_project_uuid", "project_uuid"); - dbTester.assertIndex(TABLE_NAME, "udm_message_type", "message_type"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DbVersion85Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DbVersion85Test.java deleted file mode 100644 index 54a106d30c8410812b27f35faa1c1b37be50ae85..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DbVersion85Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion85Test { - - private DbVersion underTest = new DbVersion85(); - - @Test - public void migrationNumber_starts_at_4000() { - verifyMinimumMigrationNumber(underTest, 4000); - } - - @Test - public void verify_migration_count() { - verifyMigrationNotEmpty(underTest); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphansTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphansTest.java deleted file mode 100644 index 18d6b32a7224e38beae11d98799deba010a1d4c0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphansTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -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 DeleteProjectAlmSettingsOrphansTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteProjectAlmSettingsOrphansTest.class, "schema.sql"); - - private DeleteProjectAlmSettingsOrphans underTest = new DeleteProjectAlmSettingsOrphans(db.database()); - - @Test - public void execute_migration() throws SQLException { - String projectUuid1 = insertProject(); - String projectAlmSetting1 = insertProjectAlmSetting(projectUuid1); - String projectUuid2 = insertProject(); - String projectAlmSetting2 = insertProjectAlmSetting(projectUuid2); - String projectUuid3 = insertProject(); - String projectAlmSetting3 = insertProjectAlmSetting(projectUuid3); - - // create orphans - insertProjectAlmSetting(); - insertProjectAlmSetting(); - insertProjectAlmSetting(); - insertProjectAlmSetting(); - - underTest.execute(); - - assertProjectAlmSettingsRowsExist(projectAlmSetting1, projectAlmSetting2, projectAlmSetting3); - } - - private void assertProjectAlmSettingsRowsExist(String... projectAlmSettings) { - assertThat(db.select("select uuid from project_alm_settings") - .stream() - .map(rows -> rows.get("UUID"))).containsOnly(projectAlmSettings); - } - - @Test - public void migration_should_be_reentrant() throws SQLException { - String projectUuid = insertProject(); - String projectAlmSetting = insertProjectAlmSetting(projectUuid); - // create orphans - insertProjectAlmSetting(); - insertProjectAlmSetting(); - insertProjectAlmSetting(); - insertProjectAlmSetting(); - - underTest.execute(); - // should be re-entrant - underTest.execute(); - - assertProjectAlmSettingsRowsExist(projectAlmSetting); - } - - private String insertProjectAlmSetting(String projectUuid) { - String uuid = Uuids.createFast(); - db.executeInsert("PROJECT_ALM_SETTINGS", - "UUID", uuid, - "ALM_SETTING_UUID", uuid + "-name", - "PROJECT_UUID", projectUuid, - "UPDATED_AT", System2.INSTANCE.now(), - "CREATED_AT", System2.INSTANCE.now()); - return uuid; - } - - private String insertProjectAlmSetting() { - String notExistingProjectUuid = Uuids.createFast(); - return insertProjectAlmSetting(notExistingProjectUuid); - } - - private String insertProject() { - String uuid = Uuids.createFast(); - db.executeInsert("PROJECTS", - "UUID", uuid, - "KEE", uuid + "-key", - "QUALIFIER", "TRK", - "ORGANIZATION_UUID", uuid + "-key", - "PRIVATE", Boolean.toString(false), - "UPDATED_AT", System.currentTimeMillis()); - return uuid; - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTableTest.java deleted file mode 100644 index 73ad5876042d94bf8ad9bd33b1b38915cf357471..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTableTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIssueChangesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIssueChangesTable(db.database()); - - @Test - public void dont_drop_if_tmp_table_doesnt_exist() throws SQLException { - db.executeDdl("drop table tmp_issue_changes"); - underTest.execute(); - db.assertTableExists("issue_changes"); - } - - @Test - public void execute() throws SQLException { - db.assertTableExists("issue_changes"); - underTest.execute(); - db.assertTableDoesNotExist("issue_changes"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - db.assertTableExists("issue_changes"); - - underTest.execute(); - - // re-entrant - underTest.execute(); - db.assertTableDoesNotExist("issue_changes"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromPropertiesTest.java deleted file mode 100644 index 13cab92ca6580ca6f4cdd5a7bc13056050515ac6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromPropertiesTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.time.Instant; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DropOrphanFavoritesFromPropertiesTest { - - private static final String PROPERTIES_TABLE_NAME = "properties"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrphanFavoritesFromPropertiesTest.class, "schema.sql"); - - private DataChange underTest = new DropOrphanFavoritesFromProperties(dbTester.database()); - - private static final String COMPONENT_UUID_1 = Uuids.createFast(); - private static final String COMPONENT_UUID_2 = Uuids.createFast(); - private static final String COMPONENT_UUID_3 = Uuids.createFast(); - private static final String COMPONENT_UUID_4 = Uuids.createFast(); - - private static final String USER_UUID_1 = "1"; - private static final String USER_UUID_2 = "2"; - - @Before - public void setup() { - insertProperty("1", USER_UUID_1, COMPONENT_UUID_1, "test"); - insertProperty("2", USER_UUID_2, COMPONENT_UUID_2, "test2"); - insertProperty("3", USER_UUID_2, COMPONENT_UUID_3, "test3"); - insertProperty("4", USER_UUID_2, null, "test3"); - } - - @Test - public void migrate() throws SQLException { - insertProperty("5", USER_UUID_1, COMPONENT_UUID_4, "favourite"); - // properties to remove - insertProperty("6", USER_UUID_2, null, "favourite"); - insertProperty("7", USER_UUID_2, null, "favourite"); - insertProperty("8", USER_UUID_2, null, "favourite"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isEqualTo(5); - assertThat(dbTester.select("select uuid from properties").stream().map(columns -> columns.get("UUID"))) - .containsOnly("1", "2", "3", "4", "5"); - } - - @Test - public void does_not_fail_when_properties_table_empty() throws SQLException { - dbTester.executeUpdateSql("delete from properties"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isZero(); - } - - @Test - public void does_not_remove_properties_with_key_other_than_favourite() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isEqualTo(4L); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - insertProperty("5", USER_UUID_1, COMPONENT_UUID_1, "favourite"); - // properties to remove - insertProperty("6", USER_UUID_1, null, "favourite"); - insertProperty("7", USER_UUID_2, null, "favourite"); - - underTest.execute(); - - insertProperty("8", USER_UUID_2, null, "favourite"); - insertProperty("9", USER_UUID_2, null, "favourite"); - - // re-entrant - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isEqualTo(5); - assertThat(dbTester.select("select uuid from properties").stream().map(columns -> columns.get("UUID"))) - .containsOnly("1", "2", "3", "4", "5"); - } - - private void insertProperty(String uuid, String userUuid, @Nullable String componentUuid, String propKey) { - dbTester.executeInsert(PROPERTIES_TABLE_NAME, - "uuid", uuid, - "user_uuid", userUuid, - "component_uuid", componentUuid, - "prop_key", propKey, - "is_empty", true, - "created_at", Instant.now().toEpochMilli()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTableTest.java deleted file mode 100644 index cf4f36a59fe80980157c136c6f6b2100e02e1f36..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static java.sql.Types.INTEGER; -import static java.sql.Types.VARCHAR; - -public class DropPeriodAndValueWarningColumnsFromQualityGateConditionsTableTest { - - private static final String TABLE_NAME = "quality_gate_conditions"; - private static final String COLUMN_NAME_PERIOD = "period"; - private static final String COLUMN_NAME_VALUE_WARNING = "value_warning"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropPeriodAndValueWarningColumnsFromQualityGateConditionsTableTest.class, "schema.sql"); - - private DropPeriodAndValueWarningColumnsFromQualityGateConditionsTable underTest = new DropPeriodAndValueWarningColumnsFromQualityGateConditionsTable(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - dbTester.assertColumnDefinition(TABLE_NAME, COLUMN_NAME_PERIOD, INTEGER, null, true); - dbTester.assertColumnDefinition(TABLE_NAME, COLUMN_NAME_VALUE_WARNING, VARCHAR, null, true); - underTest.execute(); - dbTester.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME_PERIOD); - dbTester.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME_VALUE_WARNING); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindingsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindingsTest.java deleted file mode 100644 index 74522662a46be7fe260bba5ed454b081626e6fcc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindingsTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropProjectAlmBindingsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropProjectAlmBindingsTest.class, "schema.sql"); - - private MigrationStep underTest = new DropProjectAlmBindings(db.database()); - - @Test - public void drops_table() throws SQLException { - insertData(); - db.assertTableExists("project_alm_bindings"); - underTest.execute(); - db.assertTableDoesNotExist("project_alm_bindings"); - } - - private void insertData() { - db.executeInsert("project_alm_bindings", - "uuid", "uuid1", - "alm_id", "alm1", - "repo_id", "repo1", - "project_uuid", "project1", - "url", "url1", - "created_at", 123L, - "updated_at", 456L - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyTypeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyTypeTest.java deleted file mode 100644 index 1104bc36dedc37bd838a62ca303a66e316de0dc6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyTypeTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.sql.Types; -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.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DropProjectBranchesKeyTypeTest { - private static final String TABLE_NAME = "project_branches"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropProjectBranchesKeyTypeTest.class, "schema.sql"); - - private MigrationStep underTest = new DropProjectBranchesKeyType(db.database()); - - @Test - public void drops_table() throws SQLException { - insertData(1, "PULL_REQUEST", "PULL_REQUEST"); - insertData(2, "BRANCH", "BRANCH"); - - db.assertColumnDefinition(TABLE_NAME, "key_type", Types.VARCHAR, 12, false); - - underTest.execute(); - db.assertIndexDoesNotExist(TABLE_NAME, "project_branches_kee_key_type"); - db.assertUniqueIndex(TABLE_NAME, "uniq_project_branches", "branch_type", "project_uuid", "kee"); - db.assertColumnDoesNotExist(TABLE_NAME, "key_type"); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(2); - } - - private void insertData(int id, String keyType, @Nullable String branchType) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "project_uuid", "project" + id, - "kee", "key" + id, - "key_type", keyType, - "created_at", id, - "updated_at", id + 1, - "need_issue_sync", true, - "branch_type", branchType - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedIndexesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedIndexesTest.java deleted file mode 100644 index 86ec83d9c0a574db2a852b1a528670b776434645..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedIndexesTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUnusedIndexesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUnusedIndexesTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUnusedIndexes(db.database()); - - @Test - public void drops_indexes() throws SQLException { - db.assertUniqueIndex("events", "events_uuid", "uuid"); - db.assertUniqueIndex("ce_activity", "ce_activity_uuid", "uuid"); - db.assertIndex("file_sources", "file_sources_updated_at", "updated_at"); - db.assertIndex("users", "users_updated_at", "updated_at"); - db.assertIndex("alm_app_installs", "alm_app_installs_external_id", "user_external_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("events", "events_uuid"); - db.assertIndexDoesNotExist("ce_activity", "ce_activity_uuid"); - db.assertIndexDoesNotExist("file_sources", "file_sources_updated_at"); - db.assertIndexDoesNotExist("users", "users_updated_at"); - db.assertIndexDoesNotExist("alm_app_installs", "alm_app_installs_external_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshotsTest.java deleted file mode 100644 index cd1f719bb4213f05232c55c81b6a0c77bccfb168..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshotsTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - -public class DropUnusedPeriodsInSnapshotsTest { - private static final String TABLE_NAME = "snapshots"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUnusedPeriodsInSnapshotsTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUnusedPeriodsInSnapshots(db.database()); - - @Test - public void drops_table() throws SQLException { - insertData(); - db.assertColumnDefinition(TABLE_NAME, "period2_mode", Types.VARCHAR, 100, true); - db.assertColumnDefinition(TABLE_NAME, "period3_mode", Types.VARCHAR, 100, true); - db.assertColumnDefinition(TABLE_NAME, "period4_mode", Types.VARCHAR, 100, true); - db.assertColumnDefinition(TABLE_NAME, "period5_mode", Types.VARCHAR, 100, true); - - db.assertColumnDefinition(TABLE_NAME, "period2_param", Types.VARCHAR, 100, true); - db.assertColumnDefinition(TABLE_NAME, "period3_param", Types.VARCHAR, 100, true); - db.assertColumnDefinition(TABLE_NAME, "period4_param", Types.VARCHAR, 100, true); - db.assertColumnDefinition(TABLE_NAME, "period5_param", Types.VARCHAR, 100, true); - - db.assertColumnDefinition(TABLE_NAME, "period2_date", Types.BIGINT, null, true); - db.assertColumnDefinition(TABLE_NAME, "period3_date", Types.BIGINT, null, true); - db.assertColumnDefinition(TABLE_NAME, "period4_date", Types.BIGINT, null, true); - db.assertColumnDefinition(TABLE_NAME, "period5_date", Types.BIGINT, null, true); - - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "period2_mode"); - db.assertColumnDoesNotExist(TABLE_NAME, "period3_mode"); - db.assertColumnDoesNotExist(TABLE_NAME, "period4_mode"); - db.assertColumnDoesNotExist(TABLE_NAME, "period5_mode"); - - db.assertColumnDoesNotExist(TABLE_NAME, "period2_param"); - db.assertColumnDoesNotExist(TABLE_NAME, "period3_param"); - db.assertColumnDoesNotExist(TABLE_NAME, "period4_param"); - db.assertColumnDoesNotExist(TABLE_NAME, "period5_param"); - - db.assertColumnDoesNotExist(TABLE_NAME, "period2_date"); - db.assertColumnDoesNotExist(TABLE_NAME, "period3_date"); - db.assertColumnDoesNotExist(TABLE_NAME, "period4_date"); - db.assertColumnDoesNotExist(TABLE_NAME, "period5_date"); - - assertThat(db.selectFirst("select * from snapshots")).contains(entry("PERIOD1_MODE", "m1")); - - } - - private void insertData() { - db.executeInsert(TABLE_NAME, - "uuid", "uuid1", - "component_uuid", "component1", - - "period1_mode", "m1", - "period2_mode", "m2", - "period3_mode", "m3", - "period4_mode", "m4", - "period5_mode", "m5", - - "period1_param", "p1", - "period2_param", "p2", - "period3_param", "p3", - "period4_param", "p4", - "period5_param", "p5", - - "period1_date", 1, - "period2_date", 2, - "period3_date", 3, - "period4_date", 4, - "period5_date", 5 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasuresTest.java deleted file mode 100644 index 8c074d991b7b49a316c4365930076319b10d4589..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasuresTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - -public class DropUnusedVariationsInProjectMeasuresTest { - private static final String TABLE_NAME = "project_measures"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUnusedVariationsInProjectMeasuresTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUnusedVariationsInProjectMeasures(db.database()); - - @Test - public void drops_table() throws SQLException { - insertData(); - db.assertColumnDefinition(TABLE_NAME, "variation_value_2", Types.DOUBLE, null, true); - db.assertColumnDefinition(TABLE_NAME, "variation_value_3", Types.DOUBLE, null, true); - db.assertColumnDefinition(TABLE_NAME, "variation_value_4", Types.DOUBLE, null, true); - db.assertColumnDefinition(TABLE_NAME, "variation_value_5", Types.DOUBLE, null, true); - - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "variation_value_2"); - db.assertColumnDoesNotExist(TABLE_NAME, "variation_value_3"); - db.assertColumnDoesNotExist(TABLE_NAME, "variation_value_4"); - db.assertColumnDoesNotExist(TABLE_NAME, "variation_value_5"); - assertThat(db.selectFirst("select * from project_measures")).contains(entry("VARIATION_VALUE_1", 1.0)); - - } - - private void insertData() { - db.executeInsert(TABLE_NAME, - "uuid", "uuid1", - "analysis_uuid", "analysis1", - "component_uuid", "component1", - "metric_uuid", "metric1", - "variation_value_1", 1.0, - "variation_value_2", 2.0, - "variation_value_3", 3.0, - "variation_value_4", 4.0, - "variation_value_5", 5.0 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchTypeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchTypeTest.java deleted file mode 100644 index 53a36e7f81e23b2b8c4977f1a5a557f03724135a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchTypeTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -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.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class FillProjectBranchesBranchTypeTest { - private static final String TABLE_NAME = "project_branches"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(FillProjectBranchesBranchTypeTest.class, "schema.sql"); - - private MigrationStep underTest = new FillProjectBranchesBranchType(db.database()); - - @Test - public void drops_table() throws SQLException { - insertData(1, "PULL_REQUEST", "PULL_REQUEST"); - insertData(2, "PULL_REQUEST", null); - insertData(3, "BRANCH", null); - insertData(4, "BRANCH", "BRANCH"); - - underTest.execute(); - assertThat(db.select("select uuid, key_type, branch_type from project_branches")) - .extracting(m -> m.get("UUID"), m -> m.get("KEY_TYPE"), m -> m.get("BRANCH_TYPE")) - .containsOnly( - tuple("uuid1", "PULL_REQUEST", "PULL_REQUEST"), - tuple("uuid2", "PULL_REQUEST", "PULL_REQUEST"), - tuple("uuid3", "BRANCH", "BRANCH"), - tuple("uuid4", "BRANCH", "BRANCH")); - - } - - private void insertData(int id, String keyType, @Nullable String branchType) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "project_uuid", "project" + id, - "kee", "key" + id, - "key_type", keyType, - "created_at", id, - "updated_at", id + 1, - "need_issue_sync", true, - "branch_type", branchType - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTableTest.java deleted file mode 100644 index ca4bb48285b5d3f69a6ee9b22bbbd50e21dcb3f6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeIssueKeyNotNullOnIssueChangesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeIssueKeyNotNullOnIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeIssueKeyNotNullOnIssueChangesTable(db.database()); - - @Test - public void issue_key_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("issue_changes", "issue_key", VARCHAR, 50, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertColumnDefinition("issue_changes", "issue_key", VARCHAR, 50, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTableTest.java deleted file mode 100644 index a8eb628d3f2c28e8b9ce9710a47c71ec667011f0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeMessageTypeColumnNotNullableOnCeTaskMessageTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeMessageTypeColumnNotNullableOnCeTaskMessageTableTest.class, "schema.sql"); - - private final MigrationStep underTest = new MakeMessageTypeColumnNotNullableOnCeTaskMessageTable(db.database()); - - @Test - public void message_type_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("ce_task_message", "message_type", VARCHAR, 255, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullableTest.java deleted file mode 100644 index b13a3b85dfb9f124ae1ec03e9b8fd3c9cf301638..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullableTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.sql.Types; -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.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MakeProjectBranchesBranchTypeNotNullableTest { - private static final String TABLE_NAME = "project_branches"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectBranchesBranchTypeNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectBranchesBranchTypeNotNullable(db.database()); - - @Test - public void drops_table() throws SQLException { - insertData(1, "PULL_REQUEST", "PULL_REQUEST"); - insertData(2, "BRANCH", "BRANCH"); - - db.assertColumnDefinition(TABLE_NAME, "branch_type", Types.VARCHAR, 12, true); - - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "branch_type", Types.VARCHAR, 12, false); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(2); - } - - private void insertData(int id, String keyType, @Nullable String branchType) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "project_uuid", "project" + id, - "kee", "key" + id, - "key_type", keyType, - "created_at", id, - "updated_at", id + 1, - "need_issue_sync", true, - "branch_type", branchType - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectUuidNotNullOnIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectUuidNotNullOnIssueChangesTableTest.java deleted file mode 100644 index 84b9170e80f32cfeaa99ff300115d5fb27355da3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeProjectUuidNotNullOnIssueChangesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeProjectUuidNotNullOnIssueChangesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectUuidNotNullOnIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectUuidNotNullOnIssueChangesTable(db.database()); - - @Test - public void issue_key_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("issue_changes", "project_uuid", VARCHAR, 50, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertColumnDefinition("issue_changes", "project_uuid", VARCHAR, 50, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTableTest.java deleted file mode 100644 index 0e8af215179972802bbcc0f0e96593cb7caf4d38..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeUuidNotNullOnIssueChangesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeUuidNotNullOnIssueChangesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeUuidNotNullOnIssueChangesTable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("issue_changes", "uuid", VARCHAR, 40, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - underTest.execute(); - - db.assertColumnDefinition("issue_changes", "uuid", VARCHAR, 40, false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCountTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCountTest.java deleted file mode 100644 index 8dfd382060f464133a2e54cb3dfc0fce9fad39a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCountTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.util.stream.Collectors; -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.core.util.SequenceUuidFactory; -import org.sonar.core.util.UuidFactory; -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.server.platform.db.migration.version.v85.PopulateFileSourceLineCount.LINE_COUNT_NOT_POPULATED; - -public class PopulateFileSourceLineCountTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateFileSourceLineCountTest.class, "schema.sql"); - - private UuidFactory uuidFactory = new SequenceUuidFactory(); - - private PopulateFileSourceLineCount underTest = new PopulateFileSourceLineCount(db.database()); - - @Test - public void execute_has_no_effect_on_empty_table() throws SQLException { - underTest.execute(); - assertThat(db.countRowsOfTable("file_sources")).isZero(); - } - - @Test - public void execute_populates_line_count_of_any_type() throws SQLException { - String projectUuid = randomAlphanumeric(4); - String fileUuid = randomAlphanumeric(5); - int lineCount = 10; - insertUnpopulatedFileSource(projectUuid, fileUuid, lineCount); - assertThat(getLineCountByFileUuid(fileUuid)).isEqualTo(LINE_COUNT_NOT_POPULATED); - - underTest.execute(); - - assertThat(getLineCountByFileUuid(fileUuid)).isEqualTo(lineCount); - } - - @Test - public void execute_changes_only_file_source_with_LINE_COUNT_NOT_POPULATED_value() throws SQLException { - String projectUuid = randomAlphanumeric(4); - String fileUuid1 = randomAlphanumeric(5); - String fileUuid2 = randomAlphanumeric(6); - String fileUuid3 = randomAlphanumeric(7); - int lineCountFile1 = 10; - int lineCountFile2 = 50; - int lineCountFile3 = 150; - - insertPopulatedFileSource(projectUuid, fileUuid1, lineCountFile1); - int badLineCountFile2 = insertInconsistentPopulatedFileSource(projectUuid, fileUuid2, lineCountFile2); - insertUnpopulatedFileSource(projectUuid, fileUuid3, lineCountFile3); - assertThat(getLineCountByFileUuid(fileUuid1)).isEqualTo(lineCountFile1); - assertThat(getLineCountByFileUuid(fileUuid2)).isEqualTo(badLineCountFile2); - assertThat(getLineCountByFileUuid(fileUuid3)).isEqualTo(LINE_COUNT_NOT_POPULATED); - - underTest.execute(); - - assertThat(getLineCountByFileUuid(fileUuid1)).isEqualTo(lineCountFile1); - assertThat(getLineCountByFileUuid(fileUuid2)).isEqualTo(badLineCountFile2); - assertThat(getLineCountByFileUuid(fileUuid3)).isEqualTo(lineCountFile3); - } - - @Test - public void execute_set_line_count_to_zero_when_file_source_has_no_line_hashes() throws SQLException { - String projectUuid = randomAlphanumeric(4); - String fileUuid1 = randomAlphanumeric(5); - - insertFileSource(projectUuid, fileUuid1, null, LINE_COUNT_NOT_POPULATED); - - underTest.execute(); - - assertThat(getLineCountByFileUuid(fileUuid1)).isZero(); - } - - @Test - public void execute_set_line_count_to_1_when_file_source_has_empty_line_hashes() throws SQLException { - String projectUuid = randomAlphanumeric(4); - String fileUuid1 = randomAlphanumeric(5); - - insertFileSource(projectUuid, fileUuid1, "", LINE_COUNT_NOT_POPULATED); - - underTest.execute(); - - assertThat(getLineCountByFileUuid(fileUuid1)).isEqualTo(1); - } - - private int getLineCountByFileUuid(String fileUuid) { - Long res = (Long) db.selectFirst("select line_count as \"LINE_COUNT\" from file_sources where file_uuid = '" + fileUuid + "'") - .get("LINE_COUNT"); - return res.intValue(); - } - - private void insertUnpopulatedFileSource(String projectUuid, String fileUuid, int numberOfHashes) { - String lineHashes = generateLineHashes(numberOfHashes); - - insertFileSource(projectUuid, fileUuid, lineHashes, LINE_COUNT_NOT_POPULATED); - } - - private void insertPopulatedFileSource(String projectUuid, String fileUuid, int lineCount) { - String lineHashes = generateLineHashes(lineCount); - - insertFileSource(projectUuid, fileUuid, lineHashes, lineCount); - } - - private int insertInconsistentPopulatedFileSource(String projectUuid, String fileUuid, int lineCount) { - String lineHashes = generateLineHashes(lineCount); - int badLineCount = lineCount + 6; - - insertFileSource(projectUuid, fileUuid, lineHashes, badLineCount); - - return badLineCount; - } - - private static String generateLineHashes(int numberOfHashes) { - return IntStream.range(0, numberOfHashes) - .mapToObj(String::valueOf) - .collect(Collectors.joining("\n")); - } - - private void insertFileSource(String projectUuid, String fileUuid, @Nullable String lineHashes, int lineCount) { - db.executeInsert( - "FILE_SOURCES", - "UUID", uuidFactory.create(), - "PROJECT_UUID", projectUuid, - "FILE_UUID", fileUuid, - "LINE_HASHES", lineHashes, - "LINE_COUNT", lineCount, - "CREATED_AT", 1_222_333L, - "UPDATED_AT", 1_222_333L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTableTest.java deleted file mode 100644 index 0bca716b1c08afae43aefbe2c42754e11ec2a25e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTableTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateMessageTypeColumnOfCeTaskMessageTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateMessageTypeColumnOfCeTaskMessageTableTest.class, "schema.sql"); - - private final DataChange underTest = new PopulateMessageTypeColumnOfCeTaskMessageTable(db.database()); - - @Test - public void add_message_type_column_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from ce_task_message")).isZero(); - } - - @Test - public void add_message_type_column_on_non_empty_table() throws SQLException { - insertTaskMessage(1L, "msg1"); - insertTaskMessage(2L, "msg2"); - insertTaskMessage(3L, "msg3"); - insertTaskMessage(4L, "msg4"); - - underTest.execute(); - - assertThat(db.countSql("select count(*) from ce_task_message")).isEqualTo(4); - assertThat(db.select("select uuid, task_uuid, message, message_type from ce_task_message")) - .extracting(m -> m.get("UUID"), m -> m.get("TASK_UUID"), m -> m.get("MESSAGE"), m -> m.get("MESSAGE_TYPE")) - .containsExactlyInAnyOrder( - tuple("uuid-1", "task-uuid-1", "msg1", "GENERIC"), - tuple("uuid-2", "task-uuid-2", "msg2", "GENERIC"), - tuple("uuid-3", "task-uuid-3", "msg3", "GENERIC"), - tuple("uuid-4", "task-uuid-4", "msg4", "GENERIC")); - } - - private void insertTaskMessage(Long id, String message) { - db.executeInsert("ce_task_message", - "uuid", "uuid-" + id, - "task_uuid", "task-uuid-" + id, - "message", message, - "created_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateTypeInPluginsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateTypeInPluginsTest.java deleted file mode 100644 index e8f1e2b53298e689305829da576f44c11080287a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/PopulateTypeInPluginsTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import java.sql.Types; -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.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateTypeInPluginsTest { - private static final String TABLE_NAME = "plugins"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateTypeInPluginsTest.class, "schema.sql"); - - private MigrationStep underTest = new PopulateTypeInPlugins(db.database()); - - @Test - public void add_column() throws SQLException { - addPlugin("1", null); - addPlugin("2", null); - addPlugin("3", "BUNDLED"); - - underTest.execute(); - db.assertColumnDefinition(TABLE_NAME, "type", Types.VARCHAR, 10, true); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(3); - assertThat(db.select("select type as \"TYPE\" from plugins order by uuid").stream().map(r -> r.get("TYPE"))).containsExactly("EXTERNAL", "EXTERNAL", "BUNDLED"); - } - - private void addPlugin(String id, @Nullable String type) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "kee", "kee" + id, - "base_plugin_key", "base" + id, - "file_hash", "hash" + id, - "type", type, - "created_at", 1L, - "updated_at", 2L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChangesTest.java deleted file mode 100644 index bd9e206d468d6bd5e8ac832f8f28f94aa3115605..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChangesTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v85; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.CoreDbTester; - -public class RenameTmpIssueChangesToIssueChangesTest { - - private static final String OLD_TABLE_NAME = "tmp_issue_changes"; - private static final String NEW_TABLE_NAME = "issue_changes"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(RenameTmpIssueChangesToIssueChangesTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private final RenameTmpIssueChangesToIssueChanges underTest = new RenameTmpIssueChangesToIssueChanges(dbTester.database()); - - @Test - public void only_rename_if_tmp_table_exists() throws SQLException { - dbTester.executeDdl("drop table " + OLD_TABLE_NAME); - underTest.execute(); - - dbTester.assertTableDoesNotExist(OLD_TABLE_NAME); - dbTester.assertTableDoesNotExist(NEW_TABLE_NAME); - } - - @Test - public void table_has_been_renamed() throws SQLException { - underTest.execute(); - - dbTester.assertTableDoesNotExist(OLD_TABLE_NAME); - dbTester.assertTableExists(NEW_TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjsTest.java deleted file mode 100644 index 46ec8337aedcd64a1799181aead03486921005aa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjsTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexToApplicationBranchProjsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToApplicationBranchProjsTest.class, "schema.sql"); - - private final MigrationStep underTest = new AddIndexToApplicationBranchProjs(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("app_branch_project_branch", "uniq_app_branch_proj", "application_branch_uuid", "project_branch_uuid"); - db.assertIndex("app_branch_project_branch", "idx_abpb_app_uuid", "application_uuid"); - db.assertIndex("app_branch_project_branch", "idx_abpb_app_branch_uuid", "application_branch_uuid"); - db.assertIndex("app_branch_project_branch", "idx_abpb_proj_uuid", "project_uuid"); - db.assertIndex("app_branch_project_branch", "idx_abpb_proj_branch_uuid", "project_branch_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjectsTest.java deleted file mode 100644 index 04c43564ca51220e24eddfc7b4f42bbd97315dc3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjectsTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexToApplicationProjectsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToApplicationProjectsTest.class, "schema.sql"); - - private final MigrationStep underTest = new AddIndexToApplicationProjects(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("app_projects", "uniq_app_projects", "application_uuid", "project_uuid"); - db.assertIndex("app_projects", "idx_app_proj_application_uuid", "application_uuid"); - db.assertIndex("app_projects", "idx_app_proj_project_uuid", "project_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjsTest.java deleted file mode 100644 index a4da4d7113da6e0676e5c22eb219dd5d103d8011..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjsTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddPkToApplicationBranchProjsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPkToApplicationBranchProjsTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPkToApplicationBranchProjs(db.database()); - - @Test - public void execute() throws SQLException { - db.assertNoPrimaryKey("app_branch_project_branch"); - underTest.execute(); - db.assertPrimaryKey("app_branch_project_branch", "pk_app_branch_project_branch", "uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjectsTest.java deleted file mode 100644 index 4c5fddc44e3a21e7c427c12218219610751d796b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjectsTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddPkToApplicationProjectsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPkToApplicationProjectsTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPkToApplicationProjects(db.database()); - - @Test - public void execute() throws SQLException { - db.assertNoPrimaryKey("app_projects"); - underTest.execute(); - db.assertPrimaryKey("app_projects", "pk_app_projects", "uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest.java deleted file mode 100644 index e19082b117caa485486619275f85cc3537ceab84..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddPrimaryKeyToDefaultQProfilesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyToDefaultQProfilesTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyToDefaultQProfiles(db.database()); - - @Test - public void execute() throws SQLException { - db.assertNoPrimaryKey("default_qprofiles"); - underTest.execute(); - db.assertPrimaryKey("default_qprofiles", "pk_default_qprofiles", "language"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsersTest.java deleted file mode 100644 index 8843ce07d81697882dbb6bc8b100567e6f9fa805..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsersTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import java.util.Objects; -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.MigrationStep; - -import static java.sql.Types.BOOLEAN; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; - -public class AddResetPasswordColumnToUsersTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddResetPasswordColumnToUsersTest.class, "schema.sql"); - - private MigrationStep underTest = new AddResetPasswordColumnToUsers(db.database()); - - @Test - public void execute_on_empty_db() throws SQLException { - db.assertColumnDoesNotExist("users", "reset_password"); - underTest.execute(); - db.assertColumnDefinition("users", "reset_password", BOOLEAN, null, true); - } - - @Test - public void execute_on_db_with_user_rows() throws SQLException { - insertUser("uuid-1"); - insertUser("uuid-2"); - insertUser("uuid-3"); - db.assertColumnDoesNotExist("users", "reset_password"); - underTest.execute(); - db.assertColumnDefinition("users", "reset_password", BOOLEAN, null, true); - - assertThatAllUsersResetPasswordFlagAreNotSet(); - } - - private void assertThatAllUsersResetPasswordFlagAreNotSet() { - assertThat(db.select("select reset_password from users") - .stream() - .map(r -> r.get("RESET_PASSWORD")) - .map(this::getBooleanValue) - .filter(Objects::nonNull) - .collect(toList())).isEmpty(); - } - - private Boolean getBooleanValue(@Nullable Object value) { - return value == null ? null : Boolean.parseBoolean(value.toString()); - } - - private void insertUser(String uuid) { - db.executeInsert("users", - "UUID", uuid, - "LOGIN", uuid + "login", - "EXTERNAL_LOGIN", uuid + "-external-login", - "EXTERNAL_IDENTITY_PROVIDER", "sonarqube", - "EXTERNAL_ID", uuid + "-external-id", - "IS_ROOT", false, - "ONBOARDED", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest.java deleted file mode 100644 index 4e3516ce0465fd6d0ed8e58e91156842104e023a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddUniqueIndexOnNameColumnOfGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexOnNameColumnOfGroupsTableTest.class, "schema.sql"); - - private final MigrationStep underTest = new AddUniqueIndexOnNameColumnOfGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("groups", "uniq_groups_name", "name"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/CreateApplicationProjectsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/CreateApplicationProjectsTableTest.java deleted file mode 100644 index 56fcaa3257ed70c878eebae3a62fc1535e19b7d4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/CreateApplicationProjectsTableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v86.CreateApplicationProjectsTable; - -public class CreateApplicationProjectsTableTest { - private final static String TABLE_NAME = "app_projects"; - - @Rule - public CoreDbTester db = CoreDbTester.createEmpty(); - - private MigrationStep underTest = new CreateApplicationProjectsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableDoesNotExist(TABLE_NAME); - underTest.execute(); - db.assertTableExists(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86Test.java deleted file mode 100644 index 50b6175024558abd49beb308e6b053587e2adbf9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86Test.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; -import org.sonar.server.platform.db.migration.version.v85.DbVersion85; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion86Test { - - private DbVersion underTest = new DbVersion86(); - - @Test - public void migrationNumber_starts_at_4100() { - verifyMinimumMigrationNumber(underTest, 4100); - } - - @Test - public void verify_migration_count() { - verifyMigrationNotEmpty(underTest); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java deleted file mode 100644 index ac99cb1a7680e9cde6318c3861ca8abbe1888f4a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropDefaultQProfilesPkTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropDefaultQProfilesPkTest.class, "schema.sql"); - - private final MigrationStep underTest = new DropDefaultQProfilesPk(db.database(), new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database()))); - - @Test - public void execute() throws SQLException { - db.assertPrimaryKey("default_qprofiles", "pk_default_qprofiles", "organization_uuid", "language"); - - underTest.execute(); - db.assertNoPrimaryKey("default_qprofiles"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest.java deleted file mode 100644 index b88f76ecd478141df255c6869c3f2db206fbde22..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationFromDefaultQProfilesTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrganizationFromDefaultQProfilesTest.class, "schema.sql"); - - private MigrationStep underTest = new DropOrganizationFromDefaultQProfiles(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("default_qprofiles", "organization_uuid", Types.VARCHAR, 40, false); - underTest.execute(); - db.assertColumnDoesNotExist("default_qprofiles", "organization_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest.java deleted file mode 100644 index 015ddad9e935df6104582d55045bd836ae915d73..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class DropOrganizationFromQualityProfileTableTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationFromQualityProfileTableTest.class, "schema.sql"); - - private DropOrganizationFromQualityProfileTable underTest = new DropOrganizationFromQualityProfileTable(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("org_qprofiles", "organization_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRolesTest.java deleted file mode 100644 index 3df26c871b417f25490b0c449777a6a3127936b7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRolesTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInGroupRolesTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInGroupRolesTest.class, "schema.sql"); - - private MigrationStep underTest = new DropOrganizationInGroupRoles(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("group_roles", "organization_uuid"); - dbTester.assertUniqueIndex("group_roles", "uniq_group_roles", "group_uuid", "component_uuid", "role"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest.java deleted file mode 100644 index 3ffe9cdf635a8a383f86234e88e1753f61e95f60..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInGroupsTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInGroupsTest.class, "schema.sql"); - - private final MigrationStep underTest = new DropOrganizationInGroups(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("groups", "organization_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplatesTest.java deleted file mode 100644 index 188884704e4f48ba78523387eba7a58badafddae..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplatesTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInPermissionTemplatesTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInPermissionTemplatesTest.class, "schema.sql"); - - private MigrationStep underTest = new DropOrganizationInPermissionTemplates(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("permission_templates", "organization_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest.java deleted file mode 100644 index 832271c0597822874e20e9e17f9730ece702cefe..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInRulesMetadataTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrganizationInRulesMetadataTest.class, "schema.sql"); - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private MigrationStep underTest = new DropOrganizationInRulesMetadata(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - db.assertColumnDoesNotExist("rules_metadata", "organization_uuid"); - db.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRolesTest.java deleted file mode 100644 index ff16bbb74d4a9e93e5933a69e872e27abc418355..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRolesTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInUserRolesTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInUserRolesTest.class, "schema.sql"); - - private MigrationStep underTest = new DropOrganizationInUserRoles(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("user_roles", "organization_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest.java deleted file mode 100644 index 8f689b4354a4605ea36a6fe3b3c33733664fd947..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInUsersTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInUsersTest.class, "schema.sql"); - - private MigrationStep underTest = new DropOrganizationInUsers(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("users", "organization_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest.java deleted file mode 100644 index eec70670bdfa1038d2b08cb67d45e9102f4cc00e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationUuidIndexFromQualityProfileTableTest { - - private static final String TABLE_NAME = "org_qprofiles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrganizationUuidIndexFromQualityProfileTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropOrganizationUuidIndexFromQualityProfileTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertIndex(TABLE_NAME, "qprofiles_org_uuid", "organization_uuid"); - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "qprofiles_org_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "qprofiles_org_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest.java deleted file mode 100644 index ac689725669e7114dfc1a3c6b489ce05a3f4c3a5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeNameColumnInGroupsTableNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeNameColumnInGroupsTableNotNullableTest.class, "schema.sql"); - - private final MigrationStep underTest = new MakeNameColumnInGroupsTableNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups", "name", VARCHAR, 500, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNullTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNullTest.java deleted file mode 100644 index da9efc5240ef4a2f148809182ed17ee5da1a66ec..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNullTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.BOOLEAN; - -public class MakeResetPasswordColumnNotNullTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeResetPasswordColumnNotNullTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeResetPasswordColumnNotNull(db.database()); - - @Test - public void execute_on_empty_db() throws SQLException { - db.assertColumnDefinition("users", "reset_password", BOOLEAN, null, true); - underTest.execute(); - db.assertColumnDefinition("users", "reset_password", BOOLEAN, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDbTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDbTest.java deleted file mode 100644 index 0d083a13f6578af445e6385bc9ddd403f5792029..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDbTest.java +++ /dev/null @@ -1,809 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -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.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.xmlunit.builder.DiffBuilder; -import org.xmlunit.builder.Input; -import org.xmlunit.diff.Diff; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.Assertions.tuple; -import static org.sonar.server.platform.db.migration.version.v86.MigrateApplicationDefinitionsFromXmlToDb.TEXT_VALUE_MAX_LENGTH; - -public class MigrateApplicationDefinitionsFromXmlToDbTest { - private static final String QUALIFIER_PROJECT = "TRK"; - private static final String QUALIFIER_APP = "APP"; - private static final long NOW = 100_000_000_000L; - - private static final String PROJECT_1_UUID = "proj1-uuid"; - private static final String PROJECT_1_MASTER_BRANCH_UUID = "proj1-master-uuid"; - private static final String PROJECT_1_BRANCH_1_UUID = "proj1-branch1-uuid"; - private static final String PROJECT_1_BRANCH_2_UUID = "proj1-branch2-uuid"; - private static final String PROJECT_2_UUID = "proj2-uuid"; - private static final String PROJECT_2_MASTER_BRANCH_UUID = "proj2-master-uuid"; - private static final String PROJECT_2_BRANCH_1_UUID = "proj2-branch1-uuid"; - private static final String APP_1_UUID = "app1-uuid"; - private static final String APP_1_MASTER_BRANCH_UUID = "app1-master-uuid"; - private static final String APP_1_BRANCH_1_UUID = "app1-branch1-uuid"; - private static final String APP_1_BRANCH_2_UUID = "app1-branch2-uuid"; - private static final String APP_2_UUID = "app2-uuid"; - private static final String APP_2_MASTER_BRANCH_UUID = "app2-master-uuid"; - private static final String APP_2_BRANCH_1_UUID = "app2-branch1-uuid"; - private static final String EMPTY_XML = ""; - - private static final String EMPTY_APP_XML = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - - private static final String APP_WITH_NO_BRANCHES_XML = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "

proj1-key

\n" + - "

proj2-key

\n" + - "
\n" + - "
"; - - private static final String APP_WITH_DUPLICATED_PROJECTS_XML = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "

proj1-key

\n" + - "

proj1-key

\n" + - " \n" + - "

proj1-key

\n" + - "
\n" + - " \n" + - "

proj1-key

\n" + - "
\n" + - "
\n" + - "
"; - - private static final String COMPLEX_XML_BEFORE = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "

proj1-key

\n" + - "

proj2-key

\n" + - " \n" + - "

proj1-key

\n" + - "

proj2-key

\n" + - "
\n" + - " \n" + - "

proj1-key

\n" + - "

proj2-key

\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "

proj1-key

\n" + - "

proj2-key

\n" + - " \n" + - "

proj1-key

\n" + - "

proj2-key

\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "

proj1-key

\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " tag1\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
"; - - private static final String COMPLEX_XML_AFTER = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "

proj1-key

\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " tag1\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
"; - - private static final String LARGE_XML_BEFORE_AND_AFTER = "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "

proj1-key

\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " tag1\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MigrateApplicationDefinitionsFromXmlToDbTest.class, "schema.sql"); - - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private final System2 system2 = new TestSystem2().setNow(NOW); - private final MigrationStep underTest = new MigrateApplicationDefinitionsFromXmlToDb(db.database(), uuidFactory, system2); - - @Test - public void does_nothing_when_no_views_def_property() throws SQLException { - setupProjectsAndApps(); - - underTest.execute(); - - assertThat(db.countSql("select count(*) from app_projects")).isZero(); - assertThat(db.countSql("select count(*) from app_branch_project_branch")).isZero(); - assertThat(db.countSql("select count(*) from internal_properties where kee='views.def'")).isZero(); - } - - @Test - public void does_nothing_when_views_def_property_empty_string() throws SQLException { - setupProjectsAndApps(); - insertViewsDefInternalProperty(""); - - underTest.execute(); - - assertThat(db.countSql("select count(*) from app_projects")).isZero(); - assertThat(db.countSql("select count(*) from app_branch_project_branch")).isZero(); - } - - @Test - public void does_nothing_when_views_def_property_empty_views_content() throws SQLException { - setupProjectsAndApps(); - insertViewsDefInternalProperty(EMPTY_XML); - - underTest.execute(); - - assertThat(db.countSql("select count(*) from app_projects")).isZero(); - assertThat(db.countSql("select count(*) from app_branch_project_branch")).isZero(); - } - - @Test - public void throws_ISE_when_views_def_property_does_not_pass_validation() { - setupProjectsAndApps(); - insertViewsDefInternalProperty("abcdefghi"); - - assertThatThrownBy(underTest::execute) - .isInstanceOf(IllegalStateException.class) - .hasMessage("Failed to migrate views definitions property."); - - assertThat(db.countSql("select count(*) from app_projects")).isZero(); - assertThat(db.countSql("select count(*) from app_branch_project_branch")).isZero(); - } - - @Test - public void migrates_applications_to_new_tables() throws SQLException { - setupProjectsAndApps(); - insertViewsDefInternalProperty(COMPLEX_XML_BEFORE); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, PROJECT_2_UUID, APP_1_UUID, APP_2_UUID); - assertThat(db.select("select application_uuid, project_uuid from app_projects")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID), - tuple(APP_2_UUID, PROJECT_2_UUID)); - assertThat(db.select("select application_uuid, project_uuid, application_branch_uuid, project_branch_uuid from app_branch_project_branch")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID"), r -> r.get("APPLICATION_BRANCH_UUID"), r -> r.get("PROJECT_BRANCH_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID, APP_1_BRANCH_1_UUID, PROJECT_2_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_2_UUID, PROJECT_1_BRANCH_2_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID, APP_1_BRANCH_2_UUID, PROJECT_2_BRANCH_1_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID, APP_2_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_2_UUID, PROJECT_2_UUID, APP_2_BRANCH_1_UUID, PROJECT_2_BRANCH_1_UUID)); - } - - @Test - public void migrates_applications_handling_project_duplications_to_new_tables() throws SQLException { - setupProjectsAndApps(); - insertViewsDefInternalProperty(APP_WITH_DUPLICATED_PROJECTS_XML); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, PROJECT_2_UUID, APP_1_UUID, APP_2_UUID); - assertThat(db.select("select application_uuid, project_uuid from app_projects")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID")) - .containsExactly(tuple(APP_1_UUID, PROJECT_1_UUID)); - assertThat(db.select("select application_uuid, project_uuid, application_branch_uuid, project_branch_uuid from app_branch_project_branch")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID"), r -> r.get("APPLICATION_BRANCH_UUID"), r -> r.get("PROJECT_BRANCH_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_2_UUID, PROJECT_1_BRANCH_2_UUID)); - } - - @Test - public void migration_is_resilient() throws SQLException { - setupProjectsAndApps(); - insertViewsDefInternalProperty(COMPLEX_XML_BEFORE); - - // first attempt - underTest.execute(); - - // xml stays the same (stopped during migration) - updateViewsDefInternalProperty(COMPLEX_XML_BEFORE); - - // second attempt should not fail - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, PROJECT_2_UUID, APP_1_UUID, APP_2_UUID); - assertThat(db.select("select application_uuid, project_uuid from app_projects")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID), - tuple(APP_2_UUID, PROJECT_2_UUID)); - assertThat(db.select("select application_uuid, project_uuid, application_branch_uuid, project_branch_uuid from app_branch_project_branch")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID"), r -> r.get("APPLICATION_BRANCH_UUID"), r -> r.get("PROJECT_BRANCH_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID, APP_1_BRANCH_1_UUID, PROJECT_2_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_2_UUID, PROJECT_1_BRANCH_2_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID, APP_1_BRANCH_2_UUID, PROJECT_2_BRANCH_1_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID, APP_2_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_2_UUID, PROJECT_2_UUID, APP_2_BRANCH_1_UUID, PROJECT_2_BRANCH_1_UUID)); - } - - @Test - public void migrates_applications_without_application_branches_to_new_tables() throws SQLException { - setupFullProject1(); - setupProject2(); - setupApp1WithNoBranches(); - insertViewsDefInternalProperty(APP_WITH_NO_BRANCHES_XML); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, PROJECT_2_UUID, APP_1_UUID); - assertThat(db.select("select application_uuid, project_uuid from app_projects")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID)); - assertThat(db.countSql("select count(*) from app_branch_project_branch")).isZero(); - } - - @Test - public void skips_apps_that_exist_in_the_definition_but_does_not_exist_in_db() throws SQLException { - setupFullProject1(); - insertViewsDefInternalProperty(EMPTY_APP_XML); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID); - assertThat(db.countSql("select count(*) from app_projects")).isZero(); - assertThat(db.countSql("select count(*) from app_branch_project_branch")).isZero(); - } - - @Test - public void migrates_app_with_0_projects_in_views_definition() throws SQLException { - setupFullProject1(); - setupProject2(); - setupApp1WithNoBranches(); - insertViewsDefInternalProperty(EMPTY_APP_XML); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, PROJECT_2_UUID, APP_1_UUID); - assertThat(db.countSql("select count(*) from app_projects")).isZero(); - assertThat(db.countSql("select count(*) from app_branch_project_branch")).isZero(); - } - - @Test - public void skips_apps_that_are_present_in_views_definition_but_not_in_db() throws SQLException { - setupFullProject1(); - setupProject2(); - setupApp1WithTwoBranches(); - insertViewsDefInternalProperty(COMPLEX_XML_BEFORE); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, PROJECT_2_UUID, APP_1_UUID); - assertThat(db.select("select application_uuid, project_uuid from app_projects")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID)); - assertThat(db.select("select application_uuid, project_uuid, application_branch_uuid, project_branch_uuid from app_branch_project_branch")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID"), r -> r.get("APPLICATION_BRANCH_UUID"), r -> r.get("PROJECT_BRANCH_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID, APP_1_BRANCH_1_UUID, PROJECT_2_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_2_UUID, PROJECT_1_BRANCH_2_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID, APP_1_BRANCH_2_UUID, PROJECT_2_BRANCH_1_UUID)); - } - - @Test - public void skips_app_branches_that_are_present_in_views_definition_but_not_in_db() throws SQLException { - setupFullProject1(); - setupProject2(); - setupApp1WithNoBranches(); - setupApp2(); - insertViewsDefInternalProperty(COMPLEX_XML_BEFORE); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, PROJECT_2_UUID, APP_1_UUID, APP_2_UUID); - assertThat(db.select("select application_uuid, project_uuid from app_projects")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID), - tuple(APP_2_UUID, PROJECT_2_UUID)); - assertThat(db.select("select application_uuid, project_uuid, application_branch_uuid, project_branch_uuid from app_branch_project_branch")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID"), r -> r.get("APPLICATION_BRANCH_UUID"), r -> r.get("PROJECT_BRANCH_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_2_UUID, PROJECT_1_UUID, APP_2_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_2_UUID, PROJECT_2_UUID, APP_2_BRANCH_1_UUID, PROJECT_2_BRANCH_1_UUID)); - } - - @Test - public void skips_projects_that_are_present_in_apps_views_definitions_but_not_in_db() throws SQLException { - setupPartialProject1(); - setupApp1WithTwoBranches(); - setupApp2(); - insertViewsDefInternalProperty(COMPLEX_XML_BEFORE); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, APP_1_UUID, APP_2_UUID); - assertThat(db.select("select application_uuid, project_uuid from app_projects")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID)); - assertThat(db.select("select application_uuid, project_uuid, application_branch_uuid, project_branch_uuid from app_branch_project_branch")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID"), r -> r.get("APPLICATION_BRANCH_UUID"), r -> r.get("PROJECT_BRANCH_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID, APP_2_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID)); - } - - @Test - public void skips_projects_branches_that_are_present_in_apps_views_definitions_but_not_in_db() throws SQLException { - setupPartialProject1(); - setupProject2(); - setupApp1WithTwoBranches(); - setupApp2(); - insertViewsDefInternalProperty(COMPLEX_XML_BEFORE); - - underTest.execute(); - - assertThat(db.select("select uuid from projects")) - .extracting(r -> r.get("UUID")) - .containsExactlyInAnyOrder(PROJECT_1_UUID, PROJECT_2_UUID, APP_1_UUID, APP_2_UUID); - assertThat(db.select("select application_uuid, project_uuid from app_projects")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID), - tuple(APP_2_UUID, PROJECT_2_UUID)); - assertThat(db.select("select application_uuid, project_uuid, application_branch_uuid, project_branch_uuid from app_branch_project_branch")) - .extracting(r -> r.get("APPLICATION_UUID"), r -> r.get("PROJECT_UUID"), r -> r.get("APPLICATION_BRANCH_UUID"), r -> r.get("PROJECT_BRANCH_UUID")) - .containsExactlyInAnyOrder( - tuple(APP_1_UUID, PROJECT_1_UUID, APP_1_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID, APP_1_BRANCH_1_UUID, PROJECT_2_BRANCH_1_UUID), - tuple(APP_1_UUID, PROJECT_2_UUID, APP_1_BRANCH_2_UUID, PROJECT_2_BRANCH_1_UUID), - tuple(APP_2_UUID, PROJECT_1_UUID, APP_2_BRANCH_1_UUID, PROJECT_1_BRANCH_1_UUID), - tuple(APP_2_UUID, PROJECT_2_UUID, APP_2_BRANCH_1_UUID, PROJECT_2_BRANCH_1_UUID)); - } - - @Test - public void removes_application_definitions_from_xml() throws SQLException { - setupProjectsAndApps(); - insertViewsDefInternalProperty(COMPLEX_XML_BEFORE); - - underTest.execute(); - - assertThat(db.countSql("select count(*) from internal_properties where kee='views.def'")).isOne(); - assertViewsXmlDefinitionSimilar(COMPLEX_XML_AFTER, false); - } - - @Test - public void removes_application_definitions_from_large_xmls() throws SQLException { - setupProjectsAndApps(); - insertViewsDefInternalProperty(LARGE_XML_BEFORE_AND_AFTER); - - underTest.execute(); - - assertThat(db.countSql("select count(*) from internal_properties where kee='views.def'")).isOne(); - assertViewsXmlDefinitionSimilar(LARGE_XML_BEFORE_AND_AFTER, true); - } - - @Test - public void does_not_change_the_xml_if_there_are_no_application_definitions() throws SQLException { - setupProjectsAndApps(); - insertViewsDefInternalProperty(EMPTY_XML); - - underTest.execute(); - - assertThat(db.countSql("select count(*) from internal_properties where kee='views.def'")).isOne(); - assertViewsXmlDefinitionSimilar(EMPTY_XML, false); - } - - private void setupProjectsAndApps() { - setupFullProject1(); - setupProject2(); - setupApp1WithTwoBranches(); - setupApp2(); - } - - private void setupFullProject1() { - setupPartialProject1(); - insertBranch(PROJECT_1_BRANCH_2_UUID, PROJECT_1_UUID, "proj1-branch-2"); - } - - private void setupPartialProject1() { - insertProject(PROJECT_1_UUID, "proj1-key", QUALIFIER_PROJECT); - insertBranch(PROJECT_1_MASTER_BRANCH_UUID, PROJECT_1_UUID, "master"); - insertBranch(PROJECT_1_BRANCH_1_UUID, PROJECT_1_UUID, "proj1-branch-1"); - } - - private void setupProject2() { - insertProject(PROJECT_2_UUID, "proj2-key", QUALIFIER_PROJECT); - insertBranch(PROJECT_2_MASTER_BRANCH_UUID, PROJECT_2_UUID, "master"); - insertBranch(PROJECT_2_BRANCH_1_UUID, PROJECT_2_UUID, "m1"); - } - - private void setupApp1WithNoBranches() { - insertProject(APP_1_UUID, "app1-key", QUALIFIER_APP); - insertBranch(APP_1_MASTER_BRANCH_UUID, APP_1_UUID, "master"); - } - - private void setupApp1WithOneBranch() { - setupApp1WithNoBranches(); - insertBranch(APP_1_BRANCH_1_UUID, APP_1_UUID, "app1-branch1"); - } - - private void setupApp1WithTwoBranches() { - setupApp1WithOneBranch(); - insertBranch(APP_1_BRANCH_2_UUID, APP_1_UUID, "app1-branch2"); - } - - private void setupApp2() { - insertProject(APP_2_UUID, "app2-key", QUALIFIER_APP); - insertBranch(APP_2_MASTER_BRANCH_UUID, APP_2_UUID, "master"); - insertBranch(APP_2_BRANCH_1_UUID, APP_2_UUID, "m1"); - } - - private void insertViewsDefInternalProperty(@Nullable String xml) { - String valueColumn = "text_value"; - if (xml != null && xml.length() > TEXT_VALUE_MAX_LENGTH) { - valueColumn = "clob_value"; - } - - db.executeInsert("internal_properties", - "kee", "views.def", - "is_empty", "false", - valueColumn, xml, - "created_at", system2.now()); - } - - private void updateViewsDefInternalProperty(@Nullable String xml) { - db.executeUpdateSql("update internal_properties set text_value = ? where kee = 'views.def'", - xml); - } - - private void insertProject(String uuid, String key, String qualifier) { - db.executeInsert("PROJECTS", - "UUID", uuid, - "KEE", key, - "QUALIFIER", qualifier, - "ORGANIZATION_UUID", uuid + "-key", - "TAGS", "tag1", - "PRIVATE", Boolean.toString(false), - "UPDATED_AT", System2.INSTANCE.now()); - } - - private void insertBranch(String uuid, String projectUuid, String key) { - db.executeInsert( - "PROJECT_BRANCHES", - "UUID", uuid, - "PROJECT_UUID", projectUuid, - "KEE", key, - "BRANCH_TYPE", "BRANCH", - "MERGE_BRANCH_UUID", null, - "CREATED_AT", System2.INSTANCE.now(), - "UPDATED_AT", System2.INSTANCE.now(), - "NEED_ISSUE_SYNC", Boolean.toString(false)); - } - - private void assertViewsXmlDefinitionSimilar(final String expectedValue, final boolean expectClob) { - Map result = db.selectFirst("select text_value, clob_value from internal_properties where kee='views.def'"); - String textValue = (String) result.get("TEXT_VALUE"); - String clobValue = (String) result.get("CLOB_VALUE"); - - String existingValue; - if (expectClob) { - existingValue = clobValue; - assertThat(textValue).isNull(); - } else { - existingValue = textValue; - assertThat(clobValue).isNull(); - } - - Diff diff = DiffBuilder - .compare(Input.fromString(expectedValue)) - .withTest(Input.fromString(existingValue)) - .ignoreWhitespace() - .ignoreComments() - .checkForSimilar() - .build(); - assertThat(diff.getDifferences()) - .as(expectedValue) - .isEmpty(); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalPropertiesTest.java deleted file mode 100644 index b01562a9708d3908ade6bd4ddff4ebb5943169a9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalPropertiesTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -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.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.Assertions.tuple; - -public class MoveDefaultTemplatesToInternalPropertiesTest { - - private static final long NOW = 100_000_000_000L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MoveDefaultTemplatesToInternalPropertiesTest.class, "schema.sql"); - - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private final System2 system2 = new TestSystem2().setNow(NOW); - - private final DataChange underTest = new MoveDefaultTemplatesToInternalProperties(db.database(), system2); - - @Test - public void create_internal_properties_for_all_components() throws SQLException { - insertDefaultOrganization("PRJ", "PORT", "APP"); - - underTest.execute(); - - assertInternalProperties( - tuple("defaultTemplate.prj", "PRJ", NOW), - tuple("defaultTemplate.port", "PORT", NOW), - tuple("defaultTemplate.app", "APP", NOW) - ); - } - - @Test - public void create_internal_properties_when_only_template_for_project() throws SQLException { - insertDefaultOrganization("PRJ", null, null); - - underTest.execute(); - - assertInternalProperties( - tuple("defaultTemplate.prj", "PRJ", NOW)); - } - - @Test - public void create_internal_properties_when_template_for_project_and_portfolio() throws SQLException { - insertDefaultOrganization("PRJ", "PORT", null); - - underTest.execute(); - - assertInternalProperties( - tuple("defaultTemplate.prj", "PRJ", NOW), - tuple("defaultTemplate.port", "PORT", NOW) - ); - } - - @Test - public void create_internal_properties_when_template_for_project_and_application() throws SQLException { - insertDefaultOrganization("PRJ", null, "APP"); - - underTest.execute(); - - assertInternalProperties( - tuple("defaultTemplate.prj", "PRJ", NOW), - tuple("defaultTemplate.app", "APP", NOW) - ); - } - - @Test - public void do_nothing_when_permission_template_for_project_is_missing() throws SQLException { - insertDefaultOrganization(null, null, "APP"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("internal_properties")).isZero(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertDefaultOrganization("PRJ", "PORT", "APP"); - - underTest.execute(); - underTest.execute(); - - assertInternalProperties( - tuple("defaultTemplate.prj", "PRJ", NOW), - tuple("defaultTemplate.port", "PORT", NOW), - tuple("defaultTemplate.app", "APP", NOW) - ); - } - - @Test - public void fail_when_default_organization_is_missing() { - assertThatThrownBy(underTest::execute) - .isInstanceOf(IllegalStateException.class) - .hasMessage("Default organization is missing"); - } - - private void assertInternalProperties(Tuple... tuples) { - assertThat(db.select("select kee, text_value, created_at from internal_properties")) - .extracting(m -> m.get("KEE"), m -> m.get("TEXT_VALUE"), m -> m.get("CREATED_AT")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertDefaultOrganization(@Nullable String defaultPermissionTemplateForProject, @Nullable String defaultPermissionTemplateForPortfolio, - @Nullable String defaultPermissionTemplateForApplication) { - String uuid = uuidFactory.create(); - db.executeInsert("organizations", - "uuid", uuid, - "kee", "default-organization", - "name", "name" + uuid, - "default_perm_template_project", defaultPermissionTemplateForProject, - "default_perm_template_port", defaultPermissionTemplateForPortfolio, - "default_perm_template_app", defaultPermissionTemplateForApplication, - "default_quality_gate_uuid", uuid, - "new_project_private", true, - "subscription", uuid, - "created_at", NOW, - "updated_at", NOW); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValueTest.java deleted file mode 100644 index 507bafce015f8f55a5d8e1e62baedea5cffd70a8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValueTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -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.impl.utils.TestSystem2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -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 PopulateResetPasswordDefaultValueTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateResetPasswordDefaultValueTest.class, "schema.sql"); - - private final TestSystem2 system2 = new TestSystem2(); - private final long NOW = 1606375781L; - - private MigrationStep underTest = new PopulateResetPasswordDefaultValue(db.database(), system2); - - @Before - public void before() { - system2.setNow(NOW); - } - - @Test - public void execute_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(db.countRowsOfTable("users")).isZero(); - } - - @Test - public void execute_on_db_with_user_rows() throws SQLException { - insertUser("uuid-1", null, NOW); - insertUser("uuid-2", null, NOW); - insertUser("uuid-3", null, NOW); - - long expectedUpdatedRowTime = 2_000_000_000L; - system2.setNow(expectedUpdatedRowTime); - - underTest.execute(); - - assertThatUserResetPasswordFlagIsEqualTo( - tuple("uuid-1", false, expectedUpdatedRowTime), - tuple("uuid-2", false, expectedUpdatedRowTime), - tuple("uuid-3", false, expectedUpdatedRowTime)); - } - - @Test - public void does_not_update_already_set_flags() throws SQLException { - insertUser("uuid-1", true, NOW); - insertUser("uuid-2", false, NOW); - insertUser("uuid-3", null, NOW); - - long expectedUpdatedRowTime = 2_000_000_000L; - system2.setNow(expectedUpdatedRowTime); - - underTest.execute(); - - insertUser("uuid-4", null, NOW); - // re-entrant - underTest.execute(); - - assertThatUserResetPasswordFlagIsEqualTo( - tuple("uuid-1", true, NOW), - tuple("uuid-2", false, NOW), - tuple("uuid-3", false, expectedUpdatedRowTime), - tuple("uuid-4", false, expectedUpdatedRowTime)); - } - - private void assertThatUserResetPasswordFlagIsEqualTo(Tuple... tuples) { - assertThat(db.select("select uuid, reset_password, updated_at from users") - .stream() - .map(r -> tuple(r.get("UUID"), getBooleanValue(r.get("RESET_PASSWORD")), r.get("UPDATED_AT"))) - .collect(toList())) - .containsExactlyInAnyOrder(tuples); - } - - private Boolean getBooleanValue(@Nullable Object value) { - return value == null ? null : Boolean.parseBoolean(value.toString()); - } - - private void insertUser(String uuid, @Nullable Boolean resetPassword, long updatedAt) { - db.executeInsert("users", - "UUID", uuid, - "LOGIN", uuid + "login", - "EXTERNAL_LOGIN", uuid + "-external-login", - "EXTERNAL_IDENTITY_PROVIDER", "sonarqube", - "EXTERNAL_ID", uuid + "-external-id", - "IS_ROOT", false, - "RESET_PASSWORD", resetPassword, - "ONBOARDED", false, - "UPDATED_AT", updatedAt); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParametersTest.java deleted file mode 100644 index db84c728415c8485c84f7ea767f442b56fd866ee..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParametersTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class SecureGitlabSecretParametersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SecureGitlabSecretParametersTest.class, "schema.sql"); - - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private final DataChange underTest = new SecureGitlabSecretParameters(db.database()); - - @Test - public void secure_gitlab_secret_parameters() throws SQLException { - insertGitlabProperties(); - - underTest.execute(); - - assertThat(db.select("select * from PROPERTIES")) - .extracting(r -> r.get("PROP_KEY"), r -> r.get("TEXT_VALUE")) - .containsExactlyInAnyOrder( - tuple("sonar.auth.gitlab.secret.secured", "secret secret"), - tuple("sonar.auth.gitlab.applicationId.secured", "secret applicationId")); - } - - private void insertGitlabProperties() { - db.executeInsert("PROPERTIES", - "prop_key", "sonar.auth.gitlab.secret", - "is_empty", false, - "text_value", "secret secret", - "uuid", uuidFactory.create(), - "created_at", System2.INSTANCE.now()); - db.executeInsert("PROPERTIES", - "prop_key", "sonar.auth.gitlab.applicationId", - "is_empty", false, - "text_value", "secret applicationId", - "uuid", uuidFactory.create(), - "created_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettingsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettingsTest.java deleted file mode 100644 index 717e6246212f27d37c919b056b1b5101290d0cc9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettingsTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import java.util.Optional; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.config.internal.Settings; -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 org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class SetForceAuthenticationSettingsTest { - - private static final long NOW = 100_000_000_000L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(SetForceAuthenticationSettingsTest.class, "schema.sql"); - - private final System2 system2 = new TestSystem2().setNow(NOW); - - private final Settings settingsMock = mock(Settings.class); - - private final DataChange underTest = new SetForceAuthenticationSettings(db.database(), system2, UuidFactoryFast.getInstance(), settingsMock); - - @Test - public void insert_force_auth_property_based_on_settings_when_false() throws SQLException { - when(settingsMock.getRawString(any())).thenReturn(Optional.of("false")); - underTest.execute(); - - assertThatForceAuthenticationEquals("false"); - } - - @Test - public void insert_force_auth_property_based_on_settings_when_true() throws SQLException { - when(settingsMock.getRawString(any())).thenReturn(Optional.of("true")); - underTest.execute(); - - assertThatForceAuthenticationEquals("true"); - } - - @Test - public void insert_force_auth_property_based_on_settings_when_empty() throws SQLException { - when(settingsMock.getRawString(any())).thenReturn(Optional.empty()); - underTest.execute(); - - assertThatForceAuthenticationEquals("false"); - } - - @Test - public void insert_force_auth_property_if_row_not_exists() throws SQLException { - underTest.execute(); - - assertThatForceAuthenticationEquals("false"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatForceAuthenticationEquals("false"); - } - - @Test - public void do_nothing_if_force_auth_property_exists_with_value_false() throws SQLException { - insertProperty("uuid-1", "sonar.forceAuthentication", "false"); - underTest.execute(); - - assertThatForceAuthenticationEquals("false"); - } - - @Test - public void do_nothing_if_force_auth_property_exists_with_value_true() throws SQLException { - insertProperty("uuid-1", "sonar.forceAuthentication", "true"); - underTest.execute(); - - assertThatForceAuthenticationEquals("true"); - } - - private void assertThatForceAuthenticationEquals(String s) { - assertThat(db.selectFirst("select p.text_value from properties p where p.prop_key = 'sonar.forceAuthentication'")) - .containsEntry("TEXT_VALUE", s); - } - - private void insertProperty(String uuid, String key, String textValue) { - db.executeInsert("properties", - "uuid", uuid, - "prop_key", key, - "is_empty", false, - "text_value", textValue, - "created_at", NOW); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChangesTest.java deleted file mode 100644 index 92791450d62537f9ddd50de2d3cfa64302cd2bff..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChangesTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v86; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class UpdateChangeDataOfQProfileChangesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(UpdateChangeDataOfQProfileChangesTest.class, "schema.sql"); - - private DataChange underTest = new UpdateChangeDataOfQProfileChanges(db.database()); - - @Test - public void change_ruleId_to_ruleUuid() throws SQLException { - insertQProfileChanges("key-1", "severity=MAJOR;ruleUuid=AXJVoXWDOFGkZYIS4z4D"); - insertQProfileChanges("key-2", "severity=MAJOR;ruleId=12915"); - insertQProfileChanges("key-3", "severity=MAJOR;ruleId=12915;something"); - insertQProfileChanges("key-4", "ruleId=12915;something"); - - underTest.execute(); - - assertThatQProfileMigrated("key-1", "severity=MAJOR;ruleUuid=AXJVoXWDOFGkZYIS4z4D"); - assertThatQProfileMigrated("key-2", "severity=MAJOR;ruleUuid=12915"); - assertThatQProfileMigrated("key-3", "severity=MAJOR;ruleUuid=12915;something"); - assertThatQProfileMigrated("key-4", "ruleUuid=12915;something"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertQProfileChanges("key-1", "severity=MAJOR;ruleUuid=AXJVoXWDOFGkZYIS4z4D"); - insertQProfileChanges("key-2", "severity=MAJOR;ruleId=12915"); - insertQProfileChanges("key-3", "severity=MAJOR;ruleId=12915;something"); - insertQProfileChanges("key-4", "ruleId=12915;something"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatQProfileMigrated("key-1", "severity=MAJOR;ruleUuid=AXJVoXWDOFGkZYIS4z4D"); - assertThatQProfileMigrated("key-2", "severity=MAJOR;ruleUuid=12915"); - assertThatQProfileMigrated("key-3", "severity=MAJOR;ruleUuid=12915;something"); - assertThatQProfileMigrated("key-4", "ruleUuid=12915;something"); - } - - private void assertThatQProfileMigrated(String key, String changeData) { - assertThat(db.select("select qpc.kee, qpc.change_data " - + "from qprofile_changes qpc where qpc.kee = '" + key + "'").stream().findFirst()) - .isNotEmpty() - .hasValueSatisfying(stringObjectMap -> assertThat(stringObjectMap) - .extractingByKeys("KEE", "CHANGE_DATA") - .contains(key, changeData)); - - } - - private void insertQProfileChanges(String kee, String changeData) { - db.executeInsert("qprofile_changes", - "kee", kee, - "rules_profile_uuid", Uuids.createFast(), - "change_type", "any", - "change_data", changeData, - "created_at", System.currentTimeMillis()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTableTest.java deleted file mode 100644 index 39084cbacb82a68a49c8d1f5bde0dc221e8da3ee..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTableTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMonorepoColumnToProjectAlmSettingsTableTest { - private static final String TABLE_NAME = "project_alm_settings"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMonorepoColumnToProjectAlmSettingsTableTest.class, "schema.sql"); - - private final DdlChange underTest = new AddMonorepoColumnToProjectAlmSettingsTable(db.database()); - - @Test - public void add_monorepo_column() throws SQLException { - insertProjectAlmSettings(1); - insertProjectAlmSettings(2); - insertProjectAlmSettings(3); - - underTest.execute(); - - db.assertColumnDefinition("project_alm_settings", "monorepo", Types.BOOLEAN, null, true); - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(3); - } - - private void insertProjectAlmSettings(int id) { - db.executeInsert("project_alm_settings", - "UUID", "uuid-" + id, - "ALM_SETTING_UUID", "ALM_SETTING_UUID", - "PROJECT_UUID", "PROJECT_UUID-" + id, - "ALM_REPO", "ALM_REPO", - "ALM_SLUG", "ALM_SLUG", - "UPDATED_AT", 12342342, - "CREATED_AT",1232342 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DbVersion87Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DbVersion87Test.java deleted file mode 100644 index d495c37873c84226c2e64628cac56403917812c8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DbVersion87Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion87Test { - - private final DbVersion underTest = new DbVersion87(); - - @Test - public void migrationNumber_starts_at_4200() { - verifyMinimumMigrationNumber(underTest, 4200); - } - - @Test - public void verify_migration_count() { - verifyMigrationNotEmpty(underTest); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest.java deleted file mode 100644 index 768ab0a3f8f498455509974146b9a75cd13fd7c8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropAlmAppInstallsTableTest { - private static final String TABLE_NAME = "alm_app_installs"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropAlmAppInstallsTableTest.class, "schema.sql"); - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private MigrationStep underTest = new DropAlmAppInstallsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - underTest.execute(); - db.assertTableDoesNotExist(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest.java deleted file mode 100644 index dfa07888f21f2f0cdfa58b05ca5725a70a8aaf22..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropDescriptionInProjectMeasuresTest { - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropDescriptionInProjectMeasuresTest.class, "schema.sql"); - - private MigrationStep underTest = new DropDescriptionInProjectMeasures(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("project_measures", "description"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTableTest.java deleted file mode 100644 index 2da0bcf4621c1fc171a77c400207e52ae41166a4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrgMembersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrgMembersTableTest.class, "schema.sql"); - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private final MigrationStep underTest = new DropOrgMembersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void table_is_dropped() throws SQLException { - db.assertTableExists("organization_members"); - underTest.execute(); - db.assertTableDoesNotExist("organization_members"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTableTest.java deleted file mode 100644 index 031e7efb2c9bedf53dca8c5ca7d3e446319bea63..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTableTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrgQualityGatesTableTest { - private static final String TABLE_NAME = "org_quality_gates"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrgQualityGatesTableTest.class, "schema.sql"); - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private MigrationStep underTest = new DropOrgQualityGatesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - underTest.execute(); - db.assertTableDoesNotExist(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTableTest.java deleted file mode 100644 index a0bc166dea6f079910ff53c0d78ed8bc504f37ed..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTableTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationAlmBindingsTableTest { - private static final String TABLE_NAME = "organization_alm_bindings"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrganizationAlmBindingsTableTest.class, "schema.sql"); - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private MigrationStep underTest = new DropOrganizationAlmBindingsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - underTest.execute(); - db.assertTableDoesNotExist(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInComponentsTest.java deleted file mode 100644 index c3b86cd6bc1b9d466eec9d75f9bcd4f43997c7a8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInComponentsTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInComponentsTest { - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInComponentsTest.class, "schema.sql"); - - private final MigrationStep underTest = new DropOrganizationInComponents(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("components", "organization_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjectsTest.java deleted file mode 100644 index a4afa12abd17f3ae6352fe66bd61026aaf59e1b4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjectsTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInProjectsTest { - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInProjectsTest.class, "schema.sql"); - - private final MigrationStep underTest = new DropOrganizationInProjects(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertColumnDoesNotExist("projects", "organization_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooksTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooksTest.java deleted file mode 100644 index d5545ae3f510480b2ab403f3c848fb97ef7148a1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooksTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationInWebhooksTest { - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInWebhooksTest.class, "schema.sql"); - - private final MigrationStep underTest = new DropOrganizationInWebhooks(dbTester.database()); - - @Test - public void column_has_been_dropped() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist("webhooks", "organization_webhook"); - dbTester.assertIndexDoesNotExist("webhooks", "project_webhook"); - dbTester.assertColumnDoesNotExist("webhooks", "organization_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTableTest.java deleted file mode 100644 index e86acbd1fd36e95b6df2de162003cb1c692f0ab2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTableTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; -import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropOrganizationsTableTest { - private static final String TABLE_NAME = "organizations"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrganizationsTableTest.class, "schema.sql"); - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - - private MigrationStep underTest = new DropOrganizationsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - underTest.execute(); - db.assertTableDoesNotExist(TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest.java deleted file mode 100644 index 47dfc60336dfa6340e71d34672c550f015e024cb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest { - private static final String TABLE_NAME = "project_alm_settings"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest.class, "schema.sql"); - - private final DdlChange underTest = new MakeMonorepoColumnInProjectAlmSettingsTableNotNullable(db.database()); - - @Test - public void verify_monorepo_column_not_nullable() throws SQLException { - insertProjectAlmSettings(1); - insertProjectAlmSettings(2); - insertProjectAlmSettings(3); - - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "monorepo", Types.BOOLEAN, null, false); - - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(3); - } - - private void insertProjectAlmSettings(int id) { - db.executeInsert("project_alm_settings", - "UUID", "uuid-" + id, - "ALM_SETTING_UUID", "ALM_SETTING_UUID", - "PROJECT_UUID", "PROJECT_UUID-" + id, - "ALM_REPO", "ALM_REPO", - "ALM_SLUG", "ALM_SLUG", - "MONOREPO", false, - "UPDATED_AT", 12342342, - "CREATED_AT",1232342 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalPropertiesTest.java deleted file mode 100644 index 7d25d989bb26cfdcae520f6e64f0cd24570fbccb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalPropertiesTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.impl.utils.TestSystem2; -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.assertThatThrownBy; - -public class MoveDefaultProjectVisibilityToGlobalPropertiesTest { - - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private final TestSystem2 system2 = new TestSystem2(); - private final long NOW = 1606375781L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MoveDefaultProjectVisibilityToGlobalPropertiesTest.class, "schema.sql"); - - private final MoveDefaultProjectVisibilityToGlobalProperties underTest = new MoveDefaultProjectVisibilityToGlobalProperties(db.database(), - UuidFactoryFast.getInstance(), system2); - - @Before - public void before() { - system2.setNow(NOW); - } - - @Test - public void fail_if_organization_not_exist() { - assertThatThrownBy(underTest::execute) - .isInstanceOf(IllegalStateException.class) - .hasMessage("Default organization is missing"); - } - - @Test - public void migrate_default_project_visibility_if_set_to_true_on_organization() throws SQLException { - insertDefaultOrganization(true); - - underTest.execute(); - - assertThatDefaultProjectVisibilityIsEqualTo("private"); - } - - @Test - public void migrate_default_project_visibility_if_set_to_false_on_organization() throws SQLException { - insertDefaultOrganization(false); - - underTest.execute(); - - assertThatDefaultProjectVisibilityIsEqualTo("public"); - } - - private void insertDefaultOrganization(boolean newProjectPrivate) { - String uuid = uuidFactory.create(); - db.executeInsert("organizations", - "uuid", uuid, - "kee", "default-organization", - "name", "name" + uuid, - "default_perm_template_project", uuidFactory.create(), - "default_perm_template_port", uuidFactory.create(), - "default_perm_template_app", uuidFactory.create(), - "default_quality_gate_uuid", uuid, - "new_project_private", newProjectPrivate, - "subscription", uuid, - "created_at", NOW, - "updated_at", NOW); - } - - private void assertThatDefaultProjectVisibilityIsEqualTo(String s) { - assertThat(db.selectFirst("select p.text_value, p.created_at from properties p where p.prop_key = 'projects.default.visibility'")) - .containsEntry("TEXT_VALUE", s) - .containsEntry("CREATED_AT", NOW); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalPropertiesTest.java deleted file mode 100644 index 318153ad13139849fcc5cb582b853fce974997de..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalPropertiesTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.impl.utils.TestSystem2; -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.assertThatThrownBy; - -public class MoveDefaultQualityGateToGlobalPropertiesTest { - - private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private final TestSystem2 system2 = new TestSystem2(); - private final long NOW = 1606375781L; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MoveDefaultQualityGateToGlobalPropertiesTest.class, "schema.sql"); - - private final MoveDefaultQualityGateToGlobalProperties underTest = new MoveDefaultQualityGateToGlobalProperties(db.database(), - UuidFactoryFast.getInstance(), system2); - - @Before - public void before() { - system2.setNow(NOW); - } - - @Test - public void fail_if_organization_not_exist() { - assertThatThrownBy(underTest::execute) - .isInstanceOf(IllegalStateException.class) - .hasMessage("Default organization is missing"); - } - - @Test - public void migrate_default_quality_gate_from_default_organization() throws SQLException { - insertDefaultOrganization("default-quality-gate-uuid"); - - underTest.execute(); - - assertThatDefaultQualityGateIsEqualTo("default-quality-gate-uuid"); - } - - private void insertDefaultOrganization(String defaultQualityGate) { - String uuid = uuidFactory.create(); - db.executeInsert("organizations", - "uuid", uuid, - "kee", "default-organization", - "name", "name" + uuid, - "default_perm_template_project", uuidFactory.create(), - "default_perm_template_port", uuidFactory.create(), - "default_perm_template_app", uuidFactory.create(), - "default_quality_gate_uuid", defaultQualityGate, - "new_project_private", false, - "subscription", uuid, - "created_at", NOW, - "updated_at", NOW); - } - - private void assertThatDefaultQualityGateIsEqualTo(String s) { - assertThat(db.selectFirst("select p.text_value, p.created_at from properties p where p.prop_key = 'qualitygate.default'")) - .containsEntry("TEXT_VALUE", s) - .containsEntry("CREATED_AT", NOW); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTableTest.java deleted file mode 100644 index 006895d400b3bbf4cbbc54fdee0971e47b61f99a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTableTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v87; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateMonorepoColumnToProjectAlmSettingsTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateMonorepoColumnToProjectAlmSettingsTableTest.class, "schema.sql"); - - private final DataChange underTest = new PopulateMonorepoColumnToProjectAlmSettingsTable(db.database()); - - @Test - public void populate_monorepo_on_empty_table() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from project_alm_settings")).isZero(); - } - - @Test - public void populate_monorepo_column() throws SQLException { - insertProjectAlmSettings(1); - insertProjectAlmSettings(2); - insertProjectAlmSettings(3); - - underTest.execute(); - - db.assertColumnDefinition("project_alm_settings", "monorepo", Types.BOOLEAN, null, true); - assertThat(db.countSql("select count(uuid) from project_alm_settings where monorepo = false")).isEqualTo(3); - } - - private void insertProjectAlmSettings(int id) { - db.executeInsert("project_alm_settings", - "UUID", "uuid-" + id, - "ALM_SETTING_UUID", "ALM_SETTING_UUID", - "PROJECT_UUID", "PROJECT_UUID-" + id, - "ALM_REPO", "ALM_REPO", - "ALM_SLUG", "ALM_SLUG", - "UPDATED_AT", 12342342, - "CREATED_AT",1232342 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v88/AddLastSonarlintConnectionToUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v88/AddLastSonarlintConnectionToUsersTest.java deleted file mode 100644 index 2583cd7f4bb56291194804d4af9f0b2144d4ead6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v88/AddLastSonarlintConnectionToUsersTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v88; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddLastSonarlintConnectionToUsersTest { - private static final String TABLE_NAME = "users"; - private static final String COLUMN_NAME = "last_sonarlint_connection"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddLastSonarlintConnectionToUsersTest.class, "schema.sql"); - private final DdlChange underTest = new AddLastSonarlintConnectionToUsers(db.database()); - - @Test - public void add_column() throws SQLException { - db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME); - underTest.execute(); - db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.BIGINT, null, true); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v88/DbVersion88Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v88/DbVersion88Test.java deleted file mode 100644 index 3dbf9b66479efbcb978241fbe37b65319aaf4a01..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v88/DbVersion88Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v88; - -import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion88Test { - - private final DbVersion underTest = new DbVersion88(); - - @Test - public void migrationNumber_starts_at_4300() { - verifyMinimumMigrationNumber(underTest, 4300); - } - - @Test - public void verify_migration_count() { - verifyMigrationNotEmpty(underTest); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTableTest.java deleted file mode 100644 index 8418f26d15040d95d0f135575e8d28865f6831a2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnWebhookUuidInWebhookDeliveriesTableTest { - - private static final String TABLE_NAME = "webhook_deliveries"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnWebhookUuidInWebhookDeliveriesTableTest.class, "schema.sql"); - - private final MigrationStep underTest = new AddIndexOnWebhookUuidInWebhookDeliveriesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_NAME, "idx_wbhk_dlvrs_wbhk_uuid", "webhook_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex(TABLE_NAME, "idx_wbhk_dlvrs_wbhk_uuid", "webhook_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTableTest.java deleted file mode 100644 index f584b63c31501e77a271f4ed8b3ddc19801269d0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndicesToNewCodePeriodTableTest { - private static final String TABLE_NAME = "new_code_periods"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndicesToNewCodePeriodTableTest.class, "schema.sql"); - - private final MigrationStep underTest = new AddIndicesToNewCodePeriodTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_NAME, "idx_ncp_type", "type"); - db.assertIndex(TABLE_NAME, "idx_ncp_value", "value"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex(TABLE_NAME, "idx_ncp_type", "type"); - db.assertIndex(TABLE_NAME, "idx_ncp_value", "value"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTableTest.java deleted file mode 100644 index fe8c6d680e6359a6090c73e53e310ed979969bfc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddMainBranchProjectUuidIndexToComponentTableTest { - private static final String TABLE_NAME = "components"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMainBranchProjectUuidIndexToComponentTableTest.class, "schema.sql"); - - private final MigrationStep underTest = new AddMainBranchProjectUuidIndexToComponentTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_NAME, "idx_main_branch_prj_uuid", "main_branch_project_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex(TABLE_NAME, "idx_main_branch_prj_uuid", "main_branch_project_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/DbVersion89Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/DbVersion89Test.java deleted file mode 100644 index 7ee1b1d5b8c0b1ca99968932c9b3cbb36fe330ee..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/DbVersion89Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import org.junit.Test; -import org.sonar.server.platform.db.migration.version.DbVersion; - -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; -import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; - -public class DbVersion89Test { - - private final DbVersion underTest = new DbVersion89(); - - @Test - public void migrationNumber_starts_at_4400() { - verifyMinimumMigrationNumber(underTest, 4400); - } - - @Test - public void verify_migration_count() { - verifyMigrationNotEmpty(underTest); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSettingTest.java deleted file mode 100644 index 379b5e0dd754955d7887e1598b98f1bc8e28f146..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSettingTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -import java.sql.SQLException; -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.Rule; -import org.junit.Test; -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.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class DropGithubEndpointOnProjectLevelSettingTest { - private static final String DROPPED_PROPERTY = "sonar.pullrequest.github.endpoint"; - private static final String PROP_1_UUID = Uuids.createFast(); - private static final String PROP_2_UUID = Uuids.createFast(); - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGithubEndpointOnProjectLevelSettingTest.class, "schema.sql"); - - private final MigrationStep underTest = new DropGithubEndpointOnProjectLevelSetting(db.database()); - - @Test - public void execute() throws SQLException { - setupProperties(); - - underTest.execute(); - - verifyResult(); - } - - @Test - public void is_reentrant() throws SQLException { - setupProperties(); - - underTest.execute(); - underTest.execute(); - - verifyResult(); - } - - @Test - public void is_successful_when_no_entries_to_drop() throws SQLException { - underTest.execute(); - - assertThat(db.select("SELECT UUID FROM PROPERTIES")).isEmpty(); - } - - private void setupProperties() { - insertProperty(Uuids.createFast(), "some.prop", "1"); - insertProperty(Uuids.createFast(), "some.other.prop", null); - insertProperty(PROP_1_UUID, DROPPED_PROPERTY, "1"); - insertProperty(PROP_2_UUID, DROPPED_PROPERTY, "2"); - insertProperty(Uuids.createFast(), DROPPED_PROPERTY, null); - } - - private void verifyResult() { - List> result = db.select("SELECT UUID, PROP_KEY, COMPONENT_UUID FROM PROPERTIES"); - assertThat(result - .stream() - .map(e -> new Tuple(e.get("PROP_KEY"), e.get("COMPONENT_UUID"))) - .collect(Collectors.toList())) - .containsExactlyInAnyOrder( - tuple("some.prop", "1"), - tuple("some.other.prop", null), - tuple(DROPPED_PROPERTY, null)); - assertThat(result) - .extracting(e -> e.get("UUID")) - .doesNotContain(PROP_1_UUID, PROP_2_UUID); - } - - private void insertProperty(String uuid, String key, @Nullable String projectUuid) { - db.executeInsert("PROPERTIES", - "UUID", uuid, - "PROP_KEY", key, - "COMPONENT_UUID", projectUuid, - "USER_UUID", null, - "IS_EMPTY", false, - "TEXT_VALUE", "AnyValue", - "CLOB_VALUE", null, - "CREATED_AT", System2.INSTANCE.now()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTableTest.java deleted file mode 100644 index c6c47e402a136818483498c3351ed8020da02377..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTableTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89; - -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; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.Assertions.tuple; - -public class IncreaseSizeOfValueColumnInNewCodePeriodsTableTest { - private static final String TABLE_NAME = "new_code_periods"; - private static final String VERY_LONG_BRANCH_NAME = "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijab" + - "cdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd" + - "efghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijxxxxx"; - private final System2 system = System2.INSTANCE; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(IncreaseSizeOfValueColumnInNewCodePeriodsTableTest.class, "schema.sql"); - - private final IncreaseSizeOfValueColumnInNewCodePeriodsTable underTest = new IncreaseSizeOfValueColumnInNewCodePeriodsTable(db.database()); - - @Test - public void cannot_insert_long_value_before_migration() { - assertThatThrownBy(() -> insertNewCodePeriod("1", VERY_LONG_BRANCH_NAME)) - .isInstanceOf(IllegalStateException.class); - } - - @Test - public void can_insert_long_value_after_migration() throws SQLException { - underTest.execute(); - assertThat(db.countRowsOfTable(TABLE_NAME)).isZero(); - - insertNewCodePeriod("1", VERY_LONG_BRANCH_NAME); - - assertThat(db.countRowsOfTable(TABLE_NAME)).isEqualTo(1); - } - - @Test - public void existing_entries_are_not_affected() throws SQLException { - insertNewCodePeriod("1", "branch1"); - insertNewCodePeriod("2", null); - - underTest.execute(); - - assertThat(db.select("select uuid as \"UUID\", value as \"VALUE\"from new_code_periods")) - .extracting(r -> r.get("UUID"), r -> r.get("VALUE")) - .containsExactlyInAnyOrder( - tuple("1", "branch1"), - tuple("2", null)); - } - - private void insertNewCodePeriod(String uuid, @Nullable String value) { - long now = system.now(); - db.executeInsert("NEW_CODE_PERIODS", - "UUID", uuid, - "PROJECT_UUID", "proj-" + uuid, - "BRANCH_UUID", "branch-1", - "TYPE", "REFERENCE_BRANCH", - "VALUE", value, - "UPDATED_AT", now, - "CREATED_AT", now); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/util/NetworkInterfaceProviderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/util/NetworkInterfaceProviderTest.java deleted file mode 100644 index 47274ed5545fa2969ddc0b884400bfa5103b8401..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v89/util/NetworkInterfaceProviderTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v89.util; - -import java.net.SocketException; -import java.util.List; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class NetworkInterfaceProviderTest { - private NetworkInterfaceProvider underTest = new NetworkInterfaceProvider(); - - @Test - public void itGetsListOfNetworkInterfaceAddresses() throws SocketException { - assertThat(underTest.getNetworkInterfaceAddresses()) - .isInstanceOf(List.class) - .hasSizeGreaterThan(0); - } -} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUniqueTest/deprecated_rule_keys.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUniqueTest/deprecated_rule_keys.sql deleted file mode 100644 index b46329a103b71b295465dcfa5e63d219944246dd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/MakeDeprecatedRuleKeysRuleIdIndexNonUniqueTest/deprecated_rule_keys.sql +++ /dev/null @@ -1,11 +0,0 @@ -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 UNIQUE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS" ("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullable/organizations.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullable/organizations.sql deleted file mode 100644 index 52060aa7dd2790ee5a1b91a566138abe14f6caed..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/MakeOrganizationsGuardedNullable/organizations.sql +++ /dev/null @@ -1,21 +0,0 @@ -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"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest/schema.sql deleted file mode 100644 index 1b64db325d6e72ffa6845b606823c1dd0a2b752e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest/schema.sql +++ /dev/null @@ -1,86 +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, - "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 "NEW_CODE_PERIODS" ( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40), - "BRANCH_UUID" VARCHAR(40), - "TYPE" VARCHAR(30) NOT NULL, - "VALUE" VARCHAR(40), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - - CONSTRAINT "PK_NEW_CODE_PERIOD" PRIMARY KEY ("UUID") -); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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 AUTO_INCREMENT (1,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 "EVENTS" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "CATEGORY" VARCHAR(50), - "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 TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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', - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE -); -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/v80/PopulateProjectQualityGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/PopulateProjectQualityGatesTableTest/schema.sql deleted file mode 100644 index 97c8f97109da6b42c250c219e63d6f818dcbcc71..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/PopulateProjectQualityGatesTableTest/schema.sql +++ /dev/null @@ -1,77 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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 "QUALITY_GATES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES" ("UUID"); - - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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_QGATES" ( -"PROJECT_UUID" VARCHAR(40) NOT NULL, -"QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - -CONSTRAINT "PK_PROJECT_QGATES" PRIMARY KEY ("PROJECT_UUID") -); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QGATES" ON "PROJECT_QGATES" ("PROJECT_UUID", "QUALITY_GATE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTableTest/schema.sql deleted file mode 100644 index 367029ea6ba011b112320ebbd4d5efab7eaf7a09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RemoveDefaultQualityGateFromPropertiesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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/v80/RemoveGitHubLoginGenerationStrategyPropertyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RemoveGitHubLoginGenerationStrategyPropertyTest/schema.sql deleted file mode 100644 index 367029ea6ba011b112320ebbd4d5efab7eaf7a09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RemoveGitHubLoginGenerationStrategyPropertyTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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/v80/RemoveLeakPeriodPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RemoveLeakPeriodPropertiesTest/schema.sql deleted file mode 100644 index 367029ea6ba011b112320ebbd4d5efab7eaf7a09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RemoveLeakPeriodPropertiesTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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/v80/RenameAnalysisPropertiesSnapshotUuidTest/analysis_properties.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RenameAnalysisPropertiesSnapshotUuidTest/analysis_properties.sql deleted file mode 100644 index 0a131046edc0fbbf74ee134b32f2f8a503e12053..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v80/RenameAnalysisPropertiesSnapshotUuidTest/analysis_properties.sql +++ /dev/null @@ -1,12 +0,0 @@ -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"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest/schema.sql deleted file mode 100644 index 32de015c84b88a34d4f3798c68d9fdd1351c5244..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE PROJECT_BRANCHES( - UUID VARCHAR(50) NOT NULL, - PROJECT_UUID VARCHAR(50) NOT NULL, - KEE VARCHAR(255) NOT NULL, - BRANCH_TYPE VARCHAR(12), - MERGE_BRANCH_UUID VARCHAR(50), - KEY_TYPE VARCHAR(12) NOT NULL, - PULL_REQUEST_BINARY BLOB, - MANUAL_BASELINE_ANALYSIS_UUID VARCHAR(40), - 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/v81/DeleteSonarPullRequestProviderPropertyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/DeleteSonarPullRequestProviderPropertyTest/schema.sql deleted file mode 100644 index 367029ea6ba011b112320ebbd4d5efab7eaf7a09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/DeleteSonarPullRequestProviderPropertyTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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/v81/MigrateAzureAlmSettingsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateAzureAlmSettingsTest/schema.sql deleted file mode 100644 index a84169c089ac6a4d108fad70240f4748d3c9fe5a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateAzureAlmSettingsTest/schema.sql +++ /dev/null @@ -1,86 +0,0 @@ -CREATE TABLE ALM_SETTINGS( - UUID VARCHAR(40) NOT NULL, - ALM_ID VARCHAR(40) NOT NULL, - KEE VARCHAR(200) NOT NULL, - URL VARCHAR(2000), - APP_ID VARCHAR(80), - PRIVATE_KEY VARCHAR(2000), - PAT VARCHAR(2000), - UPDATED_AT BIGINT NOT NULL, - CREATED_AT BIGINT NOT NULL -); -ALTER TABLE ALM_SETTINGS ADD CONSTRAINT PK_ALM_SETTINGS PRIMARY KEY(UUID); -CREATE UNIQUE INDEX UNIQ_ALM_SETTINGS ON ALM_SETTINGS(KEE); - -CREATE TABLE PROJECT_ALM_SETTINGS( - UUID VARCHAR(40) NOT NULL, - ALM_SETTING_UUID VARCHAR(40) NOT NULL, - PROJECT_UUID VARCHAR(50) NOT NULL, - ALM_REPO VARCHAR(256), - ALM_SLUG VARCHAR(256), - UPDATED_AT BIGINT NOT NULL, - CREATED_AT BIGINT NOT NULL -); -ALTER TABLE PROJECT_ALM_SETTINGS ADD CONSTRAINT PK_PROJECT_ALM_SETTINGS PRIMARY KEY(UUID); -CREATE UNIQUE INDEX UNIQ_PROJECT_ALM_SETTINGS ON PROJECT_ALM_SETTINGS(PROJECT_UUID); -CREATE INDEX PROJECT_ALM_SETTINGS_ALM ON PROJECT_ALM_SETTINGS(ALM_SETTING_UUID); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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 AUTO_INCREMENT (1,1), - UUID VARCHAR(50) NOT NULL, - ORGANIZATION_UUID VARCHAR(40) NOT NULL, - KEE VARCHAR(400), - DEPRECATED_KEE VARCHAR(400), - NAME VARCHAR(2000), - LONG_NAME VARCHAR(2000), - DESCRIPTION VARCHAR(2000), - ENABLED BOOLEAN DEFAULT TRUE NOT NULL, - SCOPE VARCHAR(3), - QUALIFIER VARCHAR(10), - PRIVATE BOOLEAN NOT NULL, - ROOT_UUID VARCHAR(50) NOT NULL, - LANGUAGE VARCHAR(20), - COPY_COMPONENT_UUID VARCHAR(50), - DEVELOPER_UUID VARCHAR(50), - PATH VARCHAR(2000), - UUID_PATH VARCHAR(1500) NOT NULL, - PROJECT_UUID VARCHAR(50) NOT NULL, - MODULE_UUID VARCHAR(50), - MODULE_UUID_PATH VARCHAR(1500), - AUTHORIZATION_UPDATED_AT BIGINT, - TAGS VARCHAR(500), - MAIN_BRANCH_PROJECT_UUID VARCHAR(50), - B_CHANGED BOOLEAN, - B_NAME VARCHAR(500), - B_LONG_NAME VARCHAR(500), - B_DESCRIPTION VARCHAR(2000), - B_ENABLED BOOLEAN, - B_QUALIFIER VARCHAR(10), - B_LANGUAGE VARCHAR(20), - B_COPY_COMPONENT_UUID VARCHAR(50), - B_PATH VARCHAR(2000), - B_UUID_PATH VARCHAR(1500), - B_MODULE_UUID VARCHAR(50), - B_MODULE_UUID_PATH VARCHAR(1500), - CREATED_AT TIMESTAMP -); -ALTER TABLE PROJECTS ADD CONSTRAINT PK_PROJECTS PRIMARY KEY(ID); -CREATE INDEX PROJECTS_ORGANIZATION ON PROJECTS(ORGANIZATION_UUID); -CREATE UNIQUE INDEX PROJECTS_KEE ON PROJECTS(KEE); -CREATE INDEX PROJECTS_MODULE_UUID ON PROJECTS(MODULE_UUID); -CREATE INDEX PROJECTS_PROJECT_UUID ON PROJECTS(PROJECT_UUID); -CREATE INDEX PROJECTS_QUALIFIER ON PROJECTS(QUALIFIER); -CREATE INDEX PROJECTS_ROOT_UUID ON PROJECTS(ROOT_UUID); -CREATE INDEX PROJECTS_UUID ON PROJECTS(UUID); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettingsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettingsTest/schema.sql deleted file mode 100644 index a84169c089ac6a4d108fad70240f4748d3c9fe5a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateBitbucketAlmSettingsTest/schema.sql +++ /dev/null @@ -1,86 +0,0 @@ -CREATE TABLE ALM_SETTINGS( - UUID VARCHAR(40) NOT NULL, - ALM_ID VARCHAR(40) NOT NULL, - KEE VARCHAR(200) NOT NULL, - URL VARCHAR(2000), - APP_ID VARCHAR(80), - PRIVATE_KEY VARCHAR(2000), - PAT VARCHAR(2000), - UPDATED_AT BIGINT NOT NULL, - CREATED_AT BIGINT NOT NULL -); -ALTER TABLE ALM_SETTINGS ADD CONSTRAINT PK_ALM_SETTINGS PRIMARY KEY(UUID); -CREATE UNIQUE INDEX UNIQ_ALM_SETTINGS ON ALM_SETTINGS(KEE); - -CREATE TABLE PROJECT_ALM_SETTINGS( - UUID VARCHAR(40) NOT NULL, - ALM_SETTING_UUID VARCHAR(40) NOT NULL, - PROJECT_UUID VARCHAR(50) NOT NULL, - ALM_REPO VARCHAR(256), - ALM_SLUG VARCHAR(256), - UPDATED_AT BIGINT NOT NULL, - CREATED_AT BIGINT NOT NULL -); -ALTER TABLE PROJECT_ALM_SETTINGS ADD CONSTRAINT PK_PROJECT_ALM_SETTINGS PRIMARY KEY(UUID); -CREATE UNIQUE INDEX UNIQ_PROJECT_ALM_SETTINGS ON PROJECT_ALM_SETTINGS(PROJECT_UUID); -CREATE INDEX PROJECT_ALM_SETTINGS_ALM ON PROJECT_ALM_SETTINGS(ALM_SETTING_UUID); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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 AUTO_INCREMENT (1,1), - UUID VARCHAR(50) NOT NULL, - ORGANIZATION_UUID VARCHAR(40) NOT NULL, - KEE VARCHAR(400), - DEPRECATED_KEE VARCHAR(400), - NAME VARCHAR(2000), - LONG_NAME VARCHAR(2000), - DESCRIPTION VARCHAR(2000), - ENABLED BOOLEAN DEFAULT TRUE NOT NULL, - SCOPE VARCHAR(3), - QUALIFIER VARCHAR(10), - PRIVATE BOOLEAN NOT NULL, - ROOT_UUID VARCHAR(50) NOT NULL, - LANGUAGE VARCHAR(20), - COPY_COMPONENT_UUID VARCHAR(50), - DEVELOPER_UUID VARCHAR(50), - PATH VARCHAR(2000), - UUID_PATH VARCHAR(1500) NOT NULL, - PROJECT_UUID VARCHAR(50) NOT NULL, - MODULE_UUID VARCHAR(50), - MODULE_UUID_PATH VARCHAR(1500), - AUTHORIZATION_UPDATED_AT BIGINT, - TAGS VARCHAR(500), - MAIN_BRANCH_PROJECT_UUID VARCHAR(50), - B_CHANGED BOOLEAN, - B_NAME VARCHAR(500), - B_LONG_NAME VARCHAR(500), - B_DESCRIPTION VARCHAR(2000), - B_ENABLED BOOLEAN, - B_QUALIFIER VARCHAR(10), - B_LANGUAGE VARCHAR(20), - B_COPY_COMPONENT_UUID VARCHAR(50), - B_PATH VARCHAR(2000), - B_UUID_PATH VARCHAR(1500), - B_MODULE_UUID VARCHAR(50), - B_MODULE_UUID_PATH VARCHAR(1500), - CREATED_AT TIMESTAMP -); -ALTER TABLE PROJECTS ADD CONSTRAINT PK_PROJECTS PRIMARY KEY(ID); -CREATE INDEX PROJECTS_ORGANIZATION ON PROJECTS(ORGANIZATION_UUID); -CREATE UNIQUE INDEX PROJECTS_KEE ON PROJECTS(KEE); -CREATE INDEX PROJECTS_MODULE_UUID ON PROJECTS(MODULE_UUID); -CREATE INDEX PROJECTS_PROJECT_UUID ON PROJECTS(PROJECT_UUID); -CREATE INDEX PROJECTS_QUALIFIER ON PROJECTS(QUALIFIER); -CREATE INDEX PROJECTS_ROOT_UUID ON PROJECTS(ROOT_UUID); -CREATE INDEX PROJECTS_UUID ON PROJECTS(UUID); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest/schema.sql deleted file mode 100644 index 45c10269b8d9cc5185ff04f27b139067f9ff9ca7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest/schema.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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 "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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/v81/MigrateDeprecatedGithubPrivateKeyToNewKeyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateDeprecatedGithubPrivateKeyToNewKeyTest/schema.sql deleted file mode 100644 index 367029ea6ba011b112320ebbd4d5efab7eaf7a09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateDeprecatedGithubPrivateKeyToNewKeyTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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/v81/MigrateGithubAlmSettingsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateGithubAlmSettingsTest/schema.sql deleted file mode 100644 index a84169c089ac6a4d108fad70240f4748d3c9fe5a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateGithubAlmSettingsTest/schema.sql +++ /dev/null @@ -1,86 +0,0 @@ -CREATE TABLE ALM_SETTINGS( - UUID VARCHAR(40) NOT NULL, - ALM_ID VARCHAR(40) NOT NULL, - KEE VARCHAR(200) NOT NULL, - URL VARCHAR(2000), - APP_ID VARCHAR(80), - PRIVATE_KEY VARCHAR(2000), - PAT VARCHAR(2000), - UPDATED_AT BIGINT NOT NULL, - CREATED_AT BIGINT NOT NULL -); -ALTER TABLE ALM_SETTINGS ADD CONSTRAINT PK_ALM_SETTINGS PRIMARY KEY(UUID); -CREATE UNIQUE INDEX UNIQ_ALM_SETTINGS ON ALM_SETTINGS(KEE); - -CREATE TABLE PROJECT_ALM_SETTINGS( - UUID VARCHAR(40) NOT NULL, - ALM_SETTING_UUID VARCHAR(40) NOT NULL, - PROJECT_UUID VARCHAR(50) NOT NULL, - ALM_REPO VARCHAR(256), - ALM_SLUG VARCHAR(256), - UPDATED_AT BIGINT NOT NULL, - CREATED_AT BIGINT NOT NULL -); -ALTER TABLE PROJECT_ALM_SETTINGS ADD CONSTRAINT PK_PROJECT_ALM_SETTINGS PRIMARY KEY(UUID); -CREATE UNIQUE INDEX UNIQ_PROJECT_ALM_SETTINGS ON PROJECT_ALM_SETTINGS(PROJECT_UUID); -CREATE INDEX PROJECT_ALM_SETTINGS_ALM ON PROJECT_ALM_SETTINGS(ALM_SETTING_UUID); - -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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 AUTO_INCREMENT (1,1), - UUID VARCHAR(50) NOT NULL, - ORGANIZATION_UUID VARCHAR(40) NOT NULL, - KEE VARCHAR(400), - DEPRECATED_KEE VARCHAR(400), - NAME VARCHAR(2000), - LONG_NAME VARCHAR(2000), - DESCRIPTION VARCHAR(2000), - ENABLED BOOLEAN DEFAULT TRUE NOT NULL, - SCOPE VARCHAR(3), - QUALIFIER VARCHAR(10), - PRIVATE BOOLEAN NOT NULL, - ROOT_UUID VARCHAR(50) NOT NULL, - LANGUAGE VARCHAR(20), - COPY_COMPONENT_UUID VARCHAR(50), - DEVELOPER_UUID VARCHAR(50), - PATH VARCHAR(2000), - UUID_PATH VARCHAR(1500) NOT NULL, - PROJECT_UUID VARCHAR(50) NOT NULL, - MODULE_UUID VARCHAR(50), - MODULE_UUID_PATH VARCHAR(1500), - AUTHORIZATION_UPDATED_AT BIGINT, - TAGS VARCHAR(500), - MAIN_BRANCH_PROJECT_UUID VARCHAR(50), - B_CHANGED BOOLEAN, - B_NAME VARCHAR(500), - B_LONG_NAME VARCHAR(500), - B_DESCRIPTION VARCHAR(2000), - B_ENABLED BOOLEAN, - B_QUALIFIER VARCHAR(10), - B_LANGUAGE VARCHAR(20), - B_COPY_COMPONENT_UUID VARCHAR(50), - B_PATH VARCHAR(2000), - B_UUID_PATH VARCHAR(1500), - B_MODULE_UUID VARCHAR(50), - B_MODULE_UUID_PATH VARCHAR(1500), - CREATED_AT TIMESTAMP -); -ALTER TABLE PROJECTS ADD CONSTRAINT PK_PROJECTS PRIMARY KEY(ID); -CREATE INDEX PROJECTS_ORGANIZATION ON PROJECTS(ORGANIZATION_UUID); -CREATE UNIQUE INDEX PROJECTS_KEE ON PROJECTS(KEE); -CREATE INDEX PROJECTS_MODULE_UUID ON PROJECTS(MODULE_UUID); -CREATE INDEX PROJECTS_PROJECT_UUID ON PROJECTS(PROJECT_UUID); -CREATE INDEX PROJECTS_QUALIFIER ON PROJECTS(QUALIFIER); -CREATE INDEX PROJECTS_ROOT_UUID ON PROJECTS(ROOT_UUID); -CREATE INDEX PROJECTS_UUID ON PROJECTS(UUID); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest/schema.sql deleted file mode 100644 index 92974731cd685682e510ec1e6790dbe3a01af392..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -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"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest/schema.sql deleted file mode 100644 index 479c9fcd6ac880091705799bcafc5531cd52e3af..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest/schema.sql +++ /dev/null @@ -1,15 +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, - "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/v81/PopulateExcludeBranchFromPurgeColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/PopulateExcludeBranchFromPurgeColumnTest/schema.sql deleted file mode 100644 index fb58dc66af97dcf10c2aa5fb07bc659ae9731252..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/PopulateExcludeBranchFromPurgeColumnTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE PROJECT_BRANCHES( - UUID VARCHAR(50) NOT NULL, - PROJECT_UUID VARCHAR(50) NOT NULL, - KEE VARCHAR(255) NOT NULL, - BRANCH_TYPE VARCHAR(12), - MERGE_BRANCH_UUID VARCHAR(50), - KEY_TYPE VARCHAR(12) NOT NULL, - PULL_REQUEST_BINARY BLOB, - MANUAL_BASELINE_ANALYSIS_UUID VARCHAR(40), - CREATED_AT BIGINT NOT NULL, - UPDATED_AT BIGINT NOT NULL, - EXCLUDE_FROM_PURGE BOOLEAN DEFAULT FALSE NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql deleted file mode 100644 index 367029ea6ba011b112320ebbd4d5efab7eaf7a09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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/v81/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql deleted file mode 100644 index 8ce5b03c09304452ac166d112369d8e72895582d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql +++ /dev/null @@ -1,11 +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") -); -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/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest/schema.sql deleted file mode 100644 index 367029ea6ba011b112320ebbd4d5efab7eaf7a09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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/v82/AddIndexOnSlugOfProjectAlmSettingsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/AddIndexOnSlugOfProjectAlmSettingsTest/schema.sql deleted file mode 100644 index 137b8c43e8ca94a6dfe76d312cb7eff385715644..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/AddIndexOnSlugOfProjectAlmSettingsTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROJECT_ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_SETTING_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "ALM_REPO" VARCHAR(256), - "ALM_SLUG" VARCHAR(256), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROJECT_ALM_SETTINGS" ADD CONSTRAINT "PK_PROJECT_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_ALM_SETTINGS" ON "PROJECT_ALM_SETTINGS"("PROJECT_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_ALM" ON "PROJECT_ALM_SETTINGS"("ALM_SETTING_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetricsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetricsTest/schema.sql deleted file mode 100644 index 8a5718c3bc35c3b8a6faf6c97d2d64661473e4c9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteQgateConditionsUsingSecurityHotspotMetricsTest/schema.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); - - -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest/schema.sql deleted file mode 100644 index 3a0e16b77b08484dbc9a6b796e5a0e2723dd218a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest/schema.sql +++ /dev/null @@ -1,82 +0,0 @@ -CREATE TABLE "COMPONENTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(50) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -ALTER TABLE "COMPONENTS" ADD CONSTRAINT "PK_PROJECTS" PRIMARY KEY("ID"); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); - -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); -CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest/schema.sql deleted file mode 100644 index d8f2d4316abc0966e6a72a7a5e51080d863654fa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest/schema.sql +++ /dev/null @@ -1,54 +0,0 @@ -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); - -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTableTest/schema.sql deleted file mode 100644 index fda0c51c86c20f902a7110cf1ccec2338baad3fe..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropTagsColumnFromComponentsTableTest/schema.sql +++ /dev/null @@ -1,47 +0,0 @@ -CREATE TABLE "COMPONENTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(50) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "DEVELOPER_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "AUTHORIZATION_UPDATED_AT" BIGINT, - "TAGS" VARCHAR(500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -ALTER TABLE "COMPONENTS" ADD CONSTRAINT "PK_PROJECTS" PRIMARY KEY("ID"); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest/issues.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest/issues.sql deleted file mode 100644 index cf65bc42c84fc7b129355756b7e09bbea3ccfe6e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest/issues.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql deleted file mode 100644 index d8f2d4316abc0966e6a72a7a5e51080d863654fa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql +++ /dev/null @@ -1,54 +0,0 @@ -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); - -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTableTest/schema.sql deleted file mode 100644 index b946b235b22b627f015ef8bc95d9136429c2ba23..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/PopulateProjectsTableTest/schema.sql +++ /dev/null @@ -1,64 +0,0 @@ -CREATE TABLE "COMPONENTS" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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 "COMPONENTS" ("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS" ("ROOT_UUID"); -CREATE UNIQUE INDEX "PROJECTS_UUID" ON "COMPONENTS" ("UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS" ("PROJECT_UUID"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS" ("MODULE_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS" ("QUALIFIER"); - -CREATE TABLE PROJECTS ( - UUID VARCHAR(40) PRIMARY KEY, - KEE VARCHAR(400) NOT NULL, - "QUALIFIER" VARCHAR(10) NOT NULL, - ORGANIZATION_UUID VARCHAR(40) NOT NULL, - NAME VARCHAR(2000), - DESCRIPTION VARCHAR(2000), - PRIVATE BOOLEAN NOT NULL, - TAGS VARCHAR(500), - CREATED_AT BIGINT NOT NULL, - UPDATED_AT BIGINT NOT NULL -); - -CREATE UNIQUE INDEX PK_PROJECTS ON PROJECTS(UUID); -CREATE UNIQUE INDEX UNIQ_PROJECTS ON PROJECTS(KEE); -CREATE INDEX IDX_QUALIFIER ON PROJECTS("QUALIFIER"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql deleted file mode 100644 index 8ce5b03c09304452ac166d112369d8e72895582d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql +++ /dev/null @@ -1,11 +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") -); -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/v82/RenameProjectsTableToComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponentsTest/schema.sql deleted file mode 100644 index 310c9497f30534291af61f719ba98e824d9419c8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponentsTest/schema.sql +++ /dev/null @@ -1,48 +0,0 @@ -CREATE TABLE "PROJECTS" ( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,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) -); -ALTER TABLE "PROJECTS" ADD CONSTRAINT "PK_PROJECTS" PRIMARY KEY("ID"); - -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/v83/AddSummaryEnabledColumnToAlmSettingsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/AddSummaryEnabledColumnToAlmSettingsTest/schema.sql deleted file mode 100644 index ead60d1b1e3de864dc9ba7dcb282e75d6a12d00c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/AddSummaryEnabledColumnToAlmSettingsTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROJECT_ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_SETTING_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "ALM_REPO" VARCHAR(256), - "ALM_SLUG" VARCHAR(256), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROJECT_ALM_SETTINGS" ADD CONSTRAINT "PK_PROJECT_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_ALM_SETTINGS" ON "PROJECT_ALM_SETTINGS"("PROJECT_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_ALM" ON "PROJECT_ALM_SETTINGS"("ALM_SETTING_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_SLUG" ON "PROJECT_ALM_SETTINGS"("ALM_SLUG"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest/schema.sql deleted file mode 100644 index 58865e22e82342629cda0485bc9f85691ed2329e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest/schema.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "COMPONENTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(50) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -ALTER TABLE "COMPONENTS" ADD CONSTRAINT "PK_PROJECTS" PRIMARY KEY("ID"); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest/schema.sql deleted file mode 100644 index 320a964ba06d679920f463dfb969e2d2f651c665..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest/schema.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_ID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(200) NOT NULL, - "URL" VARCHAR(2000), - "APP_ID" VARCHAR(80), - "PRIVATE_KEY" VARCHAR(2000), - "PAT" VARCHAR(2000), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ALM_SETTINGS" ADD CONSTRAINT "PK_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_ALM_SETTINGS" ON "ALM_SETTINGS"("KEE"); - -CREATE TABLE "PROJECT_ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_SETTING_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "ALM_REPO" VARCHAR(256), - "ALM_SLUG" VARCHAR(256), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "SUMMARY_COMMENT_ENABLED" BOOLEAN -); -ALTER TABLE "PROJECT_ALM_SETTINGS" ADD CONSTRAINT "PK_PROJECT_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_ALM_SETTINGS" ON "PROJECT_ALM_SETTINGS"("PROJECT_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_ALM" ON "PROJECT_ALM_SETTINGS"("ALM_SETTING_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_SLUG" ON "PROJECT_ALM_SETTINGS"("ALM_SLUG"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRolesTest/schema.sql deleted file mode 100644 index 9373e3f73fc9812eab31914236e546a5da5d74c0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddComponentUuidColumnToGroupRolesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES"("RESOURCE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTableTest/schema.sql deleted file mode 100644 index 36a3d90337c7936a5b399e3ec9cd7c8313f3dd22..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropResourceIdFromGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES"("RESOURCE_ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRolesTest/schema.sql deleted file mode 100644 index 04d3cb4b33bb17d41166f5c1b84473c263ec81a8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/MigrateResourceIdToUuidInGroupRolesTest/schema.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "RESOURCE_ID", "ROLE"); -CREATE UNIQUE INDEX "GROUP_ROLES_UNIQ" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES"("RESOURCE_ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); - -CREATE TABLE "COMPONENTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(50) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -ALTER TABLE "COMPONENTS" ADD CONSTRAINT "PK_PROJECTS" PRIMARY KEY("ID"); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToPropertiesTest/schema.sql deleted file mode 100644 index 2ac16011ffbb0cdef70f51307977bf5249aaa3f2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddComponentUuidColumnToPropertiesTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTableTest/schema.sql deleted file mode 100644 index 529e0a0e1b2db1d05b0d8539ea0f33013fa42bad..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropResourceIdFromPropertiesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "COMPONENT_UUID" VARCHAR(50), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInPropertiesTest/schema.sql deleted file mode 100644 index aff8977ca26c5f69a74745c05c6ca677cf7dbfd4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MigrateResourceIdToUuidInPropertiesTest/schema.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "COMPONENT_UUID" VARCHAR(50), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); - -CREATE TABLE "COMPONENTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(50) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -ALTER TABLE "COMPONENTS" ADD CONSTRAINT "PK_PROJECTS" PRIMARY KEY("ID"); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRolesTest/schema.sql deleted file mode 100644 index b4879f33cab5e6a40483729e08098276f1d55609..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddComponentUuidColumnToUserRolesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -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/v83/userroles/DropResourceIdFromUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropResourceIdFromUserRolesTableTest/schema.sql deleted file mode 100644 index 62e4238b217e69a98c4743f39d4f83a7eebcc9be..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropResourceIdFromUserRolesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES"("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRolesTest/schema.sql deleted file mode 100644 index fb91fd36c54efb9eaa34f246d9e6c827fdff1684..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/MigrateResourceIdToUuidInUserRolesTest/schema.sql +++ /dev/null @@ -1,57 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES"("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); - -CREATE TABLE "COMPONENTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(50) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -ALTER TABLE "COMPONENTS" ADD CONSTRAINT "PK_PROJECTS" PRIMARY KEY("ID"); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSyncTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSyncTest/schema.sql deleted file mode 100644 index 04995e9560f1a6eebbad7fd26589f9d620a54880..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/AddProjectBranchesNeedIssueSyncTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "PROJECT_BRANCHES"( - "UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "KEY_TYPE" VARCHAR(12) NOT NULL, - "PULL_REQUEST_BINARY" BLOB, - "MANUAL_BASELINE_ANALYSIS_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXCLUDE_FROM_PURGE" BOOLEAN DEFAULT FALSE NOT NULL -); -ALTER TABLE "PROJECT_BRANCHES" ADD 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/v84/MakeProjectBranchesNeedIssueSyncNonNullTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/MakeProjectBranchesNeedIssueSyncNonNullTest/schema.sql deleted file mode 100644 index de231f6b163e292c4149991f39c0337a0552e42d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/MakeProjectBranchesNeedIssueSyncNonNullTest/schema.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, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "KEY_TYPE" VARCHAR(12) NOT NULL, - "PULL_REQUEST_BINARY" BLOB, - "MANUAL_BASELINE_ANALYSIS_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXCLUDE_FROM_PURGE" BOOLEAN DEFAULT FALSE NOT NULL, - "NEED_ISSUE_SYNC" BOOLEAN -); -ALTER TABLE "PROJECT_BRANCHES" ADD 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/v84/PopulateProjectBranchesNeedIssueSyncTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/PopulateProjectBranchesNeedIssueSyncTest/schema.sql deleted file mode 100644 index de231f6b163e292c4149991f39c0337a0552e42d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/PopulateProjectBranchesNeedIssueSyncTest/schema.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, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "KEY_TYPE" VARCHAR(12) NOT NULL, - "PULL_REQUEST_BINARY" BLOB, - "MANUAL_BASELINE_ANALYSIS_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXCLUDE_FROM_PURGE" BOOLEAN DEFAULT FALSE NOT NULL, - "NEED_ISSUE_SYNC" BOOLEAN -); -ALTER TABLE "PROJECT_BRANCHES" ADD 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/v84/RemoveFilesFavouritesFromPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest/schema.sql deleted file mode 100644 index d3f75a5915cefec93d2a6911397cd7b12ef673de..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest/schema.sql +++ /dev/null @@ -1,55 +0,0 @@ -CREATE TABLE "COMPONENTS"( - "UUID" VARCHAR(50) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); - -CREATE TABLE "PROPERTIES"( - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "USER_UUID" VARCHAR(40), - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index 814cb67b796b04e77e0707644f611f519b9cccba..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); - -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql deleted file mode 100644 index 8366c74f29d35b21246e58a7e36cf3ec53b6dc0a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index c95e98df88d4c62507106f19f267b58912757a3b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index 88efe9d1252923eda824eda79b7091493ebc0477..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index e3fb5b749c3b27a409fe545814e4cd1c8503a41d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql deleted file mode 100644 index e3fb5b749c3b27a409fe545814e4cd1c8503a41d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql deleted file mode 100644 index 04d58e9edf0e1a22df5c65d155b8b90af5de2591..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index b074136418d27fd5a81c4023cd0f3b7fc5c96146..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 58802cb272e8acdc7fe31d08671ec81bf8f81aed..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql deleted file mode 100644 index f7f18747670d88c7f4c4d5c380b041e3345c4e19..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index 24d5888764cbc3a7ea37a17daee39339373b0285..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "ARP_ACTIVE_RULE_UUID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index faf2cd098e97ed13f959f149b1499545d5ca1529..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index fe510a7faaf5f78cff0b016568b939385d089be0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 642bd8470a6588b65a6fd42b76e6d1bad48e1e73..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql deleted file mode 100644 index 0f789b84e93066f4f4f1195c9b6550f93e4b85ac..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40), - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 49569a9667ab1ea29202bba13f2cedad7f0da89e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql deleted file mode 100644 index 5d00ec845ca3e8fc0a771db0f4c7ac6119409af3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40), - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); - -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest/schema.sql deleted file mode 100644 index 49569a9667ab1ea29202bba13f2cedad7f0da89e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumnsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumnsTest/schema.sql deleted file mode 100644 index 645a8ff17ae0a54931bf6b297abb72a5fbeb0c16..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/alm/AddClientIdAndClientSecretColumnsTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_ID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(200) NOT NULL, - "URL" VARCHAR(2000), - "APP_ID" VARCHAR(80), - "PRIVATE_KEY" VARCHAR(2000), - "PAT" VARCHAR(2000), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ALM_SETTINGS" ADD CONSTRAINT "PK_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_ALM_SETTINGS" ON "ALM_SETTINGS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql deleted file mode 100644 index 22ed140880ebd4c8fc67583b8756d6c9395e23f1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE "CE_ACTIVITY"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15) NOT NULL, - "MAIN_IS_LAST" BOOLEAN NOT NULL, - "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255), - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT, - "EXECUTED_AT" BIGINT, - "EXECUTION_COUNT" INTEGER NOT NULL, - "EXECUTION_TIME_MS" BIGINT, - "ANALYSIS_UUID" VARCHAR(50), - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647), - "ERROR_TYPE" VARCHAR(20), - "WORKER_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql deleted file mode 100644 index 9aa76b650fd112027fffae84d3c5f3eddb0d5563..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "CE_ACTIVITY"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15) NOT NULL, - "MAIN_IS_LAST" BOOLEAN NOT NULL, - "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255), - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT, - "EXECUTED_AT" BIGINT, - "EXECUTION_COUNT" INTEGER NOT NULL, - "EXECUTION_TIME_MS" BIGINT, - "ANALYSIS_UUID" VARCHAR(50), - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647), - "ERROR_TYPE" VARCHAR(20), - "WORKER_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql deleted file mode 100644 index d8fec2db8040f80d2a33d3a7e9feeb739a4105eb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "CE_ACTIVITY"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15) NOT NULL, - "MAIN_IS_LAST" BOOLEAN NOT NULL, - "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255), - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT, - "EXECUTED_AT" BIGINT, - "EXECUTION_COUNT" INTEGER NOT NULL, - "EXECUTION_TIME_MS" BIGINT, - "ANALYSIS_UUID" VARCHAR(50), - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647), - "ERROR_TYPE" VARCHAR(20), - "WORKER_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("ID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql deleted file mode 100644 index bf5f23f3e2872267ef77e7228d4fdf3c26f3b289..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "CE_QUEUE"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15), - "SUBMITTER_UUID" VARCHAR(255), - "STARTED_AT" BIGINT, - "WORKER_UUID" VARCHAR(40), - "EXECUTION_COUNT" INTEGER NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql deleted file mode 100644 index 48cfeb2001bf993ceb879f546def2db4a201ed4e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "CE_QUEUE"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15), - "SUBMITTER_UUID" VARCHAR(255), - "STARTED_AT" BIGINT, - "WORKER_UUID" VARCHAR(40), - "EXECUTION_COUNT" INTEGER NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("UUID"); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql deleted file mode 100644 index ca173102b08fb62e8723301e46b03ab7e0edd108..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "CE_QUEUE"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15), - "SUBMITTER_UUID" VARCHAR(255), - "STARTED_AT" BIGINT, - "WORKER_UUID" VARCHAR(40), - "EXECUTION_COUNT" INTEGER NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("ID"); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql deleted file mode 100644 index 8ab0a1195b353206adf3595e21795293b8a95057..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "CE_QUEUE"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15), - "SUBMITTER_UUID" VARCHAR(255), - "STARTED_AT" BIGINT, - "WORKER_UUID" VARCHAR(40), - "EXECUTION_COUNT" INTEGER NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("ID"); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql deleted file mode 100644 index de4522b3c84525e74016475753e675a5a3ce1b1c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql deleted file mode 100644 index f000152187828ae2b78346377863e69b6db3ea40..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql deleted file mode 100644 index 1399658a241fee9edb8addba30ae8ee9dfb8c78e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("UUID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql deleted file mode 100644 index e8f7a1414bed6ecda433e8c96159d4b5604818d2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 6432378da7b89ebc6b98cbb26a2617b46e0b486a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql deleted file mode 100644 index 6432378da7b89ebc6b98cbb26a2617b46e0b486a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql deleted file mode 100644 index bd6b897194cf05e3389e4f0ce6ee9e74e7dac819..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "EVENTS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "NAME" VARCHAR(400), - "CATEGORY" VARCHAR(50), - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest/schema.sql deleted file mode 100644 index ac79cfaaf79c735c6042fe8640b91e9897d3ea29..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "EVENTS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "NAME" VARCHAR(400), - "CATEGORY" VARCHAR(50), - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql deleted file mode 100644 index 2f03d9d6661920ecc8b0cca7379b35c10f0f9414..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "EVENTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "NAME" VARCHAR(400), - "CATEGORY" VARCHAR(50), - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql deleted file mode 100644 index dfb2d817bc75f0a4b5ff2f75b3c1fbe83640cc0d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql deleted file mode 100644 index 179847ee2ce6e5a3f969aa9f45f7914cd1df1bb0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql deleted file mode 100644 index 3dab0132b338e5871b25bf330e6e532db7c0b23f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql deleted file mode 100644 index a6a2a841f83679d927745f55be57c7ed476c036c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 559418594f81a0766a60e02d38521497cbb7073b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest/schema.sql deleted file mode 100644 index 559418594f81a0766a60e02d38521497cbb7073b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql deleted file mode 100644 index 3203c1421d17bd0bdb7b799a09d0caa58ac1052e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); - -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql deleted file mode 100644 index b91324d4572a39ef7efa6a4a40c8aef3a18554c2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql deleted file mode 100644 index 7ecca2b6b7167982551fc9c56e058e4ff5cf8981..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql deleted file mode 100644 index d7d1320aebe2d0eaf2301a7facc97b57a80d1040..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 7c73be272fdd4977093146ce2f63836cf2f52b31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest/schema.sql deleted file mode 100644 index 7c73be272fdd4977093146ce2f63836cf2f52b31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql deleted file mode 100644 index 8b2000be3e9b0a0f08e89e437a594013ec8fdb28..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest/schema.sql deleted file mode 100644 index a20ddd6ac663af9b4c36e50b03525894ee25847f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest/schema.sql deleted file mode 100644 index 963af911d8a66904ca769a3d925030b249666adf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql deleted file mode 100644 index 3b127b99e7a4f886a39e900104f24f0743319d41..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 5c6c10fce76257f69375c415746e46cf9e2c8624..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest/schema.sql deleted file mode 100644 index 5c6c10fce76257f69375c415746e46cf9e2c8624..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql deleted file mode 100644 index 3395ab556f26e60f1f7eb14ad96ef3d46efaa910..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql deleted file mode 100644 index f1f49219014e3b95f18ba164c52692557333e702..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql deleted file mode 100644 index 2e809ae1a2ef4e30ad9c7c3bcb9d35916f46b361..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_UUID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql deleted file mode 100644 index a17d5208a4359a46c95579c5bb5425760ccfa17c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql deleted file mode 100644 index dbed7d09f4fe497766a19d86e4fce5698756c372..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40), - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql deleted file mode 100644 index 0d7bb6e917ae595f1ce3a3bedfa31e37636f925e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 4f926b037ada8a584e270095427bd342ecdeaf0a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 6f1ef46cb307e29a0bcd47bc4006758d678e5252..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 214ddd1af92e9fa76042b034ad3d2cc2a1301ad7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql deleted file mode 100644 index 4614b88b6f94b99ee995bb90d5c5bd98da1e8200..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40), - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql deleted file mode 100644 index f3c7d7266a85165ddea824123fdd2ae1ca502466..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40), - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql deleted file mode 100644 index 169cf356975473957b2f637edb063edd555f2393..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql deleted file mode 100644 index 65e6acd566106273279c81aaeca27ac9bcaa016e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_GROUP_UUID" VARCHAR(40), - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql deleted file mode 100644 index 6ecb376b33b7b058abab65706b4af4440aa62246..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_GROUP_UUID" VARCHAR(40), - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql deleted file mode 100644 index f8f880ba7d66a9e29f38dcfc23ec373ad1b62b7e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index fa92bad8669c81736c433fe11d8e53f8994d995d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql deleted file mode 100644 index d7f1b662726b816be4f291d64e020e224f2fd7cb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql deleted file mode 100644 index b375127ef243e518af3fa0d68ea247f59fc891af..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql deleted file mode 100644 index d7d22ae97b60e4f70b380323b2e31500eeacea96..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql deleted file mode 100644 index 3a866c066aba4c50726320f82e29307516469d05..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_UUID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql deleted file mode 100644 index e4deaa55ba01dae861e70a333a8a4b793dcd6a01..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql deleted file mode 100644 index f30b909de2e0da058a7b7968c285238d9ddf43cb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40), - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql deleted file mode 100644 index 05b4a34f27943422595dead0d11437a6a73f849f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40), - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTableTest/schema.sql deleted file mode 100644 index 93de1f11d37f4dc1fb1287cdde0484de7f9e4009..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnIssueKeyOfIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTableTest/schema.sql deleted file mode 100644 index 93de1f11d37f4dc1fb1287cdde0484de7f9e4009..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddIndexOnKeeOfIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql deleted file mode 100644 index 1d8a73f53d7a379ed9850572711c4fd16540bc61..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTableTest/schema.sql deleted file mode 100644 index 7854927f3049aed55796d54614f8d641d9b513b1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/CopyIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,52 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); - -CREATE TABLE "ISSUES"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_UUID" VARCHAR(40), - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); -CREATE INDEX "ISSUES_RULE_UUID" ON "ISSUES"("RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTableTest/schema.sql deleted file mode 100644 index a188f8096fac1c3b1b191c664f817e5b7bd1df4f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); - -CREATE TABLE "ISSUE_CHANGES_COPY"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChangesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChangesTest/schema.sql deleted file mode 100644 index 051df21ef507d0e546fe8a8761951bb2ba986232..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/RenameIssueChangesCopyToIssueChangesTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES_COPY"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql deleted file mode 100644 index c195339d1d74093884d5d4f9d9d83bd0689be035..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL, - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql deleted file mode 100644 index d1048130fddb74b67c768a27494b3180c058f261..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest/schema.sql deleted file mode 100644 index 91889223c630605acb67c77b4e70c8710272876c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql deleted file mode 100644 index d1048130fddb74b67c768a27494b3180c058f261..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql deleted file mode 100644 index dae762bdba3b3d8782684f4fe5c14e4f3cb05eca..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index c9ff15f330d7e7981423692778e74eb66aa00f37..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql deleted file mode 100644 index c9ff15f330d7e7981423692778e74eb66aa00f37..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql deleted file mode 100644 index 51a7ed18a255d0f05199ac5bd7fcd9f1d5c7af1e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest/schema.sql deleted file mode 100644 index 8ca314830d261e949c08703100555043999d7964..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest/schema.sql deleted file mode 100644 index cc5c53aec36b8f1afca4f709f95efd9117990898..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql deleted file mode 100644 index a5940e9702ebbf0fb902c310fe48c83f116b62f2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 5e215f6a7a96f34a14087b51002d93613be31bf7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest/schema.sql deleted file mode 100644 index 5e215f6a7a96f34a14087b51002d93613be31bf7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql deleted file mode 100644 index 4f1c3afd5d6607d5f311176fc44bd4e314b65fdc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTableTest/schema.sql deleted file mode 100644 index 4f1c3afd5d6607d5f311176fc44bd4e314b65fdc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnProjectUuidOfLiveMeasuresTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTableTest/schema.sql deleted file mode 100644 index e969dd3add3c02ac79b3a383eb4908480271ec18..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/CopyLiveMeasuresTableTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); -CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTableTest/schema.sql deleted file mode 100644 index 979f28bb677356f72d6e9307c35af4a47f399211..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropLiveMeasuresTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); -CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); - -CREATE TABLE "LIVE_MEASURES_COPY"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasuresTest/schema.sql deleted file mode 100644 index 6688560c8be013dfa53c1a992c09782c9f5061d7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/RenameLiveMeasuresCopyToLiveMeasuresTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "LIVE_MEASURES_COPY"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql deleted file mode 100644 index 37a120d6215afd5e97939313465d750b3fe40613..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql deleted file mode 100644 index 3bb1010e374a931dc36a9c453bdb525d4cf5d3fc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql deleted file mode 100644 index fe619cf50f2fb727952344a83d1b881dbf58ddbd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql deleted file mode 100644 index fe619cf50f2fb727952344a83d1b881dbf58ddbd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index bcd93c5d249204fe9a89353a38a37893d0b0ba5d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidAndAnalysisUuidOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index bcd93c5d249204fe9a89353a38a37893d0b0ba5d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql deleted file mode 100644 index 847518066d56dc5725a91e2e91d0c9fca2cca07c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasuresTest/schema.sql deleted file mode 100644 index 8200c0c931eb6965c155dcdc7873b8bcc26ab31a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DeleteSecurityReviewRatingProjectMeasuresTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); - -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index 90d0eb46d3eba4142cc954165b2c6e4a0cf16a82..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index 55356e783002b88bd32216e7a91c6d77284627a9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_UUID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql deleted file mode 100644 index d78a04c7c95786d6c285e3c94fbec1c8bd098775..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql deleted file mode 100644 index ae7f3c32c33ef0d0376dd135c8f1295f8bfe0d00..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql deleted file mode 100644 index dff1d72e57381e169b30251d408f77f0d4f72e8e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index aa2aaf715630e507f60252c830475a428c1d04a2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql deleted file mode 100644 index 2b5a222cb91c848231e1611a95902bc61689c877..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql deleted file mode 100644 index 2b5a222cb91c848231e1611a95902bc61689c877..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql deleted file mode 100644 index 530b33a086307142d03ccadc9fd31fa3db131241..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL, - "DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql deleted file mode 100644 index bde193df88513a5361d69b7debda231554667559..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "DATA" BLOB -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest/schema.sql deleted file mode 100644 index b007218aa8935786f3b9f3f9c2bcd6f85eb25963..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL, - "DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql deleted file mode 100644 index 082c809f6e021a73d37ce3e62f56068ec454c17e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DATA" BLOB -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql deleted file mode 100644 index 3e3bae5d79d8aa16488458b950cb5a689526e588..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "CREATED_AT" BIGINT, - "DATA" BLOB -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql deleted file mode 100644 index ca8451dbfd5b54b37170443df75a05aeaefc245d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "CREATED_AT" BIGINT NULL, - "DATA" BLOB -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql deleted file mode 100644 index 52bb4a2e2c571b5604aae95b538e046547cdb8c3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql deleted file mode 100644 index 0a21fe126d2c05d011381b022d20f2891db8d2aa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql deleted file mode 100644 index abff11e7672100436722edabd6cf708c5b0278ac..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql deleted file mode 100644 index 10c79779e6ddbaa481d5fa9a6b2ed63513839cad..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql deleted file mode 100644 index ed17fd38257691b5543b7a572149e3edfd5e1185..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index a9667137aeccff52aef70b718e315f158c2c5fde..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql deleted file mode 100644 index a9667137aeccff52aef70b718e315f158c2c5fde..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql deleted file mode 100644 index 8fc600ae7dd617a8e171385ce2008e275ff03b80..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index 9be99ebafe8a342f9cccc614ed0a1a6c222669b9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index a3174f7b9474434d5a50fa14d35269c216ffb3e6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql deleted file mode 100644 index 5f566add81021872dc9546f8a6883ff3d6dd508f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); - -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql deleted file mode 100644 index e9a334d00302238de63ab24087e8b14539f76b8d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index af182cb58abfe0083984b0b1f8b103afb8aef4cd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index d175d8aa1aad824b2ecacc4667ec9d54ed92be7d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql deleted file mode 100644 index 055479cfb13cd1be8ce5059cbfb60b65c94f8d2c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); - -CREATE TABLE "PERM_TEMPLATES_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql deleted file mode 100644 index bd692486b2a93c18157b8a63a2c4c1362f070645..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 648fb65271a1b9e5a77276ee9c9e354019b5ee24..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index f61883e301911472acb79f71a9ef03eb41418bef..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_UUID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 47559a2cab0e8fd00888f073bcfc7f115b559abe..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" INTEGER NOT NULL, - "TEMPLATE_ID" VARCHAR(40) NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 5e36ef16eff99ede90b3c307ea84e1d87e56a01c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40), - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql deleted file mode 100644 index 2443d0d12c8babce9c2b4b40d6122fb8c7ef20dd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); - -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40), - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index f3319b5bc6f33efa24dc7b1a7bd31af351feaf20..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index fa6baad81b0f3273aa451932d6fda5a967097c3c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index 395419e580366973f3b498921b70372133b72b95..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index dcef0db3e5e0f005333be19970fdf96ac9ef2706..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index a1d048485270371af549f86972e8a4fca7c16b42..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql deleted file mode 100644 index a1d048485270371af549f86972e8a4fca7c16b42..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index d51c8ba224593412dfa255cf6601a043e00fe20e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index 285b963b8cd5b45e7615692e01fa8bfcb5ca7d2d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index f2974f7681330f5dc22f341a84852badfdfb3ff5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index dc2d8b31e74c3c705e09c8683df5c0130898d2af..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 23c2c4f21e6884f2aff1f112242b087d8c9a6afb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql deleted file mode 100644 index 23c2c4f21e6884f2aff1f112242b087d8c9a6afb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index e8784cadf0c13d5805c82caa5cf5cd4401d73e2d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 174c2e880c93c7e1a99f5eed7384f9fd57577f05..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 8fad4d5a96c3f677dfe3a83f3ca05ad71963067a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 3cf4c91cf6198e6861c39952b184db8359600a50..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index ea986ff54d82bf6a10d25acf3a32ca8ebdef0d2e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql deleted file mode 100644 index ea986ff54d82bf6a10d25acf3a32ca8ebdef0d2e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql deleted file mode 100644 index 81664d485b287c5e7a32320199e1351da3705aa2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index ba02385e040cc46c46d89683191b6f798108ecb8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddTechIndexOnUuidOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql deleted file mode 100644 index 3ff9ce0fef998ce443844fc1040f91d4219b3530..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index f66002cb755ec633312139793492af545eb5d2ef..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index fd01be5f1bd62d7b056a70533a375a4e5095e077..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index 09beb37f52ef8f23711dd72fa7079e7280be4dbe..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropTechIndexOnUuidOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); -CREATE INDEX "TECH_INDEX_UUID" ON "PROJECT_MEASURES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index ba02385e040cc46c46d89683191b6f798108ecb8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql deleted file mode 100644 index ba02385e040cc46c46d89683191b6f798108ecb8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql deleted file mode 100644 index b294830aee930e458048f0e59c2c4c6a8a82d8a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql deleted file mode 100644 index c7530b1d2543c7159e81d2db026dc1cc6c124a31..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql deleted file mode 100644 index d531ef1fa69b1d95f58deecf84ca89c4ab792773..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql deleted file mode 100644 index 75824e05246a06e59f7732ad1d62fecf768c80b0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index f961bdc422caa492efc3d5e8bd36b0be246c6f76..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql deleted file mode 100644 index f961bdc422caa492efc3d5e8bd36b0be246c6f76..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql deleted file mode 100644 index e2598421ec20409667ad285416ffa957dcecca81..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest/schema.sql deleted file mode 100644 index 2ac16011ffbb0cdef70f51307977bf5249aaa3f2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest/schema.sql deleted file mode 100644 index 363c084bb6fc539d8576bce2f61064bd314b4dd8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql deleted file mode 100644 index 87e741f36e3426ad00694243cd652445707f5044..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 8b61cd129070daa25bb2dfc653a50507e5a726da..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable/schema.sql deleted file mode 100644 index 9b6848f3a3c1fe63c10f0adc0ebe068896e7f2b3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER, - "UUID" VARCHAR(40), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql deleted file mode 100644 index 8b61cd129070daa25bb2dfc653a50507e5a726da..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index eb63669fd7e2f8fae1d67f2cbc7a8c90fce1ddda..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index a347b023e6630ec61ca1c9572893ff1c59ba5b19..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index 68093696c1efe288380efb14b95673d714dd3d86..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index 751e993b7eeb813ca236f4ec5eb35a322b3d102d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index dd697725c44cf7ade53288b5a4c2b137192413fe..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql deleted file mode 100644 index 2f6bb7f50c10b72d41b501abc4d2e377d9ef9ae6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql deleted file mode 100644 index 11efefb99361e6fe93cf4aa635b6e85ecfebe413..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql deleted file mode 100644 index 00b6663de816a918d82fe3ed30d9c0cc9f31d929..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest/schema.sql deleted file mode 100644 index dfcae5380ea5dd788836ce89e1f3d3ccf3f163ca..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest/schema.sql deleted file mode 100644 index 497d17eddf563727d6ae40a87da2948a62f77b06..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "QGATE_ID" INTEGER, - "QGATE_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql deleted file mode 100644 index 5093408fcdaf3cbfc83ed5cfbbcac1a9866cac20..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql deleted file mode 100644 index cd2a8e3f8533ac0b0ac75486db607069c7f0fd9b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "QGATE_ID" INTEGER, - "QGATE_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql deleted file mode 100644 index 11efefb99361e6fe93cf4aa635b6e85ecfebe413..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql deleted file mode 100644 index 5fc71ff5b95b9ad2726044656b745f091121333a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "QGATE_ID" INTEGER, - "QGATE_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql deleted file mode 100644 index 497d17eddf563727d6ae40a87da2948a62f77b06..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "QGATE_ID" INTEGER, - "QGATE_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql deleted file mode 100644 index df25471a0ba0b52377adae612d84f7767ba6db05..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql deleted file mode 100644 index 66e55fb1b3f61891a475e7d0b07e4fb70ed20b36..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest/schema.sql deleted file mode 100644 index 4045c3e578ad69b3333799d1a9bcdd4341c1e243..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql deleted file mode 100644 index 04dc8de79c8dd1d04d5906fefd939c753934f94f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql deleted file mode 100644 index ee19fb605eaddc4413ce6760997dd9373ebce322..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index e2d578ae00875516c5b85b064051f6a30d131e58..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40), - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest/schema.sql deleted file mode 100644 index ee19fb605eaddc4413ce6760997dd9373ebce322..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest/schema.sql deleted file mode 100644 index e2d578ae00875516c5b85b064051f6a30d131e58..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40), - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql deleted file mode 100644 index b3b1b4d7c043cd26a9e147b3b0bae375411c3094..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql deleted file mode 100644 index d05e47d8bc53f7482437908a83bc75cd6a6c21bb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 9156127c902a8b9a58244c33179841494168c034..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index d786db82af6ea13d5440924a4c08135e9b755012..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_UUIDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index ac68fc9c530e046587ab830e394582bcc6dbc698..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql deleted file mode 100644 index ac68fc9c530e046587ab830e394582bcc6dbc698..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql deleted file mode 100644 index 7d99e6c84e918b4ccbb4b7cb620675d3409d1649..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql deleted file mode 100644 index 5f7d81c739c25ebb8392db915a3df05a8911c35c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql deleted file mode 100644 index 9f9a6ff004a2a7e7353f677daaa813c6e4970d18..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql deleted file mode 100644 index 557f113a0c2e860fa01a49bed3122ed3f7a2437e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_UUID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index a33abf468055b4060388f199a7f94626147159a5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql deleted file mode 100644 index a33abf468055b4060388f199a7f94626147159a5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTableTest/schema.sql deleted file mode 100644 index 6b6f0a986840cff77f90bdea839caa6d8238ad48..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexesToIssuesTableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "ISSUES"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTableTest/schema.sql deleted file mode 100644 index cf65bc42c84fc7b129355756b7e09bbea3ccfe6e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/CopyIssuesTableTest/schema.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTableTest/schema.sql deleted file mode 100644 index a791fda4a80a29a1dcb5f193d0a403fe4ad53ca5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIssuesTableTest/schema.sql +++ /dev/null @@ -1,70 +0,0 @@ -CREATE TABLE "ISSUES_COPY"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN, - "RULE_UUID" VARCHAR(40) -); - -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssuesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssuesTest/schema.sql deleted file mode 100644 index 0c3fc02ca51c6cd3f4ddebd253e5cd7c6918ce1a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/RenameIssuesCopyToIssuesTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "ISSUES_COPY"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN, - "RULE_UUID" VARCHAR(40) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql deleted file mode 100644 index 7e46834a915907d82530a31e0983fb70470e4012..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql +++ /dev/null @@ -1,50 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql deleted file mode 100644 index 6dd1263edd198c49c6baf42892262e8c093017a0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql +++ /dev/null @@ -1,50 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql deleted file mode 100644 index 9f014613799af4d2517e1421cc2918c8717fbfd7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql +++ /dev/null @@ -1,51 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql deleted file mode 100644 index d7862acb77c38e8aef0df84eaa226abdc3529599..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql +++ /dev/null @@ -1,51 +0,0 @@ -create TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -alter table "RULES" add CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -create UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_UUID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 9e725d8243b6e204f936aa14120c53d011d79cee..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,51 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql deleted file mode 100644 index 9e725d8243b6e204f936aa14120c53d011d79cee..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,51 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql deleted file mode 100644 index 13198189e575cfbbbb51348e1700885b6ed6e0aa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql deleted file mode 100644 index 88e9e77a4e3606646af0f062d0ea28c14802491b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index 81bbe5119c2e2d5056037ba800948c7009acec0d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index eafb90192e1960b3d48f6003f811aaa2cad630a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -create TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -alter table "RULES" add CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -create UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -create TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) NOT NULL -); -alter table "RULES_PARAMETERS" add CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -create INDEX "RULES_PARAMETERS_RULE_UUID" ON "RULES_PARAMETERS"("RULE_UUID"); -create UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_UUID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 9fdc54dfb080a49518d908b3b254ddf0d65ad4f0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql deleted file mode 100644 index 9fdc54dfb080a49518d908b3b254ddf0d65ad4f0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index 961a5cb8cac84627fd63de186e47b0464025c03a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql deleted file mode 100644 index 98a62c638d99530a751b4b0398ba6a875c903ef0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index 60597fff32165d131533224ebb78064c772443b5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index efdec30874f0a49af9828fdbdb2dd2875e72f5ec..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 55efee589933cce61a4b192bb30d05d02df47f11..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest/schema.sql deleted file mode 100644 index 55efee589933cce61a4b192bb30d05d02df47f11..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql deleted file mode 100644 index 04d58e9edf0e1a22df5c65d155b8b90af5de2591..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index 3782982a16708699887e87f09996ce7d20487911..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_UUID" VARCHAR(40) NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index de06e416db2812cad7a144db8df43458de6f5d56..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_UUID" VARCHAR(40), - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql deleted file mode 100644 index 0bb696c346c71c481b08ffe05e3027f86b445763..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); - -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_UUID" VARCHAR(40), - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index 8f7a7f216aeec80594cb466608029a990a901bf2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql deleted file mode 100644 index de92d69aeb0c2a52580824b90cf9e7313d02f717..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index 0236b7e65547ae0d8810fb55ace5b5067d2d9f4b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index eeb2ebcbd94005dca7ec846c662e75e45f848e45..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index 20448a4d9fed16684c7e2bb04b80917a79637f6d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index eeb2ebcbd94005dca7ec846c662e75e45f848e45..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index fd1ad1ea6a239f66a19929e14aff8cdc66050487..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql deleted file mode 100644 index fd1ad1ea6a239f66a19929e14aff8cdc66050487..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql deleted file mode 100644 index d2e7c11c080dd5a7faa26962ba774c639b5b0be2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 2dedcc6b5e237a487e2451205f004c389d726acc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 2adacc4076d0076b1d1fde1b268145d68231e4f9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index d7d0db7aa7365ca5a39071561c6355d4200f333a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 161696a041fc9d136c12d3f4de065626f1bcc270..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); - -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql deleted file mode 100644 index 161696a041fc9d136c12d3f4de065626f1bcc270..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); - -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql deleted file mode 100644 index a1781cb90cc512d0334ab992877f5319ab7cf3f2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); - -CREATE TABLE "ORG_QPROFILES"( - "UUID" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "PARENT_UUID" VARCHAR(255), - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILES_ORG_UUID" ON "ORG_QPROFILES"("ORGANIZATION_UUID"); -CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID"); -CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql deleted file mode 100644 index 75148b62b2445f7d9d9bb007804124ca4b994f24..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); - -CREATE TABLE "QPROFILE_CHANGES"( - "KEE" VARCHAR(40) NOT NULL, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "USER_UUID" VARCHAR(255), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_CHANGES" ADD CONSTRAINT "PK_QPROFILE_CHANGES" PRIMARY KEY("KEE"); -CREATE INDEX "QP_CHANGES_RULES_PROFILE_UUID" ON "QPROFILE_CHANGES"("RULES_PROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql deleted file mode 100644 index dcc23f6b586ada323df636b952a97c5cfa95d862..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "SNAPSHOTS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, - "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, - "VERSION" VARCHAR(500), - "PURGE_STATUS" INTEGER, - "BUILD_STRING" VARCHAR(100), - "REVISION" VARCHAR(100), - "BUILD_DATE" BIGINT, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_DATE" BIGINT, - "PERIOD3_DATE" BIGINT, - "PERIOD4_DATE" BIGINT, - "PERIOD5_DATE" BIGINT, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql deleted file mode 100644 index c1891409f1189470d461dc62ea4a025fe8b71faa..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "SNAPSHOTS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, - "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, - "VERSION" VARCHAR(500), - "PURGE_STATUS" INTEGER, - "BUILD_STRING" VARCHAR(100), - "REVISION" VARCHAR(100), - "BUILD_DATE" BIGINT, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_DATE" BIGINT, - "PERIOD3_DATE" BIGINT, - "PERIOD4_DATE" BIGINT, - "PERIOD5_DATE" BIGINT, - "CREATED_AT" BIGINT -); -ALTER TABLE "SNAPSHOTS" ADD CONSTRAINT "PK_SNAPSHOTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql deleted file mode 100644 index 3d3e2694b15b79500c3c29d00723efbcf4e08cb6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "SNAPSHOTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, - "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, - "VERSION" VARCHAR(500), - "PURGE_STATUS" INTEGER, - "BUILD_STRING" VARCHAR(100), - "REVISION" VARCHAR(100), - "BUILD_DATE" BIGINT, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_DATE" BIGINT, - "PERIOD3_DATE" BIGINT, - "PERIOD4_DATE" BIGINT, - "PERIOD5_DATE" BIGINT, - "CREATED_AT" BIGINT -); -ALTER TABLE "SNAPSHOTS" ADD CONSTRAINT "PK_SNAPSHOTS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql deleted file mode 100644 index 782ae4e6684431a94d8a6fb5152bdebd240278e6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTableTest/schema.sql deleted file mode 100644 index b30da4d792851679c42f9d4ac4c36399bcb8623a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTableTest/schema.sql deleted file mode 100644 index 334d2d2b80f88f48f7abffb324f5eaa5e974f8f9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql deleted file mode 100644 index 1970f132a0037ff99b5a3f785991b85e25fef10e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 80f78b06ede7dcfbf47fdccafbd04eb3fbf958c9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuidTest/schema.sql deleted file mode 100644 index 80f78b06ede7dcfbf47fdccafbd04eb3fbf958c9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuidTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql deleted file mode 100644 index 3b7668e51e3601062244ee61cabb42c76ba95604..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest/schema.sql deleted file mode 100644 index c1eab3c95ac0fd1874540f173872c367c95b7d40..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql deleted file mode 100644 index 014607f5179b2bf1cdc15c00f4367b2ba386d3c7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql deleted file mode 100644 index 3b7668e51e3601062244ee61cabb42c76ba95604..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 87f8c34ea67d3f01c02e6c1160305127f919dfad..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 98085c9b74dc98c0645c8450519e44670765199c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql deleted file mode 100644 index a8f6820a912abbde0f1d394bedb297dab5e90a7f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index e0a585dd66eb4c957ba9d6b9eff15c4cb37d7d26..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index b71880d2f10d8e812be929724b268e740c43be00..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index b74eac2c9043a062459563c206ddbe84eb443dd7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 167965e4750964a492dfb8888739d1536f7701a3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql deleted file mode 100644 index 38059ac5a3a00a92fad338c2434995a864763c36..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - - -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql deleted file mode 100644 index 20cd233694137175549da772da3561f3df030bd2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql deleted file mode 100644 index 3fa77611bd627051e88f0d289127104e393ebd87..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -CREATE INDEX "ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql deleted file mode 100644 index 1a0f1aa45a5070a2bbe4c8fc623bfabd64cbc8b1..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql deleted file mode 100644 index 83a239431585eb3095e82f4b0bacd8fa573de1e7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql deleted file mode 100644 index e72612d2481710044d27d99a5af4a1f8c56aac10..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "ORG_MEMBERS_ON_USER_UUID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql deleted file mode 100644 index 6f3084dc7bab8cb8fed2821d7f4698e9a6b2710d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -CREATE INDEX "ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 5951c00d434419196d082b76a80bf156b8ab7f70..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40), -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql deleted file mode 100644 index 3dbd7d9a2150c4897e1fa903365e3cb47851948b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - - -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40), -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql deleted file mode 100644 index 10b095f9b4a4578b7d89a1b96471e0d8e4e67c71..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index fc2cdb8b5243229c2c6623972d487a9077b81067..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 752db98d4669808f310cbbfb6f7d7f655d112f12..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql deleted file mode 100644 index cd73faec4b429e58b3a030ba441491389273648a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "PERM_TEMPLATES_USERS"( - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql deleted file mode 100644 index e63f2fb66c80bcd054d6776804937c9c682623f5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql deleted file mode 100644 index a3d1fbfeeea45552242a1db2297884f516a7ac17..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); - - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql deleted file mode 100644 index 7b392af768c429188b49972ef60caec06d8a94b5..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "PROPERTIES"( - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql deleted file mode 100644 index 6111eb1f8e1e1b6ae624a3757d906e2d6722a7cb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql deleted file mode 100644 index 1149cf96ee74f40bc597aac51b44d07747ef3beb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql deleted file mode 100644 index 94fa29f1c1ab9ce24f4c6c8f92dc0db7177fc0f7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql deleted file mode 100644 index e1a14b02b7b36822c9f109be8510c1a00b862020..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_UUID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index d1a00b9e64b2c2e2a4ee4bf962a7db0f507e4169..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql deleted file mode 100644 index d10b8b5184c542d336aea2ea9022d29bbdbe6442..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql deleted file mode 100644 index fee4bf2e2c940f88221a1379fe9a60934e73552d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql deleted file mode 100644 index b1619df129c92f3238e874d44e9d091d491de176..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql deleted file mode 100644 index 6080af78618d62a2957ca0bacd50daa89ce3e943..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql deleted file mode 100644 index 6080af78618d62a2957ca0bacd50daa89ce3e943..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql deleted file mode 100644 index a1ad51f0b3861edafb3d4a53e66baf7013c787df..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql deleted file mode 100644 index ca5001f995a5b6488795cee09289e84bceeb5cb3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest/schema.sql deleted file mode 100644 index 485c3d4f80cdfc91175a04a9fc5b1471b2ac74b9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql deleted file mode 100644 index 894ee4b0fc476fbdfb2228108137b3cca382ae00..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql deleted file mode 100644 index 485c3d4f80cdfc91175a04a9fc5b1471b2ac74b9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql deleted file mode 100644 index df2072a73cb1df10b020ac3581a75f219b8b1e73..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest/schema.sql deleted file mode 100644 index b4869dc5a9c82ecd896b49722943096b44f87e15..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTableTest/schema.sql deleted file mode 100644 index aaed9cd5d0a69481ae56d1f632c7ee4882d8e9ed..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnIssueKeyForIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT, - "PROJECT_UUID" VARCHAR(50) -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTableTest/schema.sql deleted file mode 100644 index 46907cf96eb8b4e0c162aff07b20846683f0cd7e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnKeeForIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT, - "PROJECT_UUID" VARCHAR(50) -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("UUID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTableTest/schema.sql deleted file mode 100644 index 4200aab97470918408737dc4a26871f6668c1bdd..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnMessageTypeColumnOfCeTaskMessageTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -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, - "MESSAGE_TYPE" VARCHAR(255) NOT NULL -); -ALTER TABLE "CE_TASK_MESSAGE" ADD CONSTRAINT "PK_CE_TASK_MESSAGE" PRIMARY KEY("UUID"); -CREATE INDEX "CE_TASK_MESSAGE_TASK" ON "CE_TASK_MESSAGE"("TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTableTest/schema.sql deleted file mode 100644 index 7eb35b38156436ddd5e5292b5e5c96cdf9d8e51d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIndexOnProjectUuidOnIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT, - "PROJECT_UUID" VARCHAR(50) -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("UUID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIsDismissibleColumnToCeTaskMessageTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIsDismissibleColumnToCeTaskMessageTableTest/schema.sql deleted file mode 100644 index e3a716c9e4be37c9250adf6bf807a396975f3d9c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddIsDismissibleColumnToCeTaskMessageTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -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 -); -ALTER TABLE "CE_TASK_MESSAGE" ADD CONSTRAINT "PK_CE_TASK_MESSAGE" PRIMARY KEY("UUID"); -CREATE INDEX "CE_TASK_MESSAGE_TASK" ON "CE_TASK_MESSAGE"("TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTableTest/schema.sql deleted file mode 100644 index 67237e59da531dbadc6e2c5876aade6f99fa13f7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddMessageTypeColumnToCeTaskMessageTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -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"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTableTest/schema.sql deleted file mode 100644 index e712a9619abd222532bd59e4dab4ce6f2b31c7d0..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT, - "PROJECT_UUID" VARCHAR(50) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddTypeToPluginsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddTypeToPluginsTest/schema.sql deleted file mode 100644 index c2a001fefdd70b0ba99480339b97f6ec2078c198..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddTypeToPluginsTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -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 -); -ALTER TABLE "PLUGINS" ADD CONSTRAINT "PK_PLUGINS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "PLUGINS_KEY" ON "PLUGINS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullableTest/schema.sql deleted file mode 100644 index 3d438e8eaa8f55e77ce3566380b5110c7361c953..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AlterTypeInPluginNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PLUGINS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(200) NOT NULL, - "BASE_PLUGIN_KEY" VARCHAR(200), - "FILE_HASH" VARCHAR(200) NOT NULL, - "TYPE" VARCHAR(10), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PLUGINS" ADD CONSTRAINT "PK_PLUGINS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "PLUGINS_KEY" ON "PLUGINS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTableTest/schema.sql deleted file mode 100644 index 24310fbc986cdf08a80aee805e72ef4485e97ea4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/CreateTmpIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,53 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("UUID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); - -CREATE TABLE "ISSUES"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_UUID" VARCHAR(40), - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); -CREATE INDEX "ISSUES_RULE_UUID" ON "ISSUES"("RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphansTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphansTest/schema.sql deleted file mode 100644 index 9f63206c4c5a2901c96533c1a1bffe40e7688e50..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DeleteProjectAlmSettingsOrphansTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "PROJECTS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400) NOT NULL, - "QUALIFIER" VARCHAR(10) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROJECTS" ADD CONSTRAINT "PK_NEW_PROJECTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECTS_KEE" ON "PROJECTS"("KEE"); -CREATE INDEX "IDX_QUALIFIER" ON "PROJECTS"("QUALIFIER"); - -CREATE TABLE "PROJECT_ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_SETTING_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "ALM_REPO" VARCHAR(256), - "ALM_SLUG" VARCHAR(256), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "SUMMARY_COMMENT_ENABLED" BOOLEAN -); -ALTER TABLE "PROJECT_ALM_SETTINGS" ADD CONSTRAINT "PK_PROJECT_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_ALM_SETTINGS" ON "PROJECT_ALM_SETTINGS"("PROJECT_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_ALM" ON "PROJECT_ALM_SETTINGS"("ALM_SETTING_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_SLUG" ON "PROJECT_ALM_SETTINGS"("ALM_SLUG"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTableTest/schema.sql deleted file mode 100644 index f39bedb9f15b4374baaf34a614030fb62cbb31cb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); - -CREATE TABLE "TMP_ISSUE_CHANGES"( - "UUID" VARCHAR(40), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50), - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "PROJECT_UUID" VARCHAR(50), - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); - -CREATE TABLE "ISSUE_CHANGES_COPY"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromPropertiesTest/schema.sql deleted file mode 100644 index eb6cd7f9a5c0a400a2aa1a8cd834a05b7271cee8..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrphanFavoritesFromPropertiesTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "PROP_KEY" VARCHAR(512) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index 53249a51cc0d9875198ec4538d6545d817e1c585..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropPeriodAndValueWarningColumnsFromQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "QGATE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindingsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindingsTest/schema.sql deleted file mode 100644 index aac315b35acb65724bd89b26851fa083465ed8fb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropProjectAlmBindingsTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -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), - "URL" VARCHAR(2000) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROJECT_ALM_BINDINGS" ADD 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"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyTypeTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyTypeTest/schema.sql deleted file mode 100644 index 93927b5fb55c7e9af6f74c1021c60aea17ea9e18..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropProjectBranchesKeyTypeTest/schema.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, - "BRANCH_TYPE" VARCHAR(12) NOT NULL, - "MERGE_BRANCH_UUID" VARCHAR(50), - "KEY_TYPE" VARCHAR(12) NOT NULL, - "PULL_REQUEST_BINARY" BLOB, - "MANUAL_BASELINE_ANALYSIS_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXCLUDE_FROM_PURGE" BOOLEAN DEFAULT FALSE NOT NULL, - "NEED_ISSUE_SYNC" BOOLEAN NOT NULL -); -ALTER TABLE "PROJECT_BRANCHES" ADD 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/v85/DropUnusedIndexesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropUnusedIndexesTest/schema.sql deleted file mode 100644 index 2f3316e177f43d33f534f1e51cc2f9bd3818eb3b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropUnusedIndexesTest/schema.sql +++ /dev/null @@ -1,111 +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, - "IS_OWNER_USER" BOOLEAN NOT NULL, - "USER_EXTERNAL_ID" VARCHAR(255), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ALM_APP_INSTALLS" ADD 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 "USERS"( - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "FILE_SOURCES"( - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); - -CREATE TABLE "CE_ACTIVITY"( - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15) NOT NULL, - "MAIN_IS_LAST" BOOLEAN NOT NULL, - "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255), - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT, - "EXECUTED_AT" BIGINT, - "EXECUTION_COUNT" INTEGER NOT NULL, - "EXECUTION_TIME_MS" BIGINT, - "ANALYSIS_UUID" VARCHAR(50), - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647), - "ERROR_TYPE" VARCHAR(20), - "WORKER_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); - -CREATE TABLE "EVENTS"( - "UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "NAME" VARCHAR(400), - "CATEGORY" VARCHAR(50), - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshotsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshotsTest/schema.sql deleted file mode 100644 index 186c3b6bd6a28271f7ffc307817e8109445d3a93..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropUnusedPeriodsInSnapshotsTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "SNAPSHOTS"( - "UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, - "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, - "VERSION" VARCHAR(500), - "PURGE_STATUS" INTEGER, - "BUILD_STRING" VARCHAR(100), - "REVISION" VARCHAR(100), - "BUILD_DATE" BIGINT, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_DATE" BIGINT, - "PERIOD3_DATE" BIGINT, - "PERIOD4_DATE" BIGINT, - "PERIOD5_DATE" BIGINT, - "CREATED_AT" BIGINT -); -ALTER TABLE "SNAPSHOTS" ADD CONSTRAINT "PK_SNAPSHOTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasuresTest/schema.sql deleted file mode 100644 index 7f14e31a89f17e99e469a8dfb245e6ccc78a4c6c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropUnusedVariationsInProjectMeasuresTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchTypeTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchTypeTest/schema.sql deleted file mode 100644 index 094c3286a0534c986077636e0d1493223d36a329..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/FillProjectBranchesBranchTypeTest/schema.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, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "KEY_TYPE" VARCHAR(12) NOT NULL, - "PULL_REQUEST_BINARY" BLOB, - "MANUAL_BASELINE_ANALYSIS_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXCLUDE_FROM_PURGE" BOOLEAN DEFAULT FALSE NOT NULL, - "NEED_ISSUE_SYNC" BOOLEAN NOT NULL -); -ALTER TABLE "PROJECT_BRANCHES" ADD 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/v85/MakeIsDismissibleColumnNotNullableOnCeTaskMessageTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeIsDismissibleColumnNotNullableOnCeTaskMessageTableTest/schema.sql deleted file mode 100644 index 672cf3d9d73314f1b93e65b36cedd1f95c825779..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeIsDismissibleColumnNotNullableOnCeTaskMessageTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -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, - "IS_DISMISSIBLE" BOOLEAN NOT NULL -); -ALTER TABLE "CE_TASK_MESSAGE" ADD CONSTRAINT "PK_CE_TASK_MESSAGE" PRIMARY KEY("UUID"); -CREATE INDEX "CE_TASK_MESSAGE_TASK" ON "CE_TASK_MESSAGE"("TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTableTest/schema.sql deleted file mode 100644 index 79ecb88e3e84bbfe6526360b586460c4665dc63b..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeIssueKeyNotNullOnIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50), - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT, - "PROJECT_UUID" VARCHAR(50) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTableTest/schema.sql deleted file mode 100644 index c46fbbfd8c6d84186d51a71ee863f153f32b84b3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeMessageTypeColumnNotNullableOnCeTaskMessageTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -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, - "MESSAGE_TYPE" VARCHAR(255) -); -ALTER TABLE "CE_TASK_MESSAGE" ADD CONSTRAINT "PK_CE_TASK_MESSAGE" PRIMARY KEY("UUID"); -CREATE INDEX "CE_TASK_MESSAGE_TASK" ON "CE_TASK_MESSAGE"("TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullableTest/schema.sql deleted file mode 100644 index 094c3286a0534c986077636e0d1493223d36a329..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeProjectBranchesBranchTypeNotNullableTest/schema.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, - "BRANCH_TYPE" VARCHAR(12), - "MERGE_BRANCH_UUID" VARCHAR(50), - "KEY_TYPE" VARCHAR(12) NOT NULL, - "PULL_REQUEST_BINARY" BLOB, - "MANUAL_BASELINE_ANALYSIS_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "EXCLUDE_FROM_PURGE" BOOLEAN DEFAULT FALSE NOT NULL, - "NEED_ISSUE_SYNC" BOOLEAN NOT NULL -); -ALTER TABLE "PROJECT_BRANCHES" ADD 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/v85/MakeProjectUuidNotNullOnIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeProjectUuidNotNullOnIssueChangesTableTest/schema.sql deleted file mode 100644 index 917bb5a92fe86cac1406ec748dc6e629d3d0bf8d..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeProjectUuidNotNullOnIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT, - "PROJECT_UUID" VARCHAR(40) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTableTest/schema.sql deleted file mode 100644 index 66c414690f3c27ba37691760cc38b5f244667fe4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/MakeUuidNotNullOnIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "UUID" VARCHAR(40), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT, - "PROJECT_UUID" VARCHAR(50) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCountTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCountTest/schema.sql deleted file mode 100644 index 261f29921153ad2f825efa4b85e0b81548850821..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateFileSourceLineCountTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateIsDismissibleColumnOfCeTaskMessageTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateIsDismissibleColumnOfCeTaskMessageTableTest/schema.sql deleted file mode 100644 index d5fcd2b20cd12ce88f46cfc9b0baba9185a07a14..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateIsDismissibleColumnOfCeTaskMessageTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -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, - "IS_DISMISSIBLE" BOOLEAN NULL -); -ALTER TABLE "CE_TASK_MESSAGE" ADD CONSTRAINT "PK_CE_TASK_MESSAGE" PRIMARY KEY("UUID"); -CREATE INDEX "CE_TASK_MESSAGE_TASK" ON "CE_TASK_MESSAGE"("TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTableTest/schema.sql deleted file mode 100644 index c46fbbfd8c6d84186d51a71ee863f153f32b84b3..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateMessageTypeColumnOfCeTaskMessageTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -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, - "MESSAGE_TYPE" VARCHAR(255) -); -ALTER TABLE "CE_TASK_MESSAGE" ADD CONSTRAINT "PK_CE_TASK_MESSAGE" PRIMARY KEY("UUID"); -CREATE INDEX "CE_TASK_MESSAGE_TASK" ON "CE_TASK_MESSAGE"("TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateTypeInPluginsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateTypeInPluginsTest/schema.sql deleted file mode 100644 index 3d438e8eaa8f55e77ce3566380b5110c7361c953..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/PopulateTypeInPluginsTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PLUGINS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(200) NOT NULL, - "BASE_PLUGIN_KEY" VARCHAR(200), - "FILE_HASH" VARCHAR(200) NOT NULL, - "TYPE" VARCHAR(10), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PLUGINS" ADD CONSTRAINT "PK_PLUGINS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "PLUGINS_KEY" ON "PLUGINS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChangesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChangesTest/schema.sql deleted file mode 100644 index 105176773ed067ddeaf001813e84ec8e09326858..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/RenameTmpIssueChangesToIssueChangesTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "TMP_ISSUE_CHANGES"( - "UUID" VARCHAR(40), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50), - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT, - "PROJECT_UUID" VARCHAR(50) -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjsTest/schema.sql deleted file mode 100644 index 845d2fd0b181a5db671ae7ab0b0f6bc53fc1e1f9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationBranchProjsTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "APP_BRANCH_PROJECT_BRANCH"( - "UUID" VARCHAR(40) NOT NULL, - "APPLICATION_UUID" VARCHAR(40) NOT NULL, - "APPLICATION_BRANCH_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40) NOT NULL, - "PROJECT_BRANCH_UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "APP_BRANCH_PROJECT_BRANCH" ADD CONSTRAINT "PK_APP_BRANCH_PROJECT_BRANCH" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjectsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjectsTest/schema.sql deleted file mode 100644 index 7c2627968a66b03d1b61705f8cdbde5774013972..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddIndexToApplicationProjectsTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "APP_PROJECTS"( - "UUID" VARCHAR(40) NOT NULL, - "APPLICATION_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "APP_PROJECTS" ADD CONSTRAINT "PK_APP_PROJECTS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjsTest/schema.sql deleted file mode 100644 index 3270865158a79bc3a16a0b033dff49ab6f625a98..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjsTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "APP_BRANCH_PROJECT_BRANCH"( - "UUID" VARCHAR(40) NOT NULL, - "APPLICATION_UUID" VARCHAR(40) NOT NULL, - "APPLICATION_BRANCH_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40) NOT NULL, - "PROJECT_BRANCH_UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjectsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjectsTest/schema.sql deleted file mode 100644 index 3cb13c2066a9de7ce6a82a6b497cb58e15939393..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjectsTest/schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "APP_PROJECTS"( - "UUID" VARCHAR(40) NOT NULL, - "APPLICATION_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest/schema.sql deleted file mode 100644 index 6e5205d8d1f4a7b590def99cd4b354ba4a83457c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "DEFAULT_QPROFILES"( - "LANGUAGE" VARCHAR(20) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsersTest/schema.sql deleted file mode 100644 index 542deb026c85a3f1b064e5a840acb2f2597196a6..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddResetPasswordColumnToUsersTest/schema.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "USERS"( - "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_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest/schema.sql deleted file mode 100644 index e573be04b871377672275ad232dcb05167f8824e..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS"( - "NAME" VARCHAR(500) NOT NULL, - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest/schema.sql deleted file mode 100644 index 85b059b64a1560864593fd9e51c478d882898b1a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -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 -); -ALTER TABLE "DEFAULT_QPROFILES" ADD CONSTRAINT "PK_DEFAULT_QPROFILES" PRIMARY KEY("ORGANIZATION_UUID", "LANGUAGE"); -CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest/schema.sql deleted file mode 100644 index c72d6748129a2509eda4487d756ec6bca6328bca..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -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 -); -CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest/schema.sql deleted file mode 100644 index 5c036b57764d2ad59f651e8b528b9f315459d140..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest/schema.sql +++ /dev/null @@ -1,13 +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 -); -ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID"); -CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRolesTest/schema.sql deleted file mode 100644 index 0a63c1e9aec6f97728742022e0ee0761ebecccd2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupRolesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "GROUP_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_UUID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest/schema.sql deleted file mode 100644 index 3f76dd2c6109cbcc17e9cf94ede299fa13b257cf..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "GROUPS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplatesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplatesTest/schema.sql deleted file mode 100644 index c9a2ab5a05c5d7c60c45dfd5d72253a0a905d942..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInPermissionTemplatesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest/schema.sql deleted file mode 100644 index a7137424d38aca8449906f4e6bbcc58b12c169e9..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "RULES_METADATA"( - "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" CLOB, - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_UUID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRolesTest/schema.sql deleted file mode 100644 index 5acabc59b9e87055b233629efca82fa80043150a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUserRolesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest/schema.sql deleted file mode 100644 index b748aff7b53ffe55115d28a1a4fe12cc78dfa8b4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest/schema.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "USERS"( - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest/schema.sql deleted file mode 100644 index 9aa88c12962829e3087531175cae6f1ff6ff346f..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest/schema.sql +++ /dev/null @@ -1,15 +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 -); -ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILES_ORG_UUID" ON "ORG_QPROFILES"("ORGANIZATION_UUID"); -CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID"); -CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest/schema.sql deleted file mode 100644 index 2784c044c773a19d887ffd057c8b5a56fe9d9d67..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS"( - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNullTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNullTest/schema.sql deleted file mode 100644 index be6b1ef0e778d123bce63e63debdb1fcb7e41961..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeResetPasswordColumnNotNullTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "USERS"( - "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_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "RESET_PASSWORD" BOOLEAN, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDbTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDbTest/schema.sql deleted file mode 100644 index dc3010a47b549215313d7efdaaf4f01796c889a4..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MigrateApplicationDefinitionsFromXmlToDbTest/schema.sql +++ /dev/null @@ -1,66 +0,0 @@ -CREATE TABLE "PROJECTS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400) NOT NULL, - "QUALIFIER" VARCHAR(10) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROJECTS" ADD CONSTRAINT "PK_NEW_PROJECTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECTS_KEE" ON "PROJECTS"("KEE"); -CREATE INDEX "IDX_QUALIFIER" ON "PROJECTS"("QUALIFIER"); - -CREATE TABLE "PROJECT_BRANCHES"( - "UUID" VARCHAR(50) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "BRANCH_TYPE" VARCHAR(12) NOT NULL, - "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, - "EXCLUDE_FROM_PURGE" BOOLEAN DEFAULT FALSE NOT NULL, - "NEED_ISSUE_SYNC" BOOLEAN NOT NULL -); -ALTER TABLE "PROJECT_BRANCHES" ADD CONSTRAINT "PK_PROJECT_BRANCHES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_BRANCHES" ON "PROJECT_BRANCHES"("BRANCH_TYPE", "PROJECT_UUID", "KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES"( - "KEE" VARCHAR(20) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "INTERNAL_PROPERTIES" ADD CONSTRAINT "PK_INTERNAL_PROPERTIES" PRIMARY KEY("KEE"); - -CREATE TABLE "APP_BRANCH_PROJECT_BRANCH"( - "UUID" VARCHAR(40) NOT NULL, - "APPLICATION_UUID" VARCHAR(40) NOT NULL, - "APPLICATION_BRANCH_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40) NOT NULL, - "PROJECT_BRANCH_UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "APP_BRANCH_PROJECT_BRANCH" ADD CONSTRAINT "PK_APP_BRANCH_PROJECT_BRANCH" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_APP_BRANCH_PROJ" ON "APP_BRANCH_PROJECT_BRANCH"("APPLICATION_BRANCH_UUID", "PROJECT_BRANCH_UUID"); -CREATE INDEX "IDX_ABPB_APP_UUID" ON "APP_BRANCH_PROJECT_BRANCH"("APPLICATION_UUID"); -CREATE INDEX "IDX_ABPB_APP_BRANCH_UUID" ON "APP_BRANCH_PROJECT_BRANCH"("APPLICATION_BRANCH_UUID"); -CREATE INDEX "IDX_ABPB_PROJ_UUID" ON "APP_BRANCH_PROJECT_BRANCH"("PROJECT_UUID"); -CREATE INDEX "IDX_ABPB_PROJ_BRANCH_UUID" ON "APP_BRANCH_PROJECT_BRANCH"("PROJECT_BRANCH_UUID"); - -CREATE TABLE "APP_PROJECTS"( - "UUID" VARCHAR(40) NOT NULL, - "APPLICATION_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "APP_PROJECTS" ADD CONSTRAINT "PK_APP_PROJECTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_APP_PROJECTS" ON "APP_PROJECTS"("APPLICATION_UUID", "PROJECT_UUID"); -CREATE INDEX "IDX_APP_PROJ_APPLICATION_UUID" ON "APP_PROJECTS"("APPLICATION_UUID"); -CREATE INDEX "IDX_APP_PROJ_PROJECT_UUID" ON "APP_PROJECTS"("PROJECT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalPropertiesTest/schema.sql deleted file mode 100644 index a101d7797ce1d1dc74396daad80c2490b6ca0b09..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MoveDefaultTemplatesToInternalPropertiesTest/schema.sql +++ /dev/null @@ -1,29 +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 NOT NULL -); -ALTER TABLE "INTERNAL_PROPERTIES" ADD CONSTRAINT "PK_INTERNAL_PROPERTIES" PRIMARY KEY("KEE"); - -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "DEFAULT_GROUP_UUID" VARCHAR(40) -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValueTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValueTest/schema.sql deleted file mode 100644 index be6b1ef0e778d123bce63e63debdb1fcb7e41961..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/PopulateResetPasswordDefaultValueTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "USERS"( - "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_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "RESET_PASSWORD" BOOLEAN, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParametersTest/schema.sql deleted file mode 100644 index dfe931f54d1a54d9c0c701399f50a4920e6fc5c7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/SecureGitlabSecretParametersTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "PROP_KEY" VARCHAR(512) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettingsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettingsTest/schema.sql deleted file mode 100644 index dfe931f54d1a54d9c0c701399f50a4920e6fc5c7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/SetForceAuthenticationSettingsTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "PROP_KEY" VARCHAR(512) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChangesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChangesTest/schema.sql deleted file mode 100644 index 5cb1137f8de9fab4cfd7a1600fee7ca3f1bcf2fb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/UpdateChangeDataOfQProfileChangesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_CHANGES"( - "KEE" VARCHAR(40) NOT NULL, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "USER_UUID" VARCHAR(255), - "CHANGE_DATA" CLOB, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_CHANGES" ADD CONSTRAINT "PK_QPROFILE_CHANGES" PRIMARY KEY("KEE"); -CREATE INDEX "QP_CHANGES_RULES_PROFILE_UUID" ON "QPROFILE_CHANGES"("RULES_PROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTableTest/schema.sql deleted file mode 100644 index 6da26ad8dc2c67e6cc77f3028f0f64b6d64ea130..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/AddMonorepoColumnToProjectAlmSettingsTableTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "PROJECT_ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_SETTING_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "ALM_REPO" VARCHAR(256), - "ALM_SLUG" VARCHAR(256), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "SUMMARY_COMMENT_ENABLED" BOOLEAN -); -ALTER TABLE "PROJECT_ALM_SETTINGS" ADD CONSTRAINT "PK_PROJECT_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_ALM_SETTINGS" ON "PROJECT_ALM_SETTINGS"("PROJECT_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_ALM" ON "PROJECT_ALM_SETTINGS"("ALM_SETTING_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_SLUG" ON "PROJECT_ALM_SETTINGS"("ALM_SLUG"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest/schema.sql deleted file mode 100644 index 287ad39509a65770c0246e5c2c9713fba4fb9557..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest/schema.sql +++ /dev/null @@ -1,14 +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, - "IS_OWNER_USER" BOOLEAN NOT NULL, - "USER_EXTERNAL_ID" VARCHAR(255), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ALM_APP_INSTALLS" ADD 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"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest/schema.sql deleted file mode 100644 index 87fb2c67389c2d9171f33ec20bef98e168c313d2..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTableTest/schema.sql deleted file mode 100644 index 68a71ad4d6250933067e8f025f73df1a411b661a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrgMembersTableTest/schema.sql +++ /dev/null @@ -1,28 +0,0 @@ - -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) NOT NULL -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("USER_UUID", "ORGANIZATION_UUID"); -CREATE INDEX "ORG_MEMBERS_USER_UUID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); - -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "DEFAULT_GROUP_UUID" VARCHAR(40) -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTableTest/schema.sql deleted file mode 100644 index 64da6bc3e86be086fd913495ac3fe6d991e78e67..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrgQualityGatesTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORG_QUALITY_GATES"( - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "QUALITY_GATE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ORG_QUALITY_GATES" ADD CONSTRAINT "PK_ORG_QUALITY_GATES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_ORG_QUALITY_GATES" ON "ORG_QUALITY_GATES"("ORGANIZATION_UUID", "QUALITY_GATE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTableTest/schema.sql deleted file mode 100644 index 0c733480992ebcc0f7d2e08f98d80c97948b5b07..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationAlmBindingsTableTest/schema.sql +++ /dev/null @@ -1,13 +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, - "MEMBERS_SYNC_ENABLED" BOOLEAN, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORGANIZATION_ALM_BINDINGS" ADD 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/v87/DropOrganizationInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInComponentsTest/schema.sql deleted file mode 100644 index 2d117e3da7e2aa1bc8ad4cc88a38ba8120e0ab82..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInComponentsTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "COMPONENTS"( - "UUID" VARCHAR(50) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID"); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjectsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjectsTest/schema.sql deleted file mode 100644 index 282e616941b7ed44e700e54eae3db604e30ca1fb..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInProjectsTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "PROJECTS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(400) NOT NULL, - "QUALIFIER" VARCHAR(10) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "PRIVATE" BOOLEAN NOT NULL, - "TAGS" VARCHAR(500), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROJECTS" ADD CONSTRAINT "PK_NEW_PROJECTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECTS_KEE" ON "PROJECTS"("KEE"); -CREATE INDEX "IDX_QUALIFIER" ON "PROJECTS"("QUALIFIER"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooksTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooksTest/schema.sql deleted file mode 100644 index 005eb2c3b377d4cc47217b23fa1ae0b688cb2651..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationInWebhooksTest/schema.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "WEBHOOKS"( - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "SECRET" VARCHAR(200), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT -); -ALTER TABLE "WEBHOOKS" ADD CONSTRAINT "PK_WEBHOOKS" PRIMARY KEY("UUID"); -CREATE INDEX "ORGANIZATION_WEBHOOK" ON "WEBHOOKS"("ORGANIZATION_UUID"); -CREATE INDEX "PROJECT_WEBHOOK" ON "WEBHOOKS"("PROJECT_UUID"); - -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "DEFAULT_GROUP_UUID" VARCHAR(40) -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTableTest/schema.sql deleted file mode 100644 index 74675ee214824afec81cdaf983f01aa86d41423a..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropOrganizationsTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "DEFAULT_GROUP_UUID" VARCHAR(40) -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest/schema.sql deleted file mode 100644 index cf1dd7252b38bd1f9b72a7ce494a8dff32660857..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MakeMonorepoColumnInProjectAlmSettingsTableNotNullableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "PROJECT_ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_SETTING_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "ALM_REPO" VARCHAR(256), - "ALM_SLUG" VARCHAR(256), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "SUMMARY_COMMENT_ENABLED" BOOLEAN, - "MONOREPO" BOOLEAN -); -ALTER TABLE "PROJECT_ALM_SETTINGS" ADD CONSTRAINT "PK_PROJECT_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_ALM_SETTINGS" ON "PROJECT_ALM_SETTINGS"("PROJECT_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_ALM" ON "PROJECT_ALM_SETTINGS"("ALM_SETTING_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_SLUG" ON "PROJECT_ALM_SETTINGS"("ALM_SLUG"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalPropertiesTest/schema.sql deleted file mode 100644 index 09e88e08ef1c0ca7366f1bc083b0740a9e27766c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MoveDefaultProjectVisibilityToGlobalPropertiesTest/schema.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "PROP_KEY" VARCHAR(512) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); - -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "DEFAULT_GROUP_UUID" VARCHAR(40) -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalPropertiesTest/schema.sql deleted file mode 100644 index 09e88e08ef1c0ca7366f1bc083b0740a9e27766c..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/MoveDefaultQualityGateToGlobalPropertiesTest/schema.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "PROP_KEY" VARCHAR(512) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); - -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "DEFAULT_GROUP_UUID" VARCHAR(40) -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTableTest/schema.sql deleted file mode 100644 index cf1dd7252b38bd1f9b72a7ce494a8dff32660857..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/PopulateMonorepoColumnToProjectAlmSettingsTableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "PROJECT_ALM_SETTINGS"( - "UUID" VARCHAR(40) NOT NULL, - "ALM_SETTING_UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "ALM_REPO" VARCHAR(256), - "ALM_SLUG" VARCHAR(256), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "SUMMARY_COMMENT_ENABLED" BOOLEAN, - "MONOREPO" BOOLEAN -); -ALTER TABLE "PROJECT_ALM_SETTINGS" ADD CONSTRAINT "PK_PROJECT_ALM_SETTINGS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_ALM_SETTINGS" ON "PROJECT_ALM_SETTINGS"("PROJECT_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_ALM" ON "PROJECT_ALM_SETTINGS"("ALM_SETTING_UUID"); -CREATE INDEX "PROJECT_ALM_SETTINGS_SLUG" ON "PROJECT_ALM_SETTINGS"("ALM_SLUG"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v88/AddLastSonarlintConnectionToUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v88/AddLastSonarlintConnectionToUsersTest/schema.sql deleted file mode 100644 index 92b679b090578bace11dabd448048eacf9984b13..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v88/AddLastSonarlintConnectionToUsersTest/schema.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "USERS"( - "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_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "RESET_PASSWORD" BOOLEAN NOT NULL -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTableTest/schema.sql deleted file mode 100644 index b27a7bcefefd9b8284b90585853b309fecfb3899..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddIndexOnWebhookUuidInWebhookDeliveriesTableTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "WEBHOOK_DELIVERIES"( - "UUID" VARCHAR(40) NOT NULL, - "WEBHOOK_UUID" VARCHAR(40) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) NOT NULL, - "CE_TASK_UUID" VARCHAR(40), - "ANALYSIS_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "URL" VARCHAR(2000) NOT NULL, - "SUCCESS" BOOLEAN NOT NULL, - "HTTP_STATUS" INTEGER, - "DURATION_MS" BIGINT NOT NULL, - "PAYLOAD" CLOB NOT NULL, - "ERROR_STACKTRACE" CLOB, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "WEBHOOK_DELIVERIES" ADD 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"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTableTest/schema.sql deleted file mode 100644 index 534c0eb6f552d2afa370ef5e10db2c80e75fa537..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddIndicesToNewCodePeriodTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "NEW_CODE_PERIODS"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40), - "BRANCH_UUID" VARCHAR(40), - "TYPE" VARCHAR(30) NOT NULL, - "VALUE" VARCHAR(40), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "NEW_CODE_PERIODS" ADD CONSTRAINT "PK_NEW_CODE_PERIODS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_NEW_CODE_PERIODS" ON "NEW_CODE_PERIODS"("PROJECT_UUID", "BRANCH_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTableTest/schema.sql deleted file mode 100644 index adc6b495cecf1de97eeedacb5c141c32995b2974..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/AddMainBranchProjectUuidIndexToComponentTableTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "COMPONENTS"( - "UUID" VARCHAR(50) NOT NULL, - "KEE" VARCHAR(400), - "DEPRECATED_KEE" VARCHAR(400), - "NAME" VARCHAR(2000), - "LONG_NAME" VARCHAR(2000), - "DESCRIPTION" VARCHAR(2000), - "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "PRIVATE" BOOLEAN NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, - "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), - "PATH" VARCHAR(2000), - "UUID_PATH" VARCHAR(1500) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "MODULE_UUID" VARCHAR(50), - "MODULE_UUID_PATH" VARCHAR(1500), - "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50), - "B_CHANGED" BOOLEAN, - "B_NAME" VARCHAR(500), - "B_LONG_NAME" VARCHAR(500), - "B_DESCRIPTION" VARCHAR(2000), - "B_ENABLED" BOOLEAN, - "B_QUALIFIER" VARCHAR(10), - "B_LANGUAGE" VARCHAR(20), - "B_COPY_COMPONENT_UUID" VARCHAR(50), - "B_PATH" VARCHAR(2000), - "B_UUID_PATH" VARCHAR(1500), - "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(1500), - "CREATED_AT" TIMESTAMP -); -CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE"); -CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID"); -CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID"); -CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID"); -CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSettingTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSettingTest/schema.sql deleted file mode 100644 index dfe931f54d1a54d9c0c701399f50a4920e6fc5c7..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/DropGithubEndpointOnProjectLevelSettingTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "PROP_KEY" VARCHAR(512) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTableTest/schema.sql deleted file mode 100644 index b560d20c68a3f04e424006257537b9963fae7ffc..0000000000000000000000000000000000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v89/IncreaseSizeOfValueColumnInNewCodePeriodsTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "NEW_CODE_PERIODS"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(40), - "BRANCH_UUID" VARCHAR(40), - "TYPE" VARCHAR(30) NOT NULL, - "VALUE" VARCHAR(40), - "UPDATED_AT" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "NEW_CODE_PERIODS" ADD CONSTRAINT "PK_NEW_CODE_PERIODS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_NEW_CODE_PERIODS" ON "NEW_CODE_PERIODS"("PROJECT_UUID", "BRANCH_UUID"); -CREATE INDEX "IDX_NCP_TYPE" ON "NEW_CODE_PERIODS"("TYPE"); -CREATE INDEX "IDX_NCP_VALUE" ON "NEW_CODE_PERIODS"("VALUE");