]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13221 change PK to uuid of PROJECT_QPROFILES table
authorJacek <jacek.poreda@sonarsource.com>
Mon, 20 Apr 2020 08:08:18 +0000 (10:08 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 25 May 2020 20:05:19 +0000 (20:05 +0000)
23 files changed:
server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java
server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml
server/sonar-db-dao/src/schema/schema-sq.ddl
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuid.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql [new file with mode: 0644]

index 90f8d985a14df267c3c7e5a724e5ad719242582a..af0525ae5d4ca8f3cb087947708f1d1eb03bc139 100644 (file)
@@ -29,6 +29,7 @@ import java.util.Set;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.sonar.api.utils.System2;
+import org.sonar.core.util.UuidFactory;
 import org.sonar.core.util.stream.MoreCollectors;
 import org.sonar.db.Dao;
 import org.sonar.db.DatabaseUtils;
@@ -46,8 +47,10 @@ import static org.sonar.db.DatabaseUtils.executeLargeUpdates;
 public class QualityProfileDao implements Dao {
 
   private final System2 system;
+  private final UuidFactory uuidFactory;
 
-  public QualityProfileDao(System2 system) {
+  public QualityProfileDao(UuidFactory uuidFactory, System2 system) {
+    this.uuidFactory = uuidFactory;
     this.system = system;
   }
 
@@ -206,7 +209,7 @@ public class QualityProfileDao implements Dao {
   }
 
   public void insertProjectProfileAssociation(DbSession dbSession, ProjectDto project, QProfileDto profile) {
-    mapper(dbSession).insertProjectProfileAssociation(project.getUuid(), profile.getKee());
+    mapper(dbSession).insertProjectProfileAssociation(uuidFactory.create(), project.getUuid(), profile.getKee());
   }
 
   public void deleteProjectProfileAssociation(DbSession dbSession, ProjectDto project, QProfileDto profile) {
index 139c77daeb083f08df8cd7b3136d97426339d070..7679ac35c0245098bf821598a2c69e3bec1be6c8 100644 (file)
@@ -103,6 +103,7 @@ public interface QualityProfileMapper {
     @Param("languages") Collection<String> languages);
 
   void insertProjectProfileAssociation(
+    @Param("uuid") String uuid,
     @Param("projectUuid") String projectUuid,
     @Param("profileUuid") String profileUuid);
 
index b27d667f21c8758ded4ae96490c18656ec3d1050..1bd105d38cc87303598c4c499b5901df1ec9c8b5 100644 (file)
 
   <insert id="insertProjectProfileAssociation" useGeneratedKeys="false">
     insert into project_qprofiles (
+      uuid,
       project_uuid,
       profile_key
     ) values (
+      #{uuid, jdbcType=VARCHAR},
       #{projectUuid, jdbcType=VARCHAR},
       #{profileUuid, jdbcType=VARCHAR}
     )
 
   <select id="selectSelectedProjects" resultType="org.sonar.db.qualityprofile.ProjectQprofileAssociationDto">
     select
-      pp.id as id,
       pj.uuid as projectUuid,
       pj.kee as projectKey,
       pj.name as projectName,
   </select>
 
   <select id="selectDeselectedProjects" resultType="org.sonar.db.qualityprofile.ProjectQprofileAssociationDto">
-    SELECT pp.id as id, pj.uuid as projectUuid, pj.kee as projectKey, pj.name as projectName, pp.profile_key as profileKey
+    SELECT pj.uuid as projectUuid, pj.kee as projectKey, pj.name as projectName, pp.profile_key as profileKey
     FROM components pj
     LEFT JOIN project_qprofiles pp ON pp.project_uuid = pj.uuid
     AND pp.profile_key = #{profileUuid, jdbcType=VARCHAR}
   </select>
 
   <select id="selectProjectAssociations" resultType="org.sonar.db.qualityprofile.ProjectQprofileAssociationDto">
-    SELECT pp.id as id, pj.uuid as projectUuid, pj.kee as projectKey, pj.name as projectName, pp.profile_key as profileKey
+    SELECT pj.uuid as projectUuid, pj.kee as projectKey, pj.name as projectName, pp.profile_key as profileKey
     FROM components pj
     LEFT JOIN project_qprofiles pp ON pp.project_uuid = pj.uuid
     AND pp.profile_key = #{profileUuid, jdbcType=VARCHAR}
index 9b1a5c03908fd6a4db7aba3cc9b8323e88727959..b33359b86a93f0a9c1e23ce7f1ddfd6d49f7b37d 100644 (file)
@@ -702,11 +702,11 @@ ALTER TABLE "PROJECT_QGATES" ADD CONSTRAINT "PK_PROJECT_QGATES" PRIMARY KEY("PRO
 CREATE UNIQUE INDEX "UNIQ_PROJECT_QGATES" ON "PROJECT_QGATES"("PROJECT_UUID", "QUALITY_GATE_UUID");
 
 CREATE TABLE "PROJECT_QPROFILES"(
-    "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1),
     "PROJECT_UUID" VARCHAR(50) NOT NULL,
-    "PROFILE_KEY" VARCHAR(50) NOT NULL
+    "PROFILE_KEY" VARCHAR(50) NOT NULL,
+    "UUID" VARCHAR(40) NOT NULL
 );
-ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID");
+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");
 
 CREATE TABLE "PROJECTS"(
index dd717115eede79873c45969dec7a74693d4653b3..7f392bcb3465b91e08e9f898c625cadf6538541d 100644 (file)
@@ -58,6 +58,12 @@ import org.sonar.server.platform.db.migration.version.v83.projectmeasures.DropId
 import org.sonar.server.platform.db.migration.version.v83.projectmeasures.DropPrimaryKeyOnIdColumnOfProjectMeasuresTable;
 import org.sonar.server.platform.db.migration.version.v83.projectmeasures.MakeProjectMeasuresUuidColumnNotNullable;
 import org.sonar.server.platform.db.migration.version.v83.projectmeasures.PopulateProjectMeasureUuid;
+import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable;
+import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.AddUuidColumnToProjectQProfilesTable;
+import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.DropIdColumnOfProjectQProfilesTable;
+import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.DropPrimaryKeyOnIdColumnOfProjectQProfilesTable;
+import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.MakeProjectQProfilesUuidColumnNotNullable;
+import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.PopulateProjectQProfilesUuid;
 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;
@@ -151,11 +157,13 @@ public class DbVersion83 implements DbVersion {
       .add(3444, "Add primary key on 'UUID' column of 'USER_TOKENS' table", AddPrimaryKeyOnUuidColumnOfUserTokensTable.class)
       .add(3445, "Drop column 'ID' of 'USER_TOKENS' table", DropIdColumnOfUserTokensTable.class)
 
-
-
-
-
-
+      // Migration on PROJECT_QPROFILES table
+      .add(3446, "Add 'uuid' column for 'PROJECT_QPROFILES'", AddUuidColumnToProjectQProfilesTable.class)
+      .add(3447, "Populate 'uuid' column for 'PROJECT_QPROFILES'", PopulateProjectQProfilesUuid.class)
+      .add(3448, "Make 'uuid' column not nullable for 'PROJECT_QPROFILES'", MakeProjectQProfilesUuidColumnNotNullable.class)
+      .add(3449, "Drop primary key on 'ID' column of 'PROJECT_QPROFILES' table", DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.class)
+      .add(3450, "Add primary key on 'UUID' column of 'PROJECT_QPROFILES' table", AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.class)
+      .add(3451, "Drop column 'ID' of 'PROJECT_QPROFILES' table", DropIdColumnOfProjectQProfilesTable.class)
 
     ;
   }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java
new file mode 100644 (file)
index 0000000..daa7ec6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.projectqprofiles;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder;
+
+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/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java
new file mode 100644 (file)
index 0000000..b351b58
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java
new file mode 100644 (file)
index 0000000..4f08616
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java
new file mode 100644 (file)
index 0000000..ce2a784
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.projectqprofiles;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
+
+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"));
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java
new file mode 100644 (file)
index 0000000..39cdc82
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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/v83/projectqprofiles/PopulateProjectQProfilesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuid.java
new file mode 100644 (file)
index 0000000..863b7c2
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.projectqprofiles;
+
+import java.sql.SQLException;
+import java.util.concurrent.atomic.AtomicLong;
+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/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java
new file mode 100644 (file)
index 0000000..8984094
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java
new file mode 100644 (file)
index 0000000..e98ffc5
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java
new file mode 100644 (file)
index 0000000..fcb3004
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java
new file mode 100644 (file)
index 0000000..2158bc4
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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 org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
+import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest {
+  private static final String TABLE_NAME = "project_qprofiles";
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.class, "schema.sql");
+
+  private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database()));
+
+  private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(db.database(), dropPrimaryKeySqlGenerator);
+
+  @Test
+  public void execute() throws SQLException {
+    underTest.execute();
+
+    db.assertNoPrimaryKey(TABLE_NAME);
+  }
+
+  @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/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java
new file mode 100644 (file)
index 0000000..0d0be25
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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/v83/projectqprofiles/PopulateProjectQProfilesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest.java
new file mode 100644 (file)
index 0000000..24ce746
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write 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.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/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql
new file mode 100644 (file)
index 0000000..b294830
--- /dev/null
@@ -0,0 +1,7 @@
+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/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql
new file mode 100644 (file)
index 0000000..c7530b1
--- /dev/null
@@ -0,0 +1,7 @@
+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/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql
new file mode 100644 (file)
index 0000000..d531ef1
--- /dev/null
@@ -0,0 +1,8 @@
+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/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql
new file mode 100644 (file)
index 0000000..75824e0
--- /dev/null
@@ -0,0 +1,8 @@
+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/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql
new file mode 100644 (file)
index 0000000..f961bdc
--- /dev/null
@@ -0,0 +1,8 @@
+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/v83/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql
new file mode 100644 (file)
index 0000000..f961bdc
--- /dev/null
@@ -0,0 +1,8 @@
+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");