@@ -76,6 +76,7 @@ CREATE TABLE "ORG_QPROFILES" ( | |||
); | |||
CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); | |||
CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); | |||
CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES" ("PARENT_UUID"); | |||
CREATE TABLE "DEFAULT_QPROFILES" ( |
@@ -0,0 +1,52 @@ | |||
/* | |||
* 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.v78; | |||
import java.sql.SQLException; | |||
import org.sonar.db.Database; | |||
import org.sonar.server.platform.db.migration.SupportsBlueGreen; | |||
import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; | |||
import org.sonar.server.platform.db.migration.step.DdlChange; | |||
import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; | |||
@SupportsBlueGreen | |||
public class AddIndexToOrgQProfileParentUuid extends DdlChange { | |||
public AddIndexToOrgQProfileParentUuid(Database db) { | |||
super(db); | |||
} | |||
@Override | |||
public void execute(Context context) throws SQLException { | |||
context.execute(new CreateIndexBuilder(getDialect()) | |||
.addColumn(newVarcharColumnDefBuilder() | |||
.setColumnName("parent_uuid") | |||
.setLimit(255) | |||
.setIsNullable(true) | |||
.setIgnoreOracleUnit(true) | |||
.build()) | |||
.setUnique(false) | |||
.setTable("org_qprofiles") | |||
.setName("org_qprofiles_parent_uuid") | |||
.build()); | |||
} | |||
} |
@@ -27,6 +27,7 @@ public class DbVersion78 implements DbVersion { | |||
@Override | |||
public void addSteps(MigrationStepRegistry registry) { | |||
registry | |||
.add(2700, "Drop overall subscriptions on notifications about new and resolved issues", DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications.class); | |||
.add(2700, "Drop overall subscriptions on notifications about new and resolved issues", DeleteOverallSubscriptionsOnNewAndResolvedIssuesNotifications.class) | |||
.add(2701, "Add index to org_qprofile.parent_uuid", AddIndexToOrgQProfileParentUuid.class); | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
/* | |||
* 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.v78; | |||
import java.sql.SQLException; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.db.CoreDbTester; | |||
import org.sonar.server.platform.db.migration.step.DdlChange; | |||
public class AddIndexToOrgQProfileParentUuidTest { | |||
@Rule | |||
public final CoreDbTester db = CoreDbTester.createForSchema(AddIndexToOrgQProfileParentUuidTest.class, "org_qprofiles.sql"); | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
private DdlChange underTest = new AddIndexToOrgQProfileParentUuid(db.database()); | |||
@Test | |||
public void creates_index() throws SQLException { | |||
underTest.execute(); | |||
db.assertIndex("org_qprofiles", "org_qprofiles_parent_uuid", "parent_uuid"); | |||
} | |||
@Test | |||
public void migration_is_not_re_entrant() throws SQLException { | |||
underTest.execute(); | |||
expectedException.expect(IllegalStateException.class); | |||
underTest.execute(); | |||
} | |||
} |
@@ -35,7 +35,7 @@ public class DbVersion78Test { | |||
@Test | |||
public void verify_migration_count() { | |||
verifyMigrationCount(underTest, 1); | |||
verifyMigrationCount(underTest, 2); | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
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, | |||
CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY ("UUID") | |||
); | |||
CREATE INDEX "ORG_QPROFILES_ORG_UUID" ON "ORG_QPROFILES" ("ORGANIZATION_UUID"); | |||
CREATE INDEX "ORG_QPROFILES_RP_UUID" ON "ORG_QPROFILES" ("RULES_PROFILE_UUID"); |