Index: /Users/jbitner/Sites/myplay/branches/myplay/public_html/sites/all/modules/contrib/activity/activity.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/activity/activity.install,v retrieving revision 1.1.2.1.2.4 diff -u -r1.1.2.1.2.4 activity.install --- activity.install 20 Jan 2008 10:15:36 -0000 1.1.2.1.2.4 +++ activity.install 11 Feb 2008 21:27:29 -0000 @@ -78,3 +78,37 @@ $ret[] = update_sql("ALTER TABLE {activity} ADD COLUMN scope int(11) AFTER timestamp"); return $ret; } + +function activity_update_4() { + $ret = array(); + $ret[] = update_sql("ALTER TABLE {activity} CHANGE `tokens` `data` longtext NOT NULL"); + return $ret; +} + +function activity_update_5() { + $ret = array(); + if (!db_table_exists('activity_targets')) { + $ret[] = update_sql( + "CREATE TABLE {activity_targets} ( + aid int(11) NOT NULL, + target_uid int(11) NOT NULL, + target_role varchar(50) NOT NULL default '', + PRIMARY KEY (aid, target_uid), + KEY (target_uid, target_role), + KEY (target_role) + ) /*!40100 DEFAULT CHARACTER SET UTF8 */ + "); + //since we're inserting the table in an update we need to also insert some values for the + // already existing activity records. + // TODO: first make sure there are not a HUGE number of records in activity table + $query = db_query("SELECT aid, data FROM {activity}"); + while ($result = db_fetch_object($query)) { + $data = unserialize($result->data); + $ret[] = update_sql("INSERT INTO {activity_targets} (aid, target_uid, target_role) + VALUES (%d, -1, 'all')", $result->aid); + $ret[] = update_sql("INSERT INTO {activity_targets} (aid, target_uid, target_role) + VALUES (%d, %d, 'author')", $result->aid, $data['user_id']); + } + } + return $ret; +}