diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2018-05-28 09:19:25 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-05-28 20:20:43 +0200 |
commit | 4063ffe9d2b7190497514ff7e476fedb57203d5e (patch) | |
tree | 37bf40a90d39112af761f1e78a8d83df5bfb4bf0 /server/sonar-db-migration | |
parent | 2f215846b2e803811048223784b1c0023790da4f (diff) | |
download | sonarqube-4063ffe9d2b7190497514ff7e476fedb57203d5e.tar.gz sonarqube-4063ffe9d2b7190497514ff7e476fedb57203d5e.zip |
SONAR-19597 Set USERS.UUID length to 255 instead of 40
As USERS.UUID will be fed by login during the migration, this column cannot be smaller than login's length.
Diffstat (limited to 'server/sonar-db-migration')
15 files changed, 28 insertions, 22 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers.java index d05abca5a63..cc5ca02cdfe 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsers.java @@ -19,18 +19,18 @@ */ package org.sonar.server.platform.db.migration.version.v72; +import java.sql.SQLException; import org.sonar.db.Database; import org.sonar.server.platform.db.migration.def.VarcharColumnDef; import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import java.sql.SQLException; - public class AddUUIDtoUsers extends DdlChange { private static final String TABLE_NAME = "users"; private static final String UUID_COLUMN_NAME = "uuid"; - private static final int UUID_LENGTH = 40; + // We need to use a length of 255 as the migration that fed it will use login, which are using a length of 255 + private static final int UUID_LENGTH = 255; public AddUUIDtoUsers(Database db) { super(db); diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsers.java index 41dfef1548d..2092c717cef 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsers.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsers.java @@ -39,7 +39,7 @@ public class AddUniqueIndexesOnUsers extends DdlChange { .setTable("users") .setName("users_uuid") .setUnique(true) - .addColumn(notNullableColumn("uuid", 40)) + .addColumn(notNullableColumn("uuid", 255)) .build()); context.execute(new CreateIndexBuilder(getDialect()) diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullable.java index 82f18e8d28f..ca518bf7bdb 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullable.java @@ -46,7 +46,7 @@ public class MakeSomeColumnsOfUsersNotNullable extends DdlChange { .build()); context.execute(new AlterColumnsBuilder(getDialect(), USERS_TABLE) - .updateColumn(notNullableColumn("uuid", 40)) + .updateColumn(notNullableColumn("uuid", 255)) .updateColumn(notNullableColumn("login", 255)) .updateColumn(notNullableColumn("external_id", 255)) .updateColumn(notNullableColumn("external_login", 255)) diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsersTest.java index 29165a3543c..29b1f06ab94 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsersTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/AddUUIDtoUsersTest.java @@ -43,7 +43,7 @@ public class AddUUIDtoUsersTest { public void column_is_added_to_table() throws SQLException { underTest.execute(); - dbTester.assertColumnDefinition("users", "uuid", VARCHAR, 40, true); + dbTester.assertColumnDefinition("users", "uuid", VARCHAR, 255, true); } @Test diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest.java index 73c60165234..98eb7305850 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest.java @@ -38,7 +38,7 @@ public class MakeSomeColumnsOfUsersNotNullableTest { public void columns_are_set_as_not_nullable() throws SQLException { underTest.execute(); - db.assertColumnDefinition("users", "uuid", VARCHAR, 40, false); + db.assertColumnDefinition("users", "uuid", VARCHAR, 255, false); db.assertColumnDefinition("users", "login", VARCHAR, 255, false); db.assertColumnDefinition("users", "external_id", VARCHAR, 255, false); db.assertColumnDefinition("users", "external_login", VARCHAR, 255, false); @@ -51,7 +51,7 @@ public class MakeSomeColumnsOfUsersNotNullableTest { underTest.execute(); underTest.execute(); - db.assertColumnDefinition("users", "uuid", VARCHAR, 40, false); + db.assertColumnDefinition("users", "uuid", VARCHAR, 255, false); db.assertColumnDefinition("users", "login", VARCHAR, 255, false); db.assertColumnDefinition("users", "external_id", VARCHAR, 255, false); db.assertColumnDefinition("users", "external_login", VARCHAR, 255, false); diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest.java index 948a36cff7a..609eefe532d 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest.java @@ -19,11 +19,9 @@ */ package org.sonar.server.platform.db.migration.version.v72; +import com.google.common.base.Strings; import java.sql.SQLException; import java.util.ArrayList; -import java.util.Date; -import java.util.stream.Collectors; - import org.assertj.core.groups.Tuple; import org.junit.Rule; import org.junit.Test; @@ -62,7 +60,6 @@ public class PopulateUUIDOnUsersTest { @Test public void update_uuid_when_login_is_present() throws SQLException { - String login1 = insertUser(NO_UUID, randomAlphanumeric(10)); String login2 = insertUser(NO_UUID, randomAlphanumeric(10)); String login3 = insertUser(NO_UUID, randomAlphanumeric(10)); @@ -77,6 +74,15 @@ public class PopulateUUIDOnUsersTest { } @Test + public void check_max_length() throws Exception { + String login = insertUser(NO_UUID, Strings.repeat("a", 255)); + + underTest.execute(); + + assertUser(tuple(login, login, PAST, NOW)); + } + + @Test public void generate_random_uuid_when_login_is_null() throws SQLException { insertUser(NO_UUID, NO_LOGIN); insertUser(NO_UUID, NO_LOGIN); @@ -88,7 +94,7 @@ public class PopulateUUIDOnUsersTest { } @Test - public void _do_nothing_when_uuid_is_already_present() throws SQLException { + public void do_nothing_when_uuid_is_already_present() throws SQLException { String login1 = insertUser(NO_UUID, randomAlphanumeric(10)); String login2 = insertUser("existing-uuid", randomAlphanumeric(10)); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest/users.sql index c1d3972c0b5..63f3678158c 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest/users.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddExternalIdToUsersTest/users.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), + "UUID" VARCHAR(255), "LOGIN" VARCHAR(255), "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest/users.sql index 74cb1f15571..3d35b327f62 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest/users.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddOrganizationUuidToUsersTest/users.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, + "UUID" VARCHAR(255) NOT NULL, "LOGIN" VARCHAR(255) NOT NULL, "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest/users.sql index a63e0aeb4db..5d8477543c8 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest/users.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/AddUniqueIndexesOnUsersTest/users.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), + "UUID" VARCHAR(255), "LOGIN" VARCHAR(255), "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest/users.sql index a63e0aeb4db..5d8477543c8 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest/users.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/MakeSomeColumnsOfUsersNotNullableTest/users.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), + "UUID" VARCHAR(255), "LOGIN" VARCHAR(255), "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateExternalIdOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateExternalIdOnUsersTest/users.sql index a63e0aeb4db..5d8477543c8 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateExternalIdOnUsersTest/users.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateExternalIdOnUsersTest/users.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), + "UUID" VARCHAR(255), "LOGIN" VARCHAR(255), "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest/schema.sql index 194d7960153..a3d5dc0b618 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest/schema.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateOrganizationUuidOnUsersTest/schema.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40) NOT NULL, + "UUID" VARCHAR(255) NOT NULL, "LOGIN" VARCHAR(255) NOT NULL, "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest/users.sql index 9f03d34955f..d5b823e4b60 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest/users.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/PopulateUUIDOnUsersTest/users.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), + "UUID" VARCHAR(255), "LOGIN" VARCHAR(255), "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest/users.sql index 19dc45a3dd6..c88da101896 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest/users.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/RenameExternalIdentityToExternalLoginOnUsersTest/users.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), + "UUID" VARCHAR(255), "LOGIN" VARCHAR(255), "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest/users.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest/users.sql index a63e0aeb4db..5d8477543c8 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest/users.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v72/UpdateNullValuesFromExternalColumnsAndLoginOfUsersTest/users.sql @@ -1,6 +1,6 @@ CREATE TABLE "USERS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "UUID" VARCHAR(40), + "UUID" VARCHAR(255), "LOGIN" VARCHAR(255), "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), |