diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2020-04-30 13:05:38 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-05-25 20:05:22 +0000 |
commit | 7925b2f67b87f0d3d6086a3b006e276341f70566 (patch) | |
tree | a38811b48c5b62979aa848c5e04d01d15a023447 /server/sonar-db-migration | |
parent | 1cb0039c096e60727fdecb2547bb6873380dbce4 (diff) | |
download | sonarqube-7925b2f67b87f0d3d6086a3b006e276341f70566.tar.gz sonarqube-7925b2f67b87f0d3d6086a3b006e276341f70566.zip |
SONAR-13221 change PROPERTIES user_id FK to user_uuid
Diffstat (limited to 'server/sonar-db-migration')
10 files changed, 466 insertions, 0 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java index 259a43befbd..f567447bfba 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java @@ -279,6 +279,9 @@ import org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplates import org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers.DropUserIdColumnOfPermTemplatesUsersTable; import org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers.MakePermTemplatesUsersUserUuidColumnNotNullable; import org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers.PopulatePermTemplatesUsersUserUuid; +import org.sonar.server.platform.db.migration.version.v83.users.fk.properties.AddUserUuidColumnToPropertiesUsers; +import org.sonar.server.platform.db.migration.version.v83.users.fk.properties.DropUserIdColumnOfPropertiesTable; +import org.sonar.server.platform.db.migration.version.v83.users.fk.properties.PopulatePropertiesUserUuid; import org.sonar.server.platform.db.migration.version.v83.usertokens.AddPrimaryKeyOnUuidColumnOfUserTokensTable; import org.sonar.server.platform.db.migration.version.v83.usertokens.AddUuidColumnToUserTokens; import org.sonar.server.platform.db.migration.version.v83.usertokens.DropIdColumnOfUserTokensTable; @@ -674,6 +677,11 @@ public class DbVersion83 implements DbVersion { .add(3653, "Make 'user_uuid' not-null for 'PERM_TEMPLATES_USERS'", MakePermTemplatesUsersUserUuidColumnNotNullable.class) .add(3654, "Drop column on 'user_id' column of 'PERM_TEMPLATES_USERS' table", DropUserIdColumnOfPermTemplatesUsersTable.class) + // Migration of FK in PROPERTIES to USERS + .add(3616, "Add 'user_uuid' column on 'PROPERTIES' table", AddUserUuidColumnToPropertiesUsers.class) + .add(3617, "Populate 'user_uuid' for 'PROPERTIES'", PopulatePropertiesUserUuid.class) + .add(3618, "Drop column on 'user_id' column of 'PROPERTIES' table", DropUserIdColumnOfPropertiesTable.class) + ; } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java new file mode 100644 index 00000000000..7aaf723df88 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v83.users.fk.util.AddUserUuidColumnToTable; + +public class AddUserUuidColumnToPropertiesUsers extends AddUserUuidColumnToTable { + + public AddUserUuidColumnToPropertiesUsers(Database db) { + super(db, "properties"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTable.java new file mode 100644 index 00000000000..89453c14d17 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUserIdColumnOfPropertiesTable extends DdlChange { + public DropUserIdColumnOfPropertiesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "properties", "user_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuid.java new file mode 100644 index 00000000000..fb709768fec --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuid.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePropertiesUserUuid extends DataChange { + + public PopulatePropertiesUserUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select p.uuid, u.uuid " + + "from properties p " + + "join users u on p.user_id = u.id where p.user_uuid is null"); + + massUpdate.update("update properties set user_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update, index) -> { + String propertiesUuid = row.getString(1); + String userUuid = row.getString(2); + + update.setString(1, userUuid); + update.setString(2, propertiesUuid); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java new file mode 100644 index 00000000000..49370b15b1e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java @@ -0,0 +1,65 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUserUuidColumnToPropertiesUsersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToPropertiesUsersTest.class, "schema.sql"); + + private DdlChange underTest = new AddUserUuidColumnToPropertiesUsers(db.database()); + + @Before + public void setup() { + insertProperty(Uuids.createFast()); + insertProperty(Uuids.createFast()); + insertProperty(Uuids.createFast()); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("properties", "user_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(*) from properties")) + .isEqualTo(3); + } + + private void insertProperty(String uuid) { + db.executeInsert("properties", + "uuid", uuid, + "prop_key", "kee-" + uuid, + "is_empty", false, + "created_at", System.currentTimeMillis()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java new file mode 100644 index 00000000000..ca84f8399cf --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropUserIdColumnOfPropertiesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfPropertiesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUserIdColumnOfPropertiesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("properties", "user_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest.java new file mode 100644 index 00000000000..63943ddc6ad --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest.java @@ -0,0 +1,154 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.Optional; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePropertiesUserUuidTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePropertiesUserUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulatePropertiesUserUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String propertyUuid_1 = Uuids.createFast(); + insertProperty(propertyUuid_1, userId_1); + String propertyUuid_2 = Uuids.createFast(); + insertProperty(propertyUuid_2, userId_2); + String propertyUuid_3 = Uuids.createFast(); + insertProperty(propertyUuid_3, userId_3); + String propertyUuid_4 = Uuids.createFast(); + insertProperty(propertyUuid_4, userId_4); + String propertyUuid_5 = Uuids.createFast(); + insertProperty(propertyUuid_5, null); + + underTest.execute(); + + assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_2, userUuid_2); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_3, userUuid_3); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_4, userUuid_4); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_5, null); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String propertyUuid_1 = Uuids.createFast(); + insertProperty(propertyUuid_1, userId_1); + String propertyUuid_2 = Uuids.createFast(); + insertProperty(propertyUuid_2, userId_2); + String propertyUuid_3 = Uuids.createFast(); + insertProperty(propertyUuid_3, userId_3); + + underTest.execute(); + + String propertyUuid_4 = Uuids.createFast(); + insertProperty(propertyUuid_4, userId_4); + String propertyUuid_5 = Uuids.createFast(); + insertProperty(propertyUuid_5, null); + + // re-entrant + underTest.execute(); + + assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_2, userUuid_2); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_3, userUuid_3); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_4, userUuid_4); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_5, null); + } + + private void assertThatPropertyUserUuidIsEqualTo(String propertyUuid, String expectedUuid) { + Optional<Object> optional = db.select(String.format("select user_uuid from properties where uuid = '%s'", propertyUuid)) + .stream() + .map(row -> row.get("USER_UUID")) + .filter(Objects::nonNull) + .findFirst(); + + if (expectedUuid != null) { + assertThat(optional).hasValue(expectedUuid); + } else { + assertThat(optional).isEmpty(); + } + + } + + private void insertProperty(String uuid, Long userId) { + db.executeInsert("properties", + "uuid", uuid, + "user_id", userId, + "prop_key", "kee-" + uuid, + "is_empty", false, + "created_at", System.currentTimeMillis()); + } + + private void insertUser(Long id, String uuid) { + db.executeInsert("users", + "id", id, + "uuid", uuid, + "login", "login" + id, + "external_login", "ex-login" + id, + "external_identity_provider", "ex-provider" + id, + "external_id", id + 1, + "is_root", false, + "onboarded", false); + } +} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql new file mode 100644 index 00000000000..e63f2fb66c8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PROPERTIES"( + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql new file mode 100644 index 00000000000..a3d1fbfeeea --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE "PROPERTIES"( + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "USER_ID" INTEGER, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); + + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql new file mode 100644 index 00000000000..7b392af768c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql @@ -0,0 +1,44 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); + +CREATE TABLE "PROPERTIES"( + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "USER_ID" INTEGER, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); |