"PURGE_STATUS" INTEGER,
"ISLAST" BOOLEAN NOT NULL DEFAULT FALSE,
"VERSION" VARCHAR(500),
- "PROJECT_VERSION" VARCHAR(100),
"BUILD_STRING" VARCHAR(100),
"PERIOD1_MODE" VARCHAR(100),
"PERIOD1_PARAM" VARCHAR(100),
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<analysis_properties uuid="u1"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<!-- do not delete standard measure -->
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
build_string="[null]"
/>
<analysis_properties uuid="u1"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<analysis_properties uuid="u2"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<analysis_properties uuid="u1"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<analysis_properties uuid="u2"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
build_string="[null]"
/>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
</dataset>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<!-- snapshot with status "unprocessed" -> to be deleted -->
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<!-- snapshot with status "processed" and flagged as "last" -> do not purge and do not delete -->
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
</dataset>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
build_string="[null]"
/>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
</dataset>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<!-- delete only resource 1 -->
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<!-- to be deleted -->
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
</dataset>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
build_string="[null]"
/>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<project_measures id="5"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<project_measures id="1"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<project_measures id="5"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<issues id="1"
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
build_string="[null]"
/>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<!-- snapshot to be purged -->
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
</dataset>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
<!-- snapshot to be purged -->
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- project_version="[null]"
+ build_string="[null]"
/>
</dataset>
.add(2609, "Delete exceeding favorites when there are more than 100 for a user", DeleteFavoritesExceedingOneHundred.class)
.add(2610, "Truncate ES_QUEUE table content", TruncateEsQueue.class)
.add(2611, "Add SNAPSHOTS.BUILD_STRING", AddBuildStringToSnapshot.class)
+ // FIXME after deployment on SonarCloud, drop this and "Add SNAPSHOTS.PROJECT_VERSION" above as they cancel out each other
+ .add(2612, "Drop SNAPSHOTS.PROJECT_VERSION", DropProjectVersionFromSnapshots.class)
;
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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.v77;
+
+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 DropProjectVersionFromSnapshots extends DdlChange {
+
+ private static final String TABLE_NAME = "snapshots";
+
+ public DropProjectVersionFromSnapshots(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "project_version")
+ .build());
+ }
+}
@Test
public void verify_migration_count() {
- verifyMigrationCount(underTest, 12);
+ verifyMigrationCount(underTest, 13);
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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.v77;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+
+public class DropProjectVersionFromSnapshotsTest {
+
+ private static final String TABLE = "snapshots";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropProjectVersionFromSnapshotsTest.class, "snapshots.sql");
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private DropProjectVersionFromSnapshots underTest = new DropProjectVersionFromSnapshots(db.database());
+
+ @Test
+ public void drop_column_and_recreate_index() throws SQLException {
+ underTest.execute();
+
+ db.assertColumnDoesNotExist(TABLE, "project_version");
+ }
+
+ @Test
+ public void migration_is_not_re_entrant() throws SQLException {
+ underTest.execute();
+
+ expectedException.expect(IllegalStateException.class);
+
+ underTest.execute();
+ }
+
+}
--- /dev/null
+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),
+ "PROJECT_VERSION" VARCHAR(100),
+ "BUILD_STRING" VARCHAR(100),
+ "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");