Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONARCLOUD-156 Set IS_OWNER_USER not nullable in ALM_APP_INSTALLS
- Loading branch information
1 parent
e86e8c1
commit c21cf18
Showing
10 changed files
with
119 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...r/server/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstalls.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.v75; | ||
|
||
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.AlterColumnsBuilder; | ||
import org.sonar.server.platform.db.migration.step.DdlChange; | ||
|
||
import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder; | ||
|
||
@SupportsBlueGreen | ||
public class SetIsOwnerUserNotNullableInAlmAppInstalls extends DdlChange { | ||
|
||
public SetIsOwnerUserNotNullableInAlmAppInstalls(Database db) { | ||
super(db); | ||
} | ||
|
||
@Override | ||
public void execute(Context context) throws SQLException { | ||
context.execute(new AlterColumnsBuilder(getDialect(), "alm_app_installs") | ||
.updateColumn(newBooleanColumnDefBuilder() | ||
.setColumnName("is_owner_user") | ||
.setIsNullable(false) | ||
.build()) | ||
.build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...rver/platform/db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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.v75; | ||
|
||
import java.sql.SQLException; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
import org.sonar.db.CoreDbTester; | ||
|
||
import static java.sql.Types.BOOLEAN; | ||
|
||
public class SetIsOwnerUserNotNullableInAlmAppInstallsTest { | ||
@Rule | ||
public final CoreDbTester db = CoreDbTester.createForSchema(SetIsOwnerUserNotNullableInAlmAppInstallsTest.class, "almAppInstalls.sql"); | ||
|
||
@Rule | ||
public ExpectedException expectedException = ExpectedException.none(); | ||
|
||
private SetIsOwnerUserNotNullableInAlmAppInstalls underTest = new SetIsOwnerUserNotNullableInAlmAppInstalls(db.database()); | ||
|
||
@Test | ||
public void columns_are_updated() throws SQLException { | ||
underTest.execute(); | ||
|
||
db.assertColumnDefinition("alm_app_installs", "is_owner_user", BOOLEAN, null, false); | ||
} | ||
|
||
@Test | ||
public void migration_is_reentrant() throws SQLException { | ||
underTest.execute(); | ||
|
||
underTest.execute(); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...db/migration/version/v75/SetIsOwnerUserNotNullableInAlmAppInstallsTest/almAppInstalls.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE TABLE "ALM_APP_INSTALLS" ( | ||
"UUID" VARCHAR(40) NOT NULL, | ||
"ALM_ID" VARCHAR(40) NOT NULL, | ||
"OWNER_ID" VARCHAR(4000) NOT NULL, | ||
"IS_OWNER_USER" BOOLEAN, | ||
"INSTALL_ID" VARCHAR(4000) NOT NULL, | ||
"USER_EXTERNAL_ID" VARCHAR(255), | ||
"CREATED_AT" BIGINT NOT NULL, | ||
"UPDATED_AT" BIGINT NOT NULL, | ||
|
||
CONSTRAINT "PK_ALM_APP_INSTALLS" PRIMARY KEY ("UUID") | ||
); | ||
CREATE UNIQUE INDEX "ALM_APP_INSTALLS_OWNER" ON "ALM_APP_INSTALLS" ("ALM_ID", "OWNER_ID"); | ||
CREATE UNIQUE INDEX "ALM_APP_INSTALLS_INSTALL" ON "ALM_APP_INSTALLS" ("ALM_ID", "INSTALL_ID"); | ||
CREATE INDEX "ALM_APP_INSTALLS_EXTERNAL_ID" ON "ALM_APP_INSTALLS" ("USER_EXTERNAL_ID"); |