Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History
Zend_Db_Schema_Manager
  1. Edit the page
  2. Replace sample content within each zone-data tag
  3. Remove this notice
  4. Save the page
  5. When you are ready for review, remove the Under Construction notice
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 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: 2)

Table of Contents

1. Overview

Zend_Db_Schema_Manager maintains a database schema in a database agnostic format with versioning.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • Zend_Db

4. Dependencies on Other Framework Components

  • Zend_Exception

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

#If a milestone is already done, begin the description with "[DONE]", like this:

    • Milestone #: [DONE] Unit tests ...

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

9. Class Skeletons

]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.