diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-07-11 11:50:52 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-07-11 19:07:36 +0200 |
commit | 50d0c1cabba9c9f30779ca122d4d8e69b8e1e8b8 (patch) | |
tree | 6323ad63e78d80f2c810912ba73a54a7b8d159de /sonar-db | |
parent | a8be32db0c9821ad9041bfade4c1179895467ae3 (diff) | |
download | sonarqube-50d0c1cabba9c9f30779ca122d4d8e69b8e1e8b8.tar.gz sonarqube-50d0c1cabba9c9f30779ca122d4d8e69b8e1e8b8.zip |
SONAR-7786 merge PROJECTS table clean migrations and do them earlier
Diffstat (limited to 'sonar-db')
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java | 17 | ||||
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjects.java | 11 | ||||
-rw-r--r-- | sonar-db/src/test/java/org/sonar/db/version/v60/CleanUsurperRootComponentsTest.java | 83 | ||||
-rw-r--r-- | sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest.java | 20 | ||||
-rw-r--r-- | sonar-db/src/test/resources/org/sonar/db/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql | 38 | ||||
-rw-r--r-- | sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql (renamed from sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/in_progress_projects.sql) | 9 |
6 files changed, 90 insertions, 88 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java b/sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java index 742168e9945..b300d047f21 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java @@ -73,7 +73,7 @@ public class CleanUsurperRootComponents extends BaseDataChange { " p.scope = 'PRJ'" + " and p.qualifier in ('TRK', 'VW', 'DEV')" + " )"); - massUpdate.update("delete from duplications_index where component_uuid=?"); + massUpdate.update("delete from duplications_index where snapshot_id in (select id from snapshots where component_uuid=?)"); massUpdate.update("delete from project_measures where component_uuid=?"); massUpdate.update("delete from ce_activity where component_uuid=?"); massUpdate.update("delete from events where component_uuid=?"); @@ -122,7 +122,7 @@ public class CleanUsurperRootComponents extends BaseDataChange { private void cleanSnapshotWithIncorrectRoot(Context context) throws SQLException { MassUpdate massUpdate = context.prepareMassUpdate(); massUpdate.select("select" + - " sn.uuid,sn.id" + + " sn.id" + " from " + " projects p, snapshots sn" + " where" + @@ -131,22 +131,19 @@ public class CleanUsurperRootComponents extends BaseDataChange { " p.scope = 'PRJ'" + " and p.qualifier in ('TRK', 'VW', 'DEV')" + " )"); - massUpdate.update("DELETE from duplications_index WHERE analysis_uuid=?"); - massUpdate.update("DELETE from project_measures WHERE analysis_uuid=?"); - massUpdate.update("DELETE from ce_activity WHERE analysis_uuid=?"); - massUpdate.update("DELETE from events WHERE analysis_uuid=?"); + massUpdate.update("DELETE from ce_activity WHERE snapshot_id=?"); + massUpdate.update("DELETE from events WHERE snapshot_id=?"); + massUpdate.update("DELETE from project_measures WHERE snapshot_id=?"); + massUpdate.update("DELETE from duplications_index WHERE project_snapshot_id=?"); massUpdate.update("DELETE from snapshots WHERE id=?"); massUpdate.rowPluralName("snapshots with incorrect root"); massUpdate.execute((row, update, updateIndex) -> { - String analysisUuid = row.getString(1); - long snapshotId = row.getLong(2); + long snapshotId = row.getLong(1); switch (updateIndex) { case 0: case 1: case 2: case 3: - update.setString(1, analysisUuid); - return true; case 4: update.setLong(1, snapshotId); return true; diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjects.java index 2952a9fa5ff..334e66d796e 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjects.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjects.java @@ -35,15 +35,18 @@ public class FixProjectUuidOfDeveloperProjects extends BaseDataChange { @Override public void execute(Context context) throws SQLException { MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct developer_uuid from projects where qualifier = 'DEV_PRJ' and project_uuid != developer_uuid"); - massUpdate.update("update projects set project_uuid = developer_uuid where developer_uuid = ? and qualifier = 'DEV_PRJ' and project_uuid != developer_uuid"); - massUpdate.rowPluralName("developers in project"); + massUpdate.select("select distinct p.person_id,d.uuid from projects p, projects d where p.qualifier = 'DEV_PRJ' and p.project_uuid != d.uuid and d.id = p.person_id"); + massUpdate.update("update projects set project_uuid = ? where person_id = ? and qualifier = 'DEV_PRJ' and project_uuid != ?"); + massUpdate.rowPluralName("developers with incorrect project_uuid"); massUpdate.execute(FixProjectUuidOfDeveloperProjects::handleComponent); } private static boolean handleComponent(Select.Row row, SqlStatement update) throws SQLException { - String developerUuid = row.getString(1); + long personId = row.getLong(1); + String developerUuid = row.getString(2); update.setString(1, developerUuid); + update.setLong(2, personId); + update.setString(3, developerUuid); return true; } diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/CleanUsurperRootComponentsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/CleanUsurperRootComponentsTest.java index 6e54187085f..4a22d6a2f8a 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v60/CleanUsurperRootComponentsTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v60/CleanUsurperRootComponentsTest.java @@ -62,7 +62,7 @@ public class CleanUsurperRootComponentsTest { insertComponent("sc3", "qu3"), insertComponent("sc4", "qu4") }; - String[] snapshotUuids = { + Long[] snapshotIds = { insertSnapshot(componentUuids[0], "sc1", "qu1"), insertSnapshot(componentUuids[1], "sc2", "quW"), insertSnapshot(componentUuids[2], "scX", "qu3"), @@ -71,10 +71,10 @@ public class CleanUsurperRootComponentsTest { underTest.execute(); - assertSnapshot(snapshotUuids[0], "sc1", "qu1"); - assertSnapshot(snapshotUuids[1], "sc2", "qu2"); - assertSnapshot(snapshotUuids[2], "sc3", "qu3"); - assertSnapshot(snapshotUuids[3], "sc4", "qu4"); + assertSnapshot(snapshotIds[0], "sc1", "qu1"); + assertSnapshot(snapshotIds[1], "sc2", "qu2"); + assertSnapshot(snapshotIds[2], "sc3", "qu3"); + assertSnapshot(snapshotIds[3], "sc4", "qu4"); } @Test @@ -101,13 +101,13 @@ public class CleanUsurperRootComponentsTest { long usurperId = 12L; String usurperUuid = "usurper_uuid"; insertComponent(Scopes.PROJECT, Qualifiers.MODULE, usurperId, usurperUuid, usurperUuid); - insertDuplicationsIndex(usurperUuid); - insertProjectMeasures(usurperUuid, dontCare()); - insertCeActivity(usurperUuid, dontCare()); - insertEvent(usurperUuid, dontCare()); + Long snapshotId = insertSnapshot(usurperUuid, usurperUuid); + insertDuplicationsIndex(snapshotId); + insertProjectMeasures(usurperUuid, dontCareLong()); + insertCeActivity(usurperUuid, dontCareLong()); + insertEvent(usurperUuid, dontCareLong()); insertSnapshot(usurperUuid, dontCare()); insertSnapshot(dontCare(), usurperUuid); - insertSnapshot(usurperUuid, usurperUuid); insertProjectLinks(usurperUuid); insertIssue(usurperUuid, null); insertIssue(null, usurperUuid); @@ -142,7 +142,7 @@ public class CleanUsurperRootComponentsTest { insertComponent(Scopes.PROJECT, "DEV"), insertComponent(Scopes.PROJECT, "DEV_PRJ"), }; - String[] snapshotUuids = { + Long[] snapshotIds = { insertSnapshot(dontCare(), componentUuids[0]), insertSnapshot(dontCare(), componentUuids[1]), insertSnapshot(dontCare(), componentUuids[2]), @@ -156,16 +156,16 @@ public class CleanUsurperRootComponentsTest { underTest.execute(); - assertUuidsInTableProjects("snapshots", snapshotUuids[0], snapshotUuids[4], snapshotUuids[7]); + assertIdsInTableProjects("snapshots", snapshotIds[0], snapshotIds[4], snapshotIds[7]); } @Test public void execute_deletes_children_tables_of_snapshots_when_root_of_snapshot_is_not_root() throws SQLException { String componentUuid = insertComponent(Scopes.FILE, Scopes.FILE); - String snapshotUuid = insertSnapshot(dontCare(), componentUuid); - insertProjectMeasures(dontCare(), snapshotUuid); - insertCeActivity(componentUuid, snapshotUuid); - insertEvent(componentUuid, snapshotUuid); + Long snapshotId = insertSnapshot(dontCare(), componentUuid); + insertProjectMeasures(dontCare(), snapshotId); + insertCeActivity(componentUuid, snapshotId); + insertEvent(componentUuid, snapshotId); underTest.execute(); @@ -174,11 +174,11 @@ public class CleanUsurperRootComponentsTest { .forEach(s -> assertThat(db.countRowsOfTable(s)).describedAs("table " + s).isEqualTo(0)); } - private void insertDuplicationsIndex(String componentUuid) { + private void insertDuplicationsIndex(Long snapshotId) { db.executeInsert( "duplications_index", - "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", dontCare(), + "PROJECT_SNAPSHOT_ID", valueOf(dontCareLong()), + "SNAPSHOT_ID", valueOf(snapshotId), "HASH", dontCare(), "INDEX_IN_FILE", valueOf(0), "START_LINE", valueOf(0), @@ -186,22 +186,22 @@ public class CleanUsurperRootComponentsTest { db.commit(); } - private void insertProjectMeasures(String componentUuid, String analysisUuid) { + private void insertProjectMeasures(String componentUuid, Long snapshotId) { db.executeInsert( "project_measures", "METRIC_ID", valueOf(123L), "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", analysisUuid); + "SNAPSHOT_ID", valueOf(snapshotId)); db.commit(); } - private void insertCeActivity(String componentUuid, String analysisUuid) { + private void insertCeActivity(String componentUuid, Long snapshotId) { db.executeInsert( "ce_activity", "UUID", dontCare(), "TASK_TYPE", dontCare(), "COMPONENT_UUID", componentUuid, - "ANALYSIS_UUID", analysisUuid, + "SNAPSHOT_ID", valueOf(snapshotId), "STATUS", dontCare(), "IS_LAST", "true", "IS_LAST_KEY", dontCare(), @@ -211,25 +211,25 @@ public class CleanUsurperRootComponentsTest { db.commit(); } - private void insertEvent(String componentUuid, String analysisUuid) { + private void insertEvent(String componentUuid, Long snapshotId) { db.executeInsert( "events", - "ANALYSIS_UUID", analysisUuid, + "SNAPSHOT_ID", valueOf(snapshotId), "COMPONENT_UUID", componentUuid, "CREATED_AT", valueOf(122L), "EVENT_DATE", valueOf(123L)); db.commit(); } - private String insertSnapshot(String componentUuid, String rootComponentUuid) { - String uuid = "uuid_" + idGenerator++; + private Long insertSnapshot(String componentUuid, String rootComponentUuid) { + Long id = idGenerator++; db.executeInsert( "snapshots", - "UUID", uuid, + "ID", valueOf(id), "COMPONENT_UUID", componentUuid, "ROOT_COMPONENT_UUID", rootComponentUuid); db.commit(); - return uuid; + return id; } private void insertProjectLinks(String componentUuid) { @@ -311,39 +311,42 @@ public class CleanUsurperRootComponentsTest { "projects", "ID", valueOf(id), "UUID", uuid, - "ROOT_UUID", dontCare(), "PROJECT_UUID", projectUuid, - "UUID_PATH", dontCare(), "SCOPE", scope, "QUALIFIER", qualifier); db.commit(); return uuid; } - private String insertSnapshot(String componentUuid, String scope, String qualifier) { + private Long insertSnapshot(String componentUuid, String scope, String qualifier) { long id = idGenerator++; - String uuid = "uuid_" + id; db.executeInsert( "snapshots", - "ID", valueOf(id), - "UUID", uuid, + "id", valueOf(id), "component_uuid", componentUuid, "root_component_uuid", dontCare(), "scope", scope, "qualifier", qualifier); db.commit(); - return uuid; + return id; } - private void assertSnapshot(String snapshotUuid, String scope, String qualifier) { - List<Map<String, Object>> rows = db.select("select SCOPE, QUALIFIER from snapshots where UUID='" + snapshotUuid + "'"); + private void assertSnapshot(Long snapshotId, String scope, String qualifier) { + List<Map<String, Object>> rows = db.select("select SCOPE, QUALIFIER from snapshots where ID=" + snapshotId); assertThat(rows).hasSize(1); Map<String, Object> row = rows.get(0); assertThat(row.get("SCOPE")).isEqualTo(scope); assertThat(row.get("QUALIFIER")).isEqualTo(qualifier); } + private void assertIdsInTableProjects(String tableName, Long... expected) { + assertThat(db.select("select id from " + tableName) + .stream() + .map(stringObjectMap -> (Long) stringObjectMap.entrySet().iterator().next().getValue())) + .containsOnly(expected); + } + private void assertUuidsInTableProjects(String tableName, String... expected) { assertThat(db.select("select uuid from " + tableName) .stream() @@ -356,4 +359,8 @@ public class CleanUsurperRootComponentsTest { private String dontCare() { return "DC_" + dontCareGenerator++; } + + private Long dontCareLong() { + return dontCareGenerator++; + } } diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest.java index ea09dcc0838..bdb58a3ba3f 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest.java @@ -27,6 +27,7 @@ import org.junit.Test; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; +import static java.lang.String.valueOf; import static org.assertj.core.api.Assertions.assertThat; public class FixProjectUuidOfDeveloperProjectsTest { @@ -40,7 +41,7 @@ public class FixProjectUuidOfDeveloperProjectsTest { @Rule public DbTester db = DbTester.createForSchema(System2.INSTANCE, FixProjectUuidOfDeveloperProjectsTest.class, - "in_progress_projects.sql"); + "projects_5.6.sql"); private FixProjectUuidOfDeveloperProjects underTest = new FixProjectUuidOfDeveloperProjects(db.database()); @@ -84,9 +85,9 @@ public class FixProjectUuidOfDeveloperProjectsTest { insert(PROJECT_UUID, "TRK", null, PROJECT_UUID); insert(FILE_UUID, "FIL", null, PROJECT_UUID); // developer - insert(DEVELOPER_UUID, "DEV", DEVELOPER_UUID, DEVELOPER_UUID); - insert(DEV1_IN_PROJECT_UUID, "DEV_PRJ", DEVELOPER_UUID, /* not correct */PROJECT_UUID); - insert(DEV2_IN_PROJECT_UUID, "DEV_PRJ", DEVELOPER_UUID, /* not correct */PROJECT_UUID); + Long personId = insert(DEVELOPER_UUID, "DEV", null, DEVELOPER_UUID); + insert(DEV1_IN_PROJECT_UUID, "DEV_PRJ", personId, /* not correct */PROJECT_UUID); + insert(DEV2_IN_PROJECT_UUID, "DEV_PRJ", personId, /* not correct */PROJECT_UUID); db.commit(); } @@ -95,14 +96,17 @@ public class FixProjectUuidOfDeveloperProjectsTest { assertThat(rows.get("projectUuid")).isEqualTo(expectedProjectUuid); } - private String insert(String uuid, String qualifier, @Nullable String developerUuid, String projectUuid) { + private Long insert(String uuid, String qualifier, @Nullable Long personId, String projectUuid) { db.executeInsert( TABLE_PROJECTS, "UUID", uuid, - "DEVELOPER_UUID", developerUuid, + "PERSON_ID", personId == null ? null : valueOf(personId), "PROJECT_UUID", projectUuid, - "ROOT_UUID", "NOT_USED", "QUALIFIER", qualifier); - return uuid; + db.commit(); + return db.select("select ID from projects where UUID='" + uuid + "'").stream() + .findFirst() + .map(f -> (Long) f.get("ID")) + .orElseThrow(() -> new IllegalStateException("NO ID??")); } } diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql index 3706047e5ab..299da292538 100644 --- a/sonar-db/src/test/resources/org/sonar/db/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql +++ b/sonar-db/src/test/resources/org/sonar/db/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql @@ -21,9 +21,7 @@ CREATE TABLE "RULES_PROFILES" ( "RULES_UPDATED_AT" VARCHAR(100), "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT + "UPDATED_AT" TIMESTAMP ); CREATE TABLE "PROJECT_QPROFILES" ( @@ -56,7 +54,6 @@ CREATE TABLE "GROUPS" ( CREATE TABLE "SNAPSHOTS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(50) NOT NULL, "CREATED_AT" BIGINT, "BUILD_DATE" BIGINT, "COMPONENT_UUID" VARCHAR(50) NOT NULL, @@ -141,8 +138,8 @@ CREATE TABLE "WIDGET_PROPERTIES" ( CREATE TABLE "EVENTS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "NAME" VARCHAR(400), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, "COMPONENT_UUID" VARCHAR(50), + "SNAPSHOT_ID" INTEGER, "CATEGORY" VARCHAR(50), "EVENT_DATE" BIGINT NOT NULL, "CREATED_AT" BIGINT NOT NULL, @@ -187,8 +184,8 @@ CREATE TABLE "PROJECT_LINKS" ( CREATE TABLE "DUPLICATIONS_INDEX" ( "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER NOT NULL, "HASH" VARCHAR(50) NOT NULL, "INDEX_IN_FILE" INTEGER NOT NULL, "START_LINE" INTEGER NOT NULL, @@ -200,7 +197,6 @@ CREATE TABLE "PROJECT_MEASURES" ( "VALUE" DOUBLE, "METRIC_ID" INTEGER NOT NULL, "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, "SNAPSHOT_ID" INTEGER, "TEXT_VALUE" VARCHAR(4000), "ALERT_STATUS" VARCHAR(5), @@ -218,9 +214,8 @@ CREATE TABLE "PROJECT_MEASURES" ( CREATE TABLE "PROJECTS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(4000) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), "PROJECT_UUID" VARCHAR(50), "MODULE_UUID" VARCHAR(50), "MODULE_UUID_PATH" VARCHAR(4000), @@ -232,9 +227,9 @@ CREATE TABLE "PROJECTS" ( "DEPRECATED_KEE" VARCHAR(400), "PATH" VARCHAR(2000), "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), + "COPY_RESOURCE_ID" INTEGER, "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), + "PERSON_ID" INTEGER, "CREATED_AT" TIMESTAMP, "AUTHORIZATION_UPDATED_AT" BIGINT ); @@ -478,7 +473,6 @@ CREATE TABLE "PERM_TEMPLATES_GROUPS" ( CREATE TABLE "ACTIVITIES" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "LOG_KEY" VARCHAR(250), - "PROFILE_KEY" VARCHAR(255) NOT NULL, "CREATED_AT" TIMESTAMP, "USER_LOGIN" VARCHAR(255), "LOG_TYPE" VARCHAR(250), @@ -518,7 +512,7 @@ CREATE TABLE "CE_ACTIVITY" ( "UUID" VARCHAR(40) NOT NULL, "TASK_TYPE" VARCHAR(15) NOT NULL, "COMPONENT_UUID" VARCHAR(40) NULL, - "ANALYSIS_UUID" VARCHAR(50) NULL, + "SNAPSHOT_ID" INTEGER NULL, "STATUS" VARCHAR(15) NOT NULL, "IS_LAST" BOOLEAN NOT NULL, "IS_LAST_KEY" VARCHAR(55) NOT NULL, @@ -553,7 +547,7 @@ CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX" ("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX" ("ANALYSIS_UUID", "COMPONENT_UUID"); +CREATE INDEX "DUPLICATIONS_INDEX_SID" ON "DUPLICATIONS_INDEX" ("SNAPSHOT_ID"); CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); @@ -565,11 +559,9 @@ CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES" ("COMPONENT_UUID"); - CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME"); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID"); +CREATE INDEX "EVENTS_SNAPSHOT_ID" ON "EVENTS" ("SNAPSHOT_ID"); CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID"); @@ -585,10 +577,6 @@ CREATE INDEX "SNAPSHOTS_PARENT" ON "SNAPSHOTS" ("PARENT_SNAPSHOT_ID"); CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); - -CREATE INDEX "SNAPSHOTS_ROOT_COMPONENT" ON "SNAPSHOTS" ("ROOT_COMPONENT_UUID"); - CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS" ("RULE_ID"); CREATE INDEX "ACTIVE_DASHBOARDS_DASHBOARDID" ON "ACTIVE_DASHBOARDS" ("DASHBOARD_ID"); @@ -605,7 +593,7 @@ CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES" ("COMPONENT_U CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); +CREATE INDEX "PROJECTS_ROOT_ID" ON "PROJECTS" ("ROOT_ID"); CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); @@ -653,6 +641,8 @@ CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); +CREATE INDEX "SNAPSHOTS_ROOT_COMPONENT" ON "SNAPSHOTS" ("ROOT_COMPONENT_UUID"); + CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/in_progress_projects.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql index 760728a8dc3..d051017969b 100644 --- a/sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/in_progress_projects.sql +++ b/sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql @@ -1,8 +1,8 @@ CREATE TABLE "PROJECTS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "KEE" VARCHAR(400), - "UUID" VARCHAR(50) NOT NULL, - "ROOT_UUID" VARCHAR(50) NOT NULL, + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), "PROJECT_UUID" VARCHAR(50), "MODULE_UUID" VARCHAR(50), "MODULE_UUID_PATH" VARCHAR(4000), @@ -14,9 +14,10 @@ CREATE TABLE "PROJECTS" ( "DEPRECATED_KEE" VARCHAR(400), "PATH" VARCHAR(2000), "LANGUAGE" VARCHAR(20), - "COPY_COMPONENT_UUID" VARCHAR(50), + "COPY_RESOURCE_ID" INTEGER, "LONG_NAME" VARCHAR(2000), - "DEVELOPER_UUID" VARCHAR(50), + "PERSON_ID" INTEGER, "CREATED_AT" TIMESTAMP, "AUTHORIZATION_UPDATED_AT" BIGINT ); + |