/app/code/core/Mage/Weee/sql/weee_setup/install-1.6.0.0.php

https://bitbucket.org/dnejedly/eaparts · PHP · 174 lines · 134 code · 9 blank · 31 comment · 0 complexity · 1a2b2438e6759751f02799422d2155e5 MD5 · raw file

  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Weee
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /** @var $installer Mage_Weee_Model_Resource_Setup */
  27. $installer = $this;
  28. /**
  29. * Create table 'weee/tax'
  30. */
  31. $table = $installer->getConnection()
  32. ->newTable($installer->getTable('weee/tax'))
  33. ->addColumn('value_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  34. 'identity' => true,
  35. 'nullable' => false,
  36. 'primary' => true,
  37. ), 'Value Id')
  38. ->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  39. 'unsigned' => true,
  40. 'nullable' => false,
  41. 'default' => '0',
  42. ), 'Website Id')
  43. ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  44. 'unsigned' => true,
  45. 'nullable' => false,
  46. 'default' => '0',
  47. ), 'Entity Id')
  48. ->addColumn('country', Varien_Db_Ddl_Table::TYPE_TEXT, 2, array(
  49. 'nullable' => true,
  50. ), 'Country')
  51. ->addColumn('value', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
  52. 'nullable' => false,
  53. 'default' => '0.0000',
  54. ), 'Value')
  55. ->addColumn('state', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  56. 'nullable' => false,
  57. 'default' => '*',
  58. ), 'State')
  59. ->addColumn('attribute_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  60. 'unsigned' => true,
  61. 'nullable' => false,
  62. ), 'Attribute Id')
  63. ->addColumn('entity_type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  64. 'unsigned' => true,
  65. 'nullable' => false,
  66. ), 'Entity Type Id')
  67. ->addIndex($installer->getIdxName('weee/tax', array('website_id')),
  68. array('website_id'))
  69. ->addIndex($installer->getIdxName('weee/tax', array('entity_id')),
  70. array('entity_id'))
  71. ->addIndex($installer->getIdxName('weee/tax', array('country')),
  72. array('country'))
  73. ->addIndex($installer->getIdxName('weee/tax', array('attribute_id')),
  74. array('attribute_id'))
  75. ->addForeignKey($installer->getFkName('weee/tax', 'country', 'directory/country', 'country_id'),
  76. 'country', $installer->getTable('directory/country'), 'country_id',
  77. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  78. ->addForeignKey($installer->getFkName('weee/tax', 'entity_id', 'catalog/product', 'entity_id'),
  79. 'entity_id', $installer->getTable('catalog/product'), 'entity_id',
  80. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  81. ->addForeignKey($installer->getFkName('weee/tax', 'website_id', 'core/website', 'website_id'),
  82. 'website_id', $installer->getTable('core/website'), 'website_id',
  83. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  84. ->addForeignKey($installer->getFkName('weee/tax', 'attribute_id', 'eav/attribute', 'attribute_id'),
  85. 'attribute_id', $installer->getTable('eav/attribute'), 'attribute_id',
  86. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  87. ->setComment('Weee Tax');
  88. $installer->getConnection()->createTable($table);
  89. /**
  90. * Create table 'weee/discount'
  91. */
  92. $table = $installer->getConnection()
  93. ->newTable($installer->getTable('weee/discount'))
  94. ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  95. 'unsigned' => true,
  96. 'nullable' => false,
  97. 'default' => '0',
  98. ), 'Entity Id')
  99. ->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  100. 'unsigned' => true,
  101. 'nullable' => false,
  102. 'default' => '0',
  103. ), 'Website Id')
  104. ->addColumn('customer_group_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  105. 'unsigned' => true,
  106. 'nullable' => false,
  107. ), 'Customer Group Id')
  108. ->addColumn('value', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
  109. 'nullable' => false,
  110. 'default' => '0.0000',
  111. ), 'Value')
  112. ->addIndex($installer->getIdxName('weee/discount', array('website_id')),
  113. array('website_id'))
  114. ->addIndex($installer->getIdxName('weee/discount', array('entity_id')),
  115. array('entity_id'))
  116. ->addIndex($installer->getIdxName('weee/discount', array('customer_group_id')),
  117. array('customer_group_id'))
  118. ->addForeignKey($installer->getFkName('weee/discount', 'customer_group_id', 'customer/customer_group', 'customer_group_id'),
  119. 'customer_group_id', $installer->getTable('customer/customer_group'), 'customer_group_id',
  120. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  121. ->addForeignKey($installer->getFkName('weee/discount', 'entity_id', 'catalog/product', 'entity_id'),
  122. 'entity_id', $installer->getTable('catalog/product'), 'entity_id',
  123. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  124. ->addForeignKey($installer->getFkName('weee/discount', 'website_id', 'core/website', 'website_id'),
  125. 'website_id', $installer->getTable('core/website'), 'website_id',
  126. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  127. ->setComment('Weee Discount');
  128. $installer->getConnection()->createTable($table);
  129. $installer->addAttribute('order_item', 'base_weee_tax_applied_amount', array('type'=>'decimal'));
  130. $installer->addAttribute('order_item', 'base_weee_tax_applied_row_amnt', array('type'=>'decimal'));
  131. $installer->addAttribute('order_item', 'weee_tax_applied_amount', array('type'=>'decimal'));
  132. $installer->addAttribute('order_item', 'weee_tax_applied_row_amount', array('type'=>'decimal'));
  133. $installer->addAttribute('order_item', 'weee_tax_applied', array('type'=>'text'));
  134. $installer->addAttribute('quote_item', 'weee_tax_disposition', array('type'=>'decimal'));
  135. $installer->addAttribute('quote_item', 'weee_tax_row_disposition', array('type'=>'decimal'));
  136. $installer->addAttribute('quote_item', 'base_weee_tax_disposition', array('type'=>'decimal'));
  137. $installer->addAttribute('quote_item', 'base_weee_tax_row_disposition', array('type'=>'decimal'));
  138. $installer->addAttribute('order_item', 'weee_tax_disposition', array('type'=>'decimal'));
  139. $installer->addAttribute('order_item', 'weee_tax_row_disposition', array('type'=>'decimal'));
  140. $installer->addAttribute('order_item', 'base_weee_tax_disposition', array('type'=>'decimal'));
  141. $installer->addAttribute('order_item', 'base_weee_tax_row_disposition', array('type'=>'decimal'));
  142. $installer->addAttribute('invoice_item', 'base_weee_tax_applied_amount', array('type'=>'decimal'));
  143. $installer->addAttribute('invoice_item', 'base_weee_tax_applied_row_amnt', array('type'=>'decimal'));
  144. $installer->addAttribute('invoice_item', 'weee_tax_applied_amount', array('type'=>'decimal'));
  145. $installer->addAttribute('invoice_item', 'weee_tax_applied_row_amount', array('type'=>'decimal'));
  146. $installer->addAttribute('invoice_item', 'weee_tax_applied', array('type'=>'text'));
  147. $installer->addAttribute('invoice_item', 'weee_tax_disposition', array('type'=>'decimal'));
  148. $installer->addAttribute('invoice_item', 'weee_tax_row_disposition', array('type'=>'decimal'));
  149. $installer->addAttribute('invoice_item', 'base_weee_tax_disposition', array('type'=>'decimal'));
  150. $installer->addAttribute('invoice_item', 'base_weee_tax_row_disposition', array('type'=>'decimal'));
  151. $installer->addAttribute('quote_item', 'weee_tax_applied', array('type'=>'text'));
  152. $installer->addAttribute('quote_item', 'weee_tax_applied_amount', array('type'=>'decimal'));
  153. $installer->addAttribute('quote_item', 'weee_tax_applied_row_amount', array('type'=>'decimal'));
  154. $installer->addAttribute('quote_item', 'base_weee_tax_applied_amount', array('type'=>'decimal'));
  155. $installer->addAttribute('quote_item', 'base_weee_tax_applied_row_amnt', array('type'=>'decimal'));
  156. $installer->addAttribute('creditmemo_item', 'weee_tax_disposition', array('type'=>'decimal'));
  157. $installer->addAttribute('creditmemo_item', 'weee_tax_row_disposition', array('type'=>'decimal'));
  158. $installer->addAttribute('creditmemo_item', 'base_weee_tax_disposition', array('type'=>'decimal'));
  159. $installer->addAttribute('creditmemo_item', 'base_weee_tax_row_disposition', array('type'=>'decimal'));
  160. $installer->addAttribute('creditmemo_item', 'weee_tax_applied', array('type'=>'text'));
  161. $installer->addAttribute('creditmemo_item', 'base_weee_tax_applied_amount', array('type'=>'decimal'));
  162. $installer->addAttribute('creditmemo_item', 'base_weee_tax_applied_row_amnt', array('type'=>'decimal'));
  163. $installer->addAttribute('creditmemo_item', 'weee_tax_applied_amount', array('type'=>'decimal'));
  164. $installer->addAttribute('creditmemo_item', 'weee_tax_applied_row_amount', array('type'=>'decimal'));
  165. $installer->endSetup();