diff options
author | Eric Giffon <eric.giffon@sonarsource.com> | 2024-10-07 14:58:16 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-10-14 20:03:02 +0000 |
commit | 121226eab94dc57c61ee446dfa2a5c5e11765ca1 (patch) | |
tree | 30d5e93c6121f31213823d0807907e1e79e8c7b3 /server | |
parent | 112170c17981556868bd0aedbbb636d1acdc8588 (diff) | |
download | sonarqube-121226eab94dc57c61ee446dfa2a5c5e11765ca1.tar.gz sonarqube-121226eab94dc57c61ee446dfa2a5c5e11765ca1.zip |
SONAR-23213 Add PK at table creation
This ensures there is no corruption with duplicates in the table. It
would fail the actual migration for the 10.8 upgrade otherwise.
Diffstat (limited to 'server')
2 files changed, 2 insertions, 2 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/adhoc/CreateMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/adhoc/CreateMeasuresTable.java index bf5e4f19017..36e8d2ca755 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/adhoc/CreateMeasuresTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/adhoc/CreateMeasuresTable.java @@ -48,7 +48,7 @@ public class CreateMeasuresTable extends CreateTableChange { @Override public void execute(DdlChange.Context context, String tableName) throws SQLException { context.execute(new CreateTableBuilder(getDialect(), tableName) - .addColumn(newVarcharColumnDefBuilder().setColumnName(COLUMN_COMPONENT_UUID).setIsNullable(false).setLimit(UUID_SIZE).build()) + .addPkColumn(newVarcharColumnDefBuilder().setColumnName(COLUMN_COMPONENT_UUID).setIsNullable(false).setLimit(UUID_SIZE).build()) .addColumn(newVarcharColumnDefBuilder().setColumnName(COLUMN_BRANCH_UUID).setIsNullable(false).setLimit(UUID_SIZE).build()) .addColumn(newClobColumnDefBuilder().setColumnName(COLUMN_JSON_VALUE).setIsNullable(false).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName(COLUMN_JSON_VALUE_HASH).setIsNullable(false).build()) diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/adhoc/CreateMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/adhoc/CreateMeasuresTableTest.java index ede32bd4777..31658113804 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/adhoc/CreateMeasuresTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/adhoc/CreateMeasuresTableTest.java @@ -49,7 +49,7 @@ public class CreateMeasuresTableTest { underTest.execute(); db.assertTableExists(MEASURES_TABLE_NAME); - db.assertNoPrimaryKey(MEASURES_TABLE_NAME); + db.assertPrimaryKey(MEASURES_TABLE_NAME, "pk_measures", "component_uuid"); db.assertColumnDefinition(MEASURES_TABLE_NAME, COLUMN_COMPONENT_UUID, Types.VARCHAR, UUID_SIZE, false); db.assertColumnDefinition(MEASURES_TABLE_NAME, COLUMN_BRANCH_UUID, Types.VARCHAR, UUID_SIZE, false); db.assertColumnDefinition(MEASURES_TABLE_NAME, COLUMN_JSON_VALUE, Types.CLOB, null, false); |