]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13221 replace auto-incremented ID by UUID for ce_activity
authorPierre <pierre.guillot@sonarsource.com>
Wed, 8 Apr 2020 11:50:38 +0000 (13:50 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 25 May 2020 20:05:18 +0000 (20:05 +0000)
14 files changed:
server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.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/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/CreateProjectsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RenameProjectsTableToComponentsTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql [new file with mode: 0644]

index 29cab52cdd6733564ad4c298ce5c2af776076b27..3448087ba255912e8873bf597478c27a0643aa22 100644 (file)
@@ -20,7 +20,6 @@
   </sql>
 
   <sql id="columns">
-    ca.id,
     ca.uuid,
     ca.task_type as taskType,
     ca.component_uuid as componentUuid,
       <include refid="countWarnings"/>
     <include refid="sqlSelectByQuery" />
     order by
-      ca.created_at desc, id desc
+      ca.created_at desc, uuid desc
     limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
   </select>
 
   <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.ce.CeActivityDto" databaseId="mssql">
     select * from (
-    select row_number() over(order by ca.created_at desc, id desc) as number,
+    select row_number() over(order by ca.created_at desc, uuid desc) as number,
       <include refid="columns"/>,
       <include refid="countWarnings"/>
       <include refid="sqlSelectByQuery" />
       ) as query
     where
       query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
-    order by createdAt desc, id desc
+    order by createdAt desc, uuid desc
   </select>
 
   <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.ce.CeActivityDto" databaseId="oracle">
@@ -85,7 +84,7 @@
         <include refid="columns"/>,
         <include refid="countWarnings"/>
         <include refid="sqlSelectByQuery" />
-        order by ca.created_at desc, ca.id desc
+        order by ca.created_at desc, ca.uuid desc
       ) t
     ) t
     where
index d3fa90d0036e431521b2ed1b14af8c312d8c823c..7cab5a23ebd416bca9f22ea1169559e00aacb384 100644 (file)
@@ -88,7 +88,6 @@ ALTER TABLE "ANALYSIS_PROPERTIES" ADD CONSTRAINT "PK_ANALYSIS_PROPERTIES" PRIMAR
 CREATE INDEX "ANALYSIS_PROPERTIES_ANALYSIS" ON "ANALYSIS_PROPERTIES"("ANALYSIS_UUID");
 
 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),
@@ -112,7 +111,7 @@ CREATE TABLE "CE_ACTIVITY"(
     "CREATED_AT" BIGINT NOT NULL,
     "UPDATED_AT" BIGINT NOT NULL
 );
-ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("ID");
+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");
index 90659d93d7611dd6aeb2f82532474ac68914d5e1..f71ba9528b4fa6e3e917bd9025ea57a1a40f741b 100644 (file)
@@ -21,6 +21,9 @@ 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.ceactivity.AddPrimaryKeyOnUuidColumnOfCeActivityTable;
+import org.sonar.server.platform.db.migration.version.v83.ceactivity.DropIdColumnOfCeActivityTable;
+import org.sonar.server.platform.db.migration.version.v83.ceactivity.DropPrimaryKeyOnIdColumnOfCeActivityTable;
 import org.sonar.server.platform.db.migration.version.v83.cequeue.AddPrimaryKeyOnUuidColumnOfCeQueueTable;
 import org.sonar.server.platform.db.migration.version.v83.cequeue.DropIdColumnOfCeQueueTable;
 import org.sonar.server.platform.db.migration.version.v83.cequeue.DropPrimaryKeyOnIdColumnOfCeQueueTable;
