diff options
author | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-06-07 00:49:47 +0000 |
---|---|---|
committer | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-06-07 00:49:47 +0000 |
commit | b9937cd7ce2a1d42070ef710f93814c945b5bbef (patch) | |
tree | dc424ecef6ab659507cd3e23029c9a8bb6c73a28 /lib/class/update.class.php | |
parent | ae89b1daadcfecbbb6ab39cae0c40d589d22f0db (diff) | |
download | ampache-b9937cd7ce2a1d42070ef710f93814c945b5bbef.tar.gz ampache-b9937cd7ce2a1d42070ef710f93814c945b5bbef.tar.bz2 ampache-b9937cd7ce2a1d42070ef710f93814c945b5bbef.zip |
Clean up the rating code by moving uniqueness constraints into the database,
using SQL's AVG() when we want an average, updating the cache when a rating
changes, etc.
Diffstat (limited to 'lib/class/update.class.php')
-rw-r--r-- | lib/class/update.class.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/class/update.class.php b/lib/class/update.class.php index f1447ef5..80192049 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -341,6 +341,9 @@ class Update { '- Drop album_data and artist_data.<br />'; $version[] = array('version'=>'360003','description'=>$update_string); + $update_string = '- Add uniqueness constraint to ratings.<br />'; + $version[] = array('version' => '360004','description' => $update_string); + return $version; } // populate_version @@ -1915,5 +1918,16 @@ class Update { } // update_360003 + /** + * update_360004 + * This update creates an index on the rating table. + */ + public static function update_360004() { + $sql = "CREATE UNIQUE INDEX `unique_rating` ON `rating` (`user`, `object_type`, `object_id`)"; + $db_results = Dba::write($sql); + + self::set_version('db_version','360004'); + } // update_360004 + } // end update class ?> |