aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-migration
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2022-05-05 15:46:04 +0200
committersonartech <sonartech@sonarsource.com>2022-05-06 20:02:44 +0000
commit8ff29997967ef820c0e8d534cedf0e2cf2e1dad2 (patch)
treea570fa0cb0a3510ae63252e0620e0766a635ab5f /server/sonar-db-migration
parent85249a5a2a2de92eb547be3825520a9dd5fd8ddf (diff)
downloadsonarqube-8ff29997967ef820c0e8d534cedf0e2cf2e1dad2.tar.gz
sonarqube-8ff29997967ef820c0e8d534cedf0e2cf2e1dad2.zip
SONAR-16302 drop rules_metadata created_at and updated_at
Diffstat (limited to 'server/sonar-db-migration')
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DbVersion95.java4
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumn.java33
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumn.java33
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumnTest.java57
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumnTest.java57
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumnTest/schema.sql18
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumnTest/schema.sql17
7 files changed, 218 insertions, 1 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DbVersion95.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DbVersion95.java
index 2306f580e56..bbdc14b3587 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DbVersion95.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DbVersion95.java
@@ -34,6 +34,8 @@ public class DbVersion95 implements DbVersion {
.add(6406, "Insert description from RULES into RULE_DESC_SECTIONS", InsertRuleDescriptionIntoRuleDescSections.class)
.add(6407, "Create index for RULE_DESC_SECTIONS", CreateIndexForRuleDescSections.class)
.add(6408, "Drop column DESCRIPTIONS from RULES table", DropRuleDescriptionColumn.class)
- ;
+ .add(6409, "Drop column CREATED_AT from RULES_METADATA table", DropRuleMetadataCreatedAtColumn.class)
+ .add(6410, "Drop column UPDATED_AT from RULES_METADATA table", DropRuleMetadataUpdatedAtColumn.class)
+ ;
}
}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumn.java
new file mode 100644
index 00000000000..2c63b6fd1c5
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumn.java
@@ -0,0 +1,33 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v95;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropRuleMetadataCreatedAtColumn extends DropColumnChange {
+
+ private static final String TABLE_NAME = "rules_metadata";
+ private static final String COLUMN_NAME = "created_at";
+
+ protected DropRuleMetadataCreatedAtColumn(Database db) {
+ super(db, TABLE_NAME, COLUMN_NAME);
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumn.java
new file mode 100644
index 00000000000..c279abf35a6
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumn.java
@@ -0,0 +1,33 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v95;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropRuleMetadataUpdatedAtColumn extends DropColumnChange {
+
+ private static final String TABLE_NAME = "rules_metadata";
+ private static final String COLUMN_NAME = "updated_at";
+
+ protected DropRuleMetadataUpdatedAtColumn(Database db) {
+ super(db, TABLE_NAME, COLUMN_NAME);
+ }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumnTest.java
new file mode 100644
index 00000000000..57727eb8c3a
--- /dev/null
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumnTest.java
@@ -0,0 +1,57 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v95;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropRuleMetadataCreatedAtColumnTest {
+
+ private static final String COLUMN_NAME = "created_at";
+ private static final String TABLE_NAME = "rules_metadata";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropRuleMetadataCreatedAtColumnTest.class, "schema.sql");
+
+ private final DdlChange underTest = new DropRuleMetadataCreatedAtColumn(db.database());
+
+ @Test
+ public void migration_should_drop_created_at_column() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.BIGINT,null, false);
+
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+ @Test
+ public void migration_should_be_reentrant() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.BIGINT,null, false);
+ underTest.execute();
+ // re-entrant
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+
+} \ No newline at end of file
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumnTest.java
new file mode 100644
index 00000000000..57b27181c99
--- /dev/null
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumnTest.java
@@ -0,0 +1,57 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v95;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropRuleMetadataUpdatedAtColumnTest {
+
+ private static final String COLUMN_NAME = "updated_at";
+ private static final String TABLE_NAME = "rules_metadata";
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropRuleMetadataUpdatedAtColumnTest.class, "schema.sql");
+
+ private final DdlChange underTest = new DropRuleMetadataUpdatedAtColumn(db.database());
+
+ @Test
+ public void migration_should_drop_created_at_column() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.BIGINT,null, false);
+
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+ @Test
+ public void migration_should_be_reentrant() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.BIGINT,null, false);
+ underTest.execute();
+ // re-entrant
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+
+} \ No newline at end of file
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumnTest/schema.sql
new file mode 100644
index 00000000000..49d4e7c43c0
--- /dev/null
+++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataCreatedAtColumnTest/schema.sql
@@ -0,0 +1,18 @@
+CREATE TABLE "RULES_METADATA"(
+ "RULE_UUID" CHARACTER VARYING(40) NOT NULL,
+ "NOTE_DATA" CHARACTER LARGE OBJECT,
+ "NOTE_USER_UUID" CHARACTER VARYING(255),
+ "NOTE_CREATED_AT" BIGINT,
+ "NOTE_UPDATED_AT" BIGINT,
+ "REMEDIATION_FUNCTION" CHARACTER VARYING(20),
+ "REMEDIATION_GAP_MULT" CHARACTER VARYING(20),
+ "REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20),
+ "TAGS" CHARACTER VARYING(4000),
+ "AD_HOC_NAME" CHARACTER VARYING(200),
+ "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT,
+ "AD_HOC_SEVERITY" CHARACTER VARYING(10),
+ "AD_HOC_TYPE" TINYINT,
+ "CREATED_AT" BIGINT NOT NULL,
+ "UPDATED_AT" BIGINT NOT NULL
+);
+ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumnTest/schema.sql
new file mode 100644
index 00000000000..21d18ad1a28
--- /dev/null
+++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v95/DropRuleMetadataUpdatedAtColumnTest/schema.sql
@@ -0,0 +1,17 @@
+CREATE TABLE "RULES_METADATA"(
+ "RULE_UUID" CHARACTER VARYING(40) NOT NULL,
+ "NOTE_DATA" CHARACTER LARGE OBJECT,
+ "NOTE_USER_UUID" CHARACTER VARYING(255),
+ "NOTE_CREATED_AT" BIGINT,
+ "NOTE_UPDATED_AT" BIGINT,
+ "REMEDIATION_FUNCTION" CHARACTER VARYING(20),
+ "REMEDIATION_GAP_MULT" CHARACTER VARYING(20),
+ "REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20),
+ "TAGS" CHARACTER VARYING(4000),
+ "AD_HOC_NAME" CHARACTER VARYING(200),
+ "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT,
+ "AD_HOC_SEVERITY" CHARACTER VARYING(10),
+ "AD_HOC_TYPE" TINYINT,
+ "UPDATED_AT" BIGINT NOT NULL
+);
+ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_UUID");