theonedev/onedev · critical · ExplicitException
Data version mismatch (app data version: %s, db data version
Error message
Data version mismatch (app data version: %s, db data version: %s)
What it means
checkDataVersion compares the data version stored in the DB with the app data version (MigrationHelper.getVersion(DataMigrator.class)). If they differ, the database was created/migrated by a different OneDev version, so it throws this ExplicitException with both versions.
Source
Thrown at server-core/src/main/java/io/onedev/server/data/DefaultDataService.java:236
logger.error("Error executing sql: " + sql, e);
if (failOnError)
throw e;
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Override
public String checkDataVersion(Connection conn, boolean allowEmptyDB) {
String dbDataVersion = readDbDataVersion(conn);
if (!allowEmptyDB && dbDataVersion == null)
throw new ExplicitException("Database is not populated yet");
String appDataVersion = MigrationHelper.getVersion(DataMigrator.class);
if (dbDataVersion != null && !dbDataVersion.equals(appDataVersion)) {
throw new ExplicitException(String.format("Data version mismatch (app data version: %s, db data version: %s)",
appDataVersion, dbDataVersion));
}
return dbDataVersion;
}
@Override
public void populateDatabase(Connection conn) {
if (hibernateConfig.isHSQLDialect())
execute(conn, Lists.newArrayList("SET DATABASE TRANSACTION CONTROL MVCC"), true);
String dbDataVersion = checkDataVersion(conn, true);
if (dbDataVersion == null) {
File tempFile = null;
try {
tempFile = FileUtils.createTempFile("schema", ".sql");
new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
.setFormat(false).createOnly(EnumSet.of(TargetType.SCRIPT), getMetadata());View on GitHub (pinned to d44925c47c)
Solutions
- Run the matching OneDev version that the DB was migrated with, or a newer one that can upgrade it
- Restore a DB backup consistent with the current application version
- Never downgrade below the version that last migrated the database
- Check the version via the ModelVersion table and pick the correct release
Example fix
// before # running OneDev 10.0 against a DB migrated by 11.2 // after # download and run OneDev 11.2 (or newer) so the data versions match
Defensive patterns
Strategy: validation
Validate before calling
String dbVersion = queryScalar(conn, "select version from model_version"); if (dbVersion != null && !dbVersion.equals(expectedAppDataVersion)) useMatchingOneDevVersion(dbVersion);
Try / catch
try { startServer(); } catch (ExplicitException e) { if (e.getMessage().contains("Data version mismatch")) { parseVersions(e); runCompatibleRelease(); } } Prevention
- Never downgrade below the version that last migrated the DB
- Restore DB backups only into instances of matching version
- Run one OneDev version per database
- Record the app version alongside each backup
When it happens
Trigger: Starting or migrating OneDev when the DB's version row (from ModelVersion table) does not equal the version expected by the running application's DataMigrator chain.
Common situations: Downgrading OneDev after the DB was migrated to a newer schema; restoring a DB backup from a different OneDev version; running multiple OneDev versions against the same database.
Related errors
- Unable to upgrade specified installation as database is not
- Unable to upgrade specified installation due to above error
- Unable to upgrade specified installation as data version of
- Server not set up yet
- Failed to apply database constraints. If this error is cause
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/a2738216a93f0e4c.
Report an issue: GitHub.