"UUID" VARCHAR(40) NOT NULL,
"NAME" VARCHAR(400),
"ANALYSIS_UUID" VARCHAR(50) NOT NULL,
- "COMPONENT_UUID" VARCHAR(50),
+ "COMPONENT_UUID" VARCHAR(50) NOT NULL,
"CATEGORY" VARCHAR(50),
"EVENT_DATE" BIGINT NOT NULL,
"CREATED_AT" BIGINT NOT NULL,
assertThat(dbTester.countRowsOfTable("projects")).isZero();
assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(1);
- assertThat(dbTester.countRowsOfTable("events")).isEqualTo(2);
+ assertThat(dbTester.countRowsOfTable("events")).isZero();
assertThat(dbTester.countRowsOfTable("issues")).isZero();
assertThat(dbTester.countRowsOfTable("issue_changes")).isZero();
}
<events id="2"
uuid="P2"
analysis_uuid="u1"
- component_uuid="[null]"
+ component_uuid="uuid_1"
name="Version 1.0"
category="VERSION"
description="[null]"
<events id="3"
uuid="P3"
analysis_uuid="u1"
- component_uuid="[null]"
+ component_uuid="uuid_1"
name="Version 1.0"
category="VERSION"
description="[null]"
registry
.add(1700, "Drop table AUTHORS", DropTableAuthors.class)
.add(1701, "Clean orphans from USER_ROLES", CleanOrphanRowsInUserRoles.class)
- .add(1702, "Clean orphans from GROUP_ROLES", CleanOrphanRowsInGroupRoles.class);
+ .add(1702, "Clean orphans from GROUP_ROLES", CleanOrphanRowsInGroupRoles.class)
+ .add(1703, "Populate EVENTS.COMPONENT_UUID", PopulateEventsComponentUuid.class)
+ .add(1704, "Drop index EVENTS_COMPONENT_UUID", DropIndexEventsComponentUuid.class)
+ .add(1705, "Make EVENTS.COMPONENT_UUID not nullable", MakeEventsComponentUuidNotNullable.class)
+ .add(1706, "Recreate index EVENTS_COMPONENT_UUID", RecreateIndexEventsComponentUuid.class);
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v65;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropIndexEventsComponentUuid extends DdlChange {
+
+ public DropIndexEventsComponentUuid(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new DropIndexBuilder(getDialect())
+ .setTable("events")
+ .setName("events_component_uuid")
+ .build());
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v65;
+
+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 MakeEventsComponentUuidNotNullable extends DdlChange {
+
+ public MakeEventsComponentUuidNotNullable(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new AlterColumnsBuilder(getDialect(), "events")
+ .updateColumn(newVarcharColumnDefBuilder()
+ .setColumnName("component_uuid")
+ .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE)
+ .setIsNullable(false)
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v65;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+import org.sonar.server.platform.db.migration.step.MassUpdate;
+import org.sonar.server.platform.db.migration.step.Select;
+import org.sonar.server.platform.db.migration.step.SqlStatement;
+
+public class PopulateEventsComponentUuid extends DataChange {
+ public PopulateEventsComponentUuid(Database db) {
+ super(db);
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ populateColumnOrFixInconsistencies(context);
+
+ deleteOrphans(context);
+ }
+
+ private static void populateColumnOrFixInconsistencies(Context context) throws SQLException {
+ MassUpdate massUpdate = context.prepareMassUpdate();
+ massUpdate.select("select" +
+ " e.id, s.component_uuid" +
+ " from events e" +
+ " inner join snapshots s on" +
+ " s.uuid = e.analysis_uuid" +
+ " where" +
+ " e.component_uuid is null" +
+ " or e.component_uuid <> s.uuid");
+ massUpdate.update("update events set component_uuid = ? where id = ?");
+ massUpdate.rowPluralName("events without component_uuid");
+ massUpdate.execute(PopulateEventsComponentUuid::handlePopulate);
+ }
+
+ private static boolean handlePopulate(Select.Row row, SqlStatement update) throws SQLException {
+ long id = row.getLong(1);
+ String projectUuid = row.getString(2);
+
+ update.setString(1, projectUuid);
+ update.setLong(2, id);
+
+ return true;
+ }
+
+ private static void deleteOrphans(Context context) throws SQLException {
+ MassUpdate massUpdate = context.prepareMassUpdate();
+ massUpdate.select("select id from events e where" +
+ " e.component_uuid is null" +
+ " or not exists (select id from snapshots s where s.uuid = e.analysis_uuid)");
+ massUpdate.update("delete from events where id = ?");
+ massUpdate.rowPluralName("delete orphan events");
+ massUpdate.execute(PopulateEventsComponentUuid::handleDelete);
+ }
+
+ private static boolean handleDelete(Select.Row row, SqlStatement update) throws SQLException {
+ long id = row.getLong(1);
+
+ update.setLong(1, id);
+
+ return true;
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v65;
+
+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.CreateIndexBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class RecreateIndexEventsComponentUuid extends DdlChange {
+
+ public RecreateIndexEventsComponentUuid(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new CreateIndexBuilder(getDialect())
+ .setTable("events")
+ .setName("events_component_uuid")
+ .setUnique(false)
+ .addColumn(newVarcharColumnDefBuilder()
+ .setColumnName("component_uuid")
+ .setLimit(VarcharColumnDef.UUID_VARCHAR_SIZE)
+ .setIsNullable(false)
+ .build())
+ .build());
+ }
+}
@Test
public void verify_migration_count() {
- verifyMigrationCount(underTest, 3);
+ verifyMigrationCount(underTest, 7);
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v65;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+public class DropIndexEventsComponentUuidTest {
+ private static final String TABLE_EVENTS = "events";
+ private static final String INDEX_EVENTS_COMPONENT_UUID = "events_component_uuid";
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(DropIndexEventsComponentUuidTest.class, "events.sql");
+
+ private DropIndexEventsComponentUuid underTest = new DropIndexEventsComponentUuid(db.database());
+
+ @Test
+ public void execute_drops_index_EVENTS_COMPONENT_UUID() throws SQLException {
+ db.assertIndex(TABLE_EVENTS, INDEX_EVENTS_COMPONENT_UUID, "component_uuid");
+
+ underTest.execute();
+
+ db.assertIndexDoesNotExist(TABLE_EVENTS, INDEX_EVENTS_COMPONENT_UUID);
+ }
+}
+
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v65;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Random;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
+
+public class MakeEventsComponentUuidNotNullableTest {
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeEventsComponentUuidNotNullableTest.class, "events.sql");
+
+ private final Random random = new Random();
+ private MakeEventsComponentUuidNotNullable underTest = new MakeEventsComponentUuidNotNullable(db.database());
+
+ @Test
+ public void execute_makes_column_component_uuid_not_nullable_on_empty_table() throws SQLException {
+ underTest.execute();
+
+ verifyColumn();
+ }
+
+ @Test
+ public void execute_makes_column_component_uuid_not_nullable_on_populated_table() throws SQLException {
+ insertEvent();
+ insertEvent();
+ insertEvent();
+
+ underTest.execute();
+
+ verifyColumn();
+ }
+
+ private void verifyColumn() {
+ db.assertColumnDefinition("events", "component_uuid", Types.VARCHAR, 50, false);
+ }
+
+ private void insertEvent() {
+ db.executeInsert(
+ "events",
+ "UUID", randomAlphabetic(5),
+ "ANALYSIS_UUID", randomAlphabetic(5),
+ "COMPONENT_UUID", randomAlphabetic(5),
+ "EVENT_DATE", random.nextInt(),
+ "CREATED_AT", random.nextInt());
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v65;
+
+import java.sql.SQLException;
+import java.util.Random;
+import java.util.stream.Stream;
+import javax.annotation.Nullable;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class PopulateEventsComponentUuidTest {
+ private static final String TABLE_EVENTS = "events";
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateEventsComponentUuidTest.class, "events_and_snapshots.sql");
+
+ private final Random random = new Random();
+
+ private PopulateEventsComponentUuid underTest = new PopulateEventsComponentUuid(db.database());
+
+ @Test
+ public void execute_has_no_effect_if_table_is_empty() throws SQLException {
+ underTest.execute();
+ }
+
+ @Test
+ public void execute_deletes_all_events_if_snapshots_is_empty() throws SQLException {
+ insertEvent(randomAlphabetic(5), null);
+ insertEvent(randomAlphabetic(5), randomAlphabetic(10));
+
+ underTest.execute();
+
+ assertThat(getAllEventUuids()).isEmpty();
+ }
+
+ @Test
+ public void execute_populates_components_uuid_of_events_which_analysis_exists() throws SQLException {
+ String componentUuid = "foo";
+ String existingAnalysisUuid = insertSnapshot(componentUuid);
+ String missingAnalysisUuid = randomAlphabetic(5);
+ String uuid = insertEvent(existingAnalysisUuid, null);
+ insertEvent(missingAnalysisUuid, null);
+
+ underTest.execute();
+
+ assertThat(getAllEventUuids()).containsOnly(uuid);
+ assertThat(getComponentUuidOf(uuid)).isEqualTo(componentUuid);
+ }
+
+ @Test
+ public void execute_fixes_inconsistent_component_uuid_of_event_which_analysis_exists() throws SQLException {
+ String analysisUuid1 = insertSnapshot("foo");
+ String analysisUuid2 = insertSnapshot("bar");
+ String eventUuid1 = insertEvent(analysisUuid1, "foo");
+ String eventUuid2 = insertEvent(analysisUuid2, "moh");
+
+ underTest.execute();
+
+ assertThat(getAllEventUuids()).containsOnly(eventUuid1, eventUuid2);
+ assertThat(getComponentUuidOf(eventUuid1)).isEqualTo("foo");
+ assertThat(getComponentUuidOf(eventUuid2)).isEqualTo("bar");
+ }
+
+ @Test
+ public void execute_deletes_events_without_component_uuid_which_analysis_does_not_exist() throws SQLException {
+ String analysisUuid1 = insertSnapshot("foo");
+ String eventUuid1 = insertEvent(analysisUuid1, "foo");
+ insertEvent(randomAlphabetic(3), "moh");
+ insertEvent(randomAlphabetic(3), null);
+
+ underTest.execute();
+
+ assertThat(getAllEventUuids()).containsOnly(eventUuid1);
+ }
+
+ private String insertSnapshot(String componentUuid) {
+ String uuid = randomAlphabetic(10);
+ db.executeInsert(
+ "snapshots",
+ "UUID", uuid,
+ "COMPONENT_UUID", componentUuid,
+ "STATUS", "U",
+ "ISLAST", String.valueOf(true));
+ return uuid;
+ }
+
+ private String insertEvent(String analysisUuid, @Nullable String componentUuid) {
+ String uuid = randomAlphabetic(5);
+ db.executeInsert(
+ TABLE_EVENTS,
+ "UUID", uuid,
+ "ANALYSIS_UUID", analysisUuid,
+ "COMPONENT_UUID", componentUuid,
+ "EVENT_DATE", random.nextInt(),
+ "CREATED_AT", random.nextInt());
+ return uuid;
+ }
+
+ private Stream<String> getAllEventUuids() {
+ return db.select("select uuid as \"UUID\" from events").stream().map(row -> (String) row.get("UUID"));
+ }
+
+ private String getComponentUuidOf(String eventUuid) {
+ return (String) db.selectFirst("select component_uuid as \"COMPONENT_UUID\" from events where uuid = '" + eventUuid + "'")
+ .get("COMPONENT_UUID");
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v65;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+public class RecreateIndexEventsComponentUuidTest {
+ private static final String TABLE_EVENTS = "events";
+ private static final String INDEX_EVENTS_COMPONENT_UUID = "events_component_uuid";
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(RecreateIndexEventsComponentUuidTest.class, "events.sql");
+
+ private RecreateIndexEventsComponentUuid underTest = new RecreateIndexEventsComponentUuid(db.database());
+
+ @Test
+ public void execute_adds_index_EVENTS_COMPONENT_UUID() throws SQLException {
+ db.assertIndexDoesNotExist(TABLE_EVENTS, INDEX_EVENTS_COMPONENT_UUID);
+
+ underTest.execute();
+
+ db.assertIndex(TABLE_EVENTS, INDEX_EVENTS_COMPONENT_UUID, "component_uuid");
+ }
+}
--- /dev/null
+CREATE TABLE "EVENTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "UUID" VARCHAR(40) NOT NULL,
+ "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)
+);
+CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID");
+CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID");
+CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID");
--- /dev/null
+CREATE TABLE "EVENTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "UUID" VARCHAR(40) NOT NULL,
+ "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)
+);
+CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID");
+CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID");
+CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID");
--- /dev/null
+CREATE TABLE "EVENTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "UUID" VARCHAR(40) NOT NULL,
+ "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)
+);
+CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID");
+CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID");
+CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID");
+
+CREATE TABLE "SNAPSHOTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "UUID" VARCHAR(50) NOT NULL,
+ "CREATED_AT" BIGINT,
+ "BUILD_DATE" BIGINT,
+ "COMPONENT_UUID" VARCHAR(50) NOT NULL,
+ "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U',
+ "PURGE_STATUS" INTEGER,
+ "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE,
+ "VERSION" VARCHAR(500),
+ "PERIOD1_MODE" VARCHAR(100),
+ "PERIOD1_PARAM" VARCHAR(100),
+ "PERIOD1_DATE" BIGINT,
+ "PERIOD2_MODE" VARCHAR(100),
+ "PERIOD2_PARAM" VARCHAR(100),
+ "PERIOD2_DATE" BIGINT,
+ "PERIOD3_MODE" VARCHAR(100),
+ "PERIOD3_PARAM" VARCHAR(100),
+ "PERIOD3_DATE" BIGINT,
+ "PERIOD4_MODE" VARCHAR(100),
+ "PERIOD4_PARAM" VARCHAR(100),
+ "PERIOD4_DATE" BIGINT,
+ "PERIOD5_MODE" VARCHAR(100),
+ "PERIOD5_PARAM" VARCHAR(100),
+ "PERIOD5_DATE" BIGINT
+);
+CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID");
+CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID");
--- /dev/null
+CREATE TABLE "EVENTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "UUID" VARCHAR(40) NOT NULL,
+ "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)
+);
+CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS" ("ANALYSIS_UUID");
+CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS" ("UUID");