From b33d63ad5fb20e1b25ab377770fd91c6cb8f7cda Mon Sep 17 00:00:00 2001 From: Eric Hartmann Date: Wed, 14 Jun 2017 17:37:44 +0200 Subject: [PATCH] SONAR-9304 remove orphans from rules_profiles --- ...java => AddIndexRulesProfileUuidOnQProfileChanges.java} | 4 ++-- .../platform/db/migration/version/v65/DbVersion65.java | 7 ++++--- ... => AddIndexRulesProfileUuidOnQProfileChangesTest.java} | 6 +++--- .../platform/db/migration/version/v65/DbVersion65Test.java | 2 +- .../initial.sql | 0 5 files changed, 10 insertions(+), 9 deletions(-) rename server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/{AddIndexRulesProfileUuidOnQProfileChangesIsIndexed.java => AddIndexRulesProfileUuidOnQProfileChanges.java} (92%) rename server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/{AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest.java => AddIndexRulesProfileUuidOnQProfileChangesTest.java} (83%) rename server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/{AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest => AddIndexRulesProfileUuidOnQProfileChangesTest}/initial.sql (100%) diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexed.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChanges.java similarity index 92% rename from server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexed.java rename to server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChanges.java index cd7ebee4ec9..003a69d24be 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexed.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChanges.java @@ -26,13 +26,13 @@ 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 AddIndexRulesProfileUuidOnQProfileChangesIsIndexed extends DdlChange { +public class AddIndexRulesProfileUuidOnQProfileChanges extends DdlChange { private static final String TABLE_NAME = "qprofile_changes"; private static final String COLUMN_NAME = "rules_profile_uuid"; private static final String NEW_INDEX_NAME = "qp_changes_rules_profile_uuid"; - public AddIndexRulesProfileUuidOnQProfileChangesIsIndexed(Database db) { + public AddIndexRulesProfileUuidOnQProfileChanges(Database db) { super(db); } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java index 67b0d8fbf43..75ac30953ab 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java @@ -52,8 +52,9 @@ public class DbVersion65 implements DbVersion { .add(1723, "Populate table qprofiles", PopulateOrgQProfiles.class) .add(1724, "Drop columns organization_uuid and parent_kee from rules_profiles", DropOrgColumnsFromRulesProfiles.class) .add(1725, "Mark rules_profiles.is_built_in to true for default organization", SetRulesProfilesIsBuiltInToTrueForDefaultOrganization.class) - .add(1726, "Update OrgQProfiles to point to built-in profiles", UpdateOrgQProfilesToPointToBuiltInProfiles.class) - .add(1727, "Rename column qprofile_changes.qprofile_key to qprofile_changes.rules_profile_uuid", RenameQProfileKeyToRulesProfileUuidOnQProfileChanges.class) - .add(1728, "Ensure presence of index on qprofile_changes.rules_profile_uuid", AddIndexRulesProfileUuidOnQProfileChangesIsIndexed.class); + .add(1726, "Update org_qprofiles to reference built-in profiles", UpdateOrgQProfilesToPointToBuiltInProfiles.class) + .add(1727, "Delete rules_profiles orphans", DeleteOrphansFromRulesProfiles.class) + .add(1728, "Rename column qprofile_changes.qprofile_key to qprofile_changes.rules_profile_uuid", RenameQProfileKeyToRulesProfileUuidOnQProfileChanges.class) + .add(1729, "Add index on qprofile_changes.rules_profile_uuid", AddIndexRulesProfileUuidOnQProfileChanges.class); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest.java similarity index 83% rename from server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest.java rename to server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest.java index 818b4c74680..d2039468c7c 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest.java @@ -24,16 +24,16 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; -public class AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest { +public class AddIndexRulesProfileUuidOnQProfileChangesTest { private static final String TABLE_NAME = "qprofile_changes"; private static final String COLUMN_NAME = "rules_profile_uuid"; private static final String INDEX_NAME = "qp_changes_rules_profile_uuid"; @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest.class, "initial.sql"); + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexRulesProfileUuidOnQProfileChangesTest.class, "initial.sql"); - private AddIndexRulesProfileUuidOnQProfileChangesIsIndexed underTest = new AddIndexRulesProfileUuidOnQProfileChangesIsIndexed(db.database()); + private AddIndexRulesProfileUuidOnQProfileChanges underTest = new AddIndexRulesProfileUuidOnQProfileChanges(db.database()); @Test public void add_index_ON_RULES_PROFILE_UUID_of_QPROFILE_CHANGES() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java index 008357b2f8d..618c8014db3 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java @@ -35,6 +35,6 @@ public class DbVersion65Test { @Test public void verify_migration_count() { - verifyMigrationCount(underTest, 29); + verifyMigrationCount(underTest, 30); } } diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest/initial.sql similarity index 100% rename from server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesIsIndexedTest/initial.sql rename to server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/AddIndexRulesProfileUuidOnQProfileChangesTest/initial.sql -- 2.39.5