/app/code/Ecart/Tag/sql/0.1.1.php
PHP | 115 lines | 70 code | 18 blank | 27 comment | 0 complexity | d187913756f00f596fcab858c9fb3bbb MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
- <?php
- /**
- * Ecart
- *
- * This file is part of Ecart.
- *
- * Ecart is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Ecart is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ecart. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category Ecart
- * @package Ecart_Account
- * @copyright Copyright 2008-2009 E-Cart LLC
- * @license GNU Public License V3.0
- */
-
-
- class Ecart_Tag_Upgrade_0_1_1 extends Ecart_Core_Model_Migration_Abstract
- {
- protected $_version = '0.1.1';
- protected $_info = 'install';
-
- public function up()
- {
- $installer = Ecart::single('install/installer');
- $installer->run("
- -- DROP TABLE IF EXISTS `{$installer->getTable('tag_customer')}`;
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('tag_customer')}` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `customer_id` int(10) unsigned default NULL,
- `site_id` smallint(5) unsigned NOT NULL,
- `name` varchar(128) NOT NULL,
- `status` TINYINT(1) NOT NULL default '1',
- PRIMARY KEY (`id`),
- KEY `i_site_id` USING BTREE (`site_id`),
- KEY `i_customer_id` USING BTREE (`customer_id`),
- CONSTRAINT `FK_customer_tag_customer` FOREIGN KEY (`customer_id`) REFERENCES `{$installer->getTable('account_customer')}` (`id`) ON DELETE SET NULL,
- CONSTRAINT `FK_customer_tag_site` FOREIGN KEY (`site_id`) REFERENCES `{$installer->getTable('core_site')}` (`id`) ON DELETE CASCADE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1 ;
- -- DROP TABLE IF EXISTS `{$installer->getTable('tag_product')}`;
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('tag_product')}` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `customer_tag_id` int(10) unsigned NOT NULL,
- `product_id` int(10) unsigned NOT NULL,
- PRIMARY KEY (`id`),
- KEY `customer_tag_products_FKIndex1` (`customer_tag_id`),
- KEY `customer_tag_products_FKIndex2` (`product_id`),
- CONSTRAINT `FK_customer_tag_product_id` FOREIGN KEY (`product_id`) REFERENCES `{$installer->getTable('catalog_product')}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `FK_customer_tag_product_customer` FOREIGN KEY (`customer_tag_id`) REFERENCES `{$installer->getTable('tag_customer')}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
- ");
- Ecart::single('core/config_field')
- ->add('tag', 'Tag', null, null, array('translation_module' => 'Ecart_Tag'))
- ->add('tag/main/customer_status', 'Tag/General/Default customer tag status', 1, 'select', 'Default tag status added by registered customer', array('config_options' => '{"1":"approved","2":"pending","3":"disapproved"}'))
- ->add('tag/main/guest_status', 'Default guest tag status', 2, 'select', 'Default tag status added by guest', array('config_options' => '{"1":"approved","2":"pending","3":"disapproved"}'));
- Ecart::single('admin/menu')
- ->add('Catalog', null, 20, 'Ecart_Catalog')
- ->add('Catalog->Tags', 'tag_index', 50, 'Ecart_Tag');
- Ecart::single('admin/acl_resource')
- ->add('admin/tag', 'Tags All')
- ->add('admin/tag_index', 'Tags')
- ->add("admin/tag_index/delete")
- ->add("admin/tag_index/index")
- ->add("admin/tag_index/list")
- ->add("admin/tag_index/save");
- Ecart::single('core/page')
- ->add('tag/*/*')
- ->add('tag/index/*')
- ->add('tag/index/show-products');
- }
-
- public function down()
- {
- $installer = Ecart::single('install/installer');
- $installer->run("
- DROP TABLE IF EXISTS `{$installer->getTable('tag_customer')}`;
- DROP TABLE IF EXISTS `{$installer->getTable('tag_product')}`;
- ");
- Ecart::single('core/config_field')->remove('tag');
- Ecart::single('core/config_value')->remove('tag');
- Ecart::single('admin/menu')->remove('Modules->Tags');
- Ecart::single('admin/acl_resource')->remove('admin/tag');
- Ecart::single('core/page')
- ->remove('tag/*/*')
- ->remove('tag/index/*')
- ->remove('tag/index/show-products');
- //Ecart::single('core/template_box')
- // ->remove('Ecart_Tag_Cloud')
- // ->remove('Ecart_Tag_Account')
- // ->remove('Ecart_Tag_Product');
- }
- }