"COMPONENT_UUID" CHARACTER VARYING(40),
"STATUS" CHARACTER VARYING(15) NOT NULL,
"MAIN_IS_LAST" BOOLEAN NOT NULL,
- "MAIN_IS_LAST_KEY" CHARACTER VARYING(55) NOT NULL,
+ "MAIN_IS_LAST_KEY" CHARACTER VARYING(80) NOT NULL,
"IS_LAST" BOOLEAN NOT NULL,
- "IS_LAST_KEY" CHARACTER VARYING(55) NOT NULL,
+ "IS_LAST_KEY" CHARACTER VARYING(80) NOT NULL,
"SUBMITTER_UUID" CHARACTER VARYING(255),
"SUBMITTED_AT" BIGINT NOT NULL,
"STARTED_AT" BIGINT,
// ignoring bad number formatting, as it's indented that we align the migration numbers to SQ versions
@SuppressWarnings("java:S3937")
public class DbVersion102 implements DbVersion {
-
/**
* We use the start of the 10.X cycle as an opportunity to align migration numbers with the SQ version number.
* Please follow this pattern:
.add(10_2_028, "Drop column 'created_at' in 'components' table", DropCreatedAtInComponents.class)
.add(10_2_029, "Rename column 'created_at_temp' to 'created_at' in 'components' table", RenameCreatedAtTempInComponents.class)
- .add(10_2_030, "Create table 'anticipated_transitions'", CreateAnticipatedTransitionsTable.class);
+ .add(10_2_030, "Create table 'anticipated_transitions'", CreateAnticipatedTransitionsTable.class)
+
+ .add(10_2_031, "Increase size of 'ce_queue.is_last_key' from 55 to 80 characters", IncreaseIsLastKeyInCeActivity.class)
+ .add(10_2_032, "Increase size of 'ce_queue.main_is_last_key' from 55 to 80 characters", IncreaseMainIsLastKeyInCeActivity.class);
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v102;
+
+import com.google.common.annotations.VisibleForTesting;
+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;
+
+public class IncreaseIsLastKeyInCeActivity extends DdlChange {
+ @VisibleForTesting
+ static final String TABLE_NAME = "ce_activity";
+ @VisibleForTesting
+ static final String COLUMN_NAME = "is_last_key";
+ @VisibleForTesting
+ static final int NEW_COLUMN_SIZE = 80;
+
+ private static final VarcharColumnDef COLUMN_DEFINITION = VarcharColumnDef.newVarcharColumnDefBuilder()
+ .setColumnName(COLUMN_NAME)
+ .setLimit(NEW_COLUMN_SIZE)
+ .setIsNullable(false)
+ .build();
+
+ public IncreaseIsLastKeyInCeActivity(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(DdlChange.Context context) throws SQLException {
+ context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME)
+ .updateColumn(COLUMN_DEFINITION)
+ .build());
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v102;
+
+import com.google.common.annotations.VisibleForTesting;
+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;
+
+public class IncreaseMainIsLastKeyInCeActivity extends DdlChange {
+
+ @VisibleForTesting
+ static final String TABLE_NAME = "ce_activity";
+ @VisibleForTesting
+ static final String COLUMN_NAME = "main_is_last_key";
+ @VisibleForTesting
+ static final int NEW_COLUMN_SIZE = 80;
+
+ private static final VarcharColumnDef COLUMN_DEFINITION = VarcharColumnDef.newVarcharColumnDefBuilder()
+ .setColumnName(COLUMN_NAME)
+ .setLimit(NEW_COLUMN_SIZE)
+ .setIsNullable(false)
+ .build();
+
+ public IncreaseMainIsLastKeyInCeActivity(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(DdlChange.Context context) throws SQLException {
+ context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME)
+ .updateColumn(COLUMN_DEFINITION)
+ .build());
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v102;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static java.sql.Types.VARCHAR;
+import static org.sonar.server.platform.db.migration.version.v102.IncreaseIsLastKeyInCeActivity.COLUMN_NAME;
+import static org.sonar.server.platform.db.migration.version.v102.IncreaseIsLastKeyInCeActivity.NEW_COLUMN_SIZE;
+import static org.sonar.server.platform.db.migration.version.v102.IncreaseIsLastKeyInCeActivity.TABLE_NAME;
+
+public class IncreaseIsLastKeyInCeActivityTest {
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(IncreaseIsLastKeyInCeActivityTest.class, "schema.sql");
+
+ private final IncreaseIsLastKeyInCeActivity underTest = new IncreaseIsLastKeyInCeActivity(db.database());
+
+ @Test
+ public void execute_increaseColumnSize() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 55, false);
+ underTest.execute();
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 55, false);
+ underTest.execute();
+ underTest.execute();
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.v102;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static java.sql.Types.VARCHAR;
+import static org.sonar.server.platform.db.migration.version.v102.IncreaseMainIsLastKeyInCeActivity.COLUMN_NAME;
+import static org.sonar.server.platform.db.migration.version.v102.IncreaseMainIsLastKeyInCeActivity.NEW_COLUMN_SIZE;
+import static org.sonar.server.platform.db.migration.version.v102.IncreaseMainIsLastKeyInCeActivity.TABLE_NAME;
+
+public class IncreaseMainIsLastKeyInCeActivityTest {
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(IncreaseMainIsLastKeyInCeActivityTest.class, "schema.sql");
+
+ private final IncreaseMainIsLastKeyInCeActivity underTest = new IncreaseMainIsLastKeyInCeActivity(db.database());
+
+ @Test
+ public void execute_increaseColumnSize() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 55, false);
+ underTest.execute();
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 55, false);
+ underTest.execute();
+ underTest.execute();
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
+ }
+
+}
--- /dev/null
+CREATE TABLE "CE_ACTIVITY"(
+ "UUID" CHARACTER VARYING(40) NOT NULL,
+ "TASK_TYPE" CHARACTER VARYING(40) NOT NULL,
+ "ENTITY_UUID" CHARACTER VARYING(40),
+ "COMPONENT_UUID" CHARACTER VARYING(40),
+ "STATUS" CHARACTER VARYING(15) NOT NULL,
+ "MAIN_IS_LAST" BOOLEAN NOT NULL,
+ "MAIN_IS_LAST_KEY" CHARACTER VARYING(55) NOT NULL,
+ "IS_LAST" BOOLEAN NOT NULL,
+ "IS_LAST_KEY" CHARACTER VARYING(55) NOT NULL,
+ "SUBMITTER_UUID" CHARACTER VARYING(255),
+ "SUBMITTED_AT" BIGINT NOT NULL,
+ "STARTED_AT" BIGINT,
+ "EXECUTED_AT" BIGINT,
+ "EXECUTION_COUNT" INTEGER NOT NULL,
+ "EXECUTION_TIME_MS" BIGINT,
+ "ANALYSIS_UUID" CHARACTER VARYING(50),
+ "ERROR_MESSAGE" CHARACTER VARYING(1000),
+ "ERROR_STACKTRACE" CHARACTER LARGE OBJECT,
+ "ERROR_TYPE" CHARACTER VARYING(20),
+ "WORKER_UUID" CHARACTER VARYING(40),
+ "CREATED_AT" BIGINT NOT NULL,
+ "UPDATED_AT" BIGINT NOT NULL,
+ "NODE_NAME" CHARACTER VARYING(100)
+);
+ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("UUID");
+CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST" NULLS FIRST, "STATUS" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST" NULLS FIRST, "STATUS" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_ENTITY_UUID" ON "CE_ACTIVITY"("ENTITY_UUID" NULLS FIRST);
--- /dev/null
+CREATE TABLE "CE_ACTIVITY"(
+ "UUID" CHARACTER VARYING(40) NOT NULL,
+ "TASK_TYPE" CHARACTER VARYING(40) NOT NULL,
+ "ENTITY_UUID" CHARACTER VARYING(40),
+ "COMPONENT_UUID" CHARACTER VARYING(40),
+ "STATUS" CHARACTER VARYING(15) NOT NULL,
+ "MAIN_IS_LAST" BOOLEAN NOT NULL,
+ "MAIN_IS_LAST_KEY" CHARACTER VARYING(55) NOT NULL,
+ "IS_LAST" BOOLEAN NOT NULL,
+ "IS_LAST_KEY" CHARACTER VARYING(55) NOT NULL,
+ "SUBMITTER_UUID" CHARACTER VARYING(255),
+ "SUBMITTED_AT" BIGINT NOT NULL,
+ "STARTED_AT" BIGINT,
+ "EXECUTED_AT" BIGINT,
+ "EXECUTION_COUNT" INTEGER NOT NULL,
+ "EXECUTION_TIME_MS" BIGINT,
+ "ANALYSIS_UUID" CHARACTER VARYING(50),
+ "ERROR_MESSAGE" CHARACTER VARYING(1000),
+ "ERROR_STACKTRACE" CHARACTER LARGE OBJECT,
+ "ERROR_TYPE" CHARACTER VARYING(20),
+ "WORKER_UUID" CHARACTER VARYING(40),
+ "CREATED_AT" BIGINT NOT NULL,
+ "UPDATED_AT" BIGINT NOT NULL,
+ "NODE_NAME" CHARACTER VARYING(100)
+);
+ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("UUID");
+CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST" NULLS FIRST, "STATUS" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST" NULLS FIRST, "STATUS" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY" NULLS FIRST);
+CREATE INDEX "CE_ACTIVITY_ENTITY_UUID" ON "CE_ACTIVITY"("ENTITY_UUID" NULLS FIRST);