[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path Zen Cart 源代码 mysql_upgrade_zencart_120_to_121.sql
# This SQL script upgrades the core Zen Cart database structure from v1.2.0 to v1.2.1
#
# $Id: mysql_upgrade_zencart_120_to_121.sql 4243 2006-08-24 10:55:28Z drbyte $
#
## CONFIGURATION TABLE
UPDATE configuration set configuration_title = 'Define Conditions of Use' WHERE configuration_key = 'DEFINE_CONDITIONS_STATUS';
UPDATE configuration SET configuration_description = 'Automatically check to see if a new version of Zen-Cart is available. Enabling this can sometimes slow down the loading of Admin pages. (Displayed on main Index page after login, and Server Info page.)' WHERE configuration_key = 'SHOW_VERSION_UPDATE_IN_HEADER';
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Display Prices with Tax in Admin', 'DISPLAY_PRICE_WITH_TAX_ADMIN', 'false', 'Display prices with tax included (true) or add the tax at the end (false) in Admin(Invoices)', '1', '21', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now());
UPDATE configuration SET configuration_description='Products Display Order by<br />0= Product ID<br />1= Product Name<br />2= Model<br />3= Price, Product Name<br />4= Price, Model<br />5= Product Name, Model<br />6= Product Sort Order', set_function='zen_cfg_select_drop_down(array(array(\'id\'=>\'0\', \'text\'=>\'Product ID\'), array(\'id\'=>\'1\', \'text\'=>\'Name\'), array(\'id\'=>\'2\', \'text\'=>\'Product Model\'), array(\'id\'=>\'3\', \'text\'=>\'Product Price - Name\'), array(\'id\'=>\'4\', \'text\'=>\'Product Price - Model\'), array(\'id\'=>\'5\', \'text\'=>\'Product Name - Model\'), array(\'id\'=>\'6\', \'text\'=>\'Product Sort Order\')),' WHERE configuration_key='PRODUCT_INFO_PREVIOUS_NEXT_SORT';
UPDATE configuration SET configuration_title = 'Enable phpBB linkage?', configuration_description = 'Should Zen Cart synchronize new account information to your (already-installed) phpBB forum?' WHERE configuration_key = 'PHPBB_LINKS_ENABLED';
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Customers Referral Status', 'CUSTOMERS_REFERRAL_STATUS', '0', 'Customers Referral Code is created from<br />0= Off<br />1= 1st Discount Coupon Code used<br />2= Customer can add during create account or edit if blank<br /><br />NOTE: Once the Customers Referral Code has been set it can only be changed in the Admin Customer', '5', '80', 'zen_cfg_select_option(array(\'0\', \'1\', \'2\'), ', now());
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Show Category Counts - Admin', 'SHOW_COUNTS_ADMIN', 'true', 'Show Category Counts in Admin?', '1', '130', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now());
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Display "Newsletter Unsubscribe" Link?', 'SHOW_NEWSLETTER_UNSUBSCRIBE_LINK', 'true', 'Show "Newsletter Unsubscribe" link in the "Information" side-box?', '12', '70', 'zen_cfg_select_option(array(\'true\', \'false\'),', now());
## Table Structure updates to handle better use of decimal points
ALTER TABLE customers_basket CHANGE COLUMN customers_basket_quantity customers_basket_quantity FLOAT DEFAULT '0' NOT NULL;
ALTER TABLE orders_products CHANGE COLUMN products_quantity products_quantity FLOAT DEFAULT '0' NOT NULL;
ALTER TABLE products CHANGE COLUMN products_quantity products_quantity FLOAT DEFAULT '0' NOT NULL;
ALTER TABLE products CHANGE COLUMN products_ordered products_ordered FLOAT DEFAULT '0' NOT NULL;
ALTER TABLE products CHANGE COLUMN products_quantity_order_min products_quantity_order_min FLOAT DEFAULT '1' NOT NULL;
ALTER TABLE products CHANGE COLUMN products_quantity_order_units products_quantity_order_units FLOAT DEFAULT '1' NOT NULL;
ALTER TABLE products CHANGE COLUMN products_quantity_order_max products_quantity_order_max FLOAT DEFAULT '0' NOT NULL;
ALTER TABLE products_discount_quantity CHANGE COLUMN discount_qty discount_qty FLOAT DEFAULT '0' NOT NULL;
## Customers Table additions
ALTER TABLE customers ADD COLUMN customers_referral VARCHAR(32) NOT NULL default '';
## Add Coupon_Code to Order Table:
ALTER TABLE orders ADD COLUMN coupon_code varchar(32) NOT NULL default '' AFTER payment_method;
## Query Builder Update
UPDATE query_builder set query_string ='select c.customers_email_address, c.customers_lastname, c.customers_firstname from TABLE_CUSTOMERS c, TABLE_ORDERS o where c.customers_newsletter = \'1\' AND c.customers_id = o.customers_id and o.date_purchased < subdate(now(),INTERVAL 3 MONTH) GROUP BY c.customers_email_address order by c.customers_lastname, c.customers_firstname ASC' WHERE query_id='3';
UPDATE query_builder set query_string ='select c.customers_email_address, c.customers_lastname, c.customers_firstname from TABLE_CUSTOMERS c, TABLE_ORDERS o where c.customers_newsletter = \'1\' AND c.customers_id = o.customers_id and o.date_purchased > subdate(now(),INTERVAL 3 MONTH) GROUP BY c.customers_email_address order by c.customers_lastname, c.customers_firstname ASC' WHERE query_id='4';
UPDATE query_builder set query_string ='select c.customers_email_address, c.customers_lastname, c.customers_firstname from TABLE_CUSTOMERS c, TABLE_ORDERS o WHERE c.customers_id = o.customers_id and o.date_purchased > subdate(now(),INTERVAL 3 MONTH) GROUP BY c.customers_email_address order by c.customers_lastname, c.customers_firstname ASC' WHERE query_id='5';
## Reset Sales and Salemaker expiry dates if null or 0000-00-00
UPDATE specials SET expires_date='0001-01-01' where expires_date='0000-00-00';
UPDATE specials SET specials_date_available ='0001-01-01' where specials_date_available ='0000-00-00';
## PayPal IPN Updates
ALTER TABLE orders_products_attributes ADD products_options_id INT( 11 ) DEFAULT '0' NOT NULL;
ALTER TABLE orders_products_attributes ADD products_options_values_id INT( 11 ) DEFAULT '0' NOT NULL;
DROP TABLE IF EXISTS orders_session_info;
CREATE TABLE orders_session_info (
txn_signature varchar(32) NOT NULL default '',
orders_id int(11) NOT NULL default '0',
sendto int(11) NOT NULL default '1',
billto int(11) NOT NULL default '1',
language varchar(32) NOT NULL default '',
currency char(3) NOT NULL default '',
firstname varchar(32) NOT NULL default '',
lastname varchar(32) NOT NULL default '',
content_type varchar(32) NOT NULL default '',
PRIMARY KEY (txn_signature,orders_id),
KEY idx_orders_session_info_txn_signature (txn_signature)
);
DROP TABLE IF EXISTS paypal;
CREATE TABLE paypal (
paypal_ipn_id int(11) unsigned NOT NULL auto_increment,
txn_type varchar(10) NOT NULL default '',
reason_code varchar(15) default NULL,
payment_type varchar(7) NOT NULL default '',
payment_status varchar(17) NOT NULL default '',
pending_reason varchar(14) default NULL,
invoice varchar(64) default NULL,
mc_currency char(3) NOT NULL default '',
first_name varchar(32) NOT NULL default '',
last_name varchar(32) NOT NULL default '',
payer_business_name varchar(64) default NULL,
address_name varchar(32) default NULL,
address_street varchar(64) default NULL,
address_city varchar(32) default NULL,
address_state varchar(32) default NULL,
address_zip varchar(10) default NULL,
address_country varchar(64) default NULL,
address_status varchar(11) default NULL,
payer_email varchar(96) NOT NULL default '',
payer_id varchar(32) NOT NULL default '',
payer_status varchar(10) NOT NULL default '',
payment_date datetime default NULL,
business varchar(96) NOT NULL default '',
receiver_email varchar(96) NOT NULL default '',
receiver_id varchar(32) NOT NULL default '',
txn_id varchar(17) NOT NULL default '',
parent_txn_id varchar(17) default NULL,
num_cart_items tinyint(4) unsigned NOT NULL default '1',
mc_gross decimal(7,2) NOT NULL default '0.00',
mc_fee decimal(7,2) NOT NULL default '0.00',
payment_gross decimal(7,2) default NULL,
payment_fee decimal(7,2) default NULL,
settle_amount decimal(7,2) default NULL,
settle_currency char(3) default NULL,
exchange_rate decimal(4,2) default NULL,
notify_version decimal(2,1) NOT NULL default '0.0',
verify_sign varchar(128) NOT NULL default '',
last_modified datetime default NULL,
date_added datetime default NULL,
memo text,
PRIMARY KEY (paypal_ipn_id,txn_id),
KEY idx_paypal_paypal_ipn_id (paypal_ipn_id)
);
DROP TABLE IF EXISTS paypal_payment_status;
CREATE TABLE paypal_payment_status (
payment_status_id int(11) NOT NULL auto_increment,
payment_status_name varchar(64) NOT NULL default '',
PRIMARY KEY (payment_status_id)
);
INSERT INTO paypal_payment_status VALUES (1, 'Completed');
INSERT INTO paypal_payment_status VALUES (2, 'Pending');
INSERT INTO paypal_payment_status VALUES (3, 'Failed');
INSERT INTO paypal_payment_status VALUES (4, 'Denied');
INSERT INTO paypal_payment_status VALUES (5, 'Refunded');
INSERT INTO paypal_payment_status VALUES (6, 'Canceled_Reversal');
INSERT INTO paypal_payment_status VALUES (7, 'Reversed');
DROP TABLE IF EXISTS paypal_payment_status_history;
CREATE TABLE paypal_payment_status_history (
payment_status_history_id int(11) NOT NULL auto_increment,
paypal_ipn_id int(11) NOT NULL default '0',
payment_status varchar(17) NOT NULL default '',
pending_reason varchar(14) default NULL,
date_added datetime NOT NULL default '0001-01-01 00:00:00',
PRIMARY KEY (payment_status_history_id)
);
## These tables are obsolete after the new PayPal IPN is installed
DROP TABLE IF EXISTS paypal_ipn_address_status;
DROP TABLE IF EXISTS paypal_ipn_mc_currency;
DROP TABLE IF EXISTS paypal_ipn_payment_status;
DROP TABLE IF EXISTS paypal_ipn_payment_type;
DROP TABLE IF EXISTS paypal_ipn_pending_reason;
DROP TABLE IF EXISTS paypal_ipn_reason_code;
DROP TABLE IF EXISTS paypal_ipn_txn_type;
UPDATE paypal SET payment_status='Completed' where payment_status=1;
UPDATE paypal SET payment_status='Pending' where payment_status=2;
UPDATE paypal SET payment_status='Failed' where payment_status=3;
UPDATE paypal SET payment_status='Denied' where payment_status=4;
UPDATE paypal SET payment_status='Refunded' where payment_status=5;
UPDATE paypal SET payment_status='Cancelled' where payment_status=6;
UPDATE paypal SET payment_type='instant' where payment_type=1;
UPDATE paypal SET payment_type='echeck' where payment_type=2;
UPDATE paypal SET pending_reason='' where pending_reason=0;
UPDATE paypal SET pending_reason='echeck' where pending_reason=1;
UPDATE paypal SET pending_reason='multi-currency' where pending_reason=2;
UPDATE paypal SET pending_reason='intl' where pending_reason=3;
UPDATE paypal SET pending_reason='Verify' where pending_reason=4;
UPDATE paypal SET pending_reason='address' where pending_reason=5;
UPDATE paypal SET pending_reason='upgrade' where pending_reason=6;
UPDATE paypal SET pending_reason='unilateral' where pending_reason=7;
UPDATE paypal SET pending_reason='other' where pending_reason=8;
UPDATE paypal SET reason_code='' where reason_code=0;
UPDATE paypal SET reason_code='chargeback' where reason_code=1;
UPDATE paypal SET reason_code='guarantee' where reason_code=2;
UPDATE paypal SET reason_code='buyer_complaint' where reason_code=3;
UPDATE paypal SET reason_code='other' where reason_code=4;
UPDATE paypal SET txn_type='web_accept' where txn_type=1;
UPDATE paypal SET txn_type='cart' where txn_type=2;
UPDATE paypal SET txn_type='send_money' where txn_type=3;
UPDATE paypal SET txn_type='reversal' where txn_type=4;
UPDATE paypal SET mc_currency='USD' where mc_currency=1;
UPDATE paypal SET mc_currency='GBP' where mc_currency=2;
UPDATE paypal SET mc_currency='EUR' where mc_currency=3;
UPDATE paypal SET mc_currency='CAD' where mc_currency=4;
UPDATE paypal SET mc_currency='JPY' where mc_currency=5;
UPDATE paypal SET address_status='confirmed' where address_status=1;
UPDATE paypal SET address_status='unconfirmed' where address_status=2;
#NEXT_X_ROWS_AS_ONE_COMMAND:1
INSERT INTO paypal_payment_status_history
(paypal_ipn_id, payment_status, pending_reason, date_added)
SELECT paypal_ipn_id, payment_status, pending_reason, date_added
FROM paypal;
DROP TABLE IF EXISTS paypal_ipn;
DROP TABLE IF EXISTS paypal_ipn_orders;
DROP TABLE IF EXISTS paypal_ipn_orders_memo;
## END PAYPAL_IPN_MIGRATION
## THE FOLLOWING SHOULD BE THE "LAST" ITEMS IN THE FILE, so that if the upgrade fails prematurely, the version info is not updated.
UPDATE project_version SET project_version_major='1', project_version_minor='2.1', project_version_patch_major='', project_version_date_applied=now() WHERE project_version_key = 'Zen-Cart Main';
UPDATE project_version SET project_version_major='1', project_version_minor='2.1', project_version_patch_major='', project_version_date_applied=now() WHERE project_version_key = 'Zen-Cart Database';
## one final typo:
## the following fixes misspelled column name from 1.2.0:
ALTER TABLE product_types CHANGE COLUMN date_addded date_added datetime NOT NULL default '0001-01-01 00:00:00';