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 $installer->startSetup();
00030
00031 $this->getConnection()->dropColumn($this->getTable('customer_address_entity'), 'store_id');
00032
00033 $installer->run("
00034 ALTER TABLE {$this->getTable('customer_entity')}
00035 ADD COLUMN `website_id` SMALLINT(5) UNSIGNED AFTER `attribute_set_id`,
00036 ADD COLUMN `email` VARCHAR(255) NOT NULL AFTER `website_id`,
00037 ADD COLUMN `group_id` SMALLINT(3) UNSIGNED NOT NULL AFTER `email`,
00038 ADD INDEX IDX_AUTH(`email`, `website_id`),
00039 ADD CONSTRAINT `FK_CUSTOMER_WEBSITE` FOREIGN KEY `FK_CUSTOMER_WEBSITE` (`website_id`)
00040 REFERENCES {$this->getTable('core_website')} (`website_id`) ON DELETE SET NULL ON UPDATE CASCADE;
00041 ");
00042
00043 $emailAttributeId = $installer->getAttributeId('customer', 'email');
00044 $groupAttributeId = $installer->getAttributeId('customer', 'group_id');
00045
00046 $installer->run("
00047 UPDATE {$this->getTable('customer_entity')} customer, {$this->getTable('core_store')} store
00048 SET customer.website_id=store.website_id
00049 WHERE store.store_id=customer.store_id;
00050
00051 UPDATE {$this->getTable('core_website')} SET code='admin', name='Admin' WHERE website_id=0;
00052
00053 UPDATE {$this->getTable('customer_entity')} customer, {$this->getTable('customer_entity_varchar')} varchar_attribute
00054 SET customer.email=varchar_attribute.value
00055 WHERE varchar_attribute.entity_id=customer.entity_id
00056 AND varchar_attribute.attribute_id={$emailAttributeId};
00057
00058 UPDATE {$this->getTable('customer_entity')} customer, {$this->getTable('customer_entity_int')} int_attribute
00059 SET customer.group_id=int_attribute.value
00060 WHERE int_attribute.entity_id=customer.entity_id
00061 AND int_attribute.attribute_id={$groupAttributeId};
00062 ");
00063
00064 $installer->getConnection()->dropColumn($this->getTable('customer_entity'), 'parent_id');
00065 $installer->installEntities();
00066 $installer->endSetup();