Repository navigation
fix(migrations): keep app config when Nextcloud replays changeSchema() - #1192
Merged
Merged
Conversation
Nextcloud replays the changeSchema() of every migration to check the database schema: `occ db:schema:check`, and at the end of every `occ upgrade` since Nextcloud 35. Two migrations write app config there: - Version2001Date20221213083550 copies the pre-2.0 keys into the new ones. Replayed after those keys are gone, it copies empty values: openproject_instance_url, openproject_client_id and openproject_client_secret are wiped, and the integration shows as not configured. - Version2400Date20230504144300 sets fresh_project_folder_setup to 1, undoing a project folder setup done since. Moving them to postSchemaChange() is not an option: a fresh install runs the migrations schema-only, so changeSchema() is all that runs there. Make both safe to replay instead: the first does nothing once the old keys are gone, the second sets the key only when it is not there yet. Signed-off-by: Volodymyr Fesko <vladimir.fesko@gmail.com>
saw-jan
requested review from
Ashim-Stha,
Kharonus,
NobodysNightmare,
ba1ash,
dominic-braeunlein,
individual-it,
julien-nc,
psatyal,
shiroginne and
wielinde
as code owners
October 15, 2026 11:20
3 of 8 tasks
Collaborator
Author
|
/backport! to release/3.3 |
individual-it
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Port of #1191 to allow the CI to run
Closes #1191
Problem
On Nextcloud 35, every
occ upgradeends with a database schema check (OC\DB\SchemaChecker, also available asocc db:schema:check). The check replays thechangeSchema()of every migration of every app into an in-memory schema. Two migrations of this app write app config insidechangeSchema(), so the replay changes the real settings:Version2001Date20221213083550copies the pre-2.0 keys (oauth_instance_url,client_id,client_secret) intoopenproject_instance_url,openproject_client_idandopenproject_client_secret. Those old keys are long gone, so it copies empty values and wipes the current settings.Version2400Date20230504144300setsfresh_project_folder_setupto1, undoing a project folder setup done since.Nextcloud then treats the integration as not configured: no OpenProject links, no dashboard widget, no OpenProject tab on files. OpenProject's side (the file storage and its project folders) keeps working. This happens on any
occ upgrade, including the one that runs when another app is installed or updated.The check was added in Nextcloud 35.0.0 by nextcloud/server#63351 (not backported to 34): earlier versions run
changeSchema()only during the actual migration, so the problem does not exist there.Steps to reproduce, on Nextcloud 35 with the integration configured (seen with 3.2.0 and with the 35 nightly 3.3.0-20260922):
occ config:app:get integration_openproject openproject_instance_urlreturns the URL.occ db:schema:check(orocc upgrade).fresh_project_folder_setupis1.Change
Moving the writes to
postSchemaChange()is not an option: Nextcloud installs an app's migrations schema-only (Installer::installApp()callsmigrate('latest', $previousVersion === '')), so on a fresh installchangeSchema()is the only hook that runs, which is presumably also why #894 moved a migration into it. The two migrations are made safe to replay instead:Version2001Date20221213083550does nothing once none of the old keys exists.Version2400Date20230504144300setsfresh_project_folder_setuponly when the key is not there yet. After that the admin settings keep it up to date (0after the setup,1after a reset), as before.Testing
The two migrations run against a stubbed
IConfig, before and after the change:fresh_project_folder_setup= 1openproject_instance_url,openproject_client_id,openproject_client_secretcreated empty,fresh_project_folder_setup= 1fresh_project_folder_setup= 1fresh_project_folder_setup= 0)fresh_project_folder_setup= 1The "before" replay is exactly what we see on our Nextcloud 35 instances after each
occ upgrade, where we have been putting the URL back by script since.Related Issue or Workpackage
Types of changes
Checklist:
CHANGELOG.mdfile