Schema API in Drupal 6

The Schema Project has achieved a major milestone: The Schema API 1 has been committed for inclusion in Drupal 6 core. The Schema API allows modules to declare their database tables in a structured array (similar to the Form API) and provides API functions for creating, dropping, and changing tables, columns, keys, and indexes. Thanks to Frando for co-authoring the patch with me and the numerous people who helped review and test it.

Documentation for the Schema API is still being written; the work in progress is available at http://drupal.org/node/146843.

Some of the benefits of the Schema API are:

  • No more separate CREATE TABLE or ALTER TABLE statements for each database. Module developers only need to create a schema structure and/or use the Schema API functions, and Drupal takes care of the rest. This makes writing install and update functions much simpler.
  • Since the API makes it equally easy for module developers to support all databases, Drupal's support for PostgresQL will improve substantially. Also, as new database engines such as Oracle, SQLite, or Microsoft SQL Server are supported, modules using the Schema API will automatically work with them.
  • Several advanced capabilities, such as incremental database updates, a simple and consistent CRUD API, form scaffolding, simpler CCK and Views, schema and data validation, become much easier to implement in future enhancements.