#1422: Automate down() whenever possible
-------------------------+--------------------------------------------------
Reporter: lsmith | Owner: jwage
Type: defect | Status: new
Priority: minor | Milestone: 1.1.0
Component: Migrations | Version: 1.0.0
Resolution: | Keywords:
Has_test: 0 | Mystatus: Pending Core Response
Has_patch: 0 |
-------------------------+--------------------------------------------------
Old description:
> The idea is that you write a single up method and you get the down for
> free.
>
> In the migration one would then write something like:
>
> function up () { return $this->upDown('up'); }
> function down () { return $this->upDown('down'); }
>
> function upDown ($upDown) {
> $this->createTable('migration_test', array('field1' => array
> ('type' => 'string')));
> }
>
> In the base migration class one would have methods like the following
>
> function createTable($upDown, $table, $fields) {
> if ($upDown == 'up')) {
> return $this->dbal->createTable($table, $fields)
> }
> return $this->dbal->dropTable($table);
> }
>
> function dropTable($upDown, $table, $fields) {
> if ($upDown == 'up')) {
> return $this->dbal->dropTable($table);
> }
> return $this->dbal->createTable($table, $fields)
> }
New description:
The idea is that you write a single up method and you get the down for
free.
In the migration one would then write something like:
{{{
function up ()
{
return $this->upDown('up');
}
function down()
{
return $this->upDown('down');
}
function upDown($upDown)
{
$this->createTable('migration_test', array('field1' => array
('type' => 'string')));
}
In the base migration class one would have methods like the following
{{{
function createTable($upDown, $table, $fields) {
if ($upDown == 'up')) {
return $this->dbal->createTable($table, $fields)
}
return $this->dbal->dropTable($table);
}
function dropTable($upDown, $table, $fields) {
if ($upDown == 'up')) {
return $this->dbal->dropTable($table);
}
return $this->dbal->createTable($table, $fields)
}
}}}
--
Ticket URL: <http://trac.doctrine-project.org/ticket/1422#comment:3>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"doctrine-svn" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---