Drupal Update API + Database Abstraction Layer: Is Automatic Schema Rollback Feasible?
0 reputation · 30 Apr 2021, 13:47 UTC
Goal
Investigate whether Drupal can automatically revert database schema changes applied by hook_update_N when a subsequent update fails, and identify the current state of this feature.
Context
Drupal’s Update API applies schema changes via hook_update_N implementations, but the Database Abstraction Layer executes raw DDL without maintaining a version history. Consequently, a failed update leaves the database altered, and the only available rollback path is a manual database restore or a custom script.
While the Config API supports import/export rollbacks, it does not affect the underlying schema. Community discussions have highlighted the need for a versioned migration system, yet no consensus has been reached on integrating such a feature into core.
Unresolved Decision
Is there a viable path to make schema changes rollback‑safe without manual intervention, and what would be required to add such capability to Drupal core?
Specific Questions
- Does Drupal core provide any mechanism to automatically revert a schema change applied by
hook_update_Nif a subsequent update fails? - If not, what are the current best practices to ensure rollback safety for schema changes?
- Is there an ongoing discussion or proposal to add versioned schema migration support to the Update API?