@@ -81,12 +84,17 @@ public class DbVersion83 implements DbVersion {
       .add(3413, "Add primary key on 'UUID' column of 'SNAPSHOTS' table", AddPrimaryKeyOnUuidColumnOfSnapshotsTable.class)
       .add(3414, "Drop column 'ID' of 'SNAPSHOTS' table", DropIdColumnOfSnapshotsTable.class)
 
-      // Migration on ce_queue table
+      // Migration on CE_QUEUE table
       .add(3415, "Drop unique index on 'uuid' column of 'CE_QUEUE' table", DropUniqueIndexOnUuidColumnOfCeQueueTable.class)
       .add(3416, "Drop primary key on 'ID' column of 'CE_QUEUE' table", DropPrimaryKeyOnIdColumnOfCeQueueTable.class)
       .add(3417, "Add primary key on 'UUID' column of 'CE_QUEUE' table", AddPrimaryKeyOnUuidColumnOfCeQueueTable.class)
       .add(3418, "Drop column 'ID' of 'CE_QUEUE' table", DropIdColumnOfCeQueueTable.class)
 
+      // Migration on CE_ACTIVITY table
+      .add(3419, "Drop primary key on 'ID' column of 'CE_ACTIVITY' table", DropPrimaryKeyOnIdColumnOfCeActivityTable.class)
+      .add(3420, "Add primary key on 'UUID' column of 'CE_ACTIVITY' table", AddPrimaryKeyOnUuidColumnOfCeActivityTable.class)
+      .add(3421, "Drop column 'ID' of 'CE_ACTIVITY' table", DropIdColumnOfCeActivityTable.class)
+
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java
new file mode 100644 (file)
index 0000000..6b96166
--- /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.ceactivity;
+
+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 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/v83/ceactivity/DropIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTable.java
new file mode 100644 (file)
index 0000000..4fc1413
--- /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.ceactivity;
+
+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 DropIdColumnOfCeActivityTable extends DdlChange {
+
+  private Database db;
+
+  public DropIdColumnOfCeActivityTable(Database db) {
+    super(db);
+    this.db = db;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropColumnsBuilder(db.getDialect(), "ce_activity", "id").build());
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java
new file mode 100644 (file)
index 0000000..2002192
--- /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.ceactivity;
+
+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 DropPrimaryKeyOnIdColumnOfCeActivityTable extends DdlChange {
+
+  private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator;
+
+  public DropPrimaryKeyOnIdColumnOfCeActivityTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) {
+    super(db);
+    this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(dropPrimaryKeySqlGenerator.generate("ce_activity", "ce_activity","id"));
+  }
+
+}
index 4bfa02367f04211dc15cb9ad8d187e1b5d6ecf26..23819e69063a8ae3c63f0f2113abb512cd3d7a88 100644 (file)
@@ -24,7 +24,6 @@ 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.version.v82.CreateProjectsTable;
 
 import static java.sql.Types.BIGINT;
 import static java.sql.Types.BOOLEAN;
index b5ee92fdfca15b1b1b16cc9d79427491ad55f1b2..4f48be5381774f00397a06d51efc3fa19d874a50 100644 (file)
@@ -25,8 +25,6 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.db.CoreDbTester;
 
-import static org.apache.commons.lang.math.RandomUtils.nextInt;
-
 public class RenameProjectsTableToComponentsTest {
   private static final String TABLE_NAME = "projects";
   private static final String NEW_TABLE_NAME = "components";
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java
new file mode 100644 (file)
index 0000000..543a503
--- /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.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/v83/ceactivity/DropIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest.java
new file mode 100644 (file)
index 0000000..51ffa9f
--- /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.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/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java
new file mode 100644 (file)
index 0000000..d268cca
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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.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 org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
+import org.sonar.server.platform.db.migration.version.v83.util.GetConstraintHelper;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class DropPrimaryKeyOnIdColumnOfCeActivityTableTest {
+
+  private static final String TABLE_NAME = "ce_activity";
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeActivityTableTest.class, "schema.sql");
+
+  private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new GetConstraintHelper(db.database()));
+
+  private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeActivityTable(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/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql
new file mode 100644 (file)
index 0000000..22ed140
--- /dev/null
@@ -0,0 +1,32 @@
+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/v83/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql
new file mode 100644 (file)
index 0000000..9aa76b6
--- /dev/null
@@ -0,0 +1,33 @@
+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/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql
new file mode 100644 (file)
index 0000000..d8fec2d
--- /dev/null
@@ -0,0 +1,33 @@
+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");