From 3f23a8fb511ad848b8e9c1a37e95ca2a6881b40c Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 11 Jul 2016 00:40:33 +0200 Subject: [PATCH] SONAR-7700 Decrease size of B VARCHAR columns in PROJECTS --- .../org/sonar/db/version/v60/AddBColumnsToProjects.java | 6 +++--- .../sonar/db/version/v60/AddUuidPathColumnToProjects.java | 3 +-- .../version/v60/MakeUuidPathColumnNotNullOnProjects.java | 3 +-- .../src/main/resources/org/sonar/db/version/schema-h2.ddl | 8 ++++---- .../sonar/db/version/v60/AddBColumnsToProjectsTest.java | 6 +++--- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddBColumnsToProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddBColumnsToProjects.java index 72af465d5b2..630a776faf2 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v60/AddBColumnsToProjects.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v60/AddBColumnsToProjects.java @@ -43,10 +43,10 @@ public class AddBColumnsToProjects extends DdlChange { .addColumn(newVarcharColumnDefBuilder().setColumnName("b_description").setLimit(2000).setIsNullable(true).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("b_enabled").build()) .addColumn(newVarcharColumnDefBuilder().setColumnName("b_language").setLimit(20).setIsNullable(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_long_name").setLimit(2000).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_long_name").setLimit(500).setIsNullable(true).build()) .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid").setLimit(50).setIsNullable(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid_path").setLimit(4000).setIsNullable(true).build()) - .addColumn(newVarcharColumnDefBuilder().setColumnName("b_name").setLimit(2000).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid_path").setLimit(1500).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_name").setLimit(500).setIsNullable(true).build()) .addColumn(newVarcharColumnDefBuilder().setColumnName("b_path").setLimit(2000).setIsNullable(true).build()) .addColumn(newVarcharColumnDefBuilder().setColumnName("b_qualifier").setLimit(3).setIsNullable(true).build()) .build()); diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddUuidPathColumnToProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddUuidPathColumnToProjects.java index b9a46741d8a..fd0d4d8adaa 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v60/AddUuidPathColumnToProjects.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v60/AddUuidPathColumnToProjects.java @@ -24,7 +24,6 @@ import org.sonar.db.Database; import org.sonar.db.version.AddColumnsBuilder; import org.sonar.db.version.DdlChange; -import static org.sonar.db.version.VarcharColumnDef.MAX_SIZE; import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; public class AddUuidPathColumnToProjects extends DdlChange { @@ -38,7 +37,7 @@ public class AddUuidPathColumnToProjects extends DdlChange { @Override public void execute(Context context) throws SQLException { context.execute(new AddColumnsBuilder(getDialect(), TABLE_PROJECTS) - .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid_path").setLimit(MAX_SIZE).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid_path").setLimit(1500).setIsNullable(true).build()) .build()); } diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidPathColumnNotNullOnProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidPathColumnNotNullOnProjects.java index bcb3ce4c7e0..06b4578fc4e 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidPathColumnNotNullOnProjects.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidPathColumnNotNullOnProjects.java @@ -24,7 +24,6 @@ import org.sonar.db.Database; import org.sonar.db.version.AlterColumnsBuilder; import org.sonar.db.version.DdlChange; -import static org.sonar.db.version.VarcharColumnDef.MAX_SIZE; import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; public class MakeUuidPathColumnNotNullOnProjects extends DdlChange { @@ -38,7 +37,7 @@ public class MakeUuidPathColumnNotNullOnProjects extends DdlChange { @Override public void execute(Context context) throws SQLException { context.execute(new AlterColumnsBuilder(getDialect(), TABLE_PROJECTS) - .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid_path").setLimit(MAX_SIZE).setIsNullable(false).build()) + .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid_path").setLimit(1500).setIsNullable(false).build()) .build()); } diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl index 64c9fc7b99f..724960533eb 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -211,7 +211,7 @@ CREATE TABLE "PROJECTS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "KEE" VARCHAR(400), "UUID" VARCHAR(50) NOT NULL, - "UUID_PATH" VARCHAR(4000) NOT NULL, + "UUID_PATH" VARCHAR(1500) NOT NULL, "ROOT_UUID" VARCHAR(50) NOT NULL, "PROJECT_UUID" VARCHAR(50), "MODULE_UUID" VARCHAR(50), @@ -234,10 +234,10 @@ CREATE TABLE "PROJECTS" ( "B_DESCRIPTION" VARCHAR(2000), "B_ENABLED" BOOLEAN, "B_LANGUAGE" VARCHAR(20), - "B_LONG_NAME" VARCHAR(2000), + "B_LONG_NAME" VARCHAR(500), "B_MODULE_UUID" VARCHAR(50), - "B_MODULE_UUID_PATH" VARCHAR(4000), - "B_NAME" VARCHAR(2000), + "B_MODULE_UUID_PATH" VARCHAR(1500), + "B_NAME" VARCHAR(500), "B_PATH" VARCHAR(2000), "B_QUALIFIER" VARCHAR(3) ); diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/AddBColumnsToProjectsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/AddBColumnsToProjectsTest.java index facb21de02d..bb4cd65bf5b 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v60/AddBColumnsToProjectsTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v60/AddBColumnsToProjectsTest.java @@ -81,10 +81,10 @@ public class AddBColumnsToProjectsTest { db.assertColumnDefinition(TABLE, "b_description", Types.VARCHAR, 2000, true); db.assertColumnDefinition(TABLE, "b_enabled", Types.BOOLEAN, null, true); db.assertColumnDefinition(TABLE, "b_language", Types.VARCHAR, 20, true); + db.assertColumnDefinition(TABLE, "b_long_name", Types.VARCHAR, 500, true); db.assertColumnDefinition(TABLE, "b_module_uuid", Types.VARCHAR, 50, true); - db.assertColumnDefinition(TABLE, "b_module_uuid_path", Types.VARCHAR, 4000, true); - db.assertColumnDefinition(TABLE, "b_name", Types.VARCHAR, 2000, true); - db.assertColumnDefinition(TABLE, "b_long_name", Types.VARCHAR, 2000, true); + db.assertColumnDefinition(TABLE, "b_module_uuid_path", Types.VARCHAR, 1500, true); + db.assertColumnDefinition(TABLE, "b_name", Types.VARCHAR, 500, true); db.assertColumnDefinition(TABLE, "b_path", Types.VARCHAR, 2000, true); db.assertColumnDefinition(TABLE, "b_qualifier", Types.VARCHAR, 3, true); } -- 2.39.5