aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-12-02 14:43:04 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-12-05 16:51:02 +0100
commit19882feb2c947ed14cc90190a000d6fa0d3b39d0 (patch)
tree434566ea0529d2d11883e876a60d963b4bbb90c9 /sonar-db/src
parenta7b89319baa0c7fa8b2832fe80839990844cef26 (diff)
downloadsonarqube-19882feb2c947ed14cc90190a000d6fa0d3b39d0.tar.gz
sonarqube-19882feb2c947ed14cc90190a000d6fa0d3b39d0.zip
SONAR-8467 Add UUID column to db table EVENTS
Diffstat (limited to 'sonar-db/src')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/event/EventDto.java10
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java6
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v63/AddUuidToEvents.java46
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v63/PopulateUuidColumnOnEvents.java56
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v63/package-info.java25
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/event/EventMapper.xml14
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/event/EventDaoTest.java17
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v63/AddUuidToEventsTest.java58
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/delete.xml1
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/insert-result.xml1
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/shared.xml4
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml2
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml2
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/version/v63/AddUuidToEventsTest/previous-events.sql11
18 files changed, 249 insertions, 12 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/event/EventDto.java b/sonar-db/src/main/java/org/sonar/db/event/EventDto.java
index 5e377af9261..18e2845f5af 100644
--- a/sonar-db/src/main/java/org/sonar/db/event/EventDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/event/EventDto.java
@@ -29,6 +29,7 @@ public class EventDto {
public static final String CATEGORY_PROFILE = "Profile";
private Long id;
+ private String uuid;
private String analysisUuid;
private String componentUuid;
private String name;
@@ -47,6 +48,15 @@ public class EventDto {
return this;
}
+ public String getUuid() {
+ return uuid;
+ }
+
+ public EventDto setUuid(String uuid) {
+ this.uuid = uuid;
+ return this;
+ }
+
public String getAnalysisUuid() {
return analysisUuid;
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
index 2f6edd2493a..317c3ad2e47 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
@@ -30,7 +30,7 @@ import org.sonar.db.MyBatis;
public class DatabaseVersion {
- public static final int LAST_VERSION = 1_423;
+ public static final int LAST_VERSION = 1_500;
/**
* The minimum supported version which can be upgraded. Lower
diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
index 568bbf1e78c..b0a4467227b 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
@@ -182,6 +182,7 @@ import org.sonar.db.version.v62.PopulateOrganizationUuidOfGroups;
import org.sonar.db.version.v62.PopulateOrganizationUuidOfPermissionTemplates;
import org.sonar.db.version.v62.PopulateOrganizationUuidOfUserRoles;
import org.sonar.db.version.v62.UpdateQualityGateConditionsOnCoverage;
+import org.sonar.db.version.v63.AddUuidToEvents;
public class MigrationStepModule extends Module {
@Override
@@ -384,6 +385,9 @@ public class MigrationStepModule extends Module {
DropRelatedDashboardTables.class,
DropMeasureFiltersTables.class,
DropIssueFiltersTables.class,
- CreateTableWebhookDeliveries.class);
+ CreateTableWebhookDeliveries.class,
+
+ // 6.3
+ AddUuidToEvents.class);
}
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v63/AddUuidToEvents.java b/sonar-db/src/main/java/org/sonar/db/version/v63/AddUuidToEvents.java
new file mode 100644
index 00000000000..220ba52ca54
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/version/v63/AddUuidToEvents.java
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.db.version.v63;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.AddColumnsBuilder;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
+
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddUuidToEvents extends DdlChange {
+
+ public AddUuidToEvents(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ VarcharColumnDef column = newVarcharColumnDefBuilder()
+ .setColumnName("uuid")
+ .setIsNullable(true)
+ .setLimit(40)
+ .build();
+ context.execute(new AddColumnsBuilder(getDialect(), "events").addColumn(column).build());
+ }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v63/PopulateUuidColumnOnEvents.java b/sonar-db/src/main/java/org/sonar/db/version/v63/PopulateUuidColumnOnEvents.java
new file mode 100644
index 00000000000..380cac0068c
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/version/v63/PopulateUuidColumnOnEvents.java
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.db.version.v63;
+
+import java.sql.SQLException;
+import org.sonar.core.util.UuidFactory;
+import org.sonar.db.Database;
+import org.sonar.db.version.BaseDataChange;
+import org.sonar.db.version.MassUpdate;
+import org.sonar.db.version.Select;
+import org.sonar.db.version.SqlStatement;
+
+public class PopulateUuidColumnOnEvents extends BaseDataChange {
+
+ private final UuidFactory uuidFactory;
+
+ public PopulateUuidColumnOnEvents(Database db, UuidFactory uuidFactory) {
+ super(db);
+ this.uuidFactory = uuidFactory;
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ MassUpdate massUpdate = context.prepareMassUpdate();
+ massUpdate.select("SELECT e.id from events e where e.uuid is null");
+ massUpdate.update("UPDATE events SET uuid=? WHERE id=?");
+ massUpdate.rowPluralName("events");
+ massUpdate.execute(this::handle);
+ }
+
+ private boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+ long id = row.getLong(1);
+ update.setString(1, uuidFactory.create());
+ update.setLong(2, id);
+ return true;
+ }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v63/package-info.java b/sonar-db/src/main/java/org/sonar/db/version/v63/package-info.java
new file mode 100644
index 00000000000..8908b7cd4ca
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/version/v63/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.db.version.v63;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/sonar-db/src/main/resources/org/sonar/db/event/EventMapper.xml b/sonar-db/src/main/resources/org/sonar/db/event/EventMapper.xml
index cdac080c37e..ad24d2d78aa 100644
--- a/sonar-db/src/main/resources/org/sonar/db/event/EventMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/event/EventMapper.xml
@@ -4,6 +4,7 @@
<sql id="eventColumns">
e.id,
+ e.uuid,
e.analysis_uuid as "analysisUuid",
e.component_uuid as "componentUuid",
e.name,
@@ -24,8 +25,17 @@
</select>
<insert id="insert" parameterType="Event" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO events (analysis_uuid, component_uuid, name, category, description, event_data, event_date, created_at)
- VALUES (#{analysisUuid}, #{componentUuid}, #{name}, #{category}, #{description}, #{data}, #{date}, #{createdAt})
+ INSERT INTO events (uuid, analysis_uuid, component_uuid, name, category, description, event_data, event_date, created_at)
+ VALUES (
+ #{uuid, jdbcType=VARCHAR},
+ #{analysisUuid, jdbcType=VARCHAR},
+ #{componentUuid, jdbcType=VARCHAR},
+ #{name, jdbcType=VARCHAR},
+ #{category, jdbcType=VARCHAR},
+ #{description, jdbcType=VARCHAR},
+ #{data, jdbcType=VARCHAR},
+ #{date, jdbcType=BIGINT},
+ #{createdAt, jdbcType=BIGINT})
</insert>
<delete id="delete">
diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
index 816d7cf0041..59149e8346a 100644
--- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
+++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
@@ -513,6 +513,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1421');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1422');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1423');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1500');
+
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, IS_ROOT, CREATED_AT, UPDATED_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', true, '1418215735482', '1418215735482');
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
index 6c4daf0f2da..b7fd1a0331b 100644
--- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
+++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
@@ -157,6 +157,7 @@ CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY
CREATE TABLE "EVENTS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "UUID" VARCHAR(40),
"NAME" VARCHAR(400),
"ANALYSIS_UUID" VARCHAR(50) NOT NULL,
"COMPONENT_UUID" VARCHAR(50),
@@ -169,7 +170,6 @@ CREATE TABLE "EVENTS" (
CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID");
CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID");
-
CREATE TABLE "QUALITY_GATES" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"NAME" VARCHAR(100) NOT NULL,
diff --git a/sonar-db/src/test/java/org/sonar/db/event/EventDaoTest.java b/sonar-db/src/test/java/org/sonar/db/event/EventDaoTest.java
index d3203cc41f5..c61b79b2120 100644
--- a/sonar-db/src/test/java/org/sonar/db/event/EventDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/event/EventDaoTest.java
@@ -22,6 +22,7 @@ package org.sonar.db.event;
import java.util.List;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
@@ -30,22 +31,25 @@ import static org.assertj.core.api.Assertions.assertThat;
public class EventDaoTest {
@Rule
+ public ExpectedException expectedException = ExpectedException.none();
+ @Rule
public DbTester dbTester = DbTester.create(System2.INSTANCE);
- EventDao dao = dbTester.getDbClient().eventDao();
+ EventDao underTest = dbTester.getDbClient().eventDao();
@Test
public void select_by_component_uuid() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
- List<EventDto> dtos = dao.selectByComponentUuid(dbTester.getSession(), "ABCD");
+ List<EventDto> dtos = underTest.selectByComponentUuid(dbTester.getSession(), "ABCD");
assertThat(dtos).hasSize(3);
- dtos = dao.selectByComponentUuid(dbTester.getSession(), "BCDE");
+ dtos = underTest.selectByComponentUuid(dbTester.getSession(), "BCDE");
assertThat(dtos).hasSize(1);
EventDto dto = dtos.get(0);
assertThat(dto.getId()).isEqualTo(4L);
+ assertThat(dto.getUuid()).isEqualTo("E4");
assertThat(dto.getAnalysisUuid()).isEqualTo("uuid_1");
assertThat(dto.getComponentUuid()).isEqualTo("BCDE");
assertThat(dto.getName()).isEqualTo("1.0");
@@ -60,7 +64,7 @@ public class EventDaoTest {
public void return_different_categories() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
- List<EventDto> dtos = dao.selectByComponentUuid(dbTester.getSession(), "ABCD");
+ List<EventDto> dtos = underTest.selectByComponentUuid(dbTester.getSession(), "ABCD");
assertThat(dtos).extracting("category").containsOnly(EventDto.CATEGORY_ALERT, EventDto.CATEGORY_PROFILE, EventDto.CATEGORY_VERSION);
}
@@ -68,7 +72,8 @@ public class EventDaoTest {
public void insert() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
- dao.insert(dbTester.getSession(), new EventDto()
+ underTest.insert(dbTester.getSession(), new EventDto()
+ .setUuid("E1")
.setAnalysisUuid("uuid_1")
.setComponentUuid("ABCD")
.setName("1.0")
@@ -86,7 +91,7 @@ public class EventDaoTest {
public void delete() {
dbTester.prepareDbUnit(getClass(), "delete.xml");
- dao.delete(dbTester.getSession(), 1L);
+ underTest.delete(dbTester.getSession(), 1L);
dbTester.getSession().commit();
assertThat(dbTester.countRowsOfTable("events")).isEqualTo(0);
diff --git a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
index c83c4d0a7a2..b292574a3d2 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
@@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
public void verify_count_of_added_MigrationStep_types() {
ComponentContainer container = new ComponentContainer();
new MigrationStepModule().configure(container);
- assertThat(container.size()).isEqualTo(164);
+ assertThat(container.size()).isEqualTo(165);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v63/AddUuidToEventsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v63/AddUuidToEventsTest.java
new file mode 100644
index 00000000000..71b91392ff5
--- /dev/null
+++ b/sonar-db/src/test/java/org/sonar/db/version/v63/AddUuidToEventsTest.java
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.db.version.v63;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+
+
+public class AddUuidToEventsTest {
+
+ @Rule
+ public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddUuidToEventsTest.class, "previous-events.sql");
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private AddUuidToEvents underTest = new AddUuidToEvents(dbTester.database());
+
+ @Test
+ public void creates_table_on_empty_db() throws SQLException {
+ underTest.execute();
+
+ dbTester.assertColumnDefinition("events", "uuid", Types.VARCHAR, 40, true);
+ }
+
+ @Test
+ public void migration_is_not_reentrant() throws SQLException {
+ underTest.execute();
+
+ expectedException.expect(IllegalStateException.class);
+
+ underTest.execute();
+ }
+
+}
diff --git a/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/delete.xml b/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/delete.xml
index d04de02ea4f..072ba02691d 100644
--- a/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/delete.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/delete.xml
@@ -1,6 +1,7 @@
<dataset>
<events id="1"
+ uuid="E1"
analysis_uuid="uuid_1"
component_uuid="ABCD"
name="1.0"
diff --git a/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/insert-result.xml b/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/insert-result.xml
index e70d018d0d1..9a9dc7862b3 100644
--- a/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/insert-result.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/insert-result.xml
@@ -1,6 +1,7 @@
<dataset>
<events id="1"
+ uuid="E1"
analysis_uuid="uuid_1"
component_uuid="ABCD"
name="1.0"
diff --git a/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/shared.xml
index 3e7e6173481..36c8b037b89 100644
--- a/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/shared.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/event/EventDaoTest/shared.xml
@@ -1,6 +1,7 @@
<dataset>
<events id="1"
+ uuid="E1"
name="1.0"
category="Version"
description="Version 1.0"
@@ -10,6 +11,7 @@
analysis_uuid="uuid_1"
created_at="1225630680000"/>
<events id="2"
+ uuid="E2"
name="Red (was Orange)"
category="Alert"
description="Critical issues variation > 0 since previous version (1.0 - 2015 Feb 09), Open issues > 0"
@@ -19,6 +21,7 @@
analysis_uuid="uuid_1"
created_at="1225630680000"/>
<events id="3"
+ uuid="E3"
name="Changes in 'Default' (Java)"
category="Profile"
description="Version 1.0"
@@ -28,6 +31,7 @@
analysis_uuid="uuid_1"
created_at="1225630680000"/>
<events id="4"
+ uuid="E4"
name="1.0"
category="Version"
description="Version 1.0"
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml
index 251f2ea6c7a..6cb45a58538 100644
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml
@@ -57,6 +57,7 @@ Note that measures, events and reviews are not deleted.
measure_data="[null]"/>
<events id="1"
+ uuid="E1"
analysis_uuid="u1"
component_uuid="1"
category="VERSION"
@@ -116,6 +117,7 @@ Note that measures, events and reviews are not deleted.
measure_data="[null]"/>
<events id="2"
+ uuid="E2"
analysis_uuid="u2"
component_uuid="2"
category="VERSION"
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml
index fa0e9e864d1..d086021a151 100644
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml
@@ -44,6 +44,7 @@
measure_data="[null]"/>
<events id="1"
+ uuid="E1"
analysis_uuid="u1"
component_uuid="1"
category="VERSION"
@@ -108,6 +109,7 @@
measure_data="[null]"/>
<events id="2"
+ uuid="E2"
analysis_uuid="u2"
component_uuid="2"
category="VERSION"
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v63/AddUuidToEventsTest/previous-events.sql b/sonar-db/src/test/resources/org/sonar/db/version/v63/AddUuidToEventsTest/previous-events.sql
new file mode 100644
index 00000000000..b0712271a84
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/version/v63/AddUuidToEventsTest/previous-events.sql
@@ -0,0 +1,11 @@
+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),
+ "CATEGORY" VARCHAR(50),
+ "EVENT_DATE" BIGINT NOT NULL,
+ "CREATED_AT" BIGINT NOT NULL,
+ "DESCRIPTION" VARCHAR(4000),
+ "EVENT_DATA" VARCHAR(4000)
+);