]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13903 move to v86 & add organization_uuid index deletion from quality_profile...
authorPierre <pierre.guillot@sonarsource.com>
Tue, 6 Oct 2020 08:28:27 +0000 (10:28 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 7 Oct 2020 20:07:44 +0000 (20:07 +0000)
37 files changed:
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfiles.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DbVersion85.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPk.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfiles.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTable.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadata.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfiles.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTable.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfilesTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPkTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfilesTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTableTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadataTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86Test.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfilesTest/schema.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPkTest/schema.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfilesTest/schema.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTableTest/schema.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadataTest/schema.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest/schema.sql [new file with mode: 0644]

index afca486ff3486a1742240e592936c8d007527374..373250ca965a4f76e8bbac8d4f69f5fc452eaefb 100644 (file)
@@ -33,6 +33,7 @@ import org.sonar.server.platform.db.migration.version.v84.DbVersion84;
 import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper;
 import org.sonar.server.platform.db.migration.version.v85.DbVersion85;
+import org.sonar.server.platform.db.migration.version.v86.DbVersion86;
 
 public class MigrationConfigurationModule extends Module {
   @Override
@@ -46,6 +47,7 @@ public class MigrationConfigurationModule extends Module {
       DbVersion83.class,
       DbVersion84.class,
       DbVersion85.class,
+      DbVersion86.class,
 
       // migration steps
       MigrationStepRegistryImpl.class,
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfiles.java
deleted file mode 100644 (file)
index 5f0b048..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-import java.sql.SQLException;
-import org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder;
-
-public class AddPrimaryKeyToDefaultQProfiles extends DdlChange {
-  public AddPrimaryKeyToDefaultQProfiles(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new AddPrimaryKeyBuilder("default_qprofiles", "language").build());
-  }
-}
index c11641605a65a82e7533d74601a661e24a772f57..4eb5e5d871c52b41baebdd3aae93ba64bb90a2fe 100644 (file)
@@ -55,11 +55,6 @@ public class DbVersion85 implements DbVersion {
       .add(4024, "Populate 'branch_type' in 'project_branches'", FillProjectBranchesBranchType.class)
       .add(4025, "Make 'branch_type' in 'project_branches' not nullable", MakeProjectBranchesBranchTypeNotNullable.class)
       .add(4026, "Drop column 'key_type' in table 'project_branches'", DropProjectBranchesKeyType.class)
-      .add(4027, "Drop organization_uuid from 'quality_profile' table", DropOrganizationFromQualityProfileTable.class)
-      .add(4028, "Drop primary key of table 'default_qprofiles'", DropDefaultQProfilesPk.class)
-      .add(4029, "Drop organization_uuid from 'default_qprofiles' table", DropOrganizationFromDefaultQProfiles.class)
-      .add(4030, "Add primary key to the table 'default_qprofiles", AddPrimaryKeyToDefaultQProfiles.class)
-      .add(4031, "Drop 'organization_uuid' in 'rules_metadata'", DropOrganizationInRulesMetadata.class)
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPk.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPk.java
deleted file mode 100644 (file)
index ac4e274..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-import java.sql.SQLException;
-import org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.sql.DropConstraintBuilder;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-
-public class DropDefaultQProfilesPk extends DdlChange {
-  public DropDefaultQProfilesPk(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new DropConstraintBuilder(getDialect()).setName("pk_default_qprofiles").setTable("default_qprofiles").build());
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfiles.java
deleted file mode 100644 (file)
index 0c5fad1..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-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 DropOrganizationFromDefaultQProfiles extends DdlChange {
-  public DropOrganizationFromDefaultQProfiles(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new DropColumnsBuilder(getDialect(), "default_qprofiles", "organization_uuid").build());
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTable.java
deleted file mode 100644 (file)
index 441b165..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-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 DropOrganizationFromQualityProfileTable extends DdlChange {
-
-  public DropOrganizationFromQualityProfileTable(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new DropColumnsBuilder(getDialect(), "org_qprofiles", "organization_uuid").build());
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadata.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadata.java
deleted file mode 100644 (file)
index 6348aad..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-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.sql.DropConstraintBuilder;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder;
-
-public class DropOrganizationInRulesMetadata extends DdlChange {
-  private static final String TABLE_NAME = "rules_metadata";
-
-  public DropOrganizationInRulesMetadata(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new DropConstraintBuilder(getDialect()).setName("pk_rules_metadata").setTable(TABLE_NAME).build());
-    context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build());
-    context.execute(new AddPrimaryKeyBuilder(TABLE_NAME, "rule_uuid").build());
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java
new file mode 100644 (file)
index 0000000..5ff6fa5
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder;
+
+public class AddPrimaryKeyToDefaultQProfiles extends DdlChange {
+  public AddPrimaryKeyToDefaultQProfiles(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AddPrimaryKeyBuilder("default_qprofiles", "language").build());
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java
new file mode 100644 (file)
index 0000000..8b0e893
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import org.sonar.server.platform.db.migration.step.MigrationStepRegistry;
+import org.sonar.server.platform.db.migration.version.DbVersion;
+
+public class DbVersion86 implements DbVersion {
+
+  @Override
+  public void addSteps(MigrationStepRegistry registry) {
+    registry
+      .add(4100, "Drop QPROFILES_ORG_UUID index from 'quality_profile' table", DropOrganizationUuidIndexFromQualityProfileTable.class)
+      .add(4101, "Drop organization_uuid from 'quality_profile' table", DropOrganizationFromQualityProfileTable.class)
+      .add(4102, "Drop primary key of table 'default_qprofiles'", DropDefaultQProfilesPk.class)
+      .add(4103, "Drop organization_uuid from 'default_qprofiles' table", DropOrganizationFromDefaultQProfiles.class)
+      .add(4104, "Add primary key to the table 'default_qprofiles", AddPrimaryKeyToDefaultQProfiles.class)
+      .add(4105, "Drop 'organization_uuid' in 'rules_metadata'", DropOrganizationInRulesMetadata.class)
+    ;
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java
new file mode 100644 (file)
index 0000000..f9408bb
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.DropConstraintBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropDefaultQProfilesPk extends DdlChange {
+  public DropDefaultQProfilesPk(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropConstraintBuilder(getDialect()).setName("pk_default_qprofiles").setTable("default_qprofiles").build());
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfiles.java
new file mode 100644 (file)
index 0000000..0c52552
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+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 DropOrganizationFromDefaultQProfiles extends DdlChange {
+  public DropOrganizationFromDefaultQProfiles(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropColumnsBuilder(getDialect(), "default_qprofiles", "organization_uuid").build());
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTable.java
new file mode 100644 (file)
index 0000000..ea9ca73
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+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 DropOrganizationFromQualityProfileTable extends DdlChange {
+
+  public DropOrganizationFromQualityProfileTable(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropColumnsBuilder(getDialect(), "org_qprofiles", "organization_uuid").build());
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java
new file mode 100644 (file)
index 0000000..a6b7e35
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+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.sql.DropConstraintBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder;
+
+public class DropOrganizationInRulesMetadata extends DdlChange {
+  private static final String TABLE_NAME = "rules_metadata";
+
+  public DropOrganizationInRulesMetadata(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropConstraintBuilder(getDialect()).setName("pk_rules_metadata").setTable(TABLE_NAME).build());
+    context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build());
+    context.execute(new AddPrimaryKeyBuilder(TABLE_NAME, "rule_uuid").build());
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTable.java
new file mode 100644 (file)
index 0000000..3ac9909
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropIndexChange;
+
+public class DropOrganizationUuidIndexFromQualityProfileTable extends DropIndexChange {
+  private static final String TABLE_NAME = "org_qprofiles";
+  private static final String INDEX_NAME = "qprofiles_org_uuid";
+
+  public DropOrganizationUuidIndexFromQualityProfileTable(Database db) {
+    super(db, INDEX_NAME, TABLE_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfilesTest.java
deleted file mode 100644 (file)
index bb5e8e7..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.step.MigrationStep;
-
-public class AddPrimaryKeyToDefaultQProfilesTest {
-  @Rule
-  public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyToDefaultQProfilesTest.class, "schema.sql");
-
-  private MigrationStep underTest = new AddPrimaryKeyToDefaultQProfiles(db.database());
-
-  @Test
-  public void execute() throws SQLException {
-    db.assertNoPrimaryKey("default_qprofiles");
-    underTest.execute();
-    db.assertPrimaryKey("default_qprofiles", "pk_default_qprofiles", "language");
-  }
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPkTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPkTest.java
deleted file mode 100644 (file)
index 7070feb..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.step.MigrationStep;
-
-public class DropDefaultQProfilesPkTest {
-  @Rule
-  public CoreDbTester db = CoreDbTester.createForSchema(DropDefaultQProfilesPkTest.class, "schema.sql");
-
-  private MigrationStep underTest = new DropDefaultQProfilesPk(db.database());
-
-  @Test
-  public void execute() throws SQLException {
-    db.assertPrimaryKey("default_qprofiles", "pk_default_qprofiles", "organization_uuid", "language");
-
-    underTest.execute();
-    db.assertNoPrimaryKey("default_qprofiles");
-  }
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfilesTest.java
deleted file mode 100644 (file)
index 00b40ce..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-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.MigrationStep;
-
-public class DropOrganizationFromDefaultQProfilesTest {
-  @Rule
-  public CoreDbTester db = CoreDbTester.createForSchema(DropOrganizationFromDefaultQProfilesTest.class, "schema.sql");
-
-  private MigrationStep underTest = new DropOrganizationFromDefaultQProfiles(db.database());
-
-  @Test
-  public void execute() throws SQLException {
-    db.assertColumnDefinition("default_qprofiles", "organization_uuid", Types.VARCHAR, 40, false);
-    underTest.execute();
-    db.assertColumnDoesNotExist("default_qprofiles", "organization_uuid");
-  }
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTableTest.java
deleted file mode 100644 (file)
index 27471cb..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-
-public class DropOrganizationFromQualityProfileTableTest {
-
-  @Rule
-  public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationFromQualityProfileTableTest.class, "schema.sql");
-
-  private DropOrganizationFromQualityProfileTable underTest = new DropOrganizationFromQualityProfileTable(dbTester.database());
-
-  @Test
-  public void column_has_been_dropped() throws SQLException {
-    underTest.execute();
-    dbTester.assertColumnDoesNotExist("org_qprofiles", "organization_uuid");
-  }
-
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadataTest.java
deleted file mode 100644 (file)
index 6cf2e7c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v85;
-
-import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.step.MigrationStep;
-
-public class DropOrganizationInRulesMetadataTest {
-  @Rule
-  public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInRulesMetadataTest.class, "schema.sql");
-
-  private MigrationStep underTest = new DropOrganizationInRulesMetadata(dbTester.database());
-
-  @Test
-  public void column_has_been_dropped() throws SQLException {
-    underTest.execute();
-    dbTester.assertColumnDoesNotExist("rules_metadata", "organization_uuid");
-    dbTester.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_uuid");
-  }
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest.java
new file mode 100644 (file)
index 0000000..b8f97a4
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.MigrationStep;
+
+public class AddPrimaryKeyToDefaultQProfilesTest {
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyToDefaultQProfilesTest.class, "schema.sql");
+
+  private MigrationStep underTest = new AddPrimaryKeyToDefaultQProfiles(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    db.assertNoPrimaryKey("default_qprofiles");
+    underTest.execute();
+    db.assertPrimaryKey("default_qprofiles", "pk_default_qprofiles", "language");
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86Test.java
new file mode 100644 (file)
index 0000000..6d6be3c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import org.junit.Test;
+import org.sonar.server.platform.db.migration.version.DbVersion;
+import org.sonar.server.platform.db.migration.version.v85.DbVersion85;
+
+import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty;
+import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber;
+
+public class DbVersion86Test {
+
+  private DbVersion underTest = new DbVersion86();
+
+  @Test
+  public void migrationNumber_starts_at_4100() {
+    verifyMinimumMigrationNumber(underTest, 4100);
+  }
+
+  @Test
+  public void verify_migration_count() {
+    verifyMigrationNotEmpty(underTest);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java
new file mode 100644 (file)
index 0000000..45b34c2
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.MigrationStep;
+
+public class DropDefaultQProfilesPkTest {
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropDefaultQProfilesPkTest.class, "schema.sql");
+
+  private MigrationStep underTest = new DropDefaultQProfilesPk(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    db.assertPrimaryKey("default_qprofiles", "pk_default_qprofiles", "organization_uuid", "language");
+
+    underTest.execute();
+    db.assertNoPrimaryKey("default_qprofiles");
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest.java
new file mode 100644 (file)
index 0000000..6c406e4
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+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.MigrationStep;
+
+public class DropOrganizationFromDefaultQProfilesTest {
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropOrganizationFromDefaultQProfilesTest.class, "schema.sql");
+
+  private MigrationStep underTest = new DropOrganizationFromDefaultQProfiles(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    db.assertColumnDefinition("default_qprofiles", "organization_uuid", Types.VARCHAR, 40, false);
+    underTest.execute();
+    db.assertColumnDoesNotExist("default_qprofiles", "organization_uuid");
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest.java
new file mode 100644 (file)
index 0000000..6566889
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+public class DropOrganizationFromQualityProfileTableTest {
+
+  @Rule
+  public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationFromQualityProfileTableTest.class, "schema.sql");
+
+  private DropOrganizationFromQualityProfileTable underTest = new DropOrganizationFromQualityProfileTable(dbTester.database());
+
+  @Test
+  public void column_has_been_dropped() throws SQLException {
+    underTest.execute();
+    dbTester.assertColumnDoesNotExist("org_qprofiles", "organization_uuid");
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest.java
new file mode 100644 (file)
index 0000000..26bdd43
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.MigrationStep;
+
+public class DropOrganizationInRulesMetadataTest {
+  @Rule
+  public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInRulesMetadataTest.class, "schema.sql");
+
+  private MigrationStep underTest = new DropOrganizationInRulesMetadata(dbTester.database());
+
+  @Test
+  public void column_has_been_dropped() throws SQLException {
+    underTest.execute();
+    dbTester.assertColumnDoesNotExist("rules_metadata", "organization_uuid");
+    dbTester.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_uuid");
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest.java
new file mode 100644 (file)
index 0000000..50597ad
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v86;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.MigrationStep;
+
+public class DropOrganizationUuidIndexFromQualityProfileTableTest {
+
+  private static final String TABLE_NAME = "org_qprofiles";
+
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropOrganizationUuidIndexFromQualityProfileTableTest.class, "schema.sql");
+
+  private MigrationStep underTest = new DropOrganizationUuidIndexFromQualityProfileTable(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    db.assertTableExists(TABLE_NAME);
+    db.assertIndex(TABLE_NAME, "qprofiles_org_uuid", "organization_uuid");
+
+    underTest.execute();
+
+    db.assertIndexDoesNotExist(TABLE_NAME, "qprofiles_org_uuid");
+  }
+
+  @Test
+  public void migration_is_re_entrant() throws SQLException {
+    underTest.execute();
+
+    // re-entrant
+    underTest.execute();
+
+    db.assertIndexDoesNotExist(TABLE_NAME, "qprofiles_org_uuid");
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfilesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyToDefaultQProfilesTest/schema.sql
deleted file mode 100644 (file)
index 6e5205d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE "DEFAULT_QPROFILES"(
-    "LANGUAGE" VARCHAR(20) NOT NULL,
-    "QPROFILE_UUID" VARCHAR(255) NOT NULL,
-    "CREATED_AT" BIGINT NOT NULL,
-    "UPDATED_AT" BIGINT NOT NULL
-);
-CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPkTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropDefaultQProfilesPkTest/schema.sql
deleted file mode 100644 (file)
index 85b059b..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE TABLE "DEFAULT_QPROFILES"(
-    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
-    "LANGUAGE" VARCHAR(20) NOT NULL,
-    "QPROFILE_UUID" VARCHAR(255) NOT NULL,
-    "CREATED_AT" BIGINT NOT NULL,
-    "UPDATED_AT" BIGINT NOT NULL
-);
-ALTER TABLE "DEFAULT_QPROFILES" ADD CONSTRAINT "PK_DEFAULT_QPROFILES" PRIMARY KEY("ORGANIZATION_UUID", "LANGUAGE");
-CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfilesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromDefaultQProfilesTest/schema.sql
deleted file mode 100644 (file)
index c72d674..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-CREATE TABLE "DEFAULT_QPROFILES"(
-    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
-    "LANGUAGE" VARCHAR(20) NOT NULL,
-    "QPROFILE_UUID" VARCHAR(255) NOT NULL,
-    "CREATED_AT" BIGINT NOT NULL,
-    "UPDATED_AT" BIGINT NOT NULL
-);
-CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationFromQualityProfileTableTest/schema.sql
deleted file mode 100644 (file)
index 52373a8..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-CREATE TABLE "ORG_QPROFILES"(
-    "UUID" VARCHAR(255) NOT NULL,
-    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
-    "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL,
-    "PARENT_UUID" VARCHAR(255),
-    "LAST_USED" BIGINT,
-    "USER_UPDATED_AT" BIGINT,
-    "CREATED_AT" BIGINT NOT NULL,
-    "UPDATED_AT" BIGINT NOT NULL
-);
-ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID");
-CREATE INDEX "QPROFILES_ORG_UUID" ON "ORG_QPROFILES"("ORGANIZATION_UUID");
-CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID");
-CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadataTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v85/DropOrganizationInRulesMetadataTest/schema.sql
deleted file mode 100644 (file)
index a713742..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-CREATE TABLE "RULES_METADATA"(
-    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
-    "NOTE_DATA" CLOB,
-    "NOTE_USER_UUID" VARCHAR(255),
-    "NOTE_CREATED_AT" BIGINT,
-    "NOTE_UPDATED_AT" BIGINT,
-    "REMEDIATION_FUNCTION" VARCHAR(20),
-    "REMEDIATION_GAP_MULT" VARCHAR(20),
-    "REMEDIATION_BASE_EFFORT" VARCHAR(20),
-    "TAGS" VARCHAR(4000),
-    "AD_HOC_NAME" VARCHAR(200),
-    "AD_HOC_DESCRIPTION" CLOB,
-    "AD_HOC_SEVERITY" VARCHAR(10),
-    "AD_HOC_TYPE" TINYINT,
-    "CREATED_AT" BIGINT NOT NULL,
-    "UPDATED_AT" BIGINT NOT NULL,
-    "RULE_UUID" VARCHAR(40) NOT NULL
-);
-ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_UUID", "ORGANIZATION_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfilesTest/schema.sql
new file mode 100644 (file)
index 0000000..6e5205d
--- /dev/null
@@ -0,0 +1,7 @@
+CREATE TABLE "DEFAULT_QPROFILES"(
+    "LANGUAGE" VARCHAR(20) NOT NULL,
+    "QPROFILE_UUID" VARCHAR(255) NOT NULL,
+    "CREATED_AT" BIGINT NOT NULL,
+    "UPDATED_AT" BIGINT NOT NULL
+);
+CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest/schema.sql
new file mode 100644 (file)
index 0000000..85b059b
--- /dev/null
@@ -0,0 +1,9 @@
+CREATE TABLE "DEFAULT_QPROFILES"(
+    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+    "LANGUAGE" VARCHAR(20) NOT NULL,
+    "QPROFILE_UUID" VARCHAR(255) NOT NULL,
+    "CREATED_AT" BIGINT NOT NULL,
+    "UPDATED_AT" BIGINT NOT NULL
+);
+ALTER TABLE "DEFAULT_QPROFILES" ADD CONSTRAINT "PK_DEFAULT_QPROFILES" PRIMARY KEY("ORGANIZATION_UUID", "LANGUAGE");
+CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromDefaultQProfilesTest/schema.sql
new file mode 100644 (file)
index 0000000..c72d674
--- /dev/null
@@ -0,0 +1,8 @@
+CREATE TABLE "DEFAULT_QPROFILES"(
+    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+    "LANGUAGE" VARCHAR(20) NOT NULL,
+    "QPROFILE_UUID" VARCHAR(255) NOT NULL,
+    "CREATED_AT" BIGINT NOT NULL,
+    "UPDATED_AT" BIGINT NOT NULL
+);
+CREATE UNIQUE INDEX "UNIQ_DEFAULT_QPROFILES_UUID" ON "DEFAULT_QPROFILES"("QPROFILE_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationFromQualityProfileTableTest/schema.sql
new file mode 100644 (file)
index 0000000..5c036b5
--- /dev/null
@@ -0,0 +1,13 @@
+CREATE TABLE "ORG_QPROFILES"(
+    "UUID" VARCHAR(255) NOT NULL,
+    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+    "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL,
+    "PARENT_UUID" VARCHAR(255),
+    "LAST_USED" BIGINT,
+    "USER_UPDATED_AT" BIGINT,
+    "CREATED_AT" BIGINT NOT NULL,
+    "UPDATED_AT" BIGINT NOT NULL
+);
+ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID");
+CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID");
+CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadataTest/schema.sql
new file mode 100644 (file)
index 0000000..a713742
--- /dev/null
@@ -0,0 +1,19 @@
+CREATE TABLE "RULES_METADATA"(
+    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+    "NOTE_DATA" CLOB,
+    "NOTE_USER_UUID" VARCHAR(255),
+    "NOTE_CREATED_AT" BIGINT,
+    "NOTE_UPDATED_AT" BIGINT,
+    "REMEDIATION_FUNCTION" VARCHAR(20),
+    "REMEDIATION_GAP_MULT" VARCHAR(20),
+    "REMEDIATION_BASE_EFFORT" VARCHAR(20),
+    "TAGS" VARCHAR(4000),
+    "AD_HOC_NAME" VARCHAR(200),
+    "AD_HOC_DESCRIPTION" CLOB,
+    "AD_HOC_SEVERITY" VARCHAR(10),
+    "AD_HOC_TYPE" TINYINT,
+    "CREATED_AT" BIGINT NOT NULL,
+    "UPDATED_AT" BIGINT NOT NULL,
+    "RULE_UUID" VARCHAR(40) NOT NULL
+);
+ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_UUID", "ORGANIZATION_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationUuidIndexFromQualityProfileTableTest/schema.sql
new file mode 100644 (file)
index 0000000..9aa88c1
--- /dev/null
@@ -0,0 +1,15 @@
+
+CREATE TABLE "ORG_QPROFILES"(
+    "UUID" VARCHAR(255) NOT NULL,
+    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+    "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL,
+    "PARENT_UUID" VARCHAR(255),
+    "LAST_USED" BIGINT,
+    "USER_UPDATED_AT" BIGINT,
+    "CREATED_AT" BIGINT NOT NULL,
+    "UPDATED_AT" BIGINT NOT NULL
+);
+ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID");
+CREATE INDEX "QPROFILES_ORG_UUID" ON "ORG_QPROFILES"("ORGANIZATION_UUID");
+CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID");
+CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID");