[ljcom] r10755: OPSC-318: DB schema update: userapps_pay...
Committer: vtroitsky
OPSC-318: DB schema update: userapps_payments, userapps_payitems addedU trunk/bin/upgrading/update-db-local.pl
Modified: trunk/bin/upgrading/update-db-local.pl
===================================================================
--- trunk/bin/upgrading/update-db-local.pl 2011-07-12 03:35:46 UTC (rev 10754)
+++ trunk/bin/upgrading/update-db-local.pl 2011-07-12 03:38:50 UTC (rev 10755)
@@ -1637,6 +1637,51 @@
) ENGINE=InnoDB
EOC
+## See LJ::API::Payments::AppPayment
+register_tablecreate('userapps_payments', qq{
+ CREATE TABLE userapps_payments (
+ apppayment_id int unsigned PRIMARY KEY UNIQUE AUTO_INCREMENT, # Unique payment ID
+ application_id int unsigned NOT NULL, # Application where payment was inited
+ userid int(10) unsigned NOT NULL, # User who paid
+ payid int(10) unsigned NOT NULL, # LJ Shop cart id
+ is_sandbox ENUM('0','1') NOT NULL DEFAULT '1', # Sandbox bit!
+ type ENUM('payment','credit','transfer') NOT NULL DEFAULT 'payment', # Payment type
+ state ENUM('submitted','ordered','paid','delivered','refunded','cancelled') NOT NULL DEFAULT 'submitted', # payment state
+ order_id varchar(64) DEFAULT NULL, # order_id recieved from application backend server if any
+ message varchar(255) DEFAULT '', # Message being showed to the user (localized to user current language !!!)
+ parameters text DEFAULT '', # special attachment if any
+
+ ordered_time int unsigned DEFAULT 0, # payment requested by application (unixtime when application requests the payment)
+ submitted_time int unsigned DEFAULT 0, # payment submitted (unixtime when user press sumbit button)
+ executed_time int unsigned DEFAULT 0, # payment performed (unixtime when LJT are charged from user's wallet)
+ delivered_time int unsigned DEFAULT 0, # payment order delivered (unixtime when app backend server (LJ server) delivers goods )
+
+ delivery_tries int unsigned NOT NULL DEFAULT 0, # number of delivery tries
+
+ response_code varchar(65), # last response code in communications with application server
+ response_message text DEFAULT '', # last response message in communications with application server
+
+ INDEX (application_id), INDEX (userid), INDEX (payid)
+ ) ENGINE=InnoDB
+});
+# See LJ::API::Payments::AppItem
+# If goods have different description, that
+register_tablecreate('userapps_items', qq{
+ CREATE TABLE userapps_items (
+ appitem_id int unsigned PRIMARY KEY UNIQUE AUTO_INCREMENT, # internal unique - id
+ application_id int unsigned NOT NULL, # application id
+ sku_id varchar(64) NOT NULL, # unique id for an application for that goods
+ price decimal(8,2) NOT NULL, # LJ Tokens price
+ title varchar(150) DEFAULT '', # localized title
+ description varchar(255) NOT NULL DEFAULT '', # localized description
+ image_url varchar(255) NOT NULL DEFAULT '', # URL to item's image
+ image_width int(10) unsigned NOT NULL DEFAULT 0, # image width
+ image_height int(10) unsigned NOT NULL DEFAULT 0, # image height
+
+ UNIQUE INDEX (application_id, sku_id), INDEX(application_id, sku_id, price, description)
+ ) ENGINE=InnoDB
+});
+
# *************************************************************
register_alter(sub {
@@ -2062,6 +2107,13 @@
});
}
+ unless (column_type("userapps", "royalty")) {
+ do_alter("userapps", qq{
+ ALTER TABLE userapps
+ ADD COLUMN royalty TINYINT(1) DEFAULT 0;
+ });
+ }
+
unless (column_type("shop_userheads", "uh_desc")) {
do_alter("shop_userheads",
"ALTER TABLE shop_userheads ADD uh_desc VARCHAR(20) DEFAULT '' AFTER uh_author");
