"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_COMPONENT" ON "CE_ACTIVITY"("ENTITY_UUID" 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);
public class DropIndexMainComponentUuidInCeActivity extends DropIndexChange {
private static final String TABLE_NAME = "ce_activity";
- private static final String INDEX_NAME = "ce_activity_component";
+ private static final String INDEX_NAME = "ce_activity_main_component";
public DropIndexMainComponentUuidInCeActivity(Database db) {
super(db, INDEX_NAME, TABLE_NAME);
db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME);
}
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+
+ underTest.execute();
+ underTest.execute();
+
+ db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
}
--- /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;
+
+public class DropIndexComponentUuidInUserRolesTest {
+
+ private static final String TABLE_NAME = "user_roles";
+ private static final String COLUMN_NAME = "component_uuid";
+ private static final String INDEX_NAME = "user_roles_component_uuid";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexComponentUuidInUserRolesTest.class, "schema.sql");
+
+ private final RenameComponentUuidInUserRoles underTest = new RenameComponentUuidInUserRoles(db.database());
+
+ @Test
+ public void index_is_dropped() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+
+ underTest.execute();
+
+ db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+
+ underTest.execute();
+ underTest.execute();
+
+ db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+}
--- /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;
+
+public class DropIndexMainComponentUuidInCeActivityTest {
+
+ private static final String TABLE_NAME = "ce_activity";
+ private static final String COLUMN_NAME = "main_component_uuid";
+ private static final String INDEX_NAME = "ce_activity_main_component";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexMainComponentUuidInCeActivityTest.class, "schema.sql");
+
+ private final DropIndexMainComponentUuidInCeActivity underTest = new DropIndexMainComponentUuidInCeActivity(db.database());
+
+ @Test
+ public void index_is_dropped() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+
+ underTest.execute();
+
+ db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+
+ underTest.execute();
+ underTest.execute();
+
+ db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+}
--- /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;
+
+public class DropIndexMainComponentUuidInCeQueueTest {
+
+ private static final String TABLE_NAME = "ce_queue";
+ private static final String COLUMN_NAME = "main_component_uuid";
+ private static final String INDEX_NAME = "ce_queue_main_component";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexMainComponentUuidInCeQueueTest.class, "schema.sql");
+
+ private final DropIndexMainComponentUuidInCeQueue underTest = new DropIndexMainComponentUuidInCeQueue(db.database());
+
+ @Test
+ public void index_is_dropped() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+
+ underTest.execute();
+
+ db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+
+ underTest.execute();
+ underTest.execute();
+
+ db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+}
--- /dev/null
+CREATE TABLE "USER_ROLES"(
+ "UUID" CHARACTER VARYING(40) NOT NULL,
+ "ROLE" CHARACTER VARYING(64) NOT NULL,
+ "COMPONENT_UUID" CHARACTER VARYING(40),
+ "USER_UUID" CHARACTER VARYING(255)
+);
+ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID");
+CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID" NULLS FIRST);
+CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_UUID" NULLS FIRST);
--- /dev/null
+CREATE TABLE "CE_ACTIVITY"(
+ "UUID" CHARACTER VARYING(40) NOT NULL,
+ "TASK_TYPE" CHARACTER VARYING(40) NOT NULL,
+ "MAIN_COMPONENT_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_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID" 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);
--- /dev/null
+CREATE TABLE "CE_QUEUE"(
+ "UUID" CHARACTER VARYING(40) NOT NULL,
+ "TASK_TYPE" CHARACTER VARYING(40) NOT NULL,
+ "MAIN_COMPONENT_UUID" CHARACTER VARYING(40),
+ "COMPONENT_UUID" CHARACTER VARYING(40),
+ "STATUS" CHARACTER VARYING(15),
+ "SUBMITTER_UUID" CHARACTER VARYING(255),
+ "STARTED_AT" BIGINT,
+ "WORKER_UUID" CHARACTER VARYING(40),
+ "EXECUTION_COUNT" INTEGER NOT NULL,
+ "CREATED_AT" BIGINT NOT NULL,
+ "UPDATED_AT" BIGINT NOT NULL
+);
+ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("UUID");
+CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID" NULLS FIRST);
+CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID" NULLS FIRST);