Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r11597: LJSUP-11530 (prepare LJ code to run on d...

Committer: ailyin
LJSUP-11530 (prepare LJ code to run on debian squeeze)
U   trunk/bin/upgrading/update-db-local.pl
U   trunk/cgi-bin/LJ/Hooks/Userpics.pm
Modified: trunk/bin/upgrading/update-db-local.pl
===================================================================
--- trunk/bin/upgrading/update-db-local.pl	2012-03-16 13:19:23 UTC (rev 11596)
+++ trunk/bin/upgrading/update-db-local.pl	2012-03-16 13:24:23 UTC (rev 11597)
@@ -4,1745 +4,1853 @@
 
 mark_clustered(@LJ::USER_TABLES_LOCAL);
 
-register_tablecreate("sg_invites", <<EOC);
-CREATE TABLE `sg_invites` (
-    `email` VARCHAR(80) NOT NULL,
-    `age`   INT(3),
-    `sex`   CHAR(1),
-    `name`  VARCHAR(50) default NULL,
-    `time`  INT(13) default 0,
-    PRIMARY KEY (`time`)
+register_tablecreate('abuse_mail', <<'EOC');
+CREATE TABLE `abuse_mail` (
+  `mailid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `userid` int(10) unsigned NOT NULL,
+  `spid` int(10) unsigned DEFAULT NULL,
+  `status` enum('S','F') NOT NULL DEFAULT 'F',
+  `timesent` datetime NOT NULL,
+  `mailto` varchar(100) NOT NULL,
+  `subject` varchar(100) NOT NULL,
+  `message` text,
+  `type` varchar(20) NOT NULL DEFAULT '',
+  PRIMARY KEY (`mailid`),
+  KEY `userid` (`userid`),
+  KEY `spid` (`spid`),
+  KEY `mailto` (`mailto`)
 )
 EOC
 
-register_tablecreate("free2pay_trx", <<EOC);
-CREATE TABLE `free2pay_trx` (
-    `id`     int(11) NOT NULL auto_increment,
-    `name`   varchar(50) NOT NULL,
-    `date`   datetime default NULL,
-    `state`  char(3) NOT NULL default '',
-    `tokens` int(5) NOT NULL,
-    `desc`   text,
-    PRIMARY KEY(`id`),
-    KEY `state_idx` (`state`),
-    KEY `find_idx` (`name`,`date`)
+register_tablecreate('acctinvite', <<'EOC');
+CREATE TABLE `acctinvite` (
+  `userid` int(10) unsigned NOT NULL,
+  `reason` varchar(40) DEFAULT NULL,
+  `dateadd` datetime NOT NULL,
+  `acid` int(10) unsigned NOT NULL,
+  UNIQUE KEY `userid` (`userid`,`reason`),
+  KEY `acid` (`acid`)
 )
 EOC
 
-register_tablecreate("paid_invites", <<EOC);
-CREATE TABLE `paid_invites` (
-  `invite_id` int(11) NOT NULL auto_increment,
-  `datetime_sent` datetime default NULL,
-  `sender_id` int(11) default NULL,
-  `recipient_id` int(11) default NULL,
-  `discount` tinyint(3) unsigned NOT NULL default '0',
-  `ordered_type` char(4) NOT NULL default '',
-  `datetime_receive` datetime default NULL,
-  `state` char(3) NOT NULL default '',
-  PRIMARY KEY  (`invite_id`),
-  UNIQUE KEY `sender_id_2` (`sender_id`,`recipient_id`),
-  KEY `sender_id` (`sender_id`),
-  KEY `rcpt_id` (`recipient_id`)
+# old payment system:  payment row is the item
+register_tablecreate('acctpay', <<'EOC');
+CREATE TABLE `acctpay` (
+  `payid` int(10) unsigned NOT NULL,
+  `acid` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`payid`),
+  UNIQUE KEY `acid` (`acid`)
 )
 EOC
 
-register_tablecreate("paycredit", <<EOC);
-CREATE TABLE paycredit (
-  userid int(10) unsigned NOT NULL default '0',
-  days smallint(5) unsigned NOT NULL default '0',
-  issued datetime NOT NULL default '0000-00-00 00:00:00',
-  used enum('N','Y') NOT NULL default 'N',
-  useddate datetime default NULL,
-  KEY (userid),
-  KEY (used)
-) TYPE=MyISAM
+# new payment system, where payments contain multiple items
+register_tablecreate('acctpayitem', <<'EOC');
+CREATE TABLE `acctpayitem` (
+  `piid` int(10) unsigned NOT NULL,
+  `acid` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`piid`),
+  UNIQUE KEY `acid` (`acid`)
+)
 EOC
 
-# when cart:
-#   forwhat = 'cart'
-#   userid = id of remote user, or 0
-#   amount = total amount
-#   months = 0
-#   method ::= "" (new cart) | "authnet-cc" | "authnet-echeck" | "paypal" | "check"
-#   datesent = cart creation
-#   daterecv = payment processed (cc/paypal), or entered (if check)
-#   used = 'C' (still cart) then after pay 'N' (now awaiting paybatch), then 'Y' (done)
-#   mailed = likewise. ^^
-register_tablecreate("payments", <<EOC);
-CREATE TABLE payments (
-  payid int(10) unsigned NOT NULL auto_increment,
-  userid int(10) unsigned NOT NULL default '0',
-  datesent datetime NOT NULL default '0000-00-00 00:00:00',
-  daterecv datetime NOT NULL default '0000-00-00 00:00:00',
-  amount decimal(8,2) default NULL,
-  months tinyint(3) unsigned default NULL,
-  used enum('N','Y') NOT NULL default 'N',
-  mailed enum('N','Y') NOT NULL default 'N',
-  notes text,
-  method varchar(20) NOT NULL default '',
-  forwhat varchar(20) default NULL,
-  PRIMARY KEY  (payid),
-  KEY (userid),
-  KEY (used),
-  KEY (method),
-  KEY (forwhat),
-  KEY (mailed)
-) TYPE=MyISAM PACK_KEYS=1
+# Table for AdSense statistics
+register_tablecreate('adsense_stat', <<'EOC');
+CREATE TABLE `adsense_stat` (
+  `userid` int(10) unsigned NOT NULL,
+  `adsenseid` varchar(64) DEFAULT NULL,
+  `publisherid` varchar(30) DEFAULT NULL,
+  `last_status` varchar(1) DEFAULT NULL,
+  `last_check` int(10) unsigned DEFAULT NULL,
+  PRIMARY KEY (`userid`),
+  KEY `last_status` (`last_status`)
+)
 EOC
 
-# keep track of ip address of buyer, first/last name,
-# email address (if non-logged in user), etc.  not indexed
-# like payment search
-register_tablecreate("payvars", <<'EOC');
-CREATE TABLE payvars (
-  payid  INT UNSIGNED NOT NULL,
-  pkey   VARCHAR(40),
-  INDEX (payid, pkey(4)),
-  pval   VARCHAR(255)
+# recbill amortization
+register_tablecreate('amort_current', <<'EOC');
+CREATE TABLE `amort_current` (
+  `userid` int(10) unsigned NOT NULL,
+  `item` varchar(25) NOT NULL,
+  `total_amt` decimal(8,2) NOT NULL DEFAULT '0.00',
+  `amort_amt` decimal(8,2) NOT NULL DEFAULT '0.00',
+  `total_time` int(10) unsigned NOT NULL,
+  `amort_time` int(10) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (`userid`,`item`),
+  KEY `item` (`item`)
 )
 EOC
 
-# Items one can buy:
-#    paidacct     qty=<months>
-#    perm
-#    rename
-#    morestats    qty=<months>
-#    morepics?
-
-register_tablecreate("payitems", <<'EOC');
-CREATE TABLE payitems (
-   piid     INT UNSIGNED NOT NULL AUTO_INCREMENT,
-   PRIMARY KEY (piid),
-   payid    INT UNSIGNED NOT NULL,
-   INDEX (payid),
-   item       VARCHAR(25),
-   qty        SMALLINT UNSIGNED,
-   rcptid     INT UNSIGNED NOT NULL, # cart owner's ID, gift rcpt's ID, or 0 for invite/"pay" code emailed
-   amt        DECIMAL(8,2),
-   status     ENUM('cart','pend','done','refund','bogus'),
-   INDEX (status),
-   rcptemail  VARCHAR(80),     # email address to mail paycode to, if non-user
-   anon       ENUM('0','1'),   # is gift anonymous?
-   giveafter  INT UNSIGNED     # unixtime to give gift after
+register_tablecreate('amort_summary', <<'EOC');
+CREATE TABLE `amort_summary` (
+  `year` mediumint(8) unsigned NOT NULL,
+  `month` tinyint(3) unsigned NOT NULL,
+  `userid` int(10) unsigned NOT NULL,
+  `item` varchar(25) NOT NULL,
+  `amort_amt` decimal(8,2) DEFAULT NULL,
+  PRIMARY KEY (`year`,`month`,`item`,`userid`),
+  KEY `userid` (`userid`)
 )
 EOC
 
-# payid <=> state mappings
-register_tablecreate("paystates", <<'EOC');
-CREATE TABLE paystates (
-   payid int unsigned NOT NULL,
-   PRIMARY KEY (payid),
-   state VARCHAR(25) NOT NULL DEFAULT '??',
-   INDEX (state)
+register_tablecreate('authnetlog', <<'EOC');
+CREATE TABLE `authnetlog` (
+  `payid` int(10) unsigned NOT NULL,
+  `cmd` enum('authcap','credit','void','authonly','priorcap','caponly') NOT NULL DEFAULT 'authcap',
+  `datesent` datetime DEFAULT NULL,
+  `ip` varchar(15) DEFAULT NULL,
+  `amt` decimal(8,2) DEFAULT NULL,
+  `result` enum('pass','fail') DEFAULT NULL,
+  `response` text,
+  `cmdnotes` varchar(255) DEFAULT NULL,
+  KEY `payid` (`payid`)
 )
 EOC
 
-# recurring billing tables
-register_tablecreate("recbill", <<'EOC');
-CREATE TABLE recbill (
-   userid INT UNSIGNED NOT NULL,
-   bill_interval TINYINT UNSIGNED NOT NULL,
-   last_check INT UNSIGNED,
-   next_check INT UNSIGNED,
-   last_email INT UNSIGNED,
-   last_payid INT UNSIGNED,
-   try_ct TINYINT UNSIGNED DEFAULT '0',
-   last_mailed INT UNSIGNED DEFAULT '0',
-   PRIMARY KEY (userid),
-   INDEX (next_check)
+register_tablecreate('betanav_feedback', <<'EOC');
+CREATE TABLE `betanav_feedback` (
+  `userid` int(10) unsigned NOT NULL,
+  `posted` int(10) unsigned NOT NULL,
+  `feedback` text NOT NULL,
+  `state` varchar(1) NOT NULL,
+  KEY `userid` (`userid`),
+  KEY `posted` (`posted`)
 )
 EOC
 
-register_tablecreate("recbill_items", <<'EOC');
-CREATE TABLE recbill_items (
-   userid INT UNSIGNED NOT NULL,
-   item VARCHAR(25) NOT NULL,
-   flag ENUM('on', 'off'), # recbilling status
-   PRIMARY KEY (userid, item)
+# Stores examples of content restricted to be posted in communities to
+# prevent the spread of spam.
+register_tablecreate('blockedcontent', <<'EOC');
+CREATE TABLE `blockedcontent` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `blockedexpression` varchar(255) NOT NULL,
+  `isregexp` tinyint(1) unsigned DEFAULT NULL,
+  `remoteid` int(10) unsigned NOT NULL DEFAULT '0',
+  `inserttime` int(10) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `blockedexpression` (`blockedexpression`)
 )
 EOC
 
-register_tablecreate("recbill_log", <<'EOC');
-CREATE TABLE recbill_log (
-   userid INT UNSIGNED NOT NULL,
-   item VARCHAR(25) NOT NULL,
-   payid INT UNSIGNED NOT NULL,
-   instime INT UNSIGNED NOT NULL,
-   old_exptime INT UNSIGNED NOT NULL,
-   new_exptime INT UNSIGNED NOT NULL,
-   note VARCHAR(255) NOT NULL DEFAULT '',
-   INDEX(userid, item),
-   INDEX(payid)
+# bot report subsystem
+register_tablecreate('botreports', <<'EOC');
+CREATE TABLE `botreports` (
+  `srid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+  `state` char(1) NOT NULL DEFAULT 'o',
+  `journalid` int(10) unsigned NOT NULL,
+  `reporterid` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`srid`),
+  KEY `journalid` (`journalid`,`reporterid`)
 )
 EOC
 
-register_tablecreate("recbill_cc", <<'EOC');
-CREATE TABLE recbill_cc (
-   userid INT UNSIGNED NOT NULL,
-   instime INT UNSIGNED NOT NULL,
-   modtime INT UNSIGNED NOT NULL,
-   expmail INT UNSIGNED,
-   pri_flag ENUM('0', '1') DEFAULT '0' NOT NULL,
-   type ENUM('Visa', 'MasterCard', 'AmEx', 'DinersClub', 'Discover', 'CarteBlanche', 'JCB'),
-   exp_y SMALLINT UNSIGNED NOT NULL,
-   exp_m TINYINT UNSIGNED NOT NULL,
-   lastfour SMALLINT UNSIGNED NOT NULL,
-   name_first VARCHAR(20) NOT NULL,
-   name_last VARCHAR(20) NOT NULL,
-   phone_num VARCHAR(32) NOT NULL,
-   addr VARCHAR(50) NOT NULL,
-   city VARCHAR(50) NOT NULL,
-   state VARCHAR(65) NOT NULL,
-   postal_code VARCHAR(15) NOT NULL,
-   country CHAR(3) NOT NULL,
-   UNIQUE KEY (userid, lastfour),
-   KEY (exp_y, exp_m)
+register_tablecreate('botwhitelist', <<'EOC');
+CREATE TABLE `botwhitelist` (
+  `userid` int(10) unsigned NOT NULL,
+  `remoteid` int(10) unsigned NOT NULL DEFAULT '0',
+  `inserttime` int(10) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (`userid`)
 )
 EOC
 
-register_tablecreate("recbill_pendtime", <<'EOC');
-CREATE TABLE recbill_pendtime (
-   userid INT UNSIGNED NOT NULL,
-   itemname VARCHAR(25) NOT NULL,
-   ident VARCHAR(25) NOT NULL,
-   applytime INT UNSIGNED NOT NULL,
-   instime INT UNSIGNED NOT NULL,
-   timeqty INT UNSIGNED NOT NULL,
-   UNIQUE KEY (userid, itemname, ident)
+# Bazaar tables
+
+# amt: amount earned in given bazaar
+# owed:  how much remains to be be paid/expired
+# expired:  money lost to expiration
+# note: "bzid=<n>" for owed, free form (check number, etc) for paid
+register_tablecreate('bzrbalance', <<'EOC');
+CREATE TABLE `bzrbalance` (
+  `userid` int(10) unsigned NOT NULL,
+  `bzid` smallint(5) unsigned NOT NULL,
+  `date` datetime DEFAULT NULL,
+  `amt` decimal(5,2) DEFAULT NULL,
+  `owed` decimal(5,2) DEFAULT NULL,
+  `expired` decimal(5,2) DEFAULT NULL,
+  PRIMARY KEY (`userid`,`bzid`)
 )
 EOC
 
-register_tablecreate("recbill_promo", <<'EOC');
-CREATE TABLE recbill_promo (
-   userid INT UNSIGNED NOT NULL,
-   promo VARCHAR(25) NOT NULL,
-   PRIMARY KEY (userid, promo)
+# note = "coupon:(\S+)" when method = "coupon"
+# note = free form when method='money'
+register_tablecreate('bzrpayout', <<'EOC');
+CREATE TABLE `bzrpayout` (
+  `userid` int(10) unsigned NOT NULL,
+  `date` datetime DEFAULT NULL,
+  `amt` decimal(5,2) DEFAULT NULL,
+  `method` enum('money','coupon') DEFAULT NULL,
+  `note` varchar(80) DEFAULT NULL,
+  KEY `userid` (`userid`)
 )
 EOC
 
-# recbill amortization
-register_tablecreate("amort_current", <<'EOC');
-CREATE TABLE amort_current (
-   userid     INT UNSIGNED NOT NULL,
-   item       VARCHAR(25) NOT NULL,
-   size       INT UNSIGNED NOT NULL,
-   total_amt  DECIMAL(8,2) NOT NULL DEFAULT 0.0,
-   amort_amt  DECIMAL(8,2) NOT NULL DEFAULT 0.0,
-   total_time INT UNSIGNED NOT NULL,
-   PRIMARY KEY (userid,item,size),
-   INDEX (item)
+register_tablecreate('bzrpot', <<'EOC');
+CREATE TABLE `bzrpot` (
+  `bzid` smallint(5) unsigned NOT NULL,
+  `dateadd` datetime DEFAULT NULL,
+  `amt` decimal(8,2) DEFAULT NULL,
+  `reason` varchar(255) DEFAULT NULL
 )
 EOC
 
-register_tablecreate("amort_summary", <<'EOC');
-CREATE TABLE amort_summary (
-   year       MEDIUMINT UNSIGNED NOT NULL,
-   month      TINYINT UNSIGNED NOT NULL,
-   userid     INT UNSIGNED NOT NULL,
-   item       VARCHAR(25) NOT NULL,
-   size       INT UNSIGNED NOT NULL DEFAULT 0,
-   amort_amt  DECIMAL(8,2),
-   PRIMARY KEY (year,month,item,size,userid),
-   INDEX(userid)
+register_tablecreate('bzrs', <<'EOC');
+CREATE TABLE `bzrs` (
+  `bzid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
+  `name` varchar(80) DEFAULT NULL,
+  `datestart` datetime DEFAULT NULL,
+  `open` enum('0','1') DEFAULT NULL,
+  PRIMARY KEY (`bzid`)
 )
 EOC
 
-
-# clothing  babydoll-royalblue-xl  234  220
-register_tablecreate("inventory", <<'EOC');
-CREATE TABLE inventory (
-   item     VARCHAR(25) NOT NULL,
-   subitem  VARCHAR(35) NOT NULL,
-   PRIMARY KEY (item, subitem),
-   qty      SMALLINT UNSIGNED NOT NULL,
-   avail    SMALLINT UNSIGNED NOT NULL,
-   price    DECIMAL(8,2)
+register_tablecreate('bzrvote', <<'EOC');
+CREATE TABLE `bzrvote` (
+  `bzid` smallint(5) unsigned NOT NULL,
+  `userid` int(10) unsigned NOT NULL,
+  `coid` int(10) unsigned NOT NULL,
+  `weight` smallint(5) unsigned NOT NULL,
+  PRIMARY KEY (`bzid`,`userid`,`coid`),
+  KEY `userid` (`userid`),
+  KEY `coid` (`coid`)
 )
 EOC
 
-register_tablecreate("shipping", <<'EOC');
-CREATE TABLE shipping (
-   payid   INT UNSIGNED NOT NULL,
-   PRIMARY KEY (payid),
-   status   ENUM('needs', 'shipped') NOT NULL,
-   INDEX (status),
-   dateready    DATETIME,
-   dateshipped  DATETIME
+register_tablecreate('bzrvoter', <<'EOC');
+CREATE TABLE `bzrvoter` (
+  `bzid` smallint(5) unsigned NOT NULL,
+  `userid` int(10) unsigned NOT NULL,
+  `weight` float(7,5) unsigned DEFAULT NULL,
+  PRIMARY KEY (`bzid`,`userid`)
 )
 EOC
 
-register_tablecreate("coupon", <<'EOC');
-CREATE TABLE coupon (
-   cpid    MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
-   auth    CHAR(10),
-   type    VARCHAR(20),   # freeclothingitem, dollaroff (-$arg), percentoff (-%arg)
-   arg     VARCHAR(30),
-   rcptid  INT UNSIGNED NOT NULL,
-   INDEX   (rcptid),
-   locked  ENUM('0', '1') DEFAULT '0' NOT NULL,
-   payid   INT UNSIGNED NOT NULL,
-   INDEX   (payid)
+# keep track of avs fails per user
+register_tablecreate('ccfail', <<'EOC');
+CREATE TABLE `ccfail` (
+  `email` varchar(50) NOT NULL,
+  `time` int(10) unsigned NOT NULL,
+  `userid` int(10) unsigned DEFAULT NULL,
+  `why` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`email`,`time`),
+  KEY `userid` (`userid`)
 )
 EOC
 
-register_tablecreate("paymentsearch", <<'EOC');
-CREATE TABLE paymentsearch
-(
- payid INT UNSIGNED NOT NULL,
- INDEX (payid),
- ikey  varchar(12) NOT NULL,
- ival  varchar(50) NOT NULL,
- INDEX (ikey, ival)
+register_tablecreate('cdn_map', <<'EOC');
+CREATE TABLE `cdn_map` (
+  `pfx` varchar(7) NOT NULL,
+  `rules` mediumblob,
+  PRIMARY KEY (`pfx`)
 )
 EOC
 
-register_tablecreate("authnetlog", <<'EOC');
-CREATE TABLE authnetlog
-(
- payid     INT UNSIGNED NOT NULL,
- INDEX (payid),
- datesent  DATETIME,
- ip        VARCHAR(15),
- amt       DECIMAL(8,2),
- result    ENUM('pass','fail'),
- response  TEXT
+##
+## Stores the list of changed profiles
+##
+register_tablecreate('changed_profiles_list', <<'EOC');
+CREATE TABLE `changed_profiles_list` (
+  `username` char(15) DEFAULT NULL,
+  `modified` int(10) unsigned DEFAULT NULL,
+  KEY `modified` (`modified`)
 )
 EOC
 
-register_tablecreate("transferinfo", <<EOC);
-CREATE TABLE transferinfo (
-  userid int(10) unsigned NOT NULL default '0',
-  state enum('on','off','bad') default NULL,
-  method enum('ftp','scp','post','webdav') NOT NULL default 'ftp',
-  host varchar(100) default NULL,
-  username varchar(50) default NULL,
-  password varchar(50) default NULL,
-  directory varchar(100) default NULL,
-  filename varchar(50) default NULL,
-  lastxfer datetime NOT NULL default '0000-00-00 00:00:00',
-  styleid int(11) NOT NULL default '0',
-  PRIMARY KEY  (userid)
-) TYPE=MyISAM
+register_tablecreate('contributed', <<'EOC');
+CREATE TABLE `contributed` (
+  `coid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `userid` int(10) unsigned NOT NULL,
+  `cat` enum('code','doc','creative','biz','other') NOT NULL DEFAULT 'other',
+  `des` varchar(255) NOT NULL,
+  `url` varchar(100) DEFAULT NULL,
+  `dateadd` datetime NOT NULL,
+  `acks` smallint(6) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`coid`),
+  KEY `userid` (`userid`),
+  KEY `cat` (`cat`),
+  KEY `acks` (`acks`),
+  KEY `dateadd` (`dateadd`)
+)
 EOC
 
-register_tablecreate("contributed", <<'EOC');
-CREATE TABLE contributed
-(
- coid    INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
- userid  INT UNSIGNED NOT NULL,
- INDEX (userid),
- cat    ENUM('code','doc','creative','biz','other') NOT NULL DEFAULT 'other',
- INDEX (cat),
- des    VARCHAR(255) NOT NULL,
- url    VARCHAR(100),
- dateadd  DATETIME NOT NULL,
- acks   SMALLINT NOT NULL DEFAULT '0',
- INDEX (acks)
- )
+register_tablecreate('contributedack', <<'EOC');
+CREATE TABLE `contributedack` (
+  `coid` int(10) unsigned NOT NULL,
+  `ackuserid` int(10) unsigned NOT NULL,
+  UNIQUE KEY `coid` (`coid`,`ackuserid`),
+  KEY `ackuserid` (`ackuserid`)
+)
 EOC
 
-register_tablecreate("contributedack", <<'EOC');
-CREATE TABLE contributedack
-(
- coid   INT UNSIGNED NOT NULL,
- ackuserid  INT UNSIGNED NOT NULL,
- UNIQUE (coid, ackuserid),
- INDEX (ackuserid)
+register_tablecreate('coupon', <<'EOC');
+CREATE TABLE `coupon` (
+  `cpid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+  `auth` char(10) DEFAULT NULL,
+  `type` varchar(20) DEFAULT NULL,
+  `arg` varchar(30) DEFAULT NULL,
+  `rcptid` int(10) unsigned NOT NULL,
+  `locked` enum('0','1') NOT NULL DEFAULT '0',
+  `payid` int(10) unsigned NOT NULL,
+  `ppayid` int(10) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (`cpid`),
+  KEY `rcptid` (`rcptid`),
+  KEY `payid` (`payid`),
+  KEY `ppayid` (`ppayid`)
 )
 EOC
 
-register_tabledrop("tmp_contributed");
-
-# old payment system:  payment row is the item
-register_tablecreate("acctpay", <<'EOC');
-CREATE TABLE acctpay
-(
-  payid   INT UNSIGNED NOT NULL,
-  acid    INT UNSIGNED NOT NULL,
-  PRIMARY KEY (payid),
-  UNIQUE (acid)
+register_tablecreate('deletion_feedback', <<'EOC');
+CREATE TABLE `deletion_feedback` (
+  `timerecv` int(10) unsigned NOT NULL,
+  `userid` int(10) unsigned NOT NULL,
+  `qkey` varchar(30) NOT NULL,
+  `answer` text,
+  KEY `timerecv` (`timerecv`),
+  KEY `userid` (`userid`)
 )
 EOC
 
-# new payment system, where payments contain multiple items
-register_tablecreate("acctpayitem", <<'EOC');
-CREATE TABLE acctpayitem
-(
-  piid   INT UNSIGNED NOT NULL,
-  acid   INT UNSIGNED NOT NULL,
-  PRIMARY KEY (piid),
-  UNIQUE (acid)
+register_tablecreate('email_aliases', <<'EOC');
+CREATE TABLE `email_aliases` (
+  `alias` varchar(100) NOT NULL,
+  `rcpt` varchar(200) NOT NULL,
+  PRIMARY KEY (`alias`)
 )
 EOC
 
-register_tablecreate("acctinvite", <<'EOC');
-CREATE TABLE acctinvite
-(
-  userid INT UNSIGNED NOT NULL,
-  reason VARCHAR(20) NOT NULL,
-  UNIQUE (userid, reason),
-  dateadd DATETIME NOT NULL,
-  acid   INT UNSIGNED NOT NULL,
-  INDEX (acid)
+# stores email stocks
+# LJ::Sendmail::Stock is the interface
+# /admin/sendmail/stocks.bml is the user-facing interface
+register_tablecreate('emailstocks', <<'EOC');
+CREATE TABLE `emailstocks` (
+  `emailstockid` int(11) NOT NULL AUTO_INCREMENT,
+  `fromaddr` char(20) NOT NULL DEFAULT '',
+  `title` char(255) NOT NULL DEFAULT '',
+  `body` text,
+  `lastupdate_userid` int(11) NOT NULL DEFAULT '0',
+  `lastupdate_time` int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`emailstockid`),
+  KEY `fromaddr` (`fromaddr`)
 )
 EOC
 
-register_tablecreate("paiduser", <<'EOC');
-CREATE TABLE paiduser
-(
- userid  INT UNSIGNED NOT NULL PRIMARY KEY,
- paiduntil     datetime NOT NULL,
- paidreminder  datetime,
- INDEX (paiduntil)
+## See LJ::PartnerSite
+register_tablecreate('external_sites_articles_map', <<'EOC');
+CREATE TABLE `external_sites_articles_map` (
+  `partnerid` int(11) NOT NULL DEFAULT '0',
+  `docid_hash` char(22) NOT NULL DEFAULT '',
+  `docid` char(150) NOT NULL DEFAULT '',
+  `jitemid` mediumint(8) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (`partnerid`,`jitemid`),
+  UNIQUE KEY `partnerid` (`partnerid`,`docid_hash`,`docid`)
 )
 EOC
 
-register_tablecreate("paytrans", <<'EOC');
-CREATE TABLE paytrans (
-  userid INT UNSIGNED NOT NULL,
-  time INT UNSIGNED NOT NULL,
-  what ENUM('paidaccount'),
-  action ENUM('new', 'renew', 'expire', 'return'),
-  KEY (userid),
-  KEY (time)
+register_tablecreate('exturl2entry_map', <<'EOC');
+CREATE TABLE `exturl2entry_map` (
+  `userid` int(11) NOT NULL,
+  `url_md5` varchar(22) DEFAULT NULL,
+  `jitemid` int(11) NOT NULL,
+  KEY `userid` (`userid`,`url_md5`)
 )
 EOC
 
-register_tablecreate("email_aliases", <<'EOC');
-CREATE TABLE email_aliases
-(
- alias VARCHAR(100) NOT NULL,
- PRIMARY KEY (alias),
- rcpt  VARCHAR(200) NOT NULL
+register_tablecreate('featured_photos', <<'EOC');
+CREATE TABLE `featured_photos` (
+  `p_id` int(11) NOT NULL AUTO_INCREMENT,
+  `author` varchar(20) NOT NULL,
+  `title` varchar(250) NOT NULL,
+  `countries` varchar(50) DEFAULT NULL,
+  `source_post` varchar(250) NOT NULL,
+  `source_img` varchar(250) NOT NULL,
+  `target_img` varchar(200) NOT NULL,
+  `forwhat` varchar(10) NOT NULL,
+  `size` varchar(15) NOT NULL,
+  `is_error` tinyint(4) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`p_id`)
 )
 EOC
 
-register_tablecreate("abuse_mail", <<'EOC');
-CREATE TABLE abuse_mail
-(
- mailid int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
- userid int(10) UNSIGNED NOT NULL,
- INDEX (userid),
- spid int(10) UNSIGNED,
- INDEX (spid),
- status ENUM('S','F') DEFAULT 'F' NOT NULL,
- timesent DATETIME NOT NULL,
- mailto VARCHAR(100) NOT NULL,
- subject VARCHAR(100) NOT NULL,
- message TEXT
+register_tablecreate('files', <<'EOC');
+CREATE TABLE `files` (
+  `path` varchar(100) NOT NULL DEFAULT '',
+  `mime_type` varchar(20) NOT NULL DEFAULT '',
+  `content_length` int(10) unsigned DEFAULT NULL,
+  `change_time` int(11) DEFAULT NULL,
+  UNIQUE KEY `path` (`path`)
 )
 EOC
 
-register_tablecreate("renames", <<'EOC');
-CREATE TABLE renames
-(
-  renid  MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  token  CHAR(10) NOT NULL,
-  payid  INT UNSIGNED NOT NULL,
-  INDEX (payid),
-  userid    INT UNSIGNED,
-  INDEX (userid),
-  fromuser  CHAR(15),
-  touser    CHAR(15),
-  INDEX (fromuser),
-  INDEX (touser),
-  rendate  DATETIME
+# FotoBilder feedback surveys
+register_tablecreate('fotobilder_feedback', <<'EOC');
+CREATE TABLE `fotobilder_feedback` (
+  `url` varchar(100) NOT NULL,
+  `userid` int(10) unsigned DEFAULT NULL,
+  `state` char(1) NOT NULL,
+  `datetime` datetime NOT NULL,
+  `body` blob,
+  KEY `url` (`url`),
+  KEY `state` (`state`),
+  KEY `userid` (`userid`)
 )
 EOC
 
-register_tablecreate("meetup_ints", <<'EOC');
-CREATE TABLE meetup_ints (
-   intid   INT UNSIGNED NOT NULL,
-   PRIMARY KEY (intid),
-   urlkey  VARCHAR(30) NOT NULL,
-   name    VARCHAR(50)
+register_tablecreate('frank_text', <<'EOC');
+CREATE TABLE `frank_text` (
+  `txtid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `text` text NOT NULL,
+  PRIMARY KEY (`txtid`)
 )
 EOC
 
-# Bazaar tables
-register_tablecreate("bzrs", <<'EOC');
-CREATE TABLE bzrs (
-   bzid       SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
-     PRIMARY KEY (bzid),
-   name       VARCHAR(80),
-   datestart  DATETIME,
-   open       ENUM('0','1')
+# Payment fraud
+register_tablecreate('fraudsuspects', <<'EOC');
+CREATE TABLE `fraudsuspects` (
+  `payid` int(10) unsigned NOT NULL,
+  `dateadd` int(10) unsigned NOT NULL,
+  `reason` text,
+  PRIMARY KEY (`payid`)
 )
 EOC
 
-register_tablecreate("bzrpot", <<'EOC');
-CREATE TABLE bzrpot (
-   bzid       SMALLINT UNSIGNED NOT NULL,
-   dateadd    DATETIME,
-   amt        DECIMAL(8,2),
-   reason     VARCHAR(255)
+register_tablecreate('free2pay_trx', <<'EOC');
+CREATE TABLE `free2pay_trx` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `name` varchar(50) NOT NULL,
+  `date` datetime DEFAULT NULL,
+  `state` char(3) NOT NULL DEFAULT '',
+  `tokens` int(5) NOT NULL,
+  `desc` text,
+  PRIMARY KEY (`id`),
+  KEY `state_idx` (`state`),
+  KEY `find_idx` (`name`,`date`)
 )
 EOC
 
-register_tablecreate("bzrvote", <<'EOC');
-CREATE TABLE bzrvote (
-   bzid       SMALLINT UNSIGNED NOT NULL,
-   userid     INT UNSIGNED NOT NULL,
-   coid       INT UNSIGNED NOT NULL,
-   weight     SMALLINT UNSIGNED NOT NULL,
-   PRIMARY KEY (bzid, userid, coid),
-   INDEX (userid),
-   INDEX (coid)
+register_tablecreate('friendstimes', <<'EOC');
+CREATE TABLE `friendstimes` (
+  `userid` int(11) NOT NULL,
+  `journalid` int(11) NOT NULL,
+  `jitemid` int(10) unsigned NOT NULL,
+  `groupmask` int(10) unsigned NOT NULL DEFAULT '1',
+  `added` int(11) NOT NULL,
+  UNIQUE KEY `userid` (`userid`,`journalid`,`jitemid`),
+  KEY `userid_2` (`userid`,`added`)
 )
 EOC
 
-register_tablecreate("bzrvoter", <<'EOC');
-CREATE TABLE bzrvoter (
-   bzid       SMALLINT UNSIGNED NOT NULL,
-   userid     INT UNSIGNED NOT NULL,
-   weight     FLOAT(7,5) UNSIGNED,
-   PRIMARY KEY (bzid, userid)
+register_tablecreate('friendstimes2_unwatched', <<'EOC');
+CREATE TABLE `friendstimes2_unwatched` (
+  `userid` int(11) unsigned NOT NULL,
+  `unwatched_uid` int(11) unsigned NOT NULL,
+  UNIQUE KEY `userid` (`userid`,`unwatched_uid`)
 )
 EOC
 
-# amt: amount earned in given bazaar
-# owed:  how much remains to be be paid/expired
-# expired:  money lost to expiration
-# note: "bzid=<n>" for owed, free form (check number, etc) for paid
-register_tablecreate("bzrbalance", <<'EOC');
-CREATE TABLE bzrbalance (
-   userid        INT UNSIGNED NOT NULL,
-   bzid          SMALLINT UNSIGNED NOT NULL,
-   PRIMARY KEY (userid, bzid),
-
-   date          DATETIME,
-
-   amt           DECIMAL(5,2),
-   owed          DECIMAL(5,2),
-   expired       DECIMAL(5,2)
+register_tablecreate('homepage_items', <<'EOC');
+CREATE TABLE `homepage_items` (
+  `item` varchar(7) NOT NULL DEFAULT '',
+  `subitem` varchar(100) NOT NULL,
+  `show_to_sup` tinyint(1) DEFAULT NULL,
+  `url` varchar(100) NOT NULL DEFAULT ''
 )
 EOC
 
-# note = "coupon:(\S+)" when method = "coupon"
-# note = free form when method='money'
-register_tablecreate("bzrpayout", <<'EOC');
-CREATE TABLE bzrpayout (
-   userid        INT UNSIGNED NOT NULL,
-   date          DATETIME,
-   amt           DECIMAL(5,2),
-   method        ENUM('money','coupon'),
-   note          VARCHAR(80),
-   INDEX (userid)
+# see LJ::User::Inactive
+register_tablecreate('inactive_user', <<'EOC');
+CREATE TABLE `inactive_user` (
+  `userid` int(11) NOT NULL DEFAULT '0',
+  `notices_sent` int(11) NOT NULL DEFAULT '0',
+  `last_notice_time` int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`userid`),
+  KEY `notices_sent` (`notices_sent`,`last_notice_time`)
 )
 EOC
 
-register_tablecreate("tshirtpoll", <<'EOC');
-CREATE TABLE tshirtpoll (
-  userid  INT UNSIGNED NOT NULL,
-  INDEX (userid),
-  style   VARCHAR(20),
-  color   VARCHAR(20),
-  size    VARCHAR(5),
-  qty     SMALLINT UNSIGNED NOT NULL
+##
+## Article - Post mapping
+##
+register_tablecreate('independent_mapping', <<'EOC');
+CREATE TABLE `independent_mapping` (
+  `url` varchar(255) DEFAULT NULL,
+  `art_id` int(10) unsigned NOT NULL DEFAULT '0',
+  `journal_id` int(10) unsigned DEFAULT NULL,
+  `ditemid` int(10) unsigned DEFAULT NULL,
+  `author` varchar(255) DEFAULT NULL,
+  `publish_date` varchar(50) DEFAULT NULL,
+  PRIMARY KEY (`art_id`),
+  KEY `journal_id` (`journal_id`,`ditemid`)
 )
 EOC
 
-# paid item expiration times
-register_tablecreate("paidexp", <<'EOC');
-CREATE TABLE paidexp (
-  userid INT unsigned NOT NULL default '0',
-  item VARCHAR(25) NOT NULL default '',
-  expdate DATETIME NOT NULL default '0000-00-00 00:00:00',
-  daysleft SMALLINT NOT NULL DEFAULT '0',
-  PRIMARY KEY (userid, item)
+# clothing  babydoll-royalblue-xl  234  220
+register_tablecreate('inventory', <<'EOC');
+CREATE TABLE `inventory` (
+  `item` varchar(25) NOT NULL,
+  `subitem` varchar(35) NOT NULL,
+  `qty` smallint(5) unsigned NOT NULL,
+  `avail` smallint(5) unsigned NOT NULL,
+  `price` decimal(8,2) DEFAULT NULL,
+  PRIMARY KEY (`item`,`subitem`)
 )
 EOC
 
-register_tablecreate("phonepostlogin", <<'EOC');
-CREATE TABLE phonepostlogin (
-  phone       VARCHAR(20)  NOT NULL,
-  pin         VARCHAR(10)  NOT NULL,
-  userid      INT UNSIGNED NOT NULL,
-  journalid   INT UNSIGNED NOT NULL,
-  PRIMARY KEY (phone, pin),
-  UNIQUE KEY (userid, journalid)
-)
+# clustered version of jabber contact list (roster)
+register_tablecreate('jabroster2', <<'EOC');
+CREATE TABLE `jabroster2` (
+  `userid` int(10) unsigned NOT NULL,
+  `jid` varchar(250) NOT NULL,
+  `nick` text NOT NULL,
+  `subscription` char(1) NOT NULL,
+  `ask` char(1) NOT NULL,
+  `askmessage` text NOT NULL,
+  `server` char(1) NOT NULL,
+  `subscribe` text NOT NULL,
+  `type` text,
+  KEY `userid` (`userid`,`jid`(75)),
+  KEY `userid_2` (`userid`),
+  KEY `jid` (`jid`(75))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
 EOC
 
-# blob from blobid must be of type 'phonepost'.
-# security is inferred from jitemid; if there is no log2 row, it's private.
-register_tablecreate("phonepostentry", <<'EOC');
-CREATE TABLE phonepostentry (
-  userid      INT       UNSIGNED NOT NULL,
-  blobid      MEDIUMINT UNSIGNED NOT NULL,
-  lengthsecs  MEDIUMINT UNSIGNED NOT NULL,
-  anum        TINYINT   UNSIGNED NOT NULL,
-  jitemid     MEDIUMINT UNSIGNED NOT NULL,
-  posttime    INT       UNSIGNED NOT NULL,
-  PRIMARY KEY (userid, blobid),
-  INDEX (posttime)
-)
+# clustered version of contact list group
+register_tablecreate('jabrostergroups2', <<'EOC');
+CREATE TABLE `jabrostergroups2` (
+  `userid` int(10) unsigned NOT NULL,
+  `jid` varchar(250) NOT NULL,
+  `grp` varchar(250) NOT NULL,
+  KEY `userid` (`userid`,`jid`(75))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
 EOC
 
-# blob from blobid must be of type 'phonepost'.
-# security is inferred from jitemid; if there is no log2 row, it's private.
-register_tablecreate("phoneposttrans", <<'EOC');
-CREATE TABLE phoneposttrans (
-  journalid   INT       UNSIGNED NOT NULL,
-  blobid      MEDIUMINT UNSIGNED NOT NULL,
-  revid       TINYINT   UNSIGNED NOT NULL,
-  posterid    INT       UNSIGNED NOT NULL,
-  posttime    INT       UNSIGNED NOT NULL,
-  subject     VARCHAR(255) BINARY,
-  body        BLOB,
-  PRIMARY KEY (journalid, blobid, revid)
+# JamRewards partnership id usage-tracking
+register_tablecreate('jamrewards', <<'EOC');
+CREATE TABLE `jamrewards` (
+  `affid` varchar(20) NOT NULL,
+  `promokey` varchar(20) NOT NULL,
+  `arg` varchar(255) NOT NULL,
+  `timeused` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`affid`,`promokey`)
 )
 EOC
 
-# TEMP: Survey of unknown8bit posts, populated by
-#  a postpost hook in ljcom.pl .
-register_tablecreate("survey_v0_8bit", <<'EOC');
-CREATE TABLE survey_v0_8bit (
-  userid INT UNSIGNED NOT NULL,
-  timepost  INT UNSIGNED NOT NULL,
-  PRIMARY KEY (userid),
-  INDEX (timepost)
+register_tablecreate('journal_spotlight', <<'EOC');
+CREATE TABLE `journal_spotlight` (
+  `spotid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+  `time_start` int(10) unsigned NOT NULL DEFAULT '0',
+  `time_end` int(10) unsigned NOT NULL DEFAULT '0',
+  `userid` int(10) unsigned NOT NULL DEFAULT '0',
+  `active` enum('Y','N') NOT NULL DEFAULT 'Y',
+  `des` blob NOT NULL,
+  `domain` char(5) NOT NULL DEFAULT 'lj',
+  `profile_url` varchar(255) DEFAULT NULL,
+  `journal_url` varchar(255) DEFAULT NULL,
+  `small_img_url` varchar(255) DEFAULT NULL,
+  `countries` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`spotid`),
+  UNIQUE KEY `domain` (`domain`,`userid`),
+  KEY `time_start` (`time_start`),
+  KEY `time_end` (`time_end`)
 )
 EOC
 
-# keep track of avs fails per user
-register_tablecreate("ccfail", <<'EOC');
-CREATE TABLE ccfail (
-  email VARCHAR(50) NOT NULL,
-  time INT UNSIGNED NOT NULL,
-  userid INT UNSIGNED,
-  why VARCHAR(100),
-  PRIMARY KEY (email, time),
-  KEY (userid)
+register_tablecreate('loyalty_userpic_history', <<'EOC');
+CREATE TABLE `loyalty_userpic_history` (
+  `entryid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `userid` int(10) unsigned NOT NULL,
+  `action` enum('add','reset','historic') NOT NULL,
+  `qty` int(10) unsigned DEFAULT NULL,
+  `instime` int(10) unsigned NOT NULL,
+  `piid` int(10) unsigned DEFAULT NULL,
+  PRIMARY KEY (`entryid`),
+  UNIQUE KEY `piid` (`piid`),
+  KEY `userid` (`userid`)
 )
 EOC
 
-# FotoBilder feedback surveys
-register_tablecreate("fotobilder_feedback", <<'EOC');
-CREATE TABLE fotobilder_feedback (
-  url         VARCHAR(100) NOT NULL,
-  userid      INT UNSIGNED,
-  state       CHAR(1) NOT NULL,
-  body        BLOB,
-
-  INDEX       (url),
-  INDEX       (state),
-  INDEX       (userid)
+register_tablecreate('meetup_ints', <<'EOC');
+CREATE TABLE `meetup_ints` (
+  `intid` int(10) unsigned NOT NULL,
+  `urlkey` varchar(30) NOT NULL,
+  `name` varchar(50) DEFAULT NULL,
+  PRIMARY KEY (`intid`)
 )
 EOC
 
-# Payment fraud
-register_tablecreate("fraudsuspects", <<'EOC');
-CREATE TABLE fraudsuspects (
-        payid INT UNSIGNED NOT NULL,
-        PRIMARY KEY (payid),
-        dateadd INT UNSIGNED NOT NULL,
-        reason TEXT
+register_tablecreate('needed_backups', <<'EOC');
+CREATE TABLE `needed_backups` (
+  `user` varchar(15) NOT NULL,
+  PRIMARY KEY (`user`)
 )
 EOC
 
-# External phonepost destinations
-# For an explaination of this table, see
-# ljcomint/doc/notes/external_phoneposting.txt
-register_tablecreate("phonepostdests", <<'EOC');
-CREATE TABLE phonepostdests (
-    userid INT UNSIGNED NOT NULL DEFAULT 0,
-    destid INT UNSIGNED NOT NULL DEFAULT 0,
-    namespace INT UNSIGNED NOT NULL,
-    audio_type VARCHAR(20) NULL,
-    audio_post_url VARCHAR(255) NULL,
-    audio_user VARCHAR(255) NULL,
-    audio_password VARCHAR(255) NULL,
-    blog_type VARCHAR(20) NULL,
-    blog_name VARCHAR(255) NULL,
-    blog_post_url VARCHAR(255) NULL,
-    blog_user VARCHAR(255) NULL,
-    blog_password VARCHAR(255) NULL,
-    PRIMARY KEY (userid, destid, namespace)
+# used in ssldocs/tools/endpoints/offerpal.bml to prevent duplicates
+register_tablecreate('offerpal', <<'EOC');
+CREATE TABLE `offerpal` (
+  `id` varchar(18) NOT NULL,
+  `url` varchar(250) NOT NULL,
+  `timestamp` int(10) unsigned NOT NULL,
+  `ip` varchar(15) NOT NULL,
+  `payid` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`id`)
 )
 EOC
 
-# Style contest
-register_tablecreate("temp_stylecontest2poll", <<'EOC');
-CREATE TABLE temp_stylecontest2poll (
-    userid    INT UNSIGNED NOT NULL,
-    votetime  INT UNSIGNED NOT NULL,
-    vote      VARCHAR(50),
-    UNIQUE (userid, vote),
-    INDEX (vote)
+# logs all non-accepted offerpal transactions
+register_tablecreate('offerpal_failures', <<'EOC');
+CREATE TABLE `offerpal_failures` (
+  `timestamp` int(10) unsigned NOT NULL,
+  `ip` varchar(15) NOT NULL,
+  `args` varchar(250) NOT NULL,
+  `result` int(11) NOT NULL,
+  `message` varchar(250) NOT NULL
 )
 EOC
 
-# JamRewards partnership id usage-tracking
-register_tablecreate("jamrewards", <<'EOC');
-CREATE TABLE jamrewards (
-    affid     VARCHAR(20) NOT NULL,
-    promokey  VARCHAR(20) NOT NULL,
-    arg       VARCHAR(255) NOT NULL,
-    timeused  INT UNSIGNED NOT NULL,
-    PRIMARY KEY (affid, promokey)
+register_tablecreate('paid_invites', <<'EOC');
+CREATE TABLE `paid_invites` (
+  `invite_id` int(11) NOT NULL AUTO_INCREMENT,
+  `datetime_sent` datetime DEFAULT NULL,
+  `sender_id` int(11) DEFAULT NULL,
+  `recipient_id` int(11) DEFAULT NULL,
+  `discount` tinyint(3) unsigned NOT NULL DEFAULT '0',
+  `ordered_type` char(4) NOT NULL DEFAULT '',
+  `datetime_receive` datetime DEFAULT NULL,
+  `state` char(3) NOT NULL DEFAULT '',
+  PRIMARY KEY (`invite_id`),
+  UNIQUE KEY `sender_id_2` (`sender_id`,`recipient_id`),
+  KEY `sender_id` (`sender_id`),
+  KEY `rcpt_id` (`recipient_id`)
 )
 EOC
 
-# virtual gifts for a user
-# setting exptime to now effectively kills
-# the gift
-register_tablecreate("vgifts", <<'EOC');
-CREATE TABLE vgifts (
-    userid       INT UNSIGNED NOT NULL,
-    giftid       INT UNSIGNED NOT NULL,
-    exptime      INT UNSIGNED NOT NULL,
-    INDEX (userid, exptime),
-    gifttype     SMALLINT UNSIGNED NOT NULL,
-    note         TEXT,
-    giverid      INT UNSIGNED NOT NULL,
-    daterecv     INT UNSIGNED NOT NULL,
-    PRIMARY KEY (userid, giftid)
+# paid item expiration times
+register_tablecreate('paidexp', <<'EOC');
+CREATE TABLE `paidexp` (
+  `userid` int(10) unsigned NOT NULL DEFAULT '0',
+  `item` varchar(25) NOT NULL DEFAULT '',
+  `size` int(10) unsigned NOT NULL DEFAULT '0',
+  `expdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `daysleft` smallint(6) NOT NULL DEFAULT '0',
+  `lastmailed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  PRIMARY KEY (`userid`,`item`)
 )
 EOC
 
-# pardon the lame name...
-register_tablecreate("loyalty_userpic_history", <<'EOC');
-CREATE TABLE loyalty_userpic_history (
-    entryid      INT UNSIGNED NOT NULL auto_increment,
-    userid       INT UNSIGNED NOT NULL,
-    action       ENUM ('add', 'reset') NOT NULL,
-    qty          INT UNSIGNED,
-    instime      INT UNSIGNED NOT NULL,
-    piid         INT UNSIGNED,
-    PRIMARY KEY (entryid),
-    INDEX (userid),
-    UNIQUE (piid)
+register_tablecreate('paiduser', <<'EOC');
+CREATE TABLE `paiduser` (
+  `userid` int(10) unsigned NOT NULL,
+  `paiduntil` datetime NOT NULL,
+  `paidreminder` datetime DEFAULT NULL,
+  PRIMARY KEY (`userid`),
+  KEY `paiduntil` (`paiduntil`)
 )
 EOC
 
-register_tablecreate("needed_backups", <<'EOC');
-CREATE TABLE needed_backups (
-    user  VARCHAR(15) PRIMARY KEY
+register_tablecreate('partner_registration_users', <<'EOC');
+CREATE TABLE `partner_registration_users` (
+  `userid` int(10) unsigned NOT NULL,
+  `partnerid` char(32) NOT NULL,
+  `uniq` char(15) NOT NULL,
+  `ip` char(15) NOT NULL,
+  `timestamp` int(10) NOT NULL,
+  PRIMARY KEY (`userid`),
+  KEY `partner_timestamp` (`partnerid`,`timestamp`)
 )
 EOC
 
-register_tablecreate("payitemprop", <<'EOC');
-CREATE TABLE payitemprop (
-   piid     INT UNSIGNED NOT NULL,
-   propname VARCHAR(255),
-   propval  TEXT,
-   PRIMARY KEY (piid, propname)
+## --
+## -- Partners registration tables
+## --
+register_tablecreate('partner_registration_visits', <<'EOC');
+CREATE TABLE `partner_registration_visits` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `partnerid` char(32) NOT NULL,
+  `uniq` char(15) NOT NULL,
+  `ip` char(15) NOT NULL,
+  `timestamp` int(10) NOT NULL,
+  PRIMARY KEY (`id`),
+  KEY `partner_timestamp` (`partnerid`,`timestamp`)
 )
 EOC
 
-register_tablecreate("usertrans_sum", <<'EOC');
-CREATE TABLE usertrans_sum (
-    what    VARCHAR(25)     NOT NULL,
-    day     DATE            NOT NULL,
-    `before`  VARCHAR(25)     NOT NULL,
-    `after`   VARCHAR(25)     NOT NULL,
-    total   INT UNSIGNED    NOT NULL,
-    PRIMARY KEY (day, what, `before`, `after`)
+register_tablecreate('paycredit', <<'EOC');
+CREATE TABLE `paycredit` (
+  `userid` int(10) unsigned NOT NULL DEFAULT '0',
+  `days` smallint(5) unsigned NOT NULL DEFAULT '0',
+  `issued` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `used` enum('N','Y') NOT NULL DEFAULT 'N',
+  `useddate` datetime DEFAULT NULL,
+  KEY `userid` (`userid`),
+  KEY `used` (`used`)
 )
 EOC
 
-register_tablecreate("usertrans_churn", <<'EOC');
-CREATE TABLE usertrans_churn (
-    what            VARCHAR(25)     NOT NULL,
-    acct_type       VARCHAR(25)     NOT NULL,
-    day             DATE            NOT NULL,
-    days_between    INT             NOT NULL,
-    total           INT UNSIGNED    NOT NULL,
-    PRIMARY KEY (what, acct_type, day, days_between)
+register_tablecreate('payitemprop', <<'EOC');
+CREATE TABLE `payitemprop` (
+  `piid` int(10) unsigned NOT NULL,
+  `propname` varchar(255) NOT NULL DEFAULT '',
+  `propval` text,
+  PRIMARY KEY (`piid`,`propname`)
 )
 EOC
 
-
-register_tablecreate("betanav_feedback", <<'EOC');
-CREATE TABLE betanav_feedback (
-  userid INT UNSIGNED NOT NULL,
-  posted INT UNSIGNED NOT NULL,
-  feedback text NOT NULL,
-  state VARCHAR(1) NOT NULL,
-  KEY userid (userid),
-  KEY posted (posted)
+# Items one can buy:
+#    paidacct     qty=<months>
+#    perm
+#    rename
+#    morestats    qty=<months>
+#    morepics?
+# fields:
+# rcptid    : cart owner's ID, gift rcpt's ID, or 0 for invite/"pay"
+#             code emailed
+# rcptemail : email address to mail paycode to, if non-user
+# anon      : is gift anonymous?
+# giveafter : unixtime to give gift after
+register_tablecreate('payitems', <<'EOC');
+CREATE TABLE `payitems` (
+  `piid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `payid` int(10) unsigned NOT NULL,
+  `item` varchar(25) DEFAULT NULL,
+  `subitem` varchar(35) DEFAULT NULL,
+  `qty` smallint(5) unsigned DEFAULT NULL,
+  `rcptid` int(10) unsigned NOT NULL,
+  `amt` decimal(8,2) DEFAULT NULL,
+  `status` enum('cart','pend','done','refund','bogus') DEFAULT NULL,
+  `rcptemail` varchar(80) DEFAULT NULL,
+  `anon` enum('0','1') DEFAULT NULL,
+  `giveafter` int(10) unsigned DEFAULT NULL,
+  `token` varchar(25) DEFAULT NULL,
+  `tokenid` int(10) unsigned DEFAULT NULL,
+  `qty_res` smallint(5) unsigned DEFAULT NULL,
+  PRIMARY KEY (`piid`),
+  KEY `payid` (`payid`),
+  KEY `status` (`status`),
+  KEY `rcptemail` (`rcptemail`),
+  KEY `rcptid` (`rcptid`)
 )
 EOC
 
-# clustered
-register_tablecreate("sms_quota", <<'EOC');
-CREATE TABLE sms_quota (
-   userid         INT UNSIGNED NOT NULL,
-   quota_used     INT UNSIGNED DEFAULT '0',
-   quota_updated  INT UNSIGNED DEFAULT '0',
-   free_qty       INT UNSIGNED DEFAULT '0',
-   paid_qty       INT UNSIGNED DEFAULT '0',
-   PRIMARY KEY (userid)
+# when cart:
+#   forwhat = 'cart'
+#   userid = id of remote user, or 0
+#   amount = total amount
+#   months = 0
+#   method ::= "" (new cart) | "authnet-cc" | "authnet-echeck" | "paypal" | "check"
+#   datesent = cart creation
+#   daterecv = payment processed (cc/paypal), or entered (if check)
+#   used = 'C' (still cart) then after pay 'N' (now awaiting paybatch), then 'Y' (done)
+#   mailed = likewise. ^^
+register_tablecreate('payments', <<'EOC');
+CREATE TABLE `payments` (
+  `payid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `anum` smallint(5) unsigned DEFAULT NULL,
+  `userid` int(10) unsigned NOT NULL DEFAULT '0',
+  `datesent` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `daterecv` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `amount` decimal(8,2) DEFAULT NULL,
+  `months` tinyint(3) unsigned DEFAULT NULL,
+  `used` enum('N','Y','C') NOT NULL DEFAULT 'N',
+  `mailed` enum('N','Y','C','X') NOT NULL DEFAULT 'N',
+  `notes` text,
+  `method` varchar(20) NOT NULL DEFAULT '',
+  `forwhat` varchar(20) DEFAULT NULL,
+  `giveafter` int(10) unsigned DEFAULT NULL,
+  PRIMARY KEY (`payid`),
+  KEY `userid` (`userid`),
+  KEY `used` (`used`),
+  KEY `method` (`method`),
+  KEY `forwhat` (`forwhat`),
+  KEY `mailed` (`mailed`)
 )
 EOC
 
-# clustered
-register_tablecreate("sms_promo", <<'EOC');
-CREATE TABLE sms_promo (
-   userid         INT UNSIGNED NOT NULL,
-   promo_class    VARCHAR(30) NOT NULL,
-   applied        TINYINT DEFAULT "0",
-   PRIMARY KEY (userid, promo_class)
+register_tablecreate('paymentsearch', <<'EOC');
+CREATE TABLE `paymentsearch` (
+  `payid` int(10) unsigned NOT NULL,
+  `ikey` varchar(12) NOT NULL,
+  `ival` varchar(50) NOT NULL,
+  KEY `payid` (`payid`),
+  KEY `ikey` (`ikey`,`ival`)
 )
 EOC
 
-register_tablecreate("cdn_map", <<'EOC');
-CREATE TABLE cdn_map (
-   pfx    VARCHAR(7) NOT NULL PRIMARY KEY,
-   rules  MEDIUMBLOB
+# payid <=> state mappings
+register_tablecreate('paystates', <<'EOC');
+CREATE TABLE `paystates` (
+  `payid` int(10) unsigned NOT NULL,
+  `state` varchar(25) NOT NULL DEFAULT '??',
+  PRIMARY KEY (`payid`),
+  KEY `state` (`state`)
 )
 EOC
 
-0 && register_tablecreate("cdn_weights", <<'EOC');
-CREATE TABLE cdn_weights (
-   classname    VARCHAR(25) NOT NULL,
-   type         VARCHAR(25) NOT NULL,
-   weight       TINYINT UNSIGNED NOT NULL,
-   PRIMARY KEY (classname, type)
+register_tablecreate('paytrans', <<'EOC');
+CREATE TABLE `paytrans` (
+  `userid` int(10) unsigned NOT NULL,
+  `time` int(10) unsigned NOT NULL,
+  `what` enum('paidaccount') DEFAULT NULL,
+  `action` enum('new','renew','expire','return','ext') DEFAULT NULL,
+  KEY `userid` (`userid`),
+  KEY `time` (`time`)
 )
 EOC
 
-register_tablecreate("deletion_feedback", <<'EOC');
-CREATE TABLE deletion_feedback (
-   timerecv  INT UNSIGNED NOT NULL,
-   userid    INT UNSIGNED NOT NULL,
-   qkey      VARCHAR(30)  NOT NULL,
-   answer    TEXT,
-   INDEX (timerecv),
-   INDEX (userid)
+# keep track of ip address of buyer, first/last name,
+# email address (if non-logged in user), etc.  not indexed
+# like payment search
+register_tablecreate('payvars', <<'EOC');
+CREATE TABLE `payvars` (
+  `payid` int(10) unsigned NOT NULL,
+  `pkey` varchar(40) DEFAULT NULL,
+  `pval` varchar(255) DEFAULT NULL,
+  KEY `payid` (`payid`,`pkey`(4))
 )
 EOC
 
-register_tablecreate("journal_spotlight", <<'EOC');
-CREATE TABLE journal_spotlight (
-  time_start int unsigned NOT NULL default '0',
-  time_end int unsigned NOT NULL default '0',
-  userid int unsigned NOT NULL default '0',
-  active enum('Y','N') NOT NULL default 'Y',
-  des blob NOT NULL default '',
-  img_url varchar(255) default NULL,
-  INDEX (time_start),
-  INDEX (time_end),
-  INDEX (userid)
+## Record permanent account sale
+register_tablecreate('perm_sale', <<'EOC');
+CREATE TABLE `perm_sale` (
+  `payid` int(10) unsigned NOT NULL,
+  `journalid` int(10) unsigned NOT NULL,
+  `area` varchar(30) DEFAULT NULL,
+  `name` varchar(30) DEFAULT NULL,
+  `price` decimal(8,2) DEFAULT NULL,
+  `charity` decimal(8,2) DEFAULT NULL,
+  `extra` varchar(255) DEFAULT NULL,
+  KEY `journalid` (`journalid`),
+  KEY `payid` (`payid`)
 )
 EOC
 
-register_tablecreate("xuqa_log", <<'EOC');
-CREATE TABLE xuqa_log (
-  userid INT UNSIGNED NOT NULL,
-  offer_id INT NOT NULL,
-  instime INT UNSIGNED NOT NULL,
-  amt DECIMAL(3,2) NOT NULL DEFAULT '0',
-  status CHAR(1) NOT NULL,
-  cp_tokenid INT UNSIGNED,
-  KEY (userid, offer_id)
+register_tablecreate('perm_sale_200706', <<'EOC');
+CREATE TABLE `perm_sale_200706` (
+  `journalid` int(10) unsigned NOT NULL,
+  `vote` tinyint(4) NOT NULL,
+  PRIMARY KEY (`journalid`)
 )
 EOC
 
-register_tablecreate("frank_text", <<'EOC');
-CREATE TABLE frank_text (
-  txtid int(10) unsigned NOT NULL auto_increment,
-  text text NOT NULL,
-  PRIMARY KEY (txtid)
+# list of personifi categories to be used in ads
+register_tablecreate('personifi_ads_cat', <<'EOC');
+CREATE TABLE `personifi_ads_cat` (
+  `catid` int(11) NOT NULL DEFAULT '0',
+  `tagname` varchar(10) DEFAULT NULL,
+  `threshold` int(11) DEFAULT '100',
+  `enabled` tinyint(4) DEFAULT NULL,
+  PRIMARY KEY (`catid`),
+  UNIQUE KEY `catid` (`catid`)
 )
 EOC
 
-register_tablecreate("promo_set", <<'EOC');
-CREATE TABLE promo_set (
-    setid MEDIUMINT UNSIGNED PRIMARY KEY auto_increment,
-    setdom VARCHAR(25) NOT NULL,
-    adminid INT UNSIGNED NOT NULL,
-
-    # bitmask representation of cap classes that this promo set applies to
-    cap_mask SMALLINT UNSIGNED NOT NULL,
-    # show to logged out users or not
-    show_logged_out ENUM('Y','N') NOT NULL default 'N',
-
-    title VARCHAR(255) NOT NULL DEFAULT '',
-    time_start INT UNSIGNED NOT NULL,
-    time_end INT UNSIGNED NOT NULL,
-
-    INDEX (setdom, time_start)
+# list of personifi categories.
+register_tablecreate('personifi_categories', <<'EOC');
+CREATE TABLE `personifi_categories` (
+  `catid` int(11) NOT NULL AUTO_INCREMENT,
+  `name` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`catid`),
+  UNIQUE KEY `catid` (`catid`),
+  UNIQUE KEY `name` (`name`)
 )
 EOC
 
-register_tablecreate("promo_item", <<'EOC');
-CREATE TABLE promo_item (
-    itid TINYINT UNSIGNED PRIMARY KEY auto_increment,
-    setid MEDIUMINT UNSIGNED NOT NULL,
-    adminid INT UNSIGNED NOT NULL,
-
-    title VARCHAR(255) NOT NULL DEFAULT '',
-    des TEXT NOT NULL DEFAULT '',
-    link_text VARCHAR(255) NOT NULL DEFAULT '',
-    link_url VARCHAR(255) NOT NULL DEFAULT '',
-    img_url VARCHAR(255),
-    impression_url VARCHAR(255),
-
-    INDEX (setid)
+# list of personifi categories to be used in ads
+register_tablecreate('personifi_logs', <<'EOC');
+CREATE TABLE `personifi_logs` (
+  `userid` int(11) NOT NULL DEFAULT '0',
+  `action` varchar(50) DEFAULT NULL,
+  `catid` int(11) NOT NULL DEFAULT '0',
+  `field` varchar(24) DEFAULT NULL,
+  `oldval` varchar(255) DEFAULT NULL,
+  `newval` varchar(255) DEFAULT NULL,
+  `action_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  KEY `action_time` (`action_time`)
 )
 EOC
 
-register_tablecreate("spinvox_msg", <<'EOC');
-CREATE TABLE spinvox_msg (
-   msgid     VARCHAR(22) NOT NULL,
-   journalid INT UNSIGNED NOT NULL,
-   blobid    MEDIUMINT UNSIGNED NOT NULL,
-   timesent  INT UNSIGNED NOT NULL,
-   timerecv  INT UNSIGNED,
-   lang      VARCHAR(5) NOT NULL DEFAULT '',
-   country   VARCHAR(2) NOT NULL DEFAULT '',
-   status    VARCHAR(30) NOT NULL DEFAULT '',
-      
-   PRIMARY KEY (msgid),
-   UNIQUE (journalid, blobid)
+# External phonepost destinations
+# For an explaination of this table, see
+# ljcomint/doc/notes/external_phoneposting.txt
+register_tablecreate('phonepostdests', <<'EOC');
+CREATE TABLE `phonepostdests` (
+  `userid` int(10) unsigned NOT NULL DEFAULT '0',
+  `destid` int(10) unsigned NOT NULL DEFAULT '0',
+  `namespace` int(10) unsigned NOT NULL,
+  `audio_type` varchar(20) DEFAULT NULL,
+  `audio_post_url` varchar(255) DEFAULT NULL,
+  `audio_user` varchar(255) DEFAULT NULL,
+  `audio_password` varchar(255) DEFAULT NULL,
+  `blog_type` varchar(20) DEFAULT NULL,
+  `blog_name` varchar(255) DEFAULT NULL,
+  `blog_post_url` varchar(255) DEFAULT NULL,
+  `blog_user` varchar(255) DEFAULT NULL,
+  `blog_password` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`userid`,`destid`,`namespace`)
 )
 EOC
 
-register_tablecreate("perm_sale_200706", <<'EOC');
-CREATE TABLE perm_sale_200706 (
-   journalid INT UNSIGNED NOT NULL,
-   vote TINYINT NOT NULL,
-   PRIMARY KEY (journalid)
+# blob from blobid must be of type 'phonepost'.
+# security is inferred from jitemid; if there is no log2 row, it's private.
+register_tablecreate('phonepostentry', <<'EOC');
+CREATE TABLE `phonepostentry` (
+  `userid` int(10) unsigned NOT NULL,
+  `blobid` mediumint(8) unsigned NOT NULL,
+  `lengthsecs` mediumint(8) unsigned NOT NULL,
+  `anum` tinyint(3) unsigned NOT NULL,
+  `jitemid` mediumint(8) unsigned NOT NULL,
+  `posttime` int(10) unsigned NOT NULL,
+  `filetype` tinyint(3) unsigned NOT NULL DEFAULT '0',
+  `location` enum('blob','mogile','none') DEFAULT NULL,
+  PRIMARY KEY (`userid`,`blobid`)
 )
 EOC
 
-## Record permanent account sale
-register_tablecreate("perm_sale", <<'EOC');
-CREATE TABLE perm_sale (
-    payid     INT(10) UNSIGNED NOT NULL,
-    journalid INT UNSIGNED NOT NULL,
-    area      VARCHAR(30),
-    name      VARCHAR(30),
-    price     DECIMAL(8,2) DEFAULT NULL,
-    charity   DECIMAL(8,2) DEFAULT NULL,
-    extra     VARCHAR(255),
-    KEY (journalid),
-    KEY (payid)
+register_tablecreate('phonepostlogin', <<'EOC');
+CREATE TABLE `phonepostlogin` (
+  `phone` varchar(20) NOT NULL,
+  `pin` varchar(10) NOT NULL,
+  `userid` int(10) unsigned NOT NULL,
+  `journalid` int(10) unsigned NOT NULL,
+  PRIMARY KEY (`phone`,`pin`),
+  UNIQUE KEY `userid` (`userid`,`journalid`)
 )
 EOC
 
-##
-## Sponsored accounts
-##
-## --
-## -- sponsors table
-## -- each sponsor is a community with some attributes
-## --
-register_tablecreate("sup_sponsors", <<'EOC');
-CREATE TABLE sup_sponsors (
-    sponsorid       int unsigned not null,          -- sponsorid == community id of the sponsor (pk, fk)
-    domain          varchar(10) not null,           -- either 'sup' or '6a'
-    reg_date        int unsigned not null,          -- when sponsor was created, date in UNIX timestamp format
-    status          char(1) not null,               -- C, created  = newly created, inactive
-                                                    -- A, active   
-                                                    -- H, hold     = inactive, a temporary hold
-                                                    -- D, deleted  = inactive permanently, to keep history of this sponsor
-                                                        
-    slots_max           int unsigned not null,          -- max number of users that can be sponsored by the sponsor
-    slots_used          int unsigned not null,          -- how many user are sponsored now
-    trial_duration      int unsigned not null,          -- ~30 days, max time of 'trial' state of user of the sponsor
-    mail_confirmation_duration int unsigned not null,   -- ~3 days, max time for 'trial' user without confirmed e-mail
-    trusted_duration    int unsigned not null,          -- ~90 days, max time of 'trusted' state of user
-    decline_duration    int unsigned not null,          -- ~7 days, time when Trusted user can decline continuation
-    deleted_duration    int unsigned not null,          -- ~7 days, max time of finishing user status when Sponsors is deleted
-    cprod_html      text,                               -- html code of CProd block in control strip
-    
-    PRIMARY KEY (sponsorid),
-    INDEX(status),
-    INDEX(domain)
+# blob from blobid must be of type 'phonepost'.
+# security is inferred from jitemid; if there is no log2 row, it's private.
+register_tablecreate('phoneposttrans', <<'EOC');
+CREATE TABLE `phoneposttrans` (
+  `journalid` int(10) unsigned NOT NULL,
+  `blobid` mediumint(8) unsigned NOT NULL,
+  `revid` tinyint(3) unsigned NOT NULL,
+  `posterid` int(10) unsigned NOT NULL,
+  `posttime` int(10) unsigned NOT NULL,
+  `subject` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
+  `body` blob,
+  PRIMARY KEY (`journalid`,`blobid`,`revid`)
 )
-TYPE = InnoDB
 EOC
 
-## --
-## -- history of a sponsor
-## -- when sponsor was created, when his status has been changed, etc.
-## --
-register_tablecreate("sup_sponsor_history", <<'EOC');
-CREATE TABLE sup_sponsor_history (
-    sponsorid           int unsigned,               -- (fk)
-    field_name          varchar(50),                -- name of the changed property 
-    old_value           varchar(50),                -- old values of the property
-    new_value           varchar(50),                -- new value
-    change_moment       int unsigned not null,      -- when, UNIX timestamp
-    modifierid          int not null,               -- and by whom (modifierid==userid of admin/moderator/editor)
-    ip                  char(15),                   -- IP
-    xip                 char(15),                   -- X-Forwarded-For IP, if any
-
-    INDEX(sponsorid),
-    INDEX(field_name)
+register_tablecreate('promo_item', <<'EOC');
+CREATE TABLE `promo_item` (
+  `itid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+  `setid` mediumint(8) unsigned NOT NULL,
+  `adminid` int(10) unsigned NOT NULL,
+  `title` varchar(255) NOT NULL DEFAULT '',
+  `des` text NOT NULL,
+  `link_text` varchar(255) NOT NULL DEFAULT '',
+  `link_url` varchar(255) NOT NULL DEFAULT '',
+  `img_url` varchar(255) DEFAULT NULL,
+  `impression_url` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`itid`),
+  KEY `setid` (`setid`)
 )
-TYPE = InnoDB
 EOC
 
-
-## --
-## -- sponsored users
-## -- Each sponsored user is a standard user plus some attributes
-## --
-register_tablecreate("sup_sponsored_users", <<'EOC');
-CREATE TABLE sup_sponsored_users (
-    userid              int unsigned unique,    -- (pk, fk) 
-    sponsorid           int unsigned,           -- (fk)
-    status              char(1),                -- (S standard account, never be in this table, only in sup_sponsored_user_history table)
-                                                --  I, trial, when user can quit from Sponsorship
-                                                --  D, Sponsor deleted, for graceful quitting when user's Sponsor is deleted. 
-                                                --  U, trusted, when user can not just quit from Sponsorship - just can move to trust finishing 
-                                                --  F, trust finishing, when trusted user declined her Sponsor but should wait until trusted period is over
-                                                --  C, can decline to continue Trusted 
-    status_set          int unsigned not null,  -- when the current status was set
-    status_expired      int unsigned not null,  -- and when it is going to expire (or renew for TRUSTED status)
-
-    PRIMARY KEY (userid),
-    INDEX(sponsorid),
-    INDEX(status),
-    INDEX(status_expired)
+register_tablecreate('promo_set', <<'EOC');
+CREATE TABLE `promo_set` (
+  `setid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+  `setdom` varchar(255) NOT NULL,
+  `adminid` int(10) unsigned NOT NULL,
+  `cap_mask` smallint(5) unsigned NOT NULL,
+  `show_logged_out` enum('Y','N') NOT NULL DEFAULT 'N',
+  `title` varchar(255) NOT NULL DEFAULT '',
+  `time_start` int(10) unsigned NOT NULL,
+  `time_end` int(10) unsigned NOT NULL,
+  `countries` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`setid`),
+  KEY `setdom` (`setdom`,`time_start`)
 )
-TYPE = InnoDB
 EOC
-# '
 
-## --
-## -- the history of sponsored user
-## -- 
-register_tablecreate("sup_sponsored_user_history", <<'EOC');
-CREATE TABLE sup_sponsored_user_history (
-    sponsorid       int unsigned,                   -- (fk) during lifetime, a user can be
-                                                    --  sponsored by different sponsors
-    userid          int unsigned,                   -- (fk)
-    modifierid      int,                            -- by whom (modifierid==userid of admin/moderator/editor)
-    status          char(1),                        -- see table 'sup_sponsored_users' for statuses
-    status_set      int unsigned not null,          -- when this status has been set
-    status_expired  int unsigned,                   -- and when this status was going to expire,
-                                                    --  null for status 'standard account'
-    reason          varchar(50),                    -- comments, specifying who and why changed the status             
-    INDEX(sponsorid),
-    INDEX(userid)
+# recurring billing tables
+register_tablecreate('recbill', <<'EOC');
+CREATE TABLE `recbill` (
+  `userid` int(10) unsigned NOT NULL,
+  `bill_interval` tinyint(3) unsigned NOT NULL,
+  `last_check` int(10) unsigned DEFAULT NULL,
+  `next_check` int(10) unsigned DEFAULT NULL,
+  `last_email` int(10) unsigned DEFAULT NULL,
+  `last_payid` int(10) unsigned DEFAULT NULL,
+  `try_ct` tinyint(3) unsigned DEFAULT '0',
+  `last_mailed` int(10) unsigned DEFAULT '0',
+  PRIMARY KEY (`userid`),
+  KEY `next_check` (`next_check`)
 )
-TYPE = InnoDB
 EOC
 
-## --
-## -- Information blocks (text blocks) from SUP
-## --
-register_tablecreate("sup_extblocks", <<'EOC');
-CREATE TABLE sup_extblocks
-(
-    blockid         varchar(20),
-    blocktext       blob,
-    last_updated    INT UNSIGNED NOT NULL DEFAULT 0,
-    serialization   char(1),                        -- default is NULL, 'J' = JSON, 'S' = Storable
-    PRIMARY KEY (blockid)
+register_tablecreate('recbill_cc', <<'EOC');
+CREATE TABLE `recbill_cc` (
+  `userid` int(10) unsigned NOT NULL,
+  `instime` int(10) unsigned NOT NULL,
+  `modtime` int(10) unsigned NOT NULL,
+  `expmail` int(10) unsigned DEFAULT NULL,
+  `pri_flag` enum('0','1') NOT NULL DEFAULT '0',
+  `type` enum('Visa','MasterCard','AmEx','DinersClub','Discover','CarteBlanche','JCB') DEFAULT NULL,
+  `exp_y` smallint(5) unsigned NOT NULL,
+  `exp_m` tinyint(3) unsigned NOT NULL,
+  `lastfour` varchar(4) NOT NULL,
+  `name_first` varchar(20) NOT NULL,
+  `name_last` varchar(20) NOT NULL,
+  `phone_num` varchar(32) NOT NULL,
+  `addr` varchar(120) NOT NULL,
+  `city` varc...
 (truncated)
Tags: ailyin, andy, ljcom, pl, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments