From aa8d678e85a4a120177ff50ac216d34343b4280b Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Mon, 20 Apr 2020 16:16:13 -0500 Subject: [PATCH] SONAR-13221 Update Dbversion83 --- server/sonar-db-dao/src/schema/schema-sq.ddl | 30 +++++------ .../db/migration/version/v83/DbVersion83.java | 52 +++++++++++++++++++ 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl index 8b7ee9e9eda..20fe8d502b8 100644 --- a/server/sonar-db-dao/src/schema/schema-sq.ddl +++ b/server/sonar-db-dao/src/schema/schema-sq.ddl @@ -293,7 +293,6 @@ CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); 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), @@ -304,21 +303,22 @@ CREATE TABLE "FILE_SOURCES"( "LINE_COUNT" INTEGER NOT NULL, "BINARY_DATA" BLOB, "CREATED_AT" BIGINT NOT NULL, - "UPDATED_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("ID"); +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 "GROUP_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, "GROUP_ID" INTEGER, "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL ); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); +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"); @@ -361,7 +361,6 @@ CREATE TABLE "INTERNAL_PROPERTIES"( ALTER TABLE "INTERNAL_PROPERTIES" ADD CONSTRAINT "PK_INTERNAL_PROPERTIES" PRIMARY KEY("KEE"); 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), @@ -369,9 +368,10 @@ CREATE TABLE "ISSUE_CHANGES"( "CHANGE_DATA" CLOB(2147483647), "CREATED_AT" BIGINT, "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT + "ISSUE_CHANGE_CREATION_DATE" BIGINT, + "UUID" VARCHAR(40) NOT NULL ); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); +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"); @@ -770,7 +770,6 @@ CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_U CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), "QGATE_ID" INTEGER, "METRIC_ID" INTEGER, "PERIOD" INTEGER, @@ -778,9 +777,10 @@ CREATE TABLE "QUALITY_GATE_CONDITIONS"( "VALUE_ERROR" VARCHAR(64), "VALUE_WARNING" VARCHAR(64), "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL ); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); +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), @@ -919,13 +919,13 @@ ALTER TABLE "USER_PROPERTIES" ADD CONSTRAINT "PK_USER_PROPERTIES" PRIMARY KEY("U CREATE UNIQUE INDEX "USER_PROPERTIES_USER_UUID_KEE" ON "USER_PROPERTIES"("USER_UUID", "KEE"); 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) + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL ); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); +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/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java index 361fa27f127..ea62d5bc508 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java @@ -58,6 +58,12 @@ import org.sonar.server.platform.db.migration.version.v83.grouproles.DropResourc import org.sonar.server.platform.db.migration.version.v83.grouproles.MakeGroupRolesUuidColumnNotNullable; import org.sonar.server.platform.db.migration.version.v83.grouproles.MigrateResourceIdToUuidInGroupRoles; import org.sonar.server.platform.db.migration.version.v83.grouproles.PopulateGroupRolesUuid; +import org.sonar.server.platform.db.migration.version.v83.issuechanges.AddPrimaryKeyOnUuidColumnOfIssueChangesTable; +import org.sonar.server.platform.db.migration.version.v83.issuechanges.AddUuidColumnToIssueChangesTable; +import org.sonar.server.platform.db.migration.version.v83.issuechanges.DropIdColumnOfIssueChangesTable; +import org.sonar.server.platform.db.migration.version.v83.issuechanges.DropPrimaryKeyOnIdColumnOfIssueChangesTable; +import org.sonar.server.platform.db.migration.version.v83.issuechanges.MakeIssueChangesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v83.issuechanges.PopulateIssueChangesUuid; import org.sonar.server.platform.db.migration.version.v83.issues.AddPrimaryKeyOnKeeColumnOfIssuesTable; import org.sonar.server.platform.db.migration.version.v83.issues.DropIdColumnOfIssuesTable; import org.sonar.server.platform.db.migration.version.v83.issues.DropPrimaryKeyOnIdColumnOfIssuesTable; @@ -88,6 +94,12 @@ import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.Popul 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.qualitygateconditions.AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.AddUuidColumnToQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.DropIdColumnOfQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.MakeQualityGateConditionsUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.PopulateQualityGateConditionsUuid; import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.AddPrimaryKeyOnUuidColumnOfSnapshotsTable; import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.DropIdColumnOfSnapshotsTable; import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable; @@ -234,6 +246,46 @@ public class DbVersion83 implements DbVersion { .add(3476, "Drop primary key on 'ID' column of 'FILE_SOURCES' table", DropPrimaryKeyOnIdColumnOfFileSourcesTable.class) .add(3477, "Add primary key on 'UUID' column of 'FILE_SOURCES' table", AddPrimaryKeyOnUuidColumnOfFileSourcesTable.class) .add(3478, "Drop column 'ID' of 'FILE_SOURCES' table", DropIdColumnOfFileSourcesTable.class) + + // Migration of GROUP_ROLES table + .add(3479, "Add 'UUID' column on 'GROUP_ROLES' table", AddUuidColumnToGroupRolesTable.class) + .add(3480, "Populate 'uuid' for 'GROUP_ROLES'", PopulateGroupRolesUuid.class) + .add(3481, "Make 'uuid' column not nullable for 'GROUP_ROLES'", MakeGroupRolesUuidColumnNotNullable.class) + .add(3482, "Drop primary key on 'ID' column of 'GROUP_ROLES' table", DropPrimaryKeyOnIdColumnOfGroupRolesTable.class) + .add(3483, "Add primary key on 'UUID' column of 'GROUP_ROLES' table", AddPrimaryKeyOnUuidColumnOfGroupRolesTable.class) + .add(3484, "Drop column 'ID' of 'GROUP_ROLES' table", DropIdColumnOfGroupRolesTable.class) + + // Migration of USER_ROLES table + .add(3485, "Add 'UUID' column on 'USER_ROLES' table", AddUuidColumnToUserRolesTable.class) + .add(3486, "Populate 'uuid' for 'USER_ROLES'", PopulateUserRolesUuid.class) + .add(3487, "Make 'uuid' column not nullable for 'USER_ROLES'", MakeUserRolesUuidColumnNotNullable.class) + .add(3488, "Drop primary key on 'ID' column of 'USER_ROLES' table", DropPrimaryKeyOnIdColumnOfUserRolesTable.class) + .add(3489, "Add primary key on 'UUID' column of 'USER_ROLES' table", AddPrimaryKeyOnUuidColumnOfUserRolesTable.class) + .add(3490, "Drop column 'ID' of 'USER_ROLES' table", DropIdColumnOfUserRolesTable.class) + + // Migration of FILE_SOURCES table + .add(3491, "Add 'UUID' column on 'FILE_SOURCES' table", AddUuidColumnToFileSourcesTable.class) + .add(3492, "Populate 'uuid' for 'FILE_SOURCES'", PopulateFileSourcesUuid.class) + .add(3493, "Make 'uuid' column not nullable for 'FILE_SOURCES'", MakeFileSourcesUuidColumnNotNullable.class) + .add(3494, "Drop primary key on 'ID' column of 'FILE_SOURCES' table", DropPrimaryKeyOnIdColumnOfFileSourcesTable.class) + .add(3495, "Add primary key on 'UUID' column of 'FILE_SOURCES' table", AddPrimaryKeyOnUuidColumnOfFileSourcesTable.class) + .add(3496, "Drop column 'ID' of 'FILE_SOURCES' table", DropIdColumnOfFileSourcesTable.class) + + // Migration of ISSUE_CHANGES table + .add(3464, "Add 'UUID' column on 'ISSUE_CHANGES' table", AddUuidColumnToIssueChangesTable.class) + .add(3465, "Populate 'uuid' for 'ISSUE_CHANGES'", PopulateIssueChangesUuid.class) + .add(3466, "Make 'uuid' column not nullable for 'ISSUE_CHANGES'", MakeIssueChangesUuidColumnNotNullable.class) + .add(3467, "Drop primary key on 'ID' column of 'ISSUE_CHANGES' table", DropPrimaryKeyOnIdColumnOfIssueChangesTable.class) + .add(3468, "Add primary key on 'UUID' column of 'ISSUE_CHANGES' table", AddPrimaryKeyOnUuidColumnOfIssueChangesTable.class) + .add(3469, "Drop column 'ID' of 'ISSUE_CHANGES' table", DropIdColumnOfIssueChangesTable.class) + + // Migration of QUALITY_GATE_CONDITIONS table + .add(3470, "Add 'UUID' column on 'QUALITY_GATE_CONDITIONS' table", AddUuidColumnToQualityGateConditionsTable.class) + .add(3471, "Populate 'uuid' for 'QUALITY_GATE_CONDITIONS'", PopulateQualityGateConditionsUuid.class) + .add(3472, "Make 'uuid' column not nullable for 'QUALITY_GATE_CONDITIONS'", MakeQualityGateConditionsUuidColumnNotNullable.class) + .add(3473, "Drop primary key on 'ID' column of 'QUALITY_GATE_CONDITIONS' table", DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.class) + .add(3474, "Add primary key on 'UUID' column of 'QUALITY_GATE_CONDITIONS' table", AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.class) + .add(3475, "Drop column 'ID' of 'QUALITY_GATE_CONDITIONS' table", DropIdColumnOfQualityGateConditionsTable.class) ; } } -- 2.39.5