[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[116] trunk/0.3
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-08-20 01:51:04
|
Revision: 116 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=116&view=rev Author: crazedsanity Date: 2009-08-20 01:50:46 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Incorporate upgrades from cs-webdblogger v0.2.0 into the main schema. Modified Paths: -------------- trunk/0.3/setup/schema.mysql.sql trunk/0.3/setup/schema.pgsql.sql trunk/0.3/upgrades/upgrade.xml Removed Paths: ------------- trunk/0.3/upgrades/sql/ trunk/0.3/upgrades/upgradeTo0.2.0.php trunk/0.3/upgrades/upgradeTo0.2.1.php Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-08-20 01:44:14 UTC (rev 115) +++ trunk/0.3/setup/schema.mysql.sql 2009-08-20 01:50:46 UTC (rev 116) @@ -92,6 +92,50 @@ -- ALTER TABLE `cswdbl_log_table` ADD CONSTRAINT `cswdbl_log_table_event_id_fkey` FOREIGN KEY (`event_id`) REFERENCES `cswdbl_event_table` (`event_id`); + + + +-- +-- Table structure for table `cswdbl_log_attribute_table` +-- + +CREATE TABLE `cswdbl_log_attribute_table` ( + `log_attribute_id` int(11) NOT NULL auto_increment, + `log_id` int(11) NOT NULL, + `attribute_id` int(11) NOT NULL, + `value_text` text NOT NULL, + PRIMARY KEY (`log_attribute_id`), + KEY `cswdbl_log_attribute_table_log_id_fkey` (`log_id`), + KEY `cswdbl_log_attribute_table_attribute_id_fkey` (`attribute_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `cswdbl_log_table` +-- + +CREATE TABLE `cswdbl_log_table` ( + `log_id` int(11) NOT NULL auto_increment, + `creation` timestamp NOT NULL default CURRENT_TIMESTAMP, + `event_id` int(11) NOT NULL, + `uid` int(11) NOT NULL, + `affected_uid` int(11) NOT NULL, + `details` text NOT NULL, + PRIMARY KEY (`log_id`), + KEY `cswdbl_log_table_event_id_fkey` (`event_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + + + +-- +-- Constraints for table `cswdbl_log_attribute_table` +-- +ALTER TABLE `cswdbl_log_attribute_table` + ADD CONSTRAINT `cswdbl_log_attribute_table_attribute_id_fkey` FOREIGN KEY (`attribute_id`) REFERENCES `cswdbl_attribute_table` (`attribute_id`), + ADD CONSTRAINT `cswdbl_log_attribute_table_log_id_fkey` FOREIGN KEY (`log_id`) REFERENCES `cswdbl_log_table` (`log_id`); + + -- This table create statement MUST work in PostgreSQL v8.2.x+ AND MySQL v5.0.x+: Modified: trunk/0.3/setup/schema.pgsql.sql =================================================================== --- trunk/0.3/setup/schema.pgsql.sql 2009-08-20 01:44:14 UTC (rev 115) +++ trunk/0.3/setup/schema.pgsql.sql 2009-08-20 01:50:46 UTC (rev 116) @@ -63,6 +63,25 @@ details text NOT NULL ); + +-- +-- List of distinct attribute names. +-- +CREATE TABLE cswdbl_attribute_table ( + attribute_id serial NOT NULL PRIMARY KEY, + attribute_name text NOT NULL UNIQUE +); + +-- +-- Linkage for attributes to logs. +-- +CREATE TABLE cswdbl_log_attribute_table ( + log_attribute_id serial NOT NULL PRIMARY KEY, + log_id int NOT NULL REFERENCES cswdbl_log_table(log_id), + attribute_id int NOT NULL REFERENCES cswdbl_attribute_table(attribute_id), + value_text text +); + -- This table create statement MUST work in PostgreSQL v8.2.x+ AND MySQL v5.0.x+: -- otherwise separate schema files have to be created and the code will have to -- do extra checking... Modified: trunk/0.3/upgrades/upgrade.xml =================================================================== --- trunk/0.3/upgrades/upgrade.xml 2009-08-20 01:44:14 UTC (rev 115) +++ trunk/0.3/upgrades/upgrade.xml 2009-08-20 01:50:46 UTC (rev 116) @@ -18,12 +18,5 @@ to get skipped, or an exception to be thrown, potentially leaving the system in an unstable state. Unstable is bad, m'kay?</system_note> - <matching> - <v0.2.0> - <target_version>0.2.1</target_version> - <script_name>upgradeTo0.2.1.php</script_name> - <class_name>upgrade_to_0_2_1</class_name> - <call_method>run_upgrade</call_method> - </v0.2.0> - </matching> + <matching /> </upgrade> Deleted: trunk/0.3/upgrades/upgradeTo0.2.0.php =================================================================== --- trunk/0.3/upgrades/upgradeTo0.2.0.php 2009-08-20 01:44:14 UTC (rev 115) +++ trunk/0.3/upgrades/upgradeTo0.2.0.php 2009-08-20 01:50:46 UTC (rev 116) @@ -1,95 +0,0 @@ -<?php - -class upgrade_to_0_2_0 { - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if(!$db->is_connected()) { - throw new exception(__METHOD__ .": database is not connected"); - } - $this->db = $db; - - $this->gfObj = new cs_globalFunctions; - $this->gfObj->debugPrintOpt = 1; - - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - - - $upgradeFilename = dirname(__FILE__) ."/sql/upgradeTo0_2_0.". $this->db->get_dbtype() .".sql"; - if(!file_exists($upgradeFilename)) { - throw new exception(__METHOD__ .": missing upgrade filename (". $upgradeFilename ."), " . - "probably due to unsupported database type (". $this->db->get_dbtype() .")"); - } - - - $tables = array( - 'cat' => array( - 'cswdbl_category_table', - 'log_category_table', - 'category_id' - ), - 'class' => array( - 'cswdbl_class_table', - 'log_class_table', - 'class_id' - ), - 'event' => array( - 'cswdbl_event_table', - 'log_event_table', - 'event_id' - ), - 'log' => array( - 'cswdbl_log_table', - 'log_table', - 'log_id' - ) - ); - - //run the SQL file. - $file = dirname(__FILE__) .'/sql/upgradeTo0_2_0.'. $this->db->get_dbtype() .'.sql'; - $upgradeRes = false; - if(file_exists($file)) { - $this->db->run_update(file_get_contents($file),true); - $totalToSync = count($tables); - $totalSynced = 0; - - //now make sure there's the same amount of data in BOTH tables. - foreach($tables as $key => $tables) { - $c1 = $this->db->run_query("SELECT * FROM ". $tables[0]); - $num1 = $this->db->numRows(); - $c2 = $this->db->run_query("SELECT * FROM ". $tables[1]); - $num2 = $this->db->numRows(); - - if($num1 === $num2) { - $totalSynced++; - $this->db->run_update("DROP TABLE ". $tables[1] ." CASCADE", true); - - if($this->db->get_dbtype() == 'pgsql') { - //Update the sequence... - $seq = $tables[0] .'_'. $tables[2] .'_seq'; - $this->db->run_update("SELECT setval('". $seq ."', (SELECT max(". $tables[2] .") FROM ". $tables[0] ."))",true); - } - } - else { - throw new exception(__METHOD__ .": failed to sync ". $tables[0] ." with ". $tables[1] ." (". $num1 ." != ". $num2 .")"); - } - } - $upgradeRes = true; - } - else { - throw new exception(__METHOD__ .": missing upgrade SQL file (". $file .")"); - } - - return($upgradeRes); - - }//end run_upgrade() - //========================================================================= -} - -?> Deleted: trunk/0.3/upgrades/upgradeTo0.2.1.php =================================================================== --- trunk/0.3/upgrades/upgradeTo0.2.1.php 2009-08-20 01:44:14 UTC (rev 115) +++ trunk/0.3/upgrades/upgradeTo0.2.1.php 2009-08-20 01:50:46 UTC (rev 116) @@ -1,47 +0,0 @@ -<?php - -class upgrade_to_0_2_1 { - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if(!$db->is_connected()) { - throw new exception(__METHOD__ .": database is not connected"); - } - $this->db = $db; - - $this->gfObj = new cs_globalFunctions; - $this->gfObj->debugPrintOpt = 1; - - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - - - $upgradeFilename = dirname(__FILE__) ."/sql/upgradeTo0_2_1.". $this->db->get_dbtype() .".sql"; - if(!file_exists($upgradeFilename)) { - throw new exception(__METHOD__ .": missing upgrade filename (". $upgradeFilename ."), " . - "probably due to unsupported database type (". $this->db->get_dbtype() .")"); - } - - //run the SQL file. - $file = dirname(__FILE__) .'/sql/upgradeTo0_2_1.'. $this->db->get_dbtype() .'.sql'; - $upgradeRes = false; - if(file_exists($file)) { - $this->db->run_update(file_get_contents($file),true); - $upgradeRes = true; - } - else { - throw new exception(__METHOD__ .": missing upgrade SQL file (". $file .")"); - } - - return($upgradeRes); - - }//end run_upgrade() - //========================================================================= -} - -?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |