diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-12-12 17:54:28 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-12-13 15:18:40 +0100 |
commit | 0aa152d65b56a622b8fa6fcc1ee4425470ffe7d3 (patch) | |
tree | 11e00ac8e597459940a9b8ab51d6342ec08f23b9 /sonar-db/src | |
parent | b6667d3d7a9801e17f654fd9d9a4322857749c53 (diff) | |
download | sonarqube-0aa152d65b56a622b8fa6fcc1ee4425470ffe7d3.tar.gz sonarqube-0aa152d65b56a622b8fa6fcc1ee4425470ffe7d3.zip |
SONAR-5471 use v5.6 as version of initial schema
Signed-off-by: Simon Brandhof <simon.brandhof@sonarsource.com>
Diffstat (limited to 'sonar-db/src')
18 files changed, 232 insertions, 595 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java index eb22d52f273..96be3391fe7 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java +++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java @@ -20,12 +20,9 @@ package org.sonar.db.version; import org.sonar.core.platform.Module; -import org.sonar.db.version.v55.CreateInitialSchema; -import org.sonar.db.version.v55.PopulateInitialSchema; -import org.sonar.db.version.v56.FixLengthOfIssuesMessageOnOracle; -import org.sonar.db.version.v56.FixTypeOfRuleTypeOnMysql; -import org.sonar.db.version.v56.RemoveUselessIndexesOnGroupRoles; -import org.sonar.db.version.v56.UpdateUsersExternalIdentityWhenEmpty; +import org.sonar.db.version.v56.CreateInitialSchema; +import org.sonar.db.version.v56.PopulateInitialSchema; +import org.sonar.db.version.v561.UpdateUsersExternalIdentityWhenEmpty; import org.sonar.db.version.v60.AddAnalysisUuidColumnToCeActivity; import org.sonar.db.version.v60.AddAnalysisUuidColumnToEvents; import org.sonar.db.version.v60.AddAnalysisUuidColumnToMeasures; @@ -152,14 +149,11 @@ public class MigrationStepModule extends Module { @Override protected void configureModule() { add( - // 5.5 + // 5.6 CreateInitialSchema.class, PopulateInitialSchema.class, - // 5.6 - RemoveUselessIndexesOnGroupRoles.class, - FixTypeOfRuleTypeOnMysql.class, - FixLengthOfIssuesMessageOnOracle.class, + // 5.6.1 UpdateUsersExternalIdentityWhenEmpty.class, // 6.0 diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/CreateInitialSchema.java b/sonar-db/src/main/java/org/sonar/db/version/v56/CreateInitialSchema.java index 3306efd943d..91007e90792 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v55/CreateInitialSchema.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v56/CreateInitialSchema.java @@ -17,7 +17,7 @@ * 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.db.version.v55; +package org.sonar.db.version.v56; import java.sql.SQLException; import org.sonar.db.Database; @@ -95,11 +95,11 @@ public class CreateInitialSchema extends DdlChange { } private void createUserTokens(Context context) throws SQLException { - VarcharColumnDef loginCol = newVarcharBuilder("login").setLimit(255).setIsNullable(false).build(); - VarcharColumnDef nameCol = newVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); - VarcharColumnDef tokenHashCol = newVarcharBuilder("token_hash").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef loginCol = newLenientVarcharBuilder("login").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); + VarcharColumnDef tokenHashCol = newLenientVarcharBuilder("token_hash").setLimit(255).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "user_tokens") + newTableBuilder("user_tokens") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(loginCol) .addColumn(nameCol) @@ -111,21 +111,21 @@ public class CreateInitialSchema extends DdlChange { } private void createCeActivity(Context context) throws SQLException { - VarcharColumnDef uuidCol = newVarcharBuilder("uuid").setLimit(40).setIsNullable(false).build(); - VarcharColumnDef isLastKeyCol = newVarcharBuilder("is_last_key").setLimit(55).setIsNullable(false).build(); + VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(40).setIsNullable(false).build(); + VarcharColumnDef isLastKeyCol = newLenientVarcharBuilder("is_last_key").setLimit(55).setIsNullable(false).build(); BooleanColumnDef isLastCol = newBooleanColumnDefBuilder().setColumnName("is_last").setIsNullable(false).build(); - VarcharColumnDef statusCol = newVarcharBuilder("status").setLimit(15).setIsNullable(false).build(); - VarcharColumnDef componentUuidCol = newVarcharBuilder("component_uuid").setLimit(40).build(); + VarcharColumnDef statusCol = newLenientVarcharBuilder("status").setLimit(15).setIsNullable(false).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(40).build(); context.execute( - new CreateTableBuilder(getDialect(), "ce_activity") + newTableBuilder("ce_activity") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(uuidCol) - .addColumn(newVarcharBuilder("task_type").setLimit(15).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("task_type").setLimit(15).setIsNullable(false).build()) .addColumn(componentUuidCol) .addColumn(statusCol) .addColumn(isLastCol) .addColumn(isLastKeyCol) - .addColumn(newVarcharBuilder("submitter_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("submitter_login").setLimit(255).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("submitted_at").setIsNullable(false).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("started_at").build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("executed_at").build()) @@ -141,16 +141,16 @@ public class CreateInitialSchema extends DdlChange { } private void createCeQueue(Context context) throws SQLException { - VarcharColumnDef uuidCol = newVarcharBuilder("uuid").setLimit(40).setIsNullable(false).build(); - VarcharColumnDef componentUuidCol = newVarcharBuilder("component_uuid").setLimit(40).build(); + VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(40).setIsNullable(false).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(40).build(); context.execute( - new CreateTableBuilder(getDialect(), "ce_queue") + newTableBuilder("ce_queue") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(uuidCol) - .addColumn(newVarcharBuilder("task_type").setLimit(15).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("task_type").setLimit(15).setIsNullable(false).build()) .addColumn(componentUuidCol) - .addColumn(newVarcharBuilder("status").setLimit(15).build()) - .addColumn(newVarcharBuilder("submitter_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("status").setLimit(15).build()) + .addColumn(newLenientVarcharBuilder("submitter_login").setLimit(255).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("started_at").build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) @@ -160,23 +160,23 @@ public class CreateInitialSchema extends DdlChange { } private void createFileSources(Context context) throws SQLException { - VarcharColumnDef projectUuidCol = newVarcharBuilder("project_uuid").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(50).setIsNullable(false).build(); BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build(); - VarcharColumnDef dataTypeCol = newVarcharBuilder("data_type").setLimit(20).build(); - VarcharColumnDef fileUuidCol = newVarcharBuilder("file_uuid").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef dataTypeCol = newLenientVarcharBuilder("data_type").setLimit(20).build(); + VarcharColumnDef fileUuidCol = newLenientVarcharBuilder("file_uuid").setLimit(50).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "file_sources") + newTableBuilder("file_sources") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(projectUuidCol) .addColumn(fileUuidCol) .addColumn(newClobColumnDefBuilder().setColumnName("line_hashes").build()) - .addColumn(newVarcharBuilder("data_hash").setLimit(50).build()) + .addColumn(newLenientVarcharBuilder("data_hash").setLimit(50).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) .addColumn(updatedAtCol) - .addColumn(newVarcharBuilder("src_hash").setLimit(50).build()) + .addColumn(newLenientVarcharBuilder("src_hash").setLimit(50).build()) .addColumn(newBlobColumnDefBuilder().setColumnName("binary_data").build()) .addColumn(dataTypeCol) - .addColumn(newVarcharBuilder("revision").setLimit(100).build()) + .addColumn(newLenientVarcharBuilder("revision").setLimit(100).build()) .build()); addIndex(context, "file_sources", "file_sources_project_uuid", false, projectUuidCol); addIndex(context, "file_sources", "file_sources_updated_at", false, updatedAtCol); @@ -184,16 +184,16 @@ public class CreateInitialSchema extends DdlChange { } private void createActivities(Context context) throws SQLException { - VarcharColumnDef keeCol = newVarcharBuilder("log_key").setLimit(255).build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("log_key").setLimit(255).build(); context.execute( - new CreateTableBuilder(getDialect(), "activities") + newTableBuilder("activities") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newVarcharBuilder("user_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) .addColumn(newClobColumnDefBuilder().setColumnName("data_field").build()) - .addColumn(newVarcharBuilder("log_type").setLimit(50).build()) - .addColumn(newVarcharBuilder("log_action").setLimit(50).build()) - .addColumn(newVarcharBuilder("log_message").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("log_type").setLimit(50).build()) + .addColumn(newLenientVarcharBuilder("log_action").setLimit(50).build()) + .addColumn(newLenientVarcharBuilder("log_message").setLimit(4000).build()) .addColumn(keeCol) .build()); @@ -202,11 +202,11 @@ public class CreateInitialSchema extends DdlChange { private void createPermTemplatesGroups(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "perm_templates_groups") + newTableBuilder("perm_templates_groups") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newIntegerColumnDefBuilder().setColumnName("group_id").build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build()) - .addColumn(newVarcharBuilder("permission_reference").setLimit(64).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("permission_reference").setLimit(64).setIsNullable(false).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) .build()); @@ -214,11 +214,11 @@ public class CreateInitialSchema extends DdlChange { private void createPermTemplatesUsers(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "perm_templates_users") + newTableBuilder("perm_templates_users") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(false).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build()) - .addColumn(newVarcharBuilder("permission_reference").setLimit(64).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("permission_reference").setLimit(64).setIsNullable(false).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) .build()); @@ -226,21 +226,21 @@ public class CreateInitialSchema extends DdlChange { private void createPermissionTemplates(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "permission_templates") + newTableBuilder("permission_templates") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("kee").setLimit(100).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("description").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("kee").setLimit(100).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) - .addColumn(newVarcharBuilder("key_pattern").setLimit(500).build()) + .addColumn(newLenientVarcharBuilder("key_pattern").setLimit(500).build()) .build()); } private void createIssueFilterFavourites(Context context) throws SQLException { - VarcharColumnDef loginCol = newVarcharBuilder("user_login").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef loginCol = newLenientVarcharBuilder("user_login").setLimit(255).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "issue_filter_favourites") + newTableBuilder("issue_filter_favourites") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(loginCol) .addColumn(newIntegerColumnDefBuilder().setColumnName("issue_filter_id").setIsNullable(false).build()) @@ -250,14 +250,14 @@ public class CreateInitialSchema extends DdlChange { } private void createIssueFilters(Context context) throws SQLException { - VarcharColumnDef nameCol = newVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); + VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "issue_filters") + newTableBuilder("issue_filters") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(nameCol) - .addColumn(newVarcharBuilder("user_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("shared").setIsNullable(false).setDefaultValue(false).build()) - .addColumn(newVarcharBuilder("description").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) .addColumn(newClobColumnDefBuilder().setColumnName("data").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) @@ -266,15 +266,15 @@ public class CreateInitialSchema extends DdlChange { } private void createIssueChanges(Context context) throws SQLException { - VarcharColumnDef issueKeyCol = newVarcharBuilder("issue_key").setLimit(50).setIsNullable(false).build(); - VarcharColumnDef keeCol = newVarcharBuilder("kee").setLimit(50).build(); + VarcharColumnDef issueKeyCol = newLenientVarcharBuilder("issue_key").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(50).build(); context.execute( - new CreateTableBuilder(getDialect(), "issue_changes") + newTableBuilder("issue_changes") .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(keeCol) .addColumn(issueKeyCol) - .addColumn(newVarcharBuilder("user_login").setLimit(255).build()) - .addColumn(newVarcharBuilder("change_type").setLimit(20).build()) + .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("change_type").setLimit(20).build()) .addColumn(newClobColumnDefBuilder().setColumnName("change_data").build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) @@ -285,40 +285,40 @@ public class CreateInitialSchema extends DdlChange { } private void createIssues(Context context) throws SQLException { - VarcharColumnDef assigneeCol = newVarcharBuilder("assignee").setLimit(255).build(); - VarcharColumnDef componentUuidCol = newVarcharBuilder("component_uuid").setLimit(50).build(); + VarcharColumnDef assigneeCol = newLenientVarcharBuilder("assignee").setLimit(255).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(50).build(); BigIntegerColumnDef issueCreationDateCol = newBigIntegerColumnDefBuilder().setColumnName("issue_creation_date").build(); - VarcharColumnDef keeCol = newVarcharBuilder("kee").setLimit(50).setIsNullable(false).build(); - VarcharColumnDef projectUuidCol = newVarcharBuilder("project_uuid").setLimit(50).build(); - VarcharColumnDef resolutionCol = newVarcharBuilder("resolution").setLimit(20).build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(50).build(); + VarcharColumnDef resolutionCol = newLenientVarcharBuilder("resolution").setLimit(20).build(); IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").build(); BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").build(); context.execute( - new CreateTableBuilder(getDialect(), "issues") + newTableBuilder("issues") .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(keeCol) .addColumn(ruleIdCol) - .addColumn(newVarcharBuilder("severity").setLimit(10).build()) + .addColumn(newLenientVarcharBuilder("severity").setLimit(10).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("manual_severity").setIsNullable(false).build()) // unit has been fixed in SonarQube 5.6 (see migration 1151, SONAR-7493) - .addColumn(newVarcharBuilder("message").setIgnoreOracleUnit(false).setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("message").setIgnoreOracleUnit(false).setLimit(4000).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("line").build()) .addColumn(newDecimalColumnDefBuilder().setColumnName("gap").setPrecision(30).setScale(20).build()) - .addColumn(newVarcharBuilder("status").setLimit(20).build()) + .addColumn(newLenientVarcharBuilder("status").setLimit(20).build()) .addColumn(resolutionCol) - .addColumn(newVarcharBuilder("checksum").setLimit(1000).build()) - .addColumn(newVarcharBuilder("reporter").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("checksum").setLimit(1000).build()) + .addColumn(newLenientVarcharBuilder("reporter").setLimit(255).build()) .addColumn(assigneeCol) - .addColumn(newVarcharBuilder("author_login").setLimit(255).build()) - .addColumn(newVarcharBuilder("action_plan_key").setLimit(50).build()) - .addColumn(newVarcharBuilder("issue_attributes").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("author_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("action_plan_key").setLimit(50).build()) + .addColumn(newLenientVarcharBuilder("issue_attributes").setLimit(4000).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("effort").build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) .addColumn(updatedAtCol) .addColumn(issueCreationDateCol) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_update_date").build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("issue_close_date").build()) - .addColumn(newVarcharBuilder("tags").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("tags").setLimit(4000).build()) .addColumn(componentUuidCol) .addColumn(projectUuidCol) .addColumn(newBlobColumnDefBuilder().setColumnName("locations").build()) @@ -337,7 +337,7 @@ public class CreateInitialSchema extends DdlChange { private void createMeasureFilterFavourites(Context context) throws SQLException { IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "measure_filter_favourites") + newTableBuilder("measure_filter_favourites") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(userIdCol) .addColumn(newIntegerColumnDefBuilder().setColumnName("measure_filter_id").setIsNullable(false).build()) @@ -347,14 +347,14 @@ public class CreateInitialSchema extends DdlChange { } private void createMeasureFilters(Context context) throws SQLException { - VarcharColumnDef nameCol = newVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); + VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "measure_filters") + newTableBuilder("measure_filters") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(nameCol) .addColumn(newIntegerColumnDefBuilder().setColumnName("user_id").build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("shared").setDefaultValue(false).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("description").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) .addColumn(newClobColumnDefBuilder().setColumnName("data").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) @@ -363,9 +363,9 @@ public class CreateInitialSchema extends DdlChange { } private void createAuthors(Context context) throws SQLException { - VarcharColumnDef loginCol = newVarcharBuilder("login").setLimit(255).build(); + VarcharColumnDef loginCol = newLenientVarcharBuilder("login").setLimit(255).build(); context.execute( - new CreateTableBuilder(getDialect(), "authors") + newTableBuilder("authors") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newIntegerColumnDefBuilder().setColumnName("person_id").setIsNullable(false).build()) .addColumn(loginCol) @@ -376,17 +376,17 @@ public class CreateInitialSchema extends DdlChange { } private void createResourceIndex(Context context) throws SQLException { - VarcharColumnDef keeCol = newVarcharBuilder("kee").setLimit(400).setIsNullable(false).build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(400).setIsNullable(false).build(); IntegerColumnDef resourceIdCol = newIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "resource_index") + newTableBuilder("resource_index") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(keeCol) .addColumn(newIntegerColumnDefBuilder().setColumnName("position").setIsNullable(false).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("name_size").setIsNullable(false).build()) .addColumn(resourceIdCol) .addColumn(newIntegerColumnDefBuilder().setColumnName("root_project_id").setIsNullable(false).build()) - .addColumn(newVarcharBuilder("qualifier").setLimit(10).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("qualifier").setLimit(10).setIsNullable(false).build()) .build()); addIndex(context, "resource_index", "resource_index_key", false, keeCol); addIndex(context, "resource_index", "resource_index_rid", false, resourceIdCol); @@ -394,25 +394,25 @@ public class CreateInitialSchema extends DdlChange { private void createLoadedTemplates(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "loaded_templates") + newTableBuilder("loaded_templates") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newVarcharBuilder("kee").setLimit(200).build()) - .addColumn(newVarcharBuilder("template_type").setLimit(15).build()) + .addColumn(newLenientVarcharBuilder("kee").setLimit(200).build()) + .addColumn(newLenientVarcharBuilder("template_type").setLimit(15).build()) .build()); } private void createMetrics(Context context) throws SQLException { - VarcharColumnDef nameCol = newVarcharBuilder("name").setLimit(64).setIsNullable(false).build(); + VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(64).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "metrics") + newTableBuilder("metrics") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(nameCol) - .addColumn(newVarcharBuilder("description").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(255).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("direction").setIsNullable(false).setDefaultValue(0).build()) - .addColumn(newVarcharBuilder("domain").setLimit(64).build()) - .addColumn(newVarcharBuilder("short_name").setLimit(64).build()) + .addColumn(newLenientVarcharBuilder("domain").setLimit(64).build()) + .addColumn(newLenientVarcharBuilder("short_name").setLimit(64).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("qualitative").setDefaultValue(false).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("val_type").setLimit(8).build()) + .addColumn(newLenientVarcharBuilder("val_type").setLimit(8).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("user_managed").setDefaultValue(false).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("enabled").setDefaultValue(true).build()) .addColumn(newDecimalColumnDefBuilder().setColumnName("worst_value").setPrecision(38).setScale(20).build()) @@ -427,12 +427,12 @@ public class CreateInitialSchema extends DdlChange { private void createDashboards(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "dashboards") + newTableBuilder("dashboards") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newIntegerColumnDefBuilder().setColumnName("user_id").build()) - .addColumn(newVarcharBuilder("name").setLimit(256).build()) - .addColumn(newVarcharBuilder("description").setLimit(1000).build()) - .addColumn(newVarcharBuilder("column_layout").setLimit(20).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(256).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(1000).build()) + .addColumn(newLenientVarcharBuilder("column_layout").setLimit(20).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("shared").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").build()) @@ -441,24 +441,24 @@ public class CreateInitialSchema extends DdlChange { } private void createUsers(Context context) throws SQLException { - VarcharColumnDef loginCol = newVarcharBuilder("login").setLimit(255).build(); + VarcharColumnDef loginCol = newLenientVarcharBuilder("login").setLimit(255).build(); BigIntegerColumnDef updatedAtCol = newBigIntegerColumnDefBuilder().setColumnName("updated_at").build(); context.execute( - new CreateTableBuilder(getDialect(), "users") + newTableBuilder("users") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(loginCol) - .addColumn(newVarcharBuilder("name").setLimit(200).build()) - .addColumn(newVarcharBuilder("email").setLimit(100).build()) - .addColumn(newVarcharBuilder("crypted_password").setLimit(40).build()) - .addColumn(newVarcharBuilder("salt").setLimit(40).build()) - .addColumn(newVarcharBuilder("remember_token").setLimit(500).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(200).build()) + .addColumn(newLenientVarcharBuilder("email").setLimit(100).build()) + .addColumn(newLenientVarcharBuilder("crypted_password").setLimit(40).build()) + .addColumn(newLenientVarcharBuilder("salt").setLimit(40).build()) + .addColumn(newLenientVarcharBuilder("remember_token").setLimit(500).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("remember_token_expires_at").build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("active").setDefaultValue(true).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) .addColumn(updatedAtCol) - .addColumn(newVarcharBuilder("scm_accounts").setLimit(4000).build()) - .addColumn(newVarcharBuilder("external_identity").setLimit(255).build()) - .addColumn(newVarcharBuilder("external_identity_provider").setLimit(100).build()) + .addColumn(newLenientVarcharBuilder("scm_accounts").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("external_identity").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("external_identity_provider").setLimit(100).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("user_local").build()) .build()); addIndex(context, "users", "users_login", true, loginCol); @@ -467,12 +467,12 @@ public class CreateInitialSchema extends DdlChange { private void createActiveRuleParameters(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "active_rule_parameters") + newTableBuilder("active_rule_parameters") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newIntegerColumnDefBuilder().setColumnName("active_rule_id").setIsNullable(false).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("rules_parameter_id").setIsNullable(false).build()) - .addColumn(newVarcharBuilder("value").setLimit(4000).build()) - .addColumn(newVarcharBuilder("rules_parameter_key").setLimit(128).build()) + .addColumn(newLenientVarcharBuilder("value").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("rules_parameter_key").setLimit(128).build()) .build()); } @@ -480,12 +480,12 @@ public class CreateInitialSchema extends DdlChange { IntegerColumnDef profileIdCol = newIntegerColumnDefBuilder().setColumnName("profile_id").setIsNullable(false).build(); IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "active_rules") + newTableBuilder("active_rules") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(profileIdCol) .addColumn(ruleIdCol) .addColumn(newIntegerColumnDefBuilder().setColumnName("failure_level").setIsNullable(false).build()) - .addColumn(newVarcharBuilder("inheritance").setLimit(10).build()) + .addColumn(newLenientVarcharBuilder("inheritance").setLimit(10).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) .build()); @@ -496,11 +496,11 @@ public class CreateInitialSchema extends DdlChange { IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").build(); IntegerColumnDef resourceIdCol = newIntegerColumnDefBuilder().setColumnName("resource_id").build(); context.execute( - new CreateTableBuilder(getDialect(), "user_roles") + newTableBuilder("user_roles") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(userIdCol) .addColumn(resourceIdCol) - .addColumn(newVarcharBuilder("role").setLimit(64).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("role").setLimit(64).setIsNullable(false).build()) .build()); addIndex(context, "user_roles", "user_roles_resource", false, resourceIdCol); addIndex(context, "user_roles", "user_roles_user", false, userIdCol); @@ -510,7 +510,7 @@ public class CreateInitialSchema extends DdlChange { IntegerColumnDef dashboardIdCol = newIntegerColumnDefBuilder().setColumnName("dashboard_id").setIsNullable(false).build(); IntegerColumnDef userIdCol = newIntegerColumnDefBuilder().setColumnName("user_id").build(); context.execute( - new CreateTableBuilder(getDialect(), "active_dashboards") + newTableBuilder("active_dashboards") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(dashboardIdCol) .addColumn(userIdCol) @@ -522,7 +522,7 @@ public class CreateInitialSchema extends DdlChange { private void createNotifications(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "notifications") + newTableBuilder("notifications") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newBlobColumnDefBuilder().setColumnName("data").build()) .build()); @@ -532,33 +532,33 @@ public class CreateInitialSchema extends DdlChange { IntegerColumnDef projectIdCol = newIntegerColumnDefBuilder().setColumnName("project_id").setIsNullable(false).build(); IntegerColumnDef rootProjectIdCol = newIntegerColumnDefBuilder().setColumnName("root_project_id").setIsNullable(true).build(); IntegerColumnDef parentSnapshotIdCol = newIntegerColumnDefBuilder().setColumnName("parent_snapshot_id").setIsNullable(true).build(); - VarcharColumnDef qualifierCol = newVarcharBuilder("qualifier").setLimit(10).setIsNullable(true).build(); + VarcharColumnDef qualifierCol = newLenientVarcharBuilder("qualifier").setLimit(10).setIsNullable(true).build(); IntegerColumnDef rootSnapshotIdCol = newIntegerColumnDefBuilder().setColumnName("root_snapshot_id").setIsNullable(true).build(); context.execute( - new CreateTableBuilder(getDialect(), "snapshots") + newTableBuilder("snapshots") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(projectIdCol) .addColumn(parentSnapshotIdCol) - .addColumn(newVarcharBuilder("status").setLimit(4).setIsNullable(false).setDefaultValue("U").build()) + .addColumn(newLenientVarcharBuilder("status").setLimit(4).setIsNullable(false).setDefaultValue("U").build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("islast").setIsNullable(false).setDefaultValue(false).build()) - .addColumn(newVarcharBuilder("scope").setLimit(3).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("scope").setLimit(3).setIsNullable(true).build()) .addColumn(qualifierCol) .addColumn(rootSnapshotIdCol) - .addColumn(newVarcharBuilder("version").setLimit(500).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("path").setLimit(500).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("version").setLimit(500).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("path").setLimit(500).setIsNullable(true).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("depth").setIsNullable(true).build()) .addColumn(rootProjectIdCol) .addColumn(newIntegerColumnDefBuilder().setColumnName("purge_status").setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period1_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period1_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period2_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period2_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period3_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period3_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period4_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period4_param").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period5_mode").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("period5_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period1_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period1_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period2_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period2_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period3_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period3_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period4_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period4_param").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period5_mode").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("period5_param").setLimit(100).setIsNullable(true).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("build_date").setIsNullable(true).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("period1_date").setIsNullable(true).build()) @@ -576,10 +576,10 @@ public class CreateInitialSchema extends DdlChange { private void createGroups(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "groups") + newTableBuilder("groups") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newVarcharBuilder("name").setLimit(500).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("description").setLimit(200).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(500).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(200).setIsNullable(true).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) .build()); @@ -587,14 +587,14 @@ public class CreateInitialSchema extends DdlChange { private void createWidgets(Context context) throws SQLException { IntegerColumnDef dashboardId = newIntegerColumnDefBuilder().setColumnName("dashboard_id").setIsNullable(false).build(); - VarcharColumnDef widgetKey = newVarcharBuilder("widget_key").setLimit(256).setIsNullable(false).build(); + VarcharColumnDef widgetKey = newLenientVarcharBuilder("widget_key").setLimit(256).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "widgets") + newTableBuilder("widgets") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(dashboardId) .addColumn(widgetKey) - .addColumn(newVarcharBuilder("name").setLimit(256).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("description").setLimit(1000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(256).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(1000).setIsNullable(true).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("column_index").setIsNullable(true).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("row_index").setIsNullable(true).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("configured").setIsNullable(true).build()) @@ -607,10 +607,10 @@ public class CreateInitialSchema extends DdlChange { } private void createProjectQprofiles(Context context) throws SQLException { - VarcharColumnDef projectUuid = newVarcharBuilder("project_uuid").setLimit(50).setIsNullable(false).build(); - VarcharColumnDef profileKey = newVarcharBuilder("profile_key").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef projectUuid = newLenientVarcharBuilder("project_uuid").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef profileKey = newLenientVarcharBuilder("profile_key").setLimit(50).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "project_qprofiles") + newTableBuilder("project_qprofiles") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(projectUuid) .addColumn(profileKey) @@ -619,15 +619,15 @@ public class CreateInitialSchema extends DdlChange { } private void createRulesProfiles(Context context) throws SQLException { - VarcharColumnDef keeCol = newVarcharBuilder("kee").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(255).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "rules_profiles") + newTableBuilder("rules_profiles") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) .addColumn(keeCol) - .addColumn(newVarcharBuilder("parent_kee").setLimit(255).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("rules_updated_at").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("parent_kee").setLimit(255).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("rules_updated_at").setLimit(100).setIsNullable(true).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("is_default").setIsNullable(false).build()) @@ -638,13 +638,13 @@ public class CreateInitialSchema extends DdlChange { private void createRulesParameters(Context context) throws SQLException { IntegerColumnDef ruleIdCol = newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "rules_parameters") + newTableBuilder("rules_parameters") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(ruleIdCol) - .addColumn(newVarcharBuilder("name").setLimit(128).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("description").setLimit(4000).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("param_type").setLimit(512).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("default_value").setLimit(4000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(128).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(4000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("param_type").setLimit(512).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("default_value").setLimit(4000).setIsNullable(true).build()) .build()); addIndex(context, "rules_parameters", "rules_parameters_rule_id", false, ruleIdCol); } @@ -653,7 +653,7 @@ public class CreateInitialSchema extends DdlChange { BigIntegerColumnDef userIdCol = newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build(); BigIntegerColumnDef groupIdCol = newBigIntegerColumnDefBuilder().setColumnName("group_id").setIsNullable(true).build(); context.execute( - new CreateTableBuilder(getDialect(), "groups_users") + newTableBuilder("groups_users") .addColumn(userIdCol) .addColumn(groupIdCol) .build()); @@ -667,21 +667,21 @@ public class CreateInitialSchema extends DdlChange { IntegerColumnDef metricIdCol = newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(false).build(); IntegerColumnDef snapshotIdCol = newIntegerColumnDefBuilder().setColumnName("snapshot_id").setIsNullable(true).build(); context.execute( - new CreateTableBuilder(getDialect(), "project_measures") + newTableBuilder("project_measures") .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newDecimalColumnDefBuilder().setColumnName("value").setPrecision(38).setScale(20).build()) .addColumn(metricIdCol) .addColumn(snapshotIdCol) .addColumn(newIntegerColumnDefBuilder().setColumnName("rule_id").setIsNullable(true).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("rules_category_id").setIsNullable(true).build()) - .addColumn(newVarcharBuilder("text_value").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("text_value").setLimit(4000).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("tendency").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("measure_date").build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("project_id").build()) - .addColumn(newVarcharBuilder("alert_status").setLimit(5).build()) - .addColumn(newVarcharBuilder("alert_text").setLimit(4000).build()) - .addColumn(newVarcharBuilder("url").setLimit(2000).build()) - .addColumn(newVarcharBuilder("description").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("alert_status").setLimit(5).build()) + .addColumn(newLenientVarcharBuilder("alert_text").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("url").setLimit(2000).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("rule_priority").build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("characteristic_id").build()) .addColumn(personIdCol) @@ -697,15 +697,15 @@ public class CreateInitialSchema extends DdlChange { } private void createManualMeasures(Context context) throws SQLException { - VarcharColumnDef componentUuidCol = newVarcharBuilder("component_uuid").setLimit(50).build(); + VarcharColumnDef componentUuidCol = newLenientVarcharBuilder("component_uuid").setLimit(50).build(); context.execute( - new CreateTableBuilder(getDialect(), "manual_measures") + newTableBuilder("manual_measures") .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(false).build()) .addColumn(newDecimalColumnDefBuilder().setColumnName("value").setPrecision(38).setScale(20).build()) - .addColumn(newVarcharBuilder("text_value").setLimit(4000).build()) - .addColumn(newVarcharBuilder("user_login").setLimit(255).build()) - .addColumn(newVarcharBuilder("description").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("text_value").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("user_login").setLimit(255).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").build()) .addColumn(componentUuidCol) @@ -714,33 +714,33 @@ public class CreateInitialSchema extends DdlChange { } private void createProjects(Context context) throws SQLException { - VarcharColumnDef keeCol = newVarcharBuilder("kee").setLimit(400).build(); - VarcharColumnDef moduleUuidCol = newVarcharBuilder("module_uuid").setLimit(50).build(); - VarcharColumnDef projectUuidCol = newVarcharBuilder("project_uuid").setLimit(50).build(); - VarcharColumnDef qualifierCol = newVarcharBuilder("qualifier").setLimit(10).build(); + VarcharColumnDef keeCol = newLenientVarcharBuilder("kee").setLimit(400).build(); + VarcharColumnDef moduleUuidCol = newLenientVarcharBuilder("module_uuid").setLimit(50).build(); + VarcharColumnDef projectUuidCol = newLenientVarcharBuilder("project_uuid").setLimit(50).build(); + VarcharColumnDef qualifierCol = newLenientVarcharBuilder("qualifier").setLimit(10).build(); IntegerColumnDef rootIdCol = newIntegerColumnDefBuilder().setColumnName("root_id").build(); - VarcharColumnDef uuidCol = newVarcharBuilder("uuid").setLimit(50).build(); + VarcharColumnDef uuidCol = newLenientVarcharBuilder("uuid").setLimit(50).build(); context.execute( - new CreateTableBuilder(getDialect(), "projects") + newTableBuilder("projects") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newVarcharBuilder("name").setLimit(2000).build()) - .addColumn(newVarcharBuilder("description").setLimit(2000).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(2000).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(2000).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("enabled").setDefaultValue(true).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("scope").setLimit(3).build()) + .addColumn(newLenientVarcharBuilder("scope").setLimit(3).build()) .addColumn(qualifierCol) .addColumn(keeCol) .addColumn(rootIdCol) - .addColumn(newVarcharBuilder("language").setLimit(20).build()) + .addColumn(newLenientVarcharBuilder("language").setLimit(20).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("copy_resource_id").build()) - .addColumn(newVarcharBuilder("long_name").setLimit(2000).build()) + .addColumn(newLenientVarcharBuilder("long_name").setLimit(2000).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("person_id").build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").build()) - .addColumn(newVarcharBuilder("path").setLimit(2000).build()) - .addColumn(newVarcharBuilder("deprecated_kee").setLimit(400).build()) + .addColumn(newLenientVarcharBuilder("path").setLimit(2000).build()) + .addColumn(newLenientVarcharBuilder("deprecated_kee").setLimit(400).build()) .addColumn(uuidCol) .addColumn(projectUuidCol) .addColumn(moduleUuidCol) - .addColumn(newVarcharBuilder("module_uuid_path").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("module_uuid_path").setLimit(4000).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("authorization_updated_at").build()) .build()); addIndex(context, "projects", "projects_kee", true, keeCol); @@ -754,50 +754,48 @@ public class CreateInitialSchema extends DdlChange { private void createGroupRoles(Context context) throws SQLException { IntegerColumnDef groupIdCol = newIntegerColumnDefBuilder().setColumnName("group_id").setIsNullable(true).build(); IntegerColumnDef resourceIdCol = newIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build(); - VarcharColumnDef roleCol = newVarcharBuilder("role").setLimit(64).setIsNullable(false).build(); + VarcharColumnDef roleCol = newLenientVarcharBuilder("role").setLimit(64).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "group_roles") + newTableBuilder("group_roles") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(groupIdCol) .addColumn(resourceIdCol) .addColumn(roleCol) .build()); - addIndex(context, "group_roles", "group_roles_group", false, groupIdCol); addIndex(context, "group_roles", "group_roles_resource", false, resourceIdCol); - addIndex(context, "group_roles", "group_roles_role", false, roleCol); addIndex(context, "group_roles", "uniq_group_roles", true, groupIdCol, resourceIdCol, roleCol); } private void createRules(Context context) throws SQLException { - VarcharColumnDef pluginRuleKeyCol = newVarcharBuilder("plugin_rule_key").setLimit(200).setIsNullable(false).build(); - VarcharColumnDef pluginNameCol = newVarcharBuilder("plugin_name").setLimit(255).setIsNullable(false).build(); + VarcharColumnDef pluginRuleKeyCol = newLenientVarcharBuilder("plugin_rule_key").setLimit(200).setIsNullable(false).build(); + VarcharColumnDef pluginNameCol = newLenientVarcharBuilder("plugin_name").setLimit(255).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "rules") + newTableBuilder("rules") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newVarcharBuilder("name").setLimit(200).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(200).setIsNullable(true).build()) .addColumn(pluginRuleKeyCol) - .addColumn(newVarcharBuilder("plugin_config_key").setLimit(200).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("plugin_config_key").setLimit(200).setIsNullable(true).build()) .addColumn(pluginNameCol) .addColumn(newClobColumnDefBuilder().setColumnName("description").setIsNullable(true).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("priority").setIsNullable(true).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(true).build()) - .addColumn(newVarcharBuilder("status").setLimit(40).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("status").setLimit(40).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("language").setLimit(20).setIsNullable(true).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("note_created_at").setIsNullable(true).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("note_updated_at").setIsNullable(true).build()) - .addColumn(newVarcharBuilder("note_user_login").setLimit(255).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("note_user_login").setLimit(255).setIsNullable(true).build()) .addColumn(newClobColumnDefBuilder().setColumnName("note_data").setIsNullable(true).build()) - .addColumn(newVarcharBuilder("remediation_function").setLimit(200).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("def_remediation_function").setLimit(20).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("remediation_gap_mult").setLimit(20).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("def_remediation_gap_mult").setLimit(20).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("remediation_base_effort").setLimit(20).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("def_remediation_base_effort").setLimit(20).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("gap_description").setLimit(4000).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("tags").setLimit(4000).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("system_tags").setLimit(4000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("remediation_function").setLimit(200).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("def_remediation_function").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("remediation_gap_mult").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("def_remediation_gap_mult").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("remediation_base_effort").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("def_remediation_base_effort").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("gap_description").setLimit(4000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("tags").setLimit(4000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("system_tags").setLimit(4000).setIsNullable(true).build()) .addColumn(newBooleanColumnDefBuilder().setColumnName("is_template").setIsNullable(false).setDefaultValue(false).build()) - .addColumn(newVarcharBuilder("description_format").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("description_format").setLimit(20).setIsNullable(true).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) .addColumn(new TinyIntColumnDef.Builder().setColumnName("rule_type").setIsNullable(true).build()) @@ -808,26 +806,26 @@ public class CreateInitialSchema extends DdlChange { private void createWidgetProperties(Context context) throws SQLException { IntegerColumnDef widgetIdCol = newIntegerColumnDefBuilder().setColumnName("widget_id").setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "widget_properties") + newTableBuilder("widget_properties") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(widgetIdCol) - .addColumn(newVarcharBuilder("kee").setLimit(100).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("text_value").setLimit(4000).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("kee").setLimit(100).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("text_value").setLimit(4000).setIsNullable(true).build()) .build()); addIndex(context, "widget_properties", "widget_properties_widgets", false, widgetIdCol); } private void createEvents(Context context) throws SQLException { - VarcharColumnDef componentUuid = newVarcharBuilder("component_uuid").setLimit(50).setIsNullable(true).build(); + VarcharColumnDef componentUuid = newLenientVarcharBuilder("component_uuid").setLimit(50).setIsNullable(true).build(); IntegerColumnDef snapshotId = newIntegerColumnDefBuilder().setColumnName("snapshot_id").setIsNullable(true).build(); context.execute( - new CreateTableBuilder(getDialect(), "events") + newTableBuilder("events") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newVarcharBuilder("name").setLimit(400).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(400).setIsNullable(true).build()) .addColumn(snapshotId) - .addColumn(newVarcharBuilder("category").setLimit(50).build()) - .addColumn(newVarcharBuilder("description").setLimit(4000).build()) - .addColumn(newVarcharBuilder("event_data").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("category").setLimit(50).build()) + .addColumn(newLenientVarcharBuilder("description").setLimit(4000).build()) + .addColumn(newLenientVarcharBuilder("event_data").setLimit(4000).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("event_date").setIsNullable(false).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) .addColumn(componentUuid) @@ -837,9 +835,9 @@ public class CreateInitialSchema extends DdlChange { } private void createQualityGates(Context context) throws SQLException { - VarcharColumnDef nameCol = newVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); + VarcharColumnDef nameCol = newLenientVarcharBuilder("name").setLimit(100).setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "quality_gates") + newTableBuilder("quality_gates") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(nameCol) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) @@ -850,23 +848,23 @@ public class CreateInitialSchema extends DdlChange { private void createQualityGateConditions(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "quality_gate_conditions") + newTableBuilder("quality_gate_conditions") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newIntegerColumnDefBuilder().setColumnName("qgate_id").setIsNullable(true).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").setIsNullable(true).build()) .addColumn(newIntegerColumnDefBuilder().setColumnName("period").setIsNullable(true).build()) - .addColumn(newVarcharBuilder("operator").setLimit(3).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("value_error").setLimit(64).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("value_warning").setLimit(64).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("operator").setLimit(3).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("value_error").setLimit(64).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("value_warning").setLimit(64).setIsNullable(true).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("created_at").setIsNullable(true).build()) .addColumn(newTimestampColumnDefBuilder().setColumnName("updated_at").setIsNullable(true).build()) .build()); } private void createProperties(Context context) throws SQLException { - VarcharColumnDef propKey = newVarcharBuilder("prop_key").setLimit(512).setIsNullable(true).build(); + VarcharColumnDef propKey = newLenientVarcharBuilder("prop_key").setLimit(512).setIsNullable(true).build(); context.execute( - new CreateTableBuilder(getDialect(), "properties") + newTableBuilder("properties") // do not define as primary key on purpose -> already set in org.sonar.db.version.v61.CreateTableProperties2 .addColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build()) .addColumn(propKey) @@ -879,20 +877,20 @@ public class CreateInitialSchema extends DdlChange { private void createProjectLinks(Context context) throws SQLException { context.execute( - new CreateTableBuilder(getDialect(), "project_links") + newTableBuilder("project_links") .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) - .addColumn(newVarcharBuilder("link_type").setLimit(20).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("name").setLimit(128).setIsNullable(true).build()) - .addColumn(newVarcharBuilder("href").setLimit(2048).setIsNullable(false).build()) - .addColumn(newVarcharBuilder("component_uuid").setLimit(2048).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("link_type").setLimit(20).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("name").setLimit(128).setIsNullable(true).build()) + .addColumn(newLenientVarcharBuilder("href").setLimit(2048).setIsNullable(false).build()) + .addColumn(newLenientVarcharBuilder("component_uuid").setLimit(2048).setIsNullable(true).build()) .build()); } private void createDuplicationsIndex(Context context) throws SQLException { - VarcharColumnDef hashCol = newVarcharBuilder("hash").setLimit(50).setIsNullable(false).build(); + VarcharColumnDef hashCol = newLenientVarcharBuilder("hash").setLimit(50).setIsNullable(false).build(); IntegerColumnDef snapshotIdCol = newIntegerColumnDefBuilder().setColumnName("snapshot_id").setIsNullable(false).build(); context.execute( - new CreateTableBuilder(getDialect(), "duplications_index") + newTableBuilder("duplications_index") .addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(newIntegerColumnDefBuilder().setColumnName("project_snapshot_id").setIsNullable(false).build()) .addColumn(snapshotIdCol) @@ -916,7 +914,11 @@ public class CreateInitialSchema extends DdlChange { context.execute(builder.build()); } - private static VarcharColumnDef.Builder newVarcharBuilder(String column) { + private static VarcharColumnDef.Builder newLenientVarcharBuilder(String column) { return new VarcharColumnDef.Builder().setColumnName(column).setIgnoreOracleUnit(true); } + + private CreateTableBuilder newTableBuilder(String tableName) { + return new CreateTableBuilder(getDialect(), tableName); + } } diff --git a/sonar-db/src/main/java/org/sonar/db/version/v56/FixLengthOfIssuesMessageOnOracle.java b/sonar-db/src/main/java/org/sonar/db/version/v56/FixLengthOfIssuesMessageOnOracle.java deleted file mode 100644 index 3fcf5de3271..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/version/v56/FixLengthOfIssuesMessageOnOracle.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.db.version.v56; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.dialect.Oracle; -import org.sonar.db.version.DdlChange; - -public class FixLengthOfIssuesMessageOnOracle extends DdlChange { - - public FixLengthOfIssuesMessageOnOracle(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (getDialect().getId().equals(Oracle.ID)) { - // in order to not depend on value of variable NLS_LENGTH_SEMANTICS, unit of length - // is enforced to CHAR so that we're sure that type can't be 4000 BYTE. - context.execute("ALTER TABLE issues MODIFY (message VARCHAR (4000 CHAR))"); - } - } - -} diff --git a/sonar-db/src/main/java/org/sonar/db/version/v56/FixTypeOfRuleTypeOnMysql.java b/sonar-db/src/main/java/org/sonar/db/version/v56/FixTypeOfRuleTypeOnMysql.java deleted file mode 100644 index e0b52843575..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/version/v56/FixTypeOfRuleTypeOnMysql.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.db.version.v56; - -import java.sql.SQLException; -import org.sonar.api.platform.ServerUpgradeStatus; -import org.sonar.api.utils.log.Loggers; -import org.sonar.db.Database; -import org.sonar.db.dialect.MySql; -import org.sonar.db.version.DdlChange; - -public class FixTypeOfRuleTypeOnMysql extends DdlChange { - - private static final int SQ_5_5 = 1100; - private static final int SQ_5_6 = 1150; - - private final ServerUpgradeStatus dbVersion; - - public FixTypeOfRuleTypeOnMysql(Database db, ServerUpgradeStatus dbVersion) { - super(db); - this.dbVersion = dbVersion; - } - - @Override - public void execute(Context context) throws SQLException { - // In SQ 5.6, migration 1100 create columns with expected type TINYINT(2) - // In SQ 5.5, migration 1100 create columns with type TINYINT(1) instead of TINYINT(2) - // In SQ 5.4 and lower, the type TINYINT(1) was used only for boolean columns, so no problem - // As an optimization fix must be applied only for instances upgrading from 5.5.x - if (getDialect().getId().equals(MySql.ID) && - dbVersion.getInitialDbVersion() >= SQ_5_5 && dbVersion.getInitialDbVersion() < SQ_5_6) { - Loggers.get(getClass()).info("Changing TINYINT(1) to TINYINT(2)"); - context.execute("ALTER TABLE rules MODIFY COLUMN rule_type TINYINT (2)"); - context.execute("ALTER TABLE issues MODIFY COLUMN issue_type TINYINT (2)"); - } - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/PopulateInitialSchema.java b/sonar-db/src/main/java/org/sonar/db/version/v56/PopulateInitialSchema.java index 7d8185f152b..70a18b20198 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v55/PopulateInitialSchema.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v56/PopulateInitialSchema.java @@ -17,7 +17,7 @@ * 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.db.version.v55; +package org.sonar.db.version.v56; import java.sql.SQLException; import java.util.Date; diff --git a/sonar-db/src/main/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRoles.java b/sonar-db/src/main/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRoles.java deleted file mode 100644 index 36f1663aec3..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRoles.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.db.version.v56; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.version.DdlChange; -import org.sonar.db.version.DropIndexBuilder; - -/** - * SONAR-6613 - */ -public class RemoveUselessIndexesOnGroupRoles extends DdlChange { - - private static final String TABLE_NAME = "group_roles"; - - public RemoveUselessIndexesOnGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("group_roles_group") - .build()); - - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName("group_roles_role") - .build()); - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/version/v56/UpdateUsersExternalIdentityWhenEmpty.java b/sonar-db/src/main/java/org/sonar/db/version/v561/UpdateUsersExternalIdentityWhenEmpty.java index 68d5a5046d9..c7ebfb80e1f 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v56/UpdateUsersExternalIdentityWhenEmpty.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v561/UpdateUsersExternalIdentityWhenEmpty.java @@ -17,7 +17,7 @@ * 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.db.version.v56; +package org.sonar.db.version.v561; import java.sql.SQLException; import org.sonar.api.utils.System2; diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/package-info.java b/sonar-db/src/main/java/org/sonar/db/version/v561/package-info.java index c6e3adbdc98..3c210ce91d1 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v55/package-info.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v561/package-info.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ @ParametersAreNonnullByDefault -package org.sonar.db.version.v55; +package org.sonar.db.version.v561; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java index cd190a68543..579506d38b1 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java @@ -29,6 +29,6 @@ public class MigrationStepModuleTest { public void verify_count_of_added_MigrationStep_types() { ComponentContainer container = new ComponentContainer(); new MigrationStepModule().configure(container); - assertThat(container.size()).isEqualTo(129); + assertThat(container.size()).isEqualTo(126); } } diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/CreateInitialSchemaTest.java b/sonar-db/src/test/java/org/sonar/db/version/v56/CreateInitialSchemaTest.java index d5f786915b5..d92d451c1e8 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v55/CreateInitialSchemaTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v56/CreateInitialSchemaTest.java @@ -17,7 +17,7 @@ * 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.db.version.v55; +package org.sonar.db.version.v56; import java.sql.Connection; import java.sql.ResultSet; diff --git a/sonar-db/src/test/java/org/sonar/db/version/v56/FixLengthOfIssuesMessageOnOracleTest.java b/sonar-db/src/test/java/org/sonar/db/version/v56/FixLengthOfIssuesMessageOnOracleTest.java deleted file mode 100644 index b7fa56703de..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v56/FixLengthOfIssuesMessageOnOracleTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.db.version.v56; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.Dialect; -import org.sonar.db.dialect.MySql; -import org.sonar.db.dialect.Oracle; -import org.sonar.db.version.DdlChange; - -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -public class FixLengthOfIssuesMessageOnOracleTest { - - Database db = mock(Database.class, RETURNS_DEEP_STUBS); - DdlChange.Context context = mock(DdlChange.Context.class); - FixLengthOfIssuesMessageOnOracle underTest = new FixLengthOfIssuesMessageOnOracle(db); - - @Test - public void alter_column_if_upgrading_oracle() throws SQLException { - prepare(new Oracle()); - - underTest.execute(context); - - verify(context).execute("ALTER TABLE issues MODIFY (message VARCHAR (4000 CHAR))"); - } - - @Test - public void do_not_alter_column_if_not_oracle() throws SQLException { - prepare(new MySql()); - - underTest.execute(context); - - verifyZeroInteractions(context); - } - - private void prepare(Dialect dialect) { - when(db.getDialect()).thenReturn(dialect); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v56/FixTypeOfRuleTypeOnMysqlTest.java b/sonar-db/src/test/java/org/sonar/db/version/v56/FixTypeOfRuleTypeOnMysqlTest.java deleted file mode 100644 index d7e4b0ecdae..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v56/FixTypeOfRuleTypeOnMysqlTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.db.version.v56; - -import java.sql.SQLException; -import org.junit.Test; -import org.sonar.api.platform.ServerUpgradeStatus; -import org.sonar.db.Database; -import org.sonar.db.dialect.Dialect; -import org.sonar.db.dialect.MySql; -import org.sonar.db.dialect.Oracle; -import org.sonar.db.version.DdlChange; - -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -public class FixTypeOfRuleTypeOnMysqlTest { - - private static final int FRESH_MIGRATION_VERSION = -1; - private static final int A_MIGRATION_VERSION_IN_5_5 = 1105; - private static final int A_MIGRATION_VERSION_BEFORE_5_5 = 200; - - Database db = mock(Database.class, RETURNS_DEEP_STUBS); - ServerUpgradeStatus dbVersion = mock(ServerUpgradeStatus.class); - DdlChange.Context context = mock(DdlChange.Context.class); - FixTypeOfRuleTypeOnMysql underTest = new FixTypeOfRuleTypeOnMysql(db, dbVersion); - - @Test - public void alter_columns_if_upgrading_mysql_from_version_5_5() throws SQLException { - prepare(A_MIGRATION_VERSION_IN_5_5, new MySql()); - - underTest.execute(context); - - verify(context).execute("ALTER TABLE rules MODIFY COLUMN rule_type TINYINT (2)"); - verify(context).execute("ALTER TABLE issues MODIFY COLUMN issue_type TINYINT (2)"); - } - - @Test - public void do_not_alter_columns_if_fresh_mysql_install() throws SQLException { - prepare(FRESH_MIGRATION_VERSION, new MySql()); - - underTest.execute(context); - - verifyZeroInteractions(context); - } - - @Test - public void do_not_alter_columns_if_upgrading_mysql_from_before_5_5() throws SQLException { - prepare(A_MIGRATION_VERSION_BEFORE_5_5, new MySql()); - - underTest.execute(context); - - verifyZeroInteractions(context); - } - - @Test - public void do_not_alter_columns_if_upgrading_from_5_5_but_not_mysql() throws SQLException { - prepare(A_MIGRATION_VERSION_IN_5_5, new Oracle()); - - underTest.execute(context); - - verifyZeroInteractions(context); - } - - private void prepare(int initialVersion, Dialect dialect) { - when(dbVersion.getInitialDbVersion()).thenReturn(initialVersion); - when(db.getDialect()).thenReturn(dialect); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/PopulateInitialSchemaTest.java b/sonar-db/src/test/java/org/sonar/db/version/v56/PopulateInitialSchemaTest.java index 0fcc7359aed..3f3699edcc8 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v55/PopulateInitialSchemaTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v56/PopulateInitialSchemaTest.java @@ -17,7 +17,7 @@ * 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.db.version.v55; +package org.sonar.db.version.v56; import java.sql.SQLException; import java.util.List; @@ -43,7 +43,7 @@ public class PopulateInitialSchemaTest { private System2 system2 = mock(System2.class); @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateInitialSchemaTest.class, "v55.sql"); + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateInitialSchemaTest.class, "v56.sql"); private PopulateInitialSchema underTest = new PopulateInitialSchema(db.database(), system2); diff --git a/sonar-db/src/test/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRolesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRolesTest.java deleted file mode 100644 index ff0ea40618d..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRolesTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.db.version.v56; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.sonar.db.Database; -import org.sonar.db.dialect.MySql; -import org.sonar.db.version.DdlChange; - -import static java.util.Arrays.asList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -public class RemoveUselessIndexesOnGroupRolesTest { - - private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); - private DdlChange.Context context = mock(DdlChange.Context.class); - - @Before - public void setUp() { - // Some databases have unique names of indexes, so table name is not declared - // when dropping an index ("drop index <index name>"). Because of that MySQL is - // used in the test so that the table name can also be verified - when(db.getDialect()).thenReturn(new MySql()); - } - - @Test - public void remove_two_indices_from_group_roles() throws Exception { - RemoveUselessIndexesOnGroupRoles underTest = new RemoveUselessIndexesOnGroupRoles(db); - - underTest.execute(context); - - verify(context).execute(asList("DROP INDEX group_roles_group ON group_roles")); - verify(context).execute(asList("DROP INDEX group_roles_role ON group_roles")); - verifyNoMoreInteractions(context); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v56/UpdateUsersExternalIdentityWhenEmptyTest.java b/sonar-db/src/test/java/org/sonar/db/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java index 60471734237..7a32d598d97 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v56/UpdateUsersExternalIdentityWhenEmptyTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java @@ -17,7 +17,7 @@ * 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.db.version.v56; +package org.sonar.db.version.v561; import java.util.HashMap; import java.util.Map; diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/CreateInitialSchemaTest/empty.sql b/sonar-db/src/test/resources/org/sonar/db/version/v56/CreateInitialSchemaTest/empty.sql index e69de29bb2d..e69de29bb2d 100644 --- a/sonar-db/src/test/resources/org/sonar/db/version/v55/CreateInitialSchemaTest/empty.sql +++ b/sonar-db/src/test/resources/org/sonar/db/version/v56/CreateInitialSchemaTest/empty.sql diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/PopulateInitialSchemaTest/v55.sql b/sonar-db/src/test/resources/org/sonar/db/version/v56/PopulateInitialSchemaTest/v56.sql index d4d5c746f9c..d0c61c969ac 100644 --- a/sonar-db/src/test/resources/org/sonar/db/version/v55/PopulateInitialSchemaTest/v55.sql +++ b/sonar-db/src/test/resources/org/sonar/db/version/v56/PopulateInitialSchemaTest/v56.sql @@ -22,10 +22,8 @@ CREATE TABLE "GROUP_ROLES" ( "RESOURCE_ID" INTEGER, "ROLE" VARCHAR(64) NOT NULL ); -CREATE INDEX "GROUP_ROLES_ROLE" ON "GROUP_ROLES" ("ROLE"); CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE INDEX "GROUP_ROLES_GROUP" ON "GROUP_ROLES" ("GROUP_ID"); CREATE TABLE "USERS" ( diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v56/UpdateUsersExternalIdentityWhenEmptyTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v561/UpdateUsersExternalIdentityWhenEmptyTest/schema.sql index 127fc346a9f..127fc346a9f 100644 --- a/sonar-db/src/test/resources/org/sonar/db/version/v56/UpdateUsersExternalIdentityWhenEmptyTest/schema.sql +++ b/sonar-db/src/test/resources/org/sonar/db/version/v561/UpdateUsersExternalIdentityWhenEmptyTest/schema.sql |