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 $connection = $installer->getConnection();
00032
00033 $connection->beginTransaction();
00034 try {
00035 $installer->run("
00036 CREATE TABLE `{$installer->getTable('cataloginventory_stock_status')}` (
00037 `product_id` int(10) unsigned NOT NULL,
00038 `website_id` smallint(5) unsigned NOT NULL,
00039 `stock_id` smallint(4) unsigned NOT NULL,
00040 `qty` decimal(12,4) NOT NULL DEFAULT '0.0000',
00041 `stock_status` tinyint(3) unsigned NOT NULL,
00042 PRIMARY KEY (`product_id`,`website_id`,`stock_id`),
00043 CONSTRAINT `FK_CATALOGINVENTORY_STOCK_STATUS_STOCK` FOREIGN KEY (`stock_id`) REFERENCES `{$installer->getTable('cataloginventory_stock')}` (`stock_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00044 CONSTRAINT `FK_CATALOGINVENTORY_STOCK_STATUS_PRODUCT` FOREIGN KEY (`product_id`) REFERENCES `{$installer->getTable('catalog_product_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00045 CONSTRAINT `FK_CATALOGINVENTORY_STOCK_STATUS_WEBSITE` FOREIGN KEY (`website_id`) REFERENCES `{$installer->getTable('core_website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE
00046 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00047 ");
00048
00049 Mage::getModel('cataloginventory/stock_status')->rebuild();
00050 }
00051 catch (Exception $e) {
00052 $connection->rollBack();
00053 throw $e;
00054 }
00055 $connection->commit();
00056 $installer->endSetup();