Browse Source

SONAR-11279 Drop column DEFAULT_PERM_TEMPLATE_VIEW

on organizations
tags/7.5
Eric Hartmann 5 years ago
parent
commit
fedee0f1c5

+ 0
- 1
server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl View File

@@ -7,7 +7,6 @@ CREATE TABLE "ORGANIZATIONS" (
"AVATAR_URL" VARCHAR(256),
"GUARDED" BOOLEAN NOT NULL,
"DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40),
"DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40),
"DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40),
"DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40),
"DEFAULT_GROUP_ID" INTEGER,

+ 9
- 7
server/sonar-db-dao/src/test/java/org/sonar/db/organization/OrganizationDaoTest.java View File

@@ -1221,7 +1221,8 @@ public class OrganizationDaoTest {
" kee," +
" name," +
" default_perm_template_project," +
" default_perm_template_view," +
" default_perm_template_app," +
" default_perm_template_port," +
" new_project_private," +
" guarded," +
" default_quality_gate_uuid," +
@@ -1241,6 +1242,7 @@ public class OrganizationDaoTest {
" ?," +
" ?," +
" ?," +
" ?," +
" ?" +
" )")) {
preparedStatement.setString(1, organizationUuid);
@@ -1248,12 +1250,13 @@ public class OrganizationDaoTest {
preparedStatement.setString(3, organizationUuid);
preparedStatement.setString(4, project);
preparedStatement.setString(5, view);
preparedStatement.setBoolean(6, false);
preparedStatement.setString(6, view);
preparedStatement.setBoolean(7, false);
preparedStatement.setString(8, "1");
preparedStatement.setString(9, FREE.name());
preparedStatement.setLong(10, 1000L);
preparedStatement.setLong(11, 2000L);
preparedStatement.setBoolean(8, false);
preparedStatement.setString(9, "1");
preparedStatement.setString(10, FREE.name());
preparedStatement.setLong(11, 1000L);
preparedStatement.setLong(12, 2000L);
preparedStatement.execute();
} catch (SQLException e) {
throw new RuntimeException("dirty insert failed", e);
@@ -1302,7 +1305,6 @@ public class OrganizationDaoTest {
" subscription as \"subscription\"," +
" created_at as \"createdAt\", updated_at as \"updatedAt\"," +
" default_perm_template_project as \"projectDefaultPermTemplate\"," +
" default_perm_template_view as \"viewDefaultPermTemplate\"," +
" default_quality_gate_uuid as \"defaultQualityGateUuid\" " +
" from organizations");
assertThat(rows).hasSize(1);

+ 1
- 0
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74.java View File

@@ -49,6 +49,7 @@ public class DbVersion74 implements DbVersion {
.add(2326, "Create new creator permissions for applications and portfolios", CreateApplicationsAndPortfoliosCreatorPermissions.class)
.add(2327, "Populate default template permissions on organizations", PopulateDefaultPermTemplateOnOrganizations.class)
.add(2328, "Add portfolio and application creator permissions on sonar-administrators group", AddApplicationCreatorAndPortfolioCreatorToSonarAdministrator.class)
.add(2329, "Drop column DEFAULT_PERM_TEMPLATE_VIEW on organizations", DropDefaultPermTemplateViewFromOrganizations.class)
;
}
}

+ 39
- 0
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizations.java View File

@@ -0,0 +1,39 @@
/*
* SonarQube
* Copyright (C) 2009-2018 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.v74;

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.DropColumnsBuilder;
import org.sonar.server.platform.db.migration.step.DdlChange;

@SupportsBlueGreen
public class DropDefaultPermTemplateViewFromOrganizations extends DdlChange {

public DropDefaultPermTemplateViewFromOrganizations(Database db) {
super(db);
}

@Override
public void execute(Context context) throws SQLException {
context.execute(new DropColumnsBuilder(getDialect(), "organizations", "default_perm_template_view").build());
}
}

+ 1
- 1
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74Test.java View File

@@ -35,6 +35,6 @@ public class DbVersion74Test {

@Test
public void verify_migration_count() {
verifyMigrationCount(underTest, 22);
verifyMigrationCount(underTest, 23);
}
}

+ 55
- 0
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest.java View File

@@ -0,0 +1,55 @@
/*
* SonarQube
* Copyright (C) 2009-2018 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.v74;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.db.CoreDbTester;

public class DropDefaultPermTemplateViewFromOrganizationsTest {

@Rule
public final CoreDbTester db = CoreDbTester.createForSchema(DropDefaultPermTemplateViewFromOrganizationsTest.class, "organizations.sql");

@Rule
public ExpectedException expectedException = ExpectedException.none();

private DropDefaultPermTemplateViewFromOrganizations underTest = new DropDefaultPermTemplateViewFromOrganizations(db.database());

@Test
public void column_is_removed_from_table() throws SQLException {
underTest.execute();

db.assertColumnDoesNotExist("organizations", "default_perm_template_view");
}

@Test
public void migration_is_not_reentrant() throws SQLException {
underTest.execute();

expectedException.expect(IllegalStateException.class);

underTest.execute();
}

}

+ 22
- 0
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/DropDefaultPermTemplateViewFromOrganizationsTest/organizations.sql View File

@@ -0,0 +1,22 @@
CREATE TABLE "ORGANIZATIONS" (
"UUID" VARCHAR(40) NOT NULL,
"KEE" VARCHAR(32) NOT NULL,
"NAME" VARCHAR(64) NOT NULL,
"DESCRIPTION" VARCHAR(256),
"URL" VARCHAR(256),
"AVATAR_URL" VARCHAR(256),
"GUARDED" BOOLEAN NOT NULL,
"DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40),
"DEFAULT_PERM_TEMPLATE_VIEW" VARCHAR(40),
"DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40),
"DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40),
"DEFAULT_GROUP_ID" INTEGER,
"DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL,
"NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL,
"SUBSCRIPTION" VARCHAR(40) NOT NULL,
"CREATED_AT" BIGINT NOT NULL,
"UPDATED_AT" BIGINT NOT NULL,

CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY ("UUID")
);
CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE");

Loading…
Cancel
Save