{"record":{"id":"99af76aadc791dba","repo":"SonarSource/sonarqube","slug":"unsupported-database-s-99af76","errorCode":null,"errorMessage":"Unsupported database '%s'","messagePattern":"Unsupported database '(.+?)'","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGenerator.java","lineNumber":70,"sourceCode":"  }\n\n  public List<String> generate(String tableName, Collection<String> columnNames, boolean isAutoGenerated) throws SQLException {\n    Dialect dialect = db.getDialect();\n    Optional<String> constraintName = dbConstraintFinder.findConstraintName(tableName);\n    if (!constraintName.isPresent()) {\n      return Collections.emptyList();\n    }\n    switch (dialect.getId()) {\n      case PostgreSql.ID:\n        return generateForPostgresSql(tableName, columnNames, constraintName.get());\n      case MsSql.ID:\n        return generateForMsSql(tableName, constraintName.get());\n      case Oracle.ID:\n        return generateForOracle(tableName, constraintName.get(), isAutoGenerated);\n      case H2.ID:\n        return generateForH2(tableName, constraintName.get());\n      default:\n        throw new IllegalStateException(format(\"Unsupported database '%s'\", dialect.getId()));\n    }\n  }\n\n  private List<String> generateForPostgresSql(String tableName, Collection<String> columns, String constraintName) throws SQLException {\n    List<String> statements = new ArrayList<>();\n    for (String column : columns) {\n      statements.add(format(\"ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT\", tableName, column));\n      String sequence = dbConstraintFinder.getPostgresSqlSequence(tableName, column);\n      if (sequence != null) {\n        statements.add(format(\"DROP SEQUENCE %s\", sequence));\n      }\n    }\n\n    statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName));\n    return statements;\n  }\n\n  private static List<String> generateForOracle(String tableName, String constraintName, boolean isAutoGenerated) {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGenerator.java#L52-L88","documentation":"DropPrimaryKeySqlGenerator.generate() switches on the dialect id (postgresql, mssql, oracle, h2) to emit dialect-specific DROP PRIMARY KEY statements. Any other dialect id hits the default branch and throws an IllegalStateException formatted as \"Unsupported database '%s'\". The generator supports only the dialects listed in its switch.","triggerScenarios":"Invoking generate() during a migration step that drops a primary key while the configured Dialect id is not one of postgresql/mssql/oracle/h2 (e.g. an unknown or newly added dialect id).","commonSituations":"Installing SonarQube on an unsupported or brand-new database engine; a misconfigured sonar.jdbc.dialect value; running on a database fork whose driver reports a different dialect id.","solutions":["Verify sonar.jdbc.dialect matches a supported value and that the database is officially supported for this SonarQube version.","If supporting a new engine, implement the dialect's Dialect class AND add a case in DropPrimaryKeySqlGenerator (e.g. generateForXxx).","Test migrations on H2 only for dev, never expect H2-specific paths to cover other engines."],"exampleFix":"// before\ndefault:\n  throw new IllegalStateException(format(\"Unsupported database '%s'\", dialect.getId()));\n// after\ncase MySql.ID:\n  return List.of(format(\"ALTER TABLE %s DROP PRIMARY KEY\", tableName));\ndefault:\n  throw new IllegalStateException(format(\"Unsupported database '%s'\", dialect.getId()));","handlingStrategy":"validation","validationCode":"if (!Set.of(\"postgresql\", \"mssql\", \"oracle\", \"h2\").contains(dialect.getId())) {\n  throw new IllegalArgumentException(\"DropPrimaryKeySqlGenerator does not support \" + dialect.getId());\n}","typeGuard":"boolean supportedForDropPk(Dialect d) { return Set.of(PostgreSql.ID, MsSql.ID, Oracle.ID, H2.ID).contains(d.getId()); }","tryCatchPattern":"try {\n  sqls = new DropPrimaryKeySqlGenerator(dialect).generate(tableName, columns, isAutoGenerated);\n} catch (IllegalStateException e) {\n  LOG.error(\"Cannot drop primary key on {}: {}\", tableName, e.getMessage());\n}","preventionTips":["Pin deployments to officially supported databases for your SonarQube version.","Extend DropPrimaryKeySqlGenerator whenever a new dialect is registered.","Validate sonar.jdbc.dialect at startup before migrations begin."],"tags":["database","migration","unsupported-dialect","primary-key"],"backgroundTag":"unsupported-enum-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}