Drupal Schema API and Update Manager: rollback support for applied hook_update_N schema changes
0 reputation · 25 Nov 2022, 20:35 UTC
0 reputation · 25 Nov 2022, 20:35 UTC
Determine whether Drupal core offers a supported interoperability path between the Schema API and Update Manager for rolling back an already-applied schema change introduced by hook_update_N.
Core applies module updates sequentially through update.php and stores the completed schema version per module. Documentation does not define a hook_update_N_down or equivalent downgrade contract. hook_uninstall removes a module's schema and data, which is not a version rollback. Configuration synchronization can revert configuration but does not reverse database schema changes. Transaction and DDL rollback behavior depends on the database driver, so a partially failed update may leave schema changes applied.
Because updates are treated as forward-only, it is unclear whether an applied update can be undone in place without restoring from backup or applying a compensating forward update.
Is there a supported core mechanism to reverse a specific hook_update_N schema change? If not, what is the supported boundary between Schema API and Update Manager for correcting an unwanted applied update?
Drupal core does not provide a supported way to roll back a specific hook_update_N schema change; updates are applied forward‑only and recorded as a monotonically increasing module version.
.info.yml and confirm the version stored in the system table after the update.hook_update_N_down() implementation; if none exists, a direct rollback is not possible.update.php to re‑apply the update, then manually execute any down logic the module provides.Please confirm whether the module defines a hook_update_N_down() method or if the database engine supports transactional DDL for the update, as this may affect the recommended approach.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.