PageRenderTime 42ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/app/code/Ecart/Tag/sql/0.1.1.php

https://code.google.com/p/ecartcommerce/
PHP | 115 lines | 70 code | 18 blank | 27 comment | 0 complexity | d187913756f00f596fcab858c9fb3bbb MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Ecart
  4. *
  5. * This file is part of Ecart.
  6. *
  7. * Ecart is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Ecart is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Ecart. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * @category Ecart
  21. * @package Ecart_Account
  22. * @copyright Copyright 2008-2009 E-Cart LLC
  23. * @license GNU Public License V3.0
  24. */
  25. class Ecart_Tag_Upgrade_0_1_1 extends Ecart_Core_Model_Migration_Abstract
  26. {
  27. protected $_version = '0.1.1';
  28. protected $_info = 'install';
  29. public function up()
  30. {
  31. $installer = Ecart::single('install/installer');
  32. $installer->run("
  33. -- DROP TABLE IF EXISTS `{$installer->getTable('tag_customer')}`;
  34. CREATE TABLE IF NOT EXISTS `{$installer->getTable('tag_customer')}` (
  35. `id` int(10) unsigned NOT NULL auto_increment,
  36. `customer_id` int(10) unsigned default NULL,
  37. `site_id` smallint(5) unsigned NOT NULL,
  38. `name` varchar(128) NOT NULL,
  39. `status` TINYINT(1) NOT NULL default '1',
  40. PRIMARY KEY (`id`),
  41. KEY `i_site_id` USING BTREE (`site_id`),
  42. KEY `i_customer_id` USING BTREE (`customer_id`),
  43. CONSTRAINT `FK_customer_tag_customer` FOREIGN KEY (`customer_id`) REFERENCES `{$installer->getTable('account_customer')}` (`id`) ON DELETE SET NULL,
  44. CONSTRAINT `FK_customer_tag_site` FOREIGN KEY (`site_id`) REFERENCES `{$installer->getTable('core_site')}` (`id`) ON DELETE CASCADE
  45. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1 ;
  46. -- DROP TABLE IF EXISTS `{$installer->getTable('tag_product')}`;
  47. CREATE TABLE IF NOT EXISTS `{$installer->getTable('tag_product')}` (
  48. `id` int(10) unsigned NOT NULL auto_increment,
  49. `customer_tag_id` int(10) unsigned NOT NULL,
  50. `product_id` int(10) unsigned NOT NULL,
  51. PRIMARY KEY (`id`),
  52. KEY `customer_tag_products_FKIndex1` (`customer_tag_id`),
  53. KEY `customer_tag_products_FKIndex2` (`product_id`),
  54. CONSTRAINT `FK_customer_tag_product_id` FOREIGN KEY (`product_id`) REFERENCES `{$installer->getTable('catalog_product')}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  55. CONSTRAINT `FK_customer_tag_product_customer` FOREIGN KEY (`customer_tag_id`) REFERENCES `{$installer->getTable('tag_customer')}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
  56. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
  57. ");
  58. Ecart::single('core/config_field')
  59. ->add('tag', 'Tag', null, null, array('translation_module' => 'Ecart_Tag'))
  60. ->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"}'))
  61. ->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"}'));
  62. Ecart::single('admin/menu')
  63. ->add('Catalog', null, 20, 'Ecart_Catalog')
  64. ->add('Catalog->Tags', 'tag_index', 50, 'Ecart_Tag');
  65. Ecart::single('admin/acl_resource')
  66. ->add('admin/tag', 'Tags All')
  67. ->add('admin/tag_index', 'Tags')
  68. ->add("admin/tag_index/delete")
  69. ->add("admin/tag_index/index")
  70. ->add("admin/tag_index/list")
  71. ->add("admin/tag_index/save");
  72. Ecart::single('core/page')
  73. ->add('tag/*/*')
  74. ->add('tag/index/*')
  75. ->add('tag/index/show-products');
  76. }
  77. public function down()
  78. {
  79. $installer = Ecart::single('install/installer');
  80. $installer->run("
  81. DROP TABLE IF EXISTS `{$installer->getTable('tag_customer')}`;
  82. DROP TABLE IF EXISTS `{$installer->getTable('tag_product')}`;
  83. ");
  84. Ecart::single('core/config_field')->remove('tag');
  85. Ecart::single('core/config_value')->remove('tag');
  86. Ecart::single('admin/menu')->remove('Modules->Tags');
  87. Ecart::single('admin/acl_resource')->remove('admin/tag');
  88. Ecart::single('core/page')
  89. ->remove('tag/*/*')
  90. ->remove('tag/index/*')
  91. ->remove('tag/index/show-products');
  92. //Ecart::single('core/template_box')
  93. // ->remove('Ecart_Tag_Cloud')
  94. // ->remove('Ecart_Tag_Account')
  95. // ->remove('Ecart_Tag_Product');
  96. }
  97. }