PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/app/code/core/Mage/Log/sql/log_setup/install-1.6.0.0.php

https://bitbucket.org/mengqing/magento-mirror
PHP | 280 lines | 216 code | 12 blank | 52 comment | 0 complexity | ad7086a4a2931c08d5e0299f38732c41 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_Log
  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. $installer = $this;
  27. /* @var $installer Mage_Core_Model_Resource_Setup */
  28. $installer->startSetup();
  29. /**
  30. * Create table 'log/customer'
  31. */
  32. $table = $installer->getConnection()
  33. ->newTable($installer->getTable('log/customer'))
  34. ->addColumn('log_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  35. 'identity' => true,
  36. 'unsigned' => true,
  37. 'nullable' => false,
  38. 'primary' => true,
  39. ), 'Log ID')
  40. ->addColumn('visitor_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  41. 'unsigned' => true,
  42. ), 'Visitor ID')
  43. ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  44. 'nullable' => false,
  45. 'default' => '0',
  46. ), 'Customer ID')
  47. ->addColumn('login_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  48. 'nullable' => false,
  49. ), 'Login Time')
  50. ->addColumn('logout_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  51. ), 'Logout Time')
  52. ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  53. 'unsigned' => true,
  54. 'nullable' => false,
  55. ), 'Store ID')
  56. ->addIndex($installer->getIdxName('log/customer', array('visitor_id')),
  57. array('visitor_id'))
  58. ->setComment('Log Customers Table');
  59. $installer->getConnection()->createTable($table);
  60. /**
  61. * Create table 'log/quote_table'
  62. */
  63. $table = $installer->getConnection()
  64. ->newTable($installer->getTable('log/quote_table'))
  65. ->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  66. 'unsigned' => true,
  67. 'nullable' => false,
  68. 'primary' => true,
  69. 'default' => '0',
  70. ), 'Quote ID')
  71. ->addColumn('visitor_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  72. 'unsigned' => true,
  73. ), 'Visitor ID')
  74. ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  75. 'nullable' => false,
  76. ), 'Creation Time')
  77. ->addColumn('deleted_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  78. ), 'Deletion Time')
  79. ->setComment('Log Quotes Table');
  80. $installer->getConnection()->createTable($table);
  81. /**
  82. * Create table 'log/summary_table'
  83. */
  84. $table = $installer->getConnection()
  85. ->newTable($installer->getTable('log/summary_table'))
  86. ->addColumn('summary_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  87. 'identity' => true,
  88. 'unsigned' => true,
  89. 'nullable' => false,
  90. 'primary' => true,
  91. ), 'Summary ID')
  92. ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  93. 'unsigned' => true,
  94. 'nullable' => false,
  95. ), 'Store ID')
  96. ->addColumn('type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  97. 'unsigned' => true,
  98. ), 'Type ID')
  99. ->addColumn('visitor_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  100. 'nullable' => false,
  101. 'default' => '0',
  102. ), 'Visitor Count')
  103. ->addColumn('customer_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  104. 'nullable' => false,
  105. 'default' => '0',
  106. ), 'Customer Count')
  107. ->addColumn('add_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  108. 'nullable' => false,
  109. ), 'Date')
  110. ->setComment('Log Summary Table');
  111. $installer->getConnection()->createTable($table);
  112. /**
  113. * Create table 'log/summary_type_table'
  114. */
  115. $table = $installer->getConnection()
  116. ->newTable($installer->getTable('log/summary_type_table'))
  117. ->addColumn('type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  118. 'identity' => true,
  119. 'unsigned' => true,
  120. 'nullable' => false,
  121. 'primary' => true,
  122. ), 'Type ID')
  123. ->addColumn('type_code', Varien_Db_Ddl_Table::TYPE_TEXT, 64, array(
  124. 'nullable' => true,
  125. 'default' => null,
  126. ), 'Type Code')
  127. ->addColumn('period', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  128. 'unsigned' => true,
  129. 'nullable' => false,
  130. 'default' => '0',
  131. ), 'Period')
  132. ->addColumn('period_type', Varien_Db_Ddl_Table::TYPE_TEXT, 6, array(
  133. 'nullable' => false,
  134. 'default' => 'MINUTE',
  135. ), 'Period Type')
  136. ->setComment('Log Summary Types Table');
  137. $installer->getConnection()->createTable($table);
  138. /**
  139. * Create table 'log/url_table'
  140. */
  141. $table = $installer->getConnection()
  142. ->newTable($installer->getTable('log/url_table'))
  143. ->addColumn('url_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  144. 'unsigned' => true,
  145. 'nullable' => false,
  146. 'primary' => true,
  147. 'default' => '0',
  148. ), 'URL ID')
  149. ->addColumn('visitor_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  150. 'unsigned' => true,
  151. ), 'Visitor ID')
  152. ->addColumn('visit_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  153. 'nullable' => false,
  154. ), 'Visit Time')
  155. ->addIndex($installer->getIdxName('log/url_table', array('visitor_id')),
  156. array('visitor_id'))
  157. ->setComment('Log URL Table');
  158. $installer->getConnection()->createTable($table);
  159. /**
  160. * Create table 'log/url_info_table'
  161. */
  162. $table = $installer->getConnection()
  163. ->newTable($installer->getTable('log/url_info_table'))
  164. ->addColumn('url_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  165. 'identity' => true,
  166. 'unsigned' => true,
  167. 'nullable' => false,
  168. 'primary' => true,
  169. ), 'URL ID')
  170. ->addColumn('url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  171. 'nullable' => true,
  172. 'default' => null,
  173. ), 'URL')
  174. ->addColumn('referer', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  175. ), 'Referrer')
  176. ->setComment('Log URL Info Table');
  177. $installer->getConnection()->createTable($table);
  178. /**
  179. * Create table 'log/visitor'
  180. */
  181. $table = $installer->getConnection()
  182. ->newTable($installer->getTable('log/visitor'))
  183. ->addColumn('visitor_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  184. 'identity' => true,
  185. 'unsigned' => true,
  186. 'nullable' => false,
  187. 'primary' => true,
  188. ), 'Visitor ID')
  189. ->addColumn('session_id', Varien_Db_Ddl_Table::TYPE_TEXT, 64, array(
  190. 'nullable' => true,
  191. 'default' => null,
  192. ), 'Session ID')
  193. ->addColumn('first_visit_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  194. ), 'First Visit Time')
  195. ->addColumn('last_visit_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  196. 'nullable' => false,
  197. ), 'Last Visit Time')
  198. ->addColumn('last_url_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  199. 'unsigned' => true,
  200. 'nullable' => false,
  201. 'default' => '0',
  202. ), 'Last URL ID')
  203. ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
  204. 'unsigned' => true,
  205. 'nullable' => false,
  206. ), 'Store ID')
  207. ->setComment('Log Visitors Table');
  208. $installer->getConnection()->createTable($table);
  209. /**
  210. * Create table 'log/visitor_info'
  211. */
  212. $table = $installer->getConnection()
  213. ->newTable($installer->getTable('log/visitor_info'))
  214. ->addColumn('visitor_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  215. 'unsigned' => true,
  216. 'nullable' => false,
  217. 'primary' => true,
  218. 'default' => '0',
  219. ), 'Visitor ID')
  220. ->addColumn('http_referer', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  221. ), 'HTTP Referrer')
  222. ->addColumn('http_user_agent', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  223. ), 'HTTP User-Agent')
  224. ->addColumn('http_accept_charset', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  225. ), 'HTTP Accept-Charset')
  226. ->addColumn('http_accept_language', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  227. ), 'HTTP Accept-Language')
  228. ->addColumn('server_addr', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  229. ), 'Server Address')
  230. ->addColumn('remote_addr', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  231. ), 'Remote Address')
  232. ->setComment('Log Visitor Info Table');
  233. $installer->getConnection()->createTable($table);
  234. /**
  235. * Create table 'log/visitor_online'
  236. */
  237. $table = $installer->getConnection()
  238. ->newTable($installer->getTable('log/visitor_online'))
  239. ->addColumn('visitor_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  240. 'identity' => true,
  241. 'unsigned' => true,
  242. 'nullable' => false,
  243. 'primary' => true,
  244. ), 'Visitor ID')
  245. ->addColumn('visitor_type', Varien_Db_Ddl_Table::TYPE_TEXT, 1, array(
  246. 'nullable' => false,
  247. ), 'Visitor Type')
  248. ->addColumn('remote_addr', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
  249. 'nullable' => false,
  250. ), 'Remote Address')
  251. ->addColumn('first_visit_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  252. ), 'First Visit Time')
  253. ->addColumn('last_visit_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
  254. ), 'Last Visit Time')
  255. ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
  256. 'unsigned' => true,
  257. ), 'Customer ID')
  258. ->addColumn('last_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
  259. ), 'Last URL')
  260. ->addIndex($installer->getIdxName('log/visitor_online', array('visitor_type')),
  261. array('visitor_type'))
  262. ->addIndex($installer->getIdxName('log/visitor_online', array('first_visit_at', 'last_visit_at')),
  263. array('first_visit_at', 'last_visit_at'))
  264. ->addIndex($installer->getIdxName('log/visitor_online', array('customer_id')),
  265. array('customer_id'))
  266. ->setComment('Log Visitor Online Table');
  267. $installer->getConnection()->createTable($table);
  268. $installer->endSetup();