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->getConnection()->addColumn($installer->getTable('downloadable/sample'), 'sample_type', "varchar(20) NOT NULL default '' AFTER `sample_file`");
00033 $installer->getConnection()->addColumn($installer->getTable('downloadable/link'), 'link_type', "varchar(20) NOT NULL default '' AFTER `link_file`");
00034 $installer->getConnection()->addColumn($installer->getTable('downloadable/link'), 'sample_type', "varchar(20) NOT NULL default '' AFTER `sample_file`");
00035
00036 $conn->dropForeignKey($installer->getTable('downloadable/link_purchased'), 'FK_DOWNLOADABLE_ORDER_ITEM_ID');
00037 $conn->dropKey($installer->getTable('downloadable/link_purchased'), 'DOWNLOADABLE_ORDER_ITEM_ID');
00038
00039
00040 $installer->run("
00041 CREATE TABLE `{$installer->getTable('downloadable/link_purchased_item')}`(
00042 `item_id` int(10) unsigned NOT NULL auto_increment,
00043 `purchased_id` int(10) unsigned NOT NULL default '0',
00044 `order_item_id` int(10) unsigned NOT NULL default '0',
00045 `number_of_downloads_bought` int(10) unsigned NOT NULL default '0',
00046 `number_of_downloads_used` int(10) unsigned NOT NULL default '0',
00047 `link_id` int(20) unsigned NOT NULL default '0',
00048 `link_title` varchar(255) NOT NULL default '',
00049 `is_shareable` smallint(1) unsigned NOT NULL default '0',
00050 `link_url` varchar(255) NOT NULL default '',
00051 `link_file` varchar(255) NOT NULL default '',
00052 `link_type` varchar(255) NOT NULL default '',
00053 `status` varchar(50) NOT NULL default '',
00054 `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
00055 `updated_at` datetime NOT NULL default '0000-00-00 00:00:00',
00056 PRIMARY KEY (`item_id`),
00057 KEY `DOWNLOADABLE_LINK_PURCHASED_ID` (`purchased_id`),
00058 KEY `DOWNLOADABLE_ORDER_ITEM_ID` (`order_item_id`)
00059 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00060 ");
00061
00062 $conn->addConstraint(
00063 'FK_DOWNLOADABLE_LINK_PURCHASED_ID', $installer->getTable('downloadable/link_purchased_item'), 'purchased_id', $installer->getTable('downloadable/link_purchased'), 'purchased_id'
00064 );
00065 $conn->addConstraint(
00066 'FK_DOWNLOADABLE_ORDER_ITEM_ID', $installer->getTable('downloadable/link_purchased_item'), 'order_item_id', $installer->getTable('sales/order_item'), 'item_id'
00067 );
00068
00069 $installer->run("
00070 INSERT INTO `{$installer->getTable('downloadable/link_purchased_item')}`
00071 (`purchased_id`, `order_item_id`, `number_of_downloads_bought`, `number_of_downloads_used`, `link_id`, `link_title`, `is_shareable`, `link_url`, `link_file`, `status`, `created_at`, `updated_at`)
00072 SELECT
00073 `purchased_id`, `order_item_id`, `number_of_downloads_bought`, `number_of_downloads_used`, `link_id`, `link_title`, `is_shareable`, `link_url`, `link_file`, `status`, `created_at`, `updated_at`
00074 FROM `{$installer->getTable('downloadable/link_purchased')}`
00075
00076 ");
00077
00078 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'order_item_id');
00079 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'number_of_downloads_bought');
00080 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'number_of_downloads_used');
00081 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'link_id');
00082 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'link_title');
00083 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'is_shareable');
00084 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'link_url');
00085 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'link_file');
00086 $conn->dropColumn($installer->getTable('downloadable/link_purchased'), 'status');
00087
00088 $installer->getConnection()->addColumn($installer->getTable('downloadable/link_purchased'), 'link_section_title', "varchar(255) NOT NULL default '' AFTER `product_sku`");
00089
00090 $installer->endSetup();