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 DROP TABLE IF EXISTS `{$installer->getTable('downloadable/link')}`;
00034 DROP TABLE IF EXISTS `{$installer->getTable('downloadable/link_price')}`;
00035 DROP TABLE IF EXISTS `{$installer->getTable('downloadable/link_purchased')}`;
00036 DROP TABLE IF EXISTS `{$installer->getTable('downloadable/link_title')}`;
00037 DROP TABLE IF EXISTS `{$installer->getTable('downloadable/sample')}`;
00038 DROP TABLE IF EXISTS `{$installer->getTable('downloadable/sample_title')}`;
00039 ");
00040
00041 $installer->run("
00042 CREATE TABLE `{$installer->getTable('downloadable/link')}`(
00043 `link_id` int(10) unsigned NOT NULL auto_increment,
00044 `product_id` int(10) unsigned NOT NULL default '0',
00045 `sort_order` int(10) unsigned NOT NULL default '0',
00046 `number_of_downloads` int(10) unsigned default NULL,
00047 `is_shareable` smallint(1) unsigned NOT NULL default '0',
00048 `link_url` varchar(255) NOT NULL default '',
00049 `link_file` varchar(255) NOT NULL default '',
00050 `sample_file` varchar(255) NOT NULL default '',
00051 PRIMARY KEY (`link_id`),
00052 KEY `DOWNLODABLE_LINK_PRODUCT` (`product_id`),
00053 KEY `DOWNLODABLE_LINK_PRODUCT_SORT_ORDER` (`product_id`,`sort_order`)
00054 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00055 ");
00056
00057 $conn->addConstraint(
00058 'FK_DOWNLODABLE_LINK_PRODUCT', $installer->getTable('downloadable/link'), 'product_id', $installer->getTable('catalog/product'), 'entity_id'
00059 );
00060
00061 $installer->run("
00062 CREATE TABLE `{$installer->getTable('downloadable/link_price')}`(
00063 `price_id` int(10) unsigned NOT NULL auto_increment,
00064 `link_id` int(10) unsigned NOT NULL default '0',
00065 `website_id` smallint(5) unsigned NOT NULL default '0',
00066 `price` decimal(12,4) NOT NULL default '0.0000',
00067 PRIMARY KEY (`price_id`),
00068 KEY `DOWNLOADABLE_LINK_PRICE_LINK` (`link_id`),
00069 KEY `DOWNLOADABLE_LINK_PRICE_WEBSITE` (`website_id`)
00070 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00071 ");
00072
00073 $conn->addConstraint(
00074 'FK_DOWNLOADABLE_LINK_PRICE_LINK', $installer->getTable('downloadable/link_price'), 'link_id', $installer->getTable('downloadable/link'), 'link_id'
00075 );
00076 $conn->addConstraint(
00077 'FK_DOWNLOADABLE_LINK_PRICE_WEBSITE', $installer->getTable('downloadable/link_price'), 'website_id', $installer->getTable('core/website'), 'website_id'
00078 );
00079
00080 $installer->run("
00081 CREATE TABLE `{$installer->getTable('downloadable/link_purchased')}`(
00082 `purchased_id` int(10) unsigned NOT NULL auto_increment,
00083 `order_item_id` int(10) unsigned NOT NULL default '0',
00084 `order_id` int(10) unsigned NOT NULL default '0',
00085 `order_increment_id` varchar(50) NOT NULL default '',
00086 `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
00087 `updated_at` datetime NOT NULL default '0000-00-00 00:00:00',
00088 `customer_id` int(10) unsigned NOT NULL default '0',
00089 `number_of_downloads_bought` int(10) unsigned NOT NULL default '0',
00090 `number_of_downloads_used` int(10) unsigned NOT NULL default '0',
00091 `link_id` int(20) unsigned NOT NULL default '0',
00092 `link_title` varchar(255) NOT NULL default '',
00093 `link_url` varchar(255) NOT NULL default '',
00094 `link_file` varchar(255) NOT NULL default '',
00095 `status` varchar(50) NOT NULL default '',
00096 `product_name` varchar(255) NOT NULL default '',
00097 `product_sku` varchar(255) NOT NULL default '',
00098 PRIMARY KEY (`purchased_id`),
00099 KEY `DOWNLOADABLE_ORDER_ITEM_ID` (`order_item_id`),
00100 KEY `DOWNLOADABLE_ORDER_ID` (`order_id`),
00101 KEY `DOWNLOADABLE_CUSTOMER_ID` (`customer_id`)
00102 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00103 ");
00104
00105 $conn->addConstraint(
00106 'FK_DOWNLOADABLE_ORDER_ID', $installer->getTable('downloadable/link_purchased'), 'order_id', $installer->getTable('sales/order'), 'entity_id'
00107 );
00108 $conn->addConstraint(
00109 'FK_DOWNLOADABLE_ORDER_ITEM_ID', $installer->getTable('downloadable/link_purchased'), 'order_item_id', $installer->getTable('sales/order_item'), 'item_id'
00110 );
00111
00112 $installer->run("
00113 CREATE TABLE `{$installer->getTable('downloadable/link_title')}`(
00114 `title_id` int(10) unsigned NOT NULL auto_increment,
00115 `link_id` int(10) unsigned NOT NULL default '0',
00116 `store_id` smallint(5) unsigned NOT NULL default '0',
00117 `title` varchar(255) NOT NULL default '',
00118 PRIMARY KEY (`title_id`),
00119 KEY `DOWNLOADABLE_LINK_TITLE_LINK` (`link_id`),
00120 KEY `DOWNLOADABLE_LINK_TITLE_STORE` (`store_id`)
00121 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00122 ");
00123
00124 $conn->addConstraint(
00125 'FK_DOWNLOADABLE_LINK_TITLE_LINK', $installer->getTable('downloadable/link_title'), 'link_id', $installer->getTable('downloadable/link'), 'link_id'
00126 );
00127 $conn->addConstraint(
00128 'FK_DOWNLOADABLE_LINK_TITLE_STORE', $installer->getTable('downloadable/link_title'), 'store_id', $installer->getTable('core/store'), 'store_id'
00129 );
00130
00131 $installer->run("
00132 CREATE TABLE `{$installer->getTable('downloadable/sample')}`(
00133 `sample_id` int(10) unsigned NOT NULL auto_increment,
00134 `product_id` int(10) unsigned NOT NULL default '0',
00135 `sample_url` varchar(255) NOT NULL default '',
00136 `sample_file` varchar(255) NOT NULL default '',
00137 `sort_order` int(10) unsigned NOT NULL default '0',
00138 PRIMARY KEY (`sample_id`),
00139 KEY `DOWNLODABLE_SAMPLE_PRODUCT` (`product_id`)
00140 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00141 ");
00142
00143 $conn->addConstraint(
00144 'FK_DOWNLODABLE_SAMPLE_PRODUCT', $installer->getTable('downloadable/sample'), 'product_id', $installer->getTable('catalog/product'), 'entity_id'
00145 );
00146
00147 $installer->run("
00148 CREATE TABLE `{$installer->getTable('downloadable/sample_title')}`(
00149 `title_id` int(10) unsigned NOT NULL auto_increment,
00150 `sample_id` int(10) unsigned NOT NULL default '0',
00151 `store_id` smallint(5) unsigned NOT NULL default '0',
00152 `title` varchar(255) NOT NULL default '',
00153 PRIMARY KEY (`title_id`),
00154 KEY `DOWNLOADABLE_SAMPLE_TITLE_SAMPLE` (`sample_id`),
00155 KEY `DOWNLOADABLE_SAMPLE_TITLE_STORE` (`store_id`)
00156 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00157 ");
00158
00159 $conn->addConstraint(
00160 'FK_DOWNLOADABLE_SAMPLE_TITLE_SAMPLE', $installer->getTable('downloadable/sample_title'), 'sample_id', $installer->getTable('downloadable/sample'), 'sample_id'
00161 );
00162
00163 $conn->addConstraint(
00164 'FK_DOWNLOADABLE_SAMPLE_TITLE_STORE', $installer->getTable('downloadable/sample_title'), 'store_id', $installer->getTable('core/store'), 'store_id'
00165 );
00166
00167 $installer->endSetup();