PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/magento/app/code/core/Mage/Api/sql/api_setup/install-1.6.0.0.php

https://bitbucket.org/jit_bec/shopifine
PHP | 208 lines | 151 code | 10 blank | 47 comment | 0 complexity | 47e95c2077fd110d92d295202a4db2bd MD5 | raw file
Possible License(s): LGPL-3.0
  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_Api
  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. /**
  27. * Api install
  28. *
  29. * @category Mage
  30. * @package Mage_Api
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. $installer = $this;
  34. /* @var $installer Mage_Core_Model_Resource_Setup */
  35. $installer->startSetup();
  36. /**
  37. * Create table 'api/assert'
  38. */
  39. $table = $installer->getConnection()
  40. ->newTable($installer->getTable('api/assert'))
  41. ->addColumn('assert_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  42. 'identity' => true,
  43. 'unsigned' => true,
  44. 'nullable' => false,
  45. 'primary' => true,
  46. ), 'Assert id')
  47. ->addColumn('assert_type', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
  48. ), 'Assert type')
  49. ->addColumn('assert_data', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
  50. ), 'Assert additional data')
  51. ->setComment('Api ACL Asserts');
  52. $installer->getConnection()->createTable($table);
  53. /**
  54. * Create table 'api/role'
  55. */
  56. $table = $installer->getConnection()
  57. ->newTable($installer->getTable('api/role'))
  58. ->addColumn('role_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  59. 'identity' => true,
  60. 'unsigned' => true,
  61. 'nullable' => false,
  62. 'primary' => true,
  63. ), 'Role id')
  64. ->addColumn('parent_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  65. 'unsigned' => true,
  66. 'nullable' => false,
  67. 'default' => '0',
  68. ), 'Parent role id')
  69. ->addColumn('tree_level', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  70. 'unsigned' => true,
  71. 'nullable' => false,
  72. 'default' => '0',
  73. ), 'Role level in tree')
  74. ->addColumn('sort_order', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  75. 'unsigned' => true,
  76. 'nullable' => false,
  77. 'default' => '0',
  78. ), 'Sort order to display on admin area')
  79. ->addColumn('role_type', Varien_Db_Ddl_Table::TYPE_TEXT, 1, array(
  80. 'nullable' => false,
  81. 'default' => '0',
  82. ), 'Role type')
  83. ->addColumn('user_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  84. 'unsigned' => true,
  85. 'nullable' => false,
  86. 'default' => '0',
  87. ), 'User id')
  88. ->addColumn('role_name', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
  89. ), 'Role name')
  90. ->addIndex($installer->getIdxName('api/role', array('parent_id', 'sort_order')),
  91. array('parent_id', 'sort_order'))
  92. ->addIndex($installer->getIdxName('api/role', array('tree_level')),
  93. array('tree_level'))
  94. ->setComment('Api ACL Roles');
  95. $installer->getConnection()->createTable($table);
  96. /**
  97. * Create table 'api/rule'
  98. */
  99. $table = $installer->getConnection()
  100. ->newTable($installer->getTable('api/rule'))
  101. ->addColumn('rule_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  102. 'identity' => true,
  103. 'unsigned' => true,
  104. 'nullable' => false,
  105. 'primary' => true,
  106. ), 'Api rule Id')
  107. ->addColumn('role_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  108. 'unsigned' => true,
  109. 'nullable' => false,
  110. 'default' => '0',
  111. ), 'Api role Id')
  112. ->addColumn('resource_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  113. ), 'Module code')
  114. ->addColumn('api_privileges', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
  115. ), 'Privileges')
  116. ->addColumn('assert_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  117. 'unsigned' => true,
  118. 'nullable' => false,
  119. 'default' => '0',
  120. ), 'Assert id')
  121. ->addColumn('role_type', Varien_Db_Ddl_Table::TYPE_TEXT, 1, array(
  122. ), 'Role type')
  123. ->addColumn('api_permission', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(
  124. ), 'Permission')
  125. ->addIndex($installer->getIdxName('api/rule', array('resource_id', 'role_id')),
  126. array('resource_id', 'role_id'))
  127. ->addIndex($installer->getIdxName('api/rule', array('role_id', 'resource_id')),
  128. array('role_id', 'resource_id'))
  129. ->addForeignKey($installer->getFkName('api/rule', 'role_id', 'api/role', 'role_id'),
  130. 'role_id', $installer->getTable('api/role'), 'role_id',
  131. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  132. ->setComment('Api ACL Rules');
  133. $installer->getConnection()->createTable($table);
  134. /**
  135. * Create table 'api/user'
  136. */
  137. $table = $installer->getConnection()
  138. ->newTable($installer->getTable('api/user'))
  139. ->addColumn('user_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  140. 'identity' => true,
  141. 'unsigned' => true,
  142. 'nullable' => false,
  143. 'primary' => true,
  144. ), 'User id')
  145. ->addColumn('firstname', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
  146. ), 'First name')
  147. ->addColumn('lastname', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
  148. ), 'Last name')
  149. ->addColumn('email', Varien_Db_Ddl_Table::TYPE_TEXT, 128, array(
  150. ), 'Email')
  151. ->addColumn('username', Varien_Db_Ddl_Table::TYPE_TEXT, 40, array(
  152. ), 'Nickname')
  153. ->addColumn('api_key', Varien_Db_Ddl_Table::TYPE_TEXT, 40, array(
  154. ), 'Api key')
  155. ->addColumn('created', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  156. 'nullable' => false,
  157. ), 'User record create date')
  158. ->addColumn('modified', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  159. ), 'User record modify date')
  160. ->addColumn('lognum', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  161. 'unsigned' => true,
  162. 'nullable' => false,
  163. 'default' => '0',
  164. ), 'Quantity of log ins')
  165. ->addColumn('reload_acl_flag', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  166. 'nullable' => false,
  167. 'default' => '0',
  168. ), 'Refresh ACL flag')
  169. ->addColumn('is_active', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  170. 'nullable' => false,
  171. 'default' => '1',
  172. ), 'Account status')
  173. ->setComment('Api Users');
  174. $installer->getConnection()->createTable($table);
  175. /**
  176. * Create table 'api/session'
  177. */
  178. $table = $installer->getConnection()
  179. ->newTable($installer->getTable('api/session'))
  180. ->addColumn('user_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  181. 'unsigned' => true,
  182. 'nullable' => false,
  183. ), 'User id')
  184. ->addColumn('logdate', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  185. 'nullable' => false,
  186. ), 'Login date')
  187. ->addColumn('sessid', Varien_Db_Ddl_Table::TYPE_TEXT, 40, array(
  188. ), 'Sessioin id')
  189. ->addIndex($installer->getIdxName('api/session', array('user_id')),
  190. array('user_id'))
  191. ->addIndex($installer->getIdxName('api/session', array('sessid')),
  192. array('sessid'))
  193. ->addForeignKey($installer->getFkName('api/session', 'user_id', 'api/user', 'user_id'),
  194. 'user_id', $installer->getTable('api/user'), 'user_id',
  195. Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
  196. ->setComment('Api Sessions');
  197. $installer->getConnection()->createTable($table);
  198. $installer->endSetup();