activity.install in Activity 5.2
Same filename and directory in other branches
Install file for activity module.
File
activity.installView source
<?php
/**
* @file
* Install file for activity module.
*/
/**
* Implementation of hook_install().
*/
function activity_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("\n CREATE TABLE {activity} (\n aid int(11) NOT NULL,\n uid int(11) NOT NULL,\n module varchar(50) NOT NULL default '',\n type varchar(25) NOT NULL default '',\n action varchar(25) NOT NULL default '',\n tokens mediumtext NOT NULL,\n timestamp int(11) NOT NULL,\n PRIMARY KEY (aid),\n KEY (uid),\n KEY (module)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */\n ");
break;
case 'pgsql':
db_query("\n CREATE TABLE {activity} (\n aid int(11) NOT NULL,\n uid int(11) NOT NULL,\n module varchar(50) NOT NULL default '',\n type varchar(25) NOT NULL default '',\n action varchar(25) NOT NULL default '',\n tokens mediumtext NOT NULL,\n timestamp int(11) NOT NULL,\n PRIMARY KEY (aid)\n );\n ");
db_query("CREATE INDEX {activity}_uid_idx ON {activity} (uid)");
db_query("CREATE INDEX {activity}_module_idx ON {activity} (uid)");
break;
}
}
function activity_uninstall() {
if (db_table_exists('activity')) {
db_query("DROP TABLE {activity}");
}
// Delete any variables that have been set.
// We don't just DELETE FROM {variable}, even though we could.
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'activity_%'");
// Instead we use the API, because API's can change!
while ($row = db_fetch_object($result)) {
variable_del($row->name);
}
}
function activity_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {activity} ADD PRIMARY KEY (aid)');
$ret[] = update_sql('ALTER TABLE {activity} ADD KEY (uid)');
$ret[] = update_sql('ALTER TABLE {activity} ADD KEY (module)');
break;
}
return $ret;
}
Functions
Name | Description |
---|---|
activity_install | Implementation of hook_install(). |
activity_uninstall | |
activity_update_1 |