MDB2_Schema and maintaining database across versions

From: Date: Sun, 29 Apr 2007 19:42:43 +0000
Subject: MDB2_Schema and maintaining database across versions
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-27173@lists.php.net to get a copy of this message
I have an application deployed as a PEAR package. It uses at database, which I maintain through MDB2_Schema. The following will do the trick, when I want to upgrade the database from an old version to a new version: [php]
     $current_definition = $this->schema->getDefinitionFromDatabase();
       if (PEAR::isError($current_definition)) {
           die('current: ' . $current_definition->getMessage() .
$current_definition->getUserInfo());
       }
       $result = $this->schema->updateDatabase(
           $this->new_definition_file,
           $current_definition,
           array('create' =>'0', 'name' =>$this->database)
       );
       if (PEAR::isError($result)) {
           die($result->getUserInfo);
       }
[/php] Now suppose I wanted to revert from 1.0.1 to 1.0.0 because I discoved an error. However values has been entered in some of the new fields in the database. If I just run the code above all new fields would be deleted. Is the best way to solve this situation to do as it is done on pearweb where old versions is saved in the doc_root/sql directory and that is the file used to do the comparisons? -- Lars Olesen Gratis backup https://mozy.com/?code=9MYJPF

« previous php.pear.general (#27173) next »