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