Changeset 5285

Show
Ignore:
Timestamp:
12/11/08 05:22:00 (7 months ago)
Author:
jwage
Message:

[1.2] Updating UPGRADE file to document the changes to SoftDelete?.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.1/UPGRADE_TO_1_1

    r5244 r5285  
    22====================== 
    33 
    4 This document details the changes made to Doctrine 1.1 to make it easier for you to upgrade your projects to use this version. 
     4This document details the changes made to Doctrine 1.1 to make it easier for you 
     5to upgrade your projects to use this version. 
    56 
    67Doctrine Record 
    78--------------- 
    89 
    9 [r5014](http://trac.doctrine-project.org/changeset/5014) - Added support for `FROM User u WHERE u.id IN ?` in the Doctrine_Query api. 
    10  
     10[r5014](http://trac.doctrine-project.org/changeset/5014) - Added support for  
     11`FROM User u WHERE u.id IN ?` in the Doctrine_Query api. 
     12 
     13    [php] 
    1114    $q = Doctrine_Query::create() 
    1215      ->from('User u') 
     
    1417    $users = $q->execute(); 
    1518 
    16 [r5019](http://trac.doctrine-project.org/changeset/5019) - `unlink()` and `link()` have been changed to not delete references until `save()` is called on the object. Also, fixed synchronizeWithArray() to synchronize many to many relationships. 
    17  
     19[r5019](http://trac.doctrine-project.org/changeset/5019) - `unlink()` and  
     20`link()` have been changed to not delete references until `save()` is called  
     21on the object. Also, fixed synchronizeWithArray() to synchronize many to many  
     22relationships. 
     23 
     24    [php] 
    1825    // Does not link until save() 
    1926    $user = Doctrine::getTable('User')->find(1); 
     
    3744    $user->save(); 
    3845 
    39 [r5034](http://trac.doctrine-project.org/changeset/5034) - You can now retrieve the old values of records through the getModified() function. By default it returns an array of fieldName => newValue but if you specify getModified(true) it will return the old values. 
    40  
     46[r5034](http://trac.doctrine-project.org/changeset/5034) - You can now retrieve  
     47the old values of records through the getModified() function. By default it  
     48returns an array of fieldName => newValue but if you specify getModified(true)  
     49it will return the old values. 
     50 
     51    [php] 
    4152    $users = Doctrine::getTable('User')->findAll(); 
    4253    $user = $users->getFirst(); 
     
    5768    */ 
    5869 
    59 [r5035](http://trac.doctrine-project.org/changeset/5035) - Added ability to use custom setters with fromArray() 
    60  
     70[r5035](http://trac.doctrine-project.org/changeset/5035) - Added ability to use  
     71custom setters with fromArray() 
     72 
     73    [php] 
    6174    public function setTableDefinition() 
    6275    { 
     
    7689--------------- 
    7790 
    78 [r5027](http://trac.doctrine-project.org/changeset/5039) - Added support for setting default charset and collate for tables. 
     91[r5027](http://trac.doctrine-project.org/changeset/5039) - Added support for  
     92setting default charset and collate for tables. 
    7993 
    8094Set globally on a Doctrine_Manager instance. 
    8195 
     96    [php] 
    8297    $manager->setCollate('utf8_unicode_ci'); 
    8398    $manager->setCharset('utf8'); 
     
    85100The same can be set on the Doctrine_Connection and Doctrine_Record levels. 
    86101 
     102    [php] 
    87103    $connection->setCollate('utf8_unicode_ci'); 
    88104    $connection->setCharset('utf8'); 
     
    94110    } 
    95111 
    96 [r5030](http://trac.doctrine-project.org/changeset/5039) - Added support for setting default options for columns and auto added identifier columns. 
    97  
    98 The following is now possible on Doctrine_Manager, Doctrine_Connection and Doctrine_Record. 
    99  
    100     $manager->setAttribute(Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS, array('type' => 'string', 'length' => 255, 'notnull' => true)); 
     112[r5030](http://trac.doctrine-project.org/changeset/5039) - Added support for  
     113setting default options for columns and auto added identifier columns. 
     114 
     115The following is now possible on Doctrine_Manager, Doctrine_Connection and  
     116Doctrine_Record. 
     117 
     118    [php] 
     119    $manager->setAttribute(Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS,  
     120      array('type' => 'string', 'length' => 255, 'notnull' => true)); 
    101121 
    102122You can also customize the values that make up the auto added identifier column as well. 
    103123 
    104     $manager->setAttribute(Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS, array('name' => '%s_id', 'type' => 'string', 'length' => 16)); // %s in the name is replaced with the table name. 
    105  
    106 [r5079](http://trac.doctrine-project.org/changeset/5079) - Added ability to retrieve the modified properties from the last transaction with the Doctrine_Record::getLastModified() method 
    107  
     124    [php] 
     125    // %s in the name is replaced with the table name. 
     126    $manager->setAttribute(Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS,  
     127      array('name' => '%s_id', 'type' => 'string', 'length' => 16)); 
     128 
     129[r5079](http://trac.doctrine-project.org/changeset/5079) - Added ability to  
     130retrieve the modified properties from the last transaction with the  
     131Doctrine_Record::getLastModified() method 
     132 
     133    [php] 
    108134    $user = new User(); 
    109135    $user->username = 'jwage'; 
     
    111137    $user->save(); 
    112138 
    113     // getModified() returns the current modified properties and in this case now no propeties are modified. 
     139    // getModified() returns the current modified properties and in this case  
     140    now no propeties are modified. 
    114141    print_r($user->getModified()); // array() 
    115142 
     
    120147-------------- 
    121148 
    122 [r5031](http://trac.doctrine-project.org/changeset/5031) - A query can now be transformed from an update() or delete() to a select() or any combination. Run a query once to update a field then turn it to a select and execute it. 
    123  
     149[r5031](http://trac.doctrine-project.org/changeset/5031) - A query can now be  
     150transformed from an update() or delete() to a select() or any combination. Run a  
     151query once to update a field then turn it to a select and execute it. 
     152 
     153    [php] 
    124154    $q = Doctrine_Query::create() 
    125155        ->update('User u') 
     
    132162    $user = $q->fetchOne(); 
    133163 
    134 [r5018](http://trac.doctrine-project.org/changeset/5018) - Added `Doctrine::ATTR_AUTO_FREE_QUERY_OBJECTS` for auto freeing query objects after execution  
    135  
     164[r5018](http://trac.doctrine-project.org/changeset/5018) - Added  
     165`Doctrine::ATTR_AUTO_FREE_QUERY_OBJECTS` for auto freeing query objects after  
     166execution  
     167 
     168    [php] 
    136169    $manager->setAttribute('auto_free_query_objects'); 
    137170    $q = Doctrine_Query::create() 
     
    139172    $users = $q->execute(); // $q->free() is triggered 
    140173 
    141 [r5121](http://trac.doctrine-project.org/changeset/5121) - Added new Doctrine_Query_Abstract::getFlattenedParams() to replace Doctrine_Query_Abstract::getParams() and Doctrine_Query_Abstract::getParams() now returns the raw unmodified array of query parameters. 
     174[r5121](http://trac.doctrine-project.org/changeset/5121) - Added new  
     175Doctrine_Query_Abstract::getFlattenedParams() to replace  
     176Doctrine_Query_Abstract::getParams() and Doctrine_Query_Abstract::getParams()  
     177now returns the raw unmodified array of query parameters. 
    142178 
    143179Doctrine Collection 
    144180------------------- 
    145181 
    146 [r5032](http://trac.doctrine-project.org/changeset/5032) - You can now convert a Doctrine_Collection in to a key value array made up of the values from the two specified columns. 
    147  
     182[r5032](http://trac.doctrine-project.org/changeset/5032) - You can now convert  
     183a Doctrine_Collection in to a key value array made up of the values from the two  
     184specified columns. 
     185 
     186    [php] 
    148187    $q = Doctrine_Query::create() 
    149188        ->from('User u'); 
     
    169208------------------- 
    170209 
    171 [r5033](http://trac.doctrine-project.org/changeset/5033) - You can now specify a unique validator on a set of fields. The argument of the unique() function can either be an array of fields or an argument for each field. 
    172  
     210[r5033](http://trac.doctrine-project.org/changeset/5033) - You can now specify a  
     211unique validator on a set of fields. The argument of the unique() function can  
     212either be an array of fields or an argument for each field. 
     213 
     214    [php] 
    173215    public function setTableDefinition() 
    174216    { 
     
    182224---------------------- 
    183225 
    184 In Doctrine 1.1 you now have the ability to register custom validators so that Doctrine is aware of them. You can also get the allowed validators. 
     226In Doctrine 1.1 you now have the ability to register custom validators so that  
     227Doctrine is aware of them. You can also get the allowed validators. 
    185228 
    186229    [php] 
     
    195238---------------- 
    196239 
    197 You now have the ability to configure the Email validator to not check the mx record of the e-mail address. 
     240You now have the ability to configure the Email validator to not check the mx  
     241record of the e-mail address. 
    198242 
    199243    [php] 
     
    211255------------------ 
    212256 
    213 [r5016](http://trac.doctrine-project.org/changeset/5016) - A performance change was made to the hydration process which should yield some improvements when hydrating large result sets. 
     257[r5016](http://trac.doctrine-project.org/changeset/5016) - A performance change  
     258was made to the hydration process which should yield some improvements when  
     259hydrating large result sets. 
    214260 
    215261Doctrine Schema Files 
    216262--------------------- 
    217263 
    218 You are now able to pass extra attributes through the YAML schema parser to store any custom column information and you have access to it through the Doctrine_Table. 
    219  
    220     --- 
     264You are now able to pass extra attributes through the YAML schema parser to  
     265store any custom column information and you have access to it through the  
     266Doctrine_Table. 
     267 
     268    [yml] 
    221269    User: 
    222270      columns: 
     
    236284Doctrine will now generate phpDoc property tags with the generated base classes. 
    237285 
    238     --- 
     286    [yml] 
    239287    User: 
    240288      columns: 
     
    252300Generates the following User and Phonenumber class 
    253301 
     302    [php] 
    254303    /** 
     304     * BaseUser 
     305     *  
    255306     * This class has been auto-generated by the Doctrine ORM Framework 
    256      * 
     307     *  
    257308     * @property string $username 
    258309     * @property string $password 
    259      * @property $Phonenumbers 
     310     * @property Doctrine_Collection $Phonenumbers 
     311     *  
     312     * @package    ##PACKAGE## 
     313     * @subpackage ##SUBPACKAGE## 
     314     * @author     ##NAME## <##EMAIL##> 
     315     * @version    SVN: $Id: Builder.php 5270 2008-12-05 20:47:43Z jwage $ 
    260316     */ 
    261317    abstract class BaseUser extends Doctrine_Record 
     
    276332 
    277333    /** 
     334     * BasePhonenumber 
     335     *  
    278336     * This class has been auto-generated by the Doctrine ORM Framework 
    279      * 
     337     *  
    280338     * @property integer $user_id 
    281339     * @property string $phonenumber 
    282      * @property $User 
     340     * @property User $User 
     341     *  
     342     * @package    ##PACKAGE## 
     343     * @subpackage ##SUBPACKAGE## 
     344     * @author     ##NAME## <##EMAIL##> 
     345     * @version    SVN: $Id: Builder.php 5270 2008-12-05 20:47:43Z jwage $ 
    283346     */ 
    284347    abstract class BasePhonenumber extends Doctrine_Record 
     
    301364-------------------- 
    302365 
    303 [r5084](http://trac.doctrine-project.org/changeset/5084) - As of Doctrine 1.1 you are now able to reference relationships defined on the versioned model from the {CLASS}Version auto generated model. 
    304  
     366[r5084](http://trac.doctrine-project.org/changeset/5084) - As of Doctrine 1.1  
     367you are now able to reference relationships defined on the versioned model  
     368from the {CLASS}Version auto generated model. 
     369 
     370    [php] 
    305371    // These relationships are defined on the User model but they 
    306372    // are copied to the UserVersion model when it is generated. 
     
    311377        ->leftJoin('u.Groups g'); 
    312378 
    313 [r5097](http://trac.doctrine-project.org/changeset/5097) - Added ability to disable automatic deleting of versions when a record is deleted 
    314  
     379[r5097](http://trac.doctrine-project.org/changeset/5097) - Added ability to  
     380disable automatic deleting of versions when a record is deleted 
     381 
     382    [php] 
    315383    $this->actAs('Versionable', array('deleteVersions' => false)); 
    316      
     384 
     385    [yml] 
    317386    actAs: 
    318387      Versionable: 
    319388        deleteVersions: false 
    320389 
    321 [r5098](http://trac.doctrine-project.org/changeset/5098) - Added ability to define custom accessors/mutators for a Doctrine record 
    322  
     390[r5098](http://trac.doctrine-project.org/changeset/5098) - Added ability to  
     391define custom accessors/mutators for a Doctrine record 
     392 
     393    [php] 
    323394    public function setTableDefinition() 
    324395    { 
     
    342413    } 
    343414 
    344 [r5220](http://trac.doctrine-project.org/changeset/5220) - Added ability to define foreign key constraint format to be used when generating tables on database 
    345  
    346     Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_FKNAME_FORMAT, '%localtbl_%localcol_%reftbl_%refcol_%i'); // Default is %localtbl_%localcol_%reftbl_%refcol 
    347  
    348 [r5236](http://trac.doctrine-project.org/changeset/5236) - Added ability to alias record listeners 
    349  
     415[r5236](http://trac.doctrine-project.org/changeset/5236) - Added ability to  
     416alias record listeners 
     417 
     418    [php] 
    350419    $this->addListener(new My_Listener_FooListener($this->_options), 'FooListener'); 
    351420 
    352     YAML: 
    353  
    354         - No aliasing and no options usage: 
    355  
    356 Foo: 
    357   columns: 
    358     bar: string(50) 
    359   listeners: [My_Listener_FooListener] 
    360  
    361         - No aliasing and using options 
    362  
    363 Foo: 
    364   columns: 
    365     bar: string(50) 
    366   listeners: 
    367     My_Listener_FooListener: 
    368       useOptions: true 
    369  
    370         - Using alias definition 
    371  
    372 Foo: 
    373   columns: 
    374     bar: string(50) 
    375   listeners: 
    376     FooListener: 
    377       class: My_Listener_FooListener 
    378       useOptions: true  
    379  
    380  
    381 [r5236](http://trac.doctrine-project.org/changeset/5236) - Added ability to enable/disable record listeners 
    382  
    383     - Possibility to remove all listeners of all record listeners 
    384  
    385         Doctrine::getTable('Foo')->getRecordListener()->setOption('disabled', true); 
    386  
    387     - Possibility to remove some listeners of all record listeners 
    388  
    389         Doctrine::getTable('Foo')->getRecordListener()->setOption('disabled', array('preSerialize', 'postHydrate')); 
    390  
    391     - Possibility to remove all listeners of a single record listener 
    392  
    393         Doctrine::getTable('Foo')->getRecordListener()->get('FooListener')->setOption('disabled', true); 
    394  
    395     - Possibility to remove some listeners of a single record listener 
    396  
    397         Doctrine::getTable('Foo')->getRecordListener()->get('FooListener')->setOption('disabled', array('preSave', 'postInsert')); 
    398  
    399 [r5241](http://trac.doctrine-project.org/changeset/5240) - Added ability to work with mapped values as if they were part of the record. It is useful to store transient data into record (this data is not persisted to database). 
    400  
    401 class Foo extends Doctrine_Record { 
    402     public function setTableDefinition() { 
    403         $this->mapValue('name'); 
    404     } 
    405  
    406     // ... 
    407 } 
     421No aliasing and no options usage: 
     422 
     423    [yml] 
     424    Foo: 
     425      columns: 
     426        bar: string(50) 
     427      listeners: [My_Listener_FooListener] 
     428 
     429No aliasing and using options 
     430 
     431    [yml] 
     432    Foo: 
     433      columns: 
     434        bar: string(50) 
     435      listeners: 
     436        My_Listener_FooListener: 
     437          useOptions: true 
     438 
     439Using alias definition 
     440 
     441    [yml] 
     442    Foo: 
     443      columns: 
     444        bar: string(50) 
     445      listeners: 
     446        FooListener: 
     447          class: My_Listener_FooListener 
     448          useOptions: true  
     449 
     450[r5236](http://trac.doctrine-project.org/changeset/5236) - Added ability to  
     451enable/disable record listeners 
     452 
     453Possibility to remove all listeners of all record listeners 
     454 
     455    [php] 
     456    Doctrine::getTable('Foo')->getRecordListener()->setOption('disabled', true); 
     457 
     458Possibility to remove some listeners of all record listeners 
     459 
     460    [php] 
     461    Doctrine::getTable('Foo')->getRecordListener()->setOption('disabled',  
     462      array('preSerialize', 'postHydrate')); 
     463 
     464Possibility to remove all listeners of a single record listener 
     465 
     466    [php] 
     467    Doctrine::getTable('Foo')->getRecordListener()->get('FooListener') 
     468      ->setOption('disabled', true); 
     469 
     470Possibility to remove some listeners of a single record listener 
     471 
     472    [php] 
     473    Doctrine::getTable('Foo')->getRecordListener()->get('FooListener') 
     474      ->setOption('disabled', array('preSave', 'postInsert')); 
     475 
     476[r5241](http://trac.doctrine-project.org/changeset/5240) - Added ability to  
     477work with mapped values as if they were part of the record. It is useful to  
     478store transient data into record (this data is not persisted to database). 
     479 
     480    [php] 
     481    class Foo extends Doctrine_Record { 
     482        public function setTableDefinition() { 
     483            $this->mapValue('name'); 
     484        } 
     485 
     486        // ... 
     487    } 
    408488 
    409489$foo = new Foo(); 
     
    418498In Doctrine 1.1 we have made a few changes to migrations. 
    419499 
    420  * Generated migration classes are prefixed with a timestamp instead of a incremented integer. 
    421  * Added possibility for automation of up/down methods. 
    422  * Re-ordered arguments for addColumn() so that type is first before length. 
    423  * Added `Doctrine_Migration_Diff` tool. 
     500* Generated migration classes are prefixed with a timestamp instead of a  
     501incremented integer. 
     502* Added possibility for automation of up/down methods. 
     503* Re-ordered arguments for addColumn() so that type is first before length. 
     504* Added `Doctrine_Migration_Diff` tool. 
     505 
     506Here is an example of how you can automate the opposite up or down of a migration 
     507api method. 
    424508 
    425509    [php] 
     
    429513    } 
    430514 
    431 The above example will create the column when $direction == up and will remove the column when $direction == down. 
     515The above example will create the column when $direction == up and will remove  
     516the column when $direction == down. 
     517 
     518SoftDelete 
     519---------- 
     520 
     521In Doctrine 1.1 the SoftDelete behavior was changed slightly to store a `deleted_at` 
     522timestamp to indicate a deleted record rather than a `deleted` boolean flag. 
     523 
     524You will need to modify your existing database schema and rename the `deleted` 
     525column to `deleted_at` and modify the type to be a timestamp.