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/link_purchased'), 'order_item_id', "int(10) unsigned NOT NULL default '0' AFTER `order_increment_id`");
00033
00034 $conn->addKey($installer->getTable('downloadable/link_purchased'), 'KEY_DOWNLOADABLE_ORDER_ITEM_ID', 'order_item_id');
00035
00036 $conn->addConstraint(
00037 'FK_DOWNLOADABLE_PURCHASED_ORDER_ITEM_ID', $installer->getTable('downloadable/link_purchased'), 'order_item_id', $installer->getTable('sales/order_item'), 'item_id'
00038 );
00039
00040 $select = $installer->getConnection()->select()
00041 ->from($installer->getTable('downloadable/link_purchased_item'), array(
00042 'purchased_id',
00043 'order_item_id',
00044 ));
00045 $result = $installer->getConnection()->fetchAll($select);
00046
00047 foreach ($result as $row) {
00048 $installer->getConnection()->update(
00049 $installer->getTable('downloadable/link_purchased'),
00050 array('order_item_id' => $row['order_item_id']),
00051 $installer->getConnection()->quoteInto('purchased_id = ?', $row['purchased_id'])
00052 );
00053 }
00054
00055 $installer->endSetup();