00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 $installer = $this;
00028
00029
00030 $installer->startSetup();
00031
00032 $installer->run("
00033
00034 -- DROP TABLE IF EXISTS {$this->getTable('salesrule')};
00035 CREATE TABLE {$this->getTable('salesrule')} (
00036 `rule_id` int(10) unsigned NOT NULL auto_increment,
00037 `name` varchar(255) NOT NULL default '',
00038 `description` text NOT NULL,
00039 `from_date` date default '0000-00-00',
00040 `to_date` date default '0000-00-00',
00041 `store_ids` varchar(255) NOT NULL default '',
00042 `coupon_code` varchar(255) default NULL,
00043 `uses_per_coupon` smallint(11) NOT NULL default '0',
00044 `uses_per_customer` smallint(11) NOT NULL default '0',
00045 `customer_group_ids` varchar(255) NOT NULL default '',
00046 `is_active` tinyint(1) NOT NULL default '0',
00047 `conditions_serialized` text NOT NULL,
00048 `actions_serialized` text NOT NULL,
00049 `stop_rules_processing` tinyint(1) NOT NULL default '1',
00050 `is_advanced` tinyint(3) unsigned NOT NULL default '1',
00051 `product_ids` text,
00052 `sort_order` int(10) unsigned NOT NULL default '0',
00053 `simple_action` varchar(32) NOT NULL default '',
00054 `discount_amount` decimal(12,4) NOT NULL default '0.0000',
00055 `discount_qty` decimal(12,4) unsigned default NULL,
00056 `simple_free_shipping` tinyint(1) unsigned NOT NULL default '0',
00057 PRIMARY KEY (`rule_id`),
00058 KEY `sort_order` (`is_active`,`sort_order`,`to_date`,`from_date`)
00059 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00060
00061 -- DROP TABLE IF EXISTS {$this->getTable('salesrule_customer')};
00062 CREATE TABLE {$this->getTable('salesrule_customer')} (
00063 `rule_customer_id` int(10) unsigned NOT NULL auto_increment,
00064 `rule_id` int(10) unsigned NOT NULL default '0',
00065 `customer_id` int(10) unsigned NOT NULL default '0',
00066 `times_used` smallint(11) unsigned NOT NULL default '0',
00067 PRIMARY KEY (`rule_customer_id`),
00068 KEY `rule_id` (`rule_id`,`customer_id`),
00069 KEY `customer_id` (`customer_id`,`rule_id`),
00070 CONSTRAINT `FK_salesrule_customer_id` FOREIGN KEY (`customer_id`) REFERENCES {$this->getTable('customer_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00071 CONSTRAINT `FK_salesrule_customer_rule` FOREIGN KEY (`rule_id`) REFERENCES {$this->getTable('salesrule')} (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
00072 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00073
00074 -- DROP TABLE IF EXISTS {$this->getTable('salesrule_product')};
00075 CREATE TABLE {$this->getTable('salesrule_product')} (
00076 `rule_product_id` int(10) unsigned NOT NULL auto_increment,
00077 `rule_id` int(10) unsigned NOT NULL default '0',
00078 `from_time` int(10) unsigned NOT NULL default '0',
00079 `to_time` int(10) unsigned NOT NULL default '0',
00080 `store_id` smallint(5) unsigned NOT NULL default '0',
00081 `customer_group_id` smallint(5) unsigned NOT NULL default '0',
00082 `product_id` int(10) unsigned NOT NULL default '0',
00083 `coupon_code` varchar(255) default NULL,
00084 `sort_order` int(10) unsigned NOT NULL default '0',
00085 PRIMARY KEY (`rule_product_id`),
00086 UNIQUE KEY `sort_order` (`from_time`,`to_time`,`store_id`,`customer_group_id`,`product_id`,`coupon_code`,`sort_order`),
00087 KEY `FK_salesrule_product_rule` (`rule_id`),
00088 KEY `FK_salesrule_product_store` (`store_id`),
00089 KEY `FK_salesrule_product_customergroup` (`customer_group_id`),
00090 CONSTRAINT `FK_salesrule_product_customergroup` FOREIGN KEY (`customer_group_id`) REFERENCES {$this->getTable('customer_group')} (`customer_group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00091 CONSTRAINT `FK_salesrule_product_rule` FOREIGN KEY (`rule_id`) REFERENCES {$this->getTable('salesrule')} (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00092 CONSTRAINT `FK_salesrule_product_store` FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core_store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00093 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00094
00095 -- DROP TABLE IF EXISTS {$this->getTable('salesrule_product_action')};
00096 CREATE TABLE {$this->getTable('salesrule_product_action')} (
00097 `rule_product_action_id` int(10) unsigned NOT NULL auto_increment,
00098 `rule_product_id` int(10) unsigned NOT NULL default '0',
00099 `action_type` varchar(255) NOT NULL default '',
00100 `action_attribute` varchar(255) NOT NULL default '',
00101 `action_operator` varchar(255) NOT NULL default '',
00102 `action_value` varchar(255) NOT NULL default '',
00103 PRIMARY KEY (`rule_product_action_id`),
00104 KEY `rule_product_id` (`rule_product_id`),
00105 CONSTRAINT `salesrule_product_action_ibfk_1` FOREIGN KEY (`rule_product_id`) REFERENCES {$this->getTable('salesrule_product')} (`rule_product_id`) ON DELETE CASCADE ON UPDATE CASCADE
00106 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00107
00108 ");
00109
00110 $installer->endSetup();