function userpoints_install in User Points 5
Same name and namespace in other branches
- 5.3 userpoints.install \userpoints_install()
- 5.2 userpoints.install \userpoints_install()
- 6 userpoints.install \userpoints_install()
- 7.2 userpoints.install \userpoints_install()
Install the initial schema.
File
- ./
userpoints.install, line 6
Code
function userpoints_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {userpoints} (\n uid INT(10) NOT NULL DEFAULT '0',\n points INT(10) NOT NULL DEFAULT '0',\n max_points INT(10) NOT NULL DEFAULT '0',\n last_update INT(11) NOT NULL DEFAULT '0',\n PRIMARY KEY (uid),\n KEY (last_update)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
db_query("CREATE TABLE {userpoints_txn} (\n txn_id INT NOT NULL AUTO_INCREMENT,\n uid INT(10) NOT NULL DEFAULT '0',\n approver_uid INT(10) NOT NULL DEFAULT '0',\n points INT(10) NOT NULL DEFAULT '0',\n time_stamp INT(11) NOT NULL DEFAULT '0',\n status INT(1) NOT NULL DEFAULT '0',\n event VARCHAR(32),\n description TEXT,\n reference varchar(128),\n PRIMARY KEY (txn_id),\n KEY (event),\n KEY (reference),\n KEY (status)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
db_query("CREATE TABLE {userpoints} (\n uid SERIAL,\n\t points INTEGER NOT NULL default '0',\n\t max_points INTEGER NOT NULL default '0',\n\t last_update INTEGER NOT NULL default '0',\n\t PRIMARY KEY (uid)\n );");
db_query("CREATE TABLE {userpoints_txn} (\n txn_id SERIAL,\n\t uid INTEGER NOT NULL default '0',\n\t approver_uid INTEGER NOT NULL default '0',\n\t points INTEGER NOT NULL default '0',\n\t time_stamp INTEGER NOT NULL default '0',\n\t status INTEGER NOT NULL default '0',\n\t event VARCHAR,\n\t description VARCHAR,\n\t PRIMARY KEY (txn_id)\n\t );");
break;
}
}