function userpoints_install in User Points 5.3
Same name and namespace in other branches
- 5 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 pid INT(11) NOT NULL AUTO_INCREMENT,\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 tid INT(11) NOT NULL default '0',\n PRIMARY KEY (pid),\n KEY (last_update),\n KEY (uid, tid)\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 expirydate INT(11) NULL DEFAULT '0',\n expired TINYINT(1) NOT NULL DEFAULT '0',\n parent_txn_id INT(11) NOT NULL DEFAULT '0',\n tid INT(11) NOT NULL DEFAULT '0',\n entity_id INT(11) NULL DEFAULT NULL, \n entity_type VARCHAR(32) DEFAULT NULL, \n operation VARCHAR(32),\n reference VARCHAR(128),\n description TEXT,\n PRIMARY KEY (txn_id),\n KEY (status),\n KEY (operation),\n KEY (reference)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
db_query("CREATE TABLE {userpoints} (\n pid INTEGER NOT NULL auto_increment,\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 tid INTEGER NOT NULL default '0',\n\t PRIMARY KEY (pid),\n\t KEY (last_update),\n KEY (uid, tid)\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 expirydate INTEGER NOT NULL default '0',\n expired BOOLEAN, \n parent_txn_id INTEGER NOT NULL default '0'\n tid INTEGER NOT NULL DEFAULT '0',\n entity_id INTEGER NULL DEFAULT NULL, \n entity_type VARCHAR DEFAULT NULL, \n operation VARCHAR,\n reference VARCHAR,\n description VARCHAR,\n\t PRIMARY KEY (txn_id),\n KEY (status),\n KEY (operation),\n KEY (reference)\n\t );");
break;
}
}