| Under Construction This proposal is under construction and is not ready for review. |
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[
Zend_Db_Schema_Manager maintains a database schema as a set of PHP files in a database agnostic format. Zend Framework: Zend_Db_Schema_Manager Component Proposal
Proposed Component Name
Zend_Db_Schema_Manager
Developer Notes
http://framework.zend.com/wiki/display/ZFDEV/Zend_Db_Schema_Manager
Proposers
Rob Allen
Revision
0.1 - 25 October 2006: Initial release. (wiki revision: 6)
Table of Contents
1. Overview
This ensures that the same change can be applied to multiple databases and all changes can be stored in
a version control system.2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- Zend_Db_Schema_Manager requires a database specific adapter for each supported database.
4. Dependencies on Other Framework Components
- Zend_Exception
- Zend_Db
5. Theory of Operation
Zend_Db_SchemaManager enables easy changes to a database schema without destroying
data. They can also be rolled back if required. The schema manager executes database
migration scripts which are collections of database operations such as adding a field to
a table.
Each migration script is a class extending from Zend_Db_Schema_Change which contains two
abstract methods: up() and down(). Migration script files are named like 001_initialSchema.php
so that they can be operated upon in order. The class within 001_initialSchema.php is called
initialSchema.
Note that for Zend_Db_Schema_Manager to work, a new table is required within the the database
being managed. This table, schema_info, holds the current version of the schema and is used
by the Manager to decide if the current operation is an upgrade or a rollback.
In order to work, a database independent structure to describe a table is used.
6. Milestones / Tasks
- Milestone 1: Completed design on wiki
- Milestone 2: Working prototype with unit tests checked into the incubator.
- Milestone 3: Documentation exists
7. Class Index
- Zend_Db_Schema_Exception - exception handler
- Zend_Db_Schema_Manager - class to manage migrating from one schema version to another
- Zend_Db_Schema_Change - abstract class to inherit each migrations script from
- Zend_Db_Schema_Table - database independant table creation and altering
- Zend_Db_Schema_Adapter - abstract class for database specific schema-change adapters
- Zend_Db_Schema_Adapter_Mysql - MySQL adapter for adding/deleting/editing tables
- Zend_Db_Schema_Adapter_Mssql - MSSQL adapter for adding/deleting/editing tables
8. Use Cases
| UC-01 |
|---|
The main use case is when you need to change the database schema of a live application.
Obviously this is done on the development machine first and the Schema_Manager will
ensure that the same changes to the database will occur on the live site.
Example migration script: 001_AddSecondEmailAddressColumn.php
Example CLI script to run the Manager: updateSchema.php