{"record":{"id":"37dda753b14479cc","repo":"theonedev/onedev","slug":"onedev-program-is-too-old-please-use-a-newer-vers","errorCode":null,"errorMessage":"OneDev program is too old, please use a newer version","messagePattern":"OneDev program is too old, please use a newer version","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/commandhandler/Upgrade.java","lineNumber":309,"sourceCode":"\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tvar callable = new Callable<Void>() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic Void call() {\n\t\t\t\t\t\t\tvar newAppDataVersion = parseInt(MigrationHelper.getVersion(DataMigrator.class));\n\t\t\t\t\t\t\tvar dataVersion = getDataVersion(upgradeDir);\n\t\t\t\t\t\t\tvar oldAppDataVersion = dataVersion.app;\n\t\t\t\t\t\t\tvar dbDataVersion = dataVersion.db;\n\t\t\t\t\t\t\tif (dbDataVersion == 0) \n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unable to upgrade specified installation as database is not populated yet\");\n\t\t\t\t\t\t\tif (dbDataVersion == -1) \n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unable to upgrade specified installation due to above error\");\n\t\t\t\t\t\t\tif (dbDataVersion != oldAppDataVersion && dbDataVersion != newAppDataVersion) \n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unable to upgrade specified installation as data version of application and database is not the same\");\n\t\t\t\t\t\t\tif (newAppDataVersion < oldAppDataVersion) \n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"OneDev program is too old, please use a newer version\");\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tString timestamp = DateTimeFormat.forPattern(BACKUP_DATETIME_FORMAT).print(new DateTime());\n\t\t\t\t\t\t\tFile programBackup = new File(upgradeDir, \"site/program-backup/\" + timestamp);\n\t\t\t\t\t\t\tFileUtils.createDir(programBackup);\n\n\t\t\t\t\t\t\tlogger.info(\"Backing up old program files as {}...\", programBackup.getAbsolutePath());\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tfor (File each : upgradeDir.listFiles()) {\n\t\t\t\t\t\t\t\t\tif (each.isFile()) {\n\t\t\t\t\t\t\t\t\t\tFileUtils.copyFileToDirectory(each, programBackup);\n\t\t\t\t\t\t\t\t\t} else if (!each.getName().equals(\"temp\")\n\t\t\t\t\t\t\t\t\t\t\t&& !each.getName().equals(\"site\")\n\t\t\t\t\t\t\t\t\t\t\t&& !each.getName().equals(\"internaldb\")) {\n\t\t\t\t\t\t\t\t\t\tFileUtils.copyDirectoryToDirectory(each, programBackup);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\t\t\tthrow new RuntimeException(e);","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/commandhandler/Upgrade.java#L291-L327","documentation":"Upgrade.call() compares the newest data version supported by the running program (newAppDataVersion from DataMigrator) with the old application data version found in the upgrade dir. If the program's version is older than the data version on disk (i.e. the installation's data has already been migrated by a newer OneDev), the upgrade aborts with 'OneDev program is too old, please use a newer version' to prevent downgrading the data format.","triggerScenarios":"Running 'upgrade' with an older OneDev distribution against a site directory whose data was already migrated by a newer version — newAppDataVersion < oldAppDataVersion.","commonSituations":"Downgrading OneDev after trying a newer release; deploying an older Docker image over an upgraded data volume; running an old version binary against a site directory that a newer version already upgraded.","solutions":["Download and run a OneDev version equal to or newer than the one that last upgraded the data.","If downgrade is unavoidable, restore the site directory and database from a backup taken before the newer version ran.","Check the data version in logs/upgrade output to identify which program version is required.","Avoid mixing program versions and site data; keep container tags and data volumes in sync."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure the target program version is not older than the data\nif (runningProgramVersion < lastVersionThatUpgradedData)\n    throw new IllegalStateException(\"Use a OneDev version >= \" + lastVersionThatUpgradedData);","typeGuard":null,"tryCatchPattern":"try {\n    upgrade.call();\n} catch (ExplicitException e) {\n    if (e.getMessage().contains(\"OneDev program is too old\"))\n    logger.error(\"Data already migrated by a newer version; deploy matching or newer build\");\n}","preventionTips":["Never downgrade OneDev below the version that last touched the data volume.","Pin container image tags consistently with the site data version.","Take a full site+DB backup before trying a newer version so you can roll back safely."],"tags":["upgrade","versioning","downgrade","migration"],"backgroundTag":"database-schema-version-mismatch","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}