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

/magento/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php

https://bitbucket.org/jit_bec/shopifine
PHP | 414 lines | 364 code | 16 blank | 34 comment | 0 complexity | e96587ee57c61761dff71071fe4f85c5 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_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. /* @var $installer Mage_Core_Model_Resource_Setup */
  27. $installer = $this;
  28. $installer->startSetup();
  29. /**
  30. * Drop indexes
  31. */
  32. $installer->getConnection()->dropIndex(
  33. $installer->getTable('log/customer'),
  34. 'IDX_VISITOR'
  35. );
  36. $installer->getConnection()->dropIndex(
  37. $installer->getTable('log_visitor_online'),
  38. 'IDX_VISITOR_TYPE'
  39. );
  40. $installer->getConnection()->dropIndex(
  41. $installer->getTable('log_visitor_online'),
  42. 'IDX_VISIT_TIME'
  43. );
  44. $installer->getConnection()->dropIndex(
  45. $installer->getTable('log_visitor_online'),
  46. 'IDX_CUSTOMER'
  47. );
  48. $installer->getConnection()->dropIndex(
  49. $installer->getTable('log_url'),
  50. 'IDX_VISITOR'
  51. );
  52. /**
  53. * Change columns
  54. */
  55. $tables = array(
  56. $installer->getTable('log/customer') => array(
  57. 'columns' => array(
  58. 'log_id' => array(
  59. 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
  60. 'identity' => true,
  61. 'unsigned' => true,
  62. 'nullable' => false,
  63. 'primary' => true,
  64. 'comment' => 'Log ID'
  65. ),
  66. 'visitor_id' => array(
  67. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  68. 'unsigned' => true,
  69. 'comment' => 'Visitor ID'
  70. ),
  71. 'customer_id' => array(
  72. 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
  73. 'nullable' => false,
  74. 'default' => '0',
  75. 'comment' => 'Customer ID'
  76. ),
  77. 'login_at' => array(
  78. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  79. 'nullable' => false,
  80. 'comment' => 'Login Time'
  81. ),
  82. 'logout_at' => array(
  83. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  84. 'comment' => 'Logout Time'
  85. ),
  86. 'store_id' => array(
  87. 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
  88. 'unsigned' => true,
  89. 'nullable' => false,
  90. 'comment' => 'Store ID'
  91. )
  92. ),
  93. 'comment' => 'Log Customers Table'
  94. ),
  95. $installer->getTable('log/visitor') => array(
  96. 'columns' => array(
  97. 'visitor_id' => array(
  98. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  99. 'identity' => true,
  100. 'unsigned' => true,
  101. 'nullable' => false,
  102. 'primary' => true,
  103. 'comment' => 'Visitor ID'
  104. ),
  105. 'session_id' => array(
  106. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  107. 'length' => 64,
  108. 'nullable' => false,
  109. 'comment' => 'Session ID'
  110. ),
  111. 'first_visit_at' => array(
  112. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  113. 'comment' => 'First Visit Time'
  114. ),
  115. 'last_visit_at' => array(
  116. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  117. 'nullable' => false,
  118. 'comment' => 'Last Visit Time'
  119. ),
  120. 'last_url_id' => array(
  121. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  122. 'unsigned' => true,
  123. 'nullable' => false,
  124. 'default' => '0',
  125. 'comment' => 'Last URL ID'
  126. ),
  127. 'store_id' => array(
  128. 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
  129. 'unsigned' => true,
  130. 'nullable' => false,
  131. 'comment' => 'Store ID'
  132. )
  133. ),
  134. 'comment' => 'Log Visitors Table'
  135. ),
  136. $installer->getTable('log/visitor_info') => array(
  137. 'columns' => array(
  138. 'visitor_id' => array(
  139. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  140. 'unsigned' => true,
  141. 'nullable' => false,
  142. 'primary' => true,
  143. 'default' => '0',
  144. 'comment' => 'Visitor ID'
  145. ),
  146. 'http_referer' => array(
  147. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  148. 'length' => 255,
  149. 'comment' => 'HTTP Referrer'
  150. ),
  151. 'http_user_agent' => array(
  152. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  153. 'length' => 255,
  154. 'comment' => 'HTTP User-Agent'
  155. ),
  156. 'http_accept_charset' => array(
  157. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  158. 'length' => 255,
  159. 'comment' => 'HTTP Accept-Charset'
  160. ),
  161. 'http_accept_language' => array(
  162. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  163. 'length' => 255,
  164. 'comment' => 'HTTP Accept-Language'
  165. ),
  166. 'server_addr' => array(
  167. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  168. 'comment' => 'Server Address'
  169. ),
  170. 'remote_addr' => array(
  171. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  172. 'comment' => 'Remote Address'
  173. )
  174. ),
  175. 'comment' => 'Log Visitor Info Table'
  176. ),
  177. $installer->getTable('log/url_table') => array(
  178. 'columns' => array(
  179. 'url_id' => array(
  180. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  181. 'unsigned' => true,
  182. 'nullable' => false,
  183. 'primary' => true,
  184. 'default' => '0',
  185. 'comment' => 'URL ID'
  186. ),
  187. 'visitor_id' => array(
  188. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  189. 'unsigned' => true,
  190. 'comment' => 'Visitor ID'
  191. ),
  192. 'visit_time' => array(
  193. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  194. 'nullable' => false,
  195. 'comment' => 'Visit Time'
  196. )
  197. ),
  198. 'comment' => 'Log URL Table'
  199. ),
  200. $installer->getTable('log/url_info_table') => array(
  201. 'columns' => array(
  202. 'url_id' => array(
  203. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  204. 'identity' => true,
  205. 'unsigned' => true,
  206. 'nullable' => false,
  207. 'primary' => true,
  208. 'comment' => 'URL ID'
  209. ),
  210. 'url' => array(
  211. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  212. 'length' => 255,
  213. 'nullable' => true,
  214. 'default' => null,
  215. 'comment' => 'URL'
  216. ),
  217. 'referer' => array(
  218. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  219. 'length' => 255,
  220. 'comment' => 'Referrer'
  221. )
  222. ),
  223. 'comment' => 'Log URL Info Table'
  224. ),
  225. $installer->getTable('log/summary_table') => array(
  226. 'columns' => array(
  227. 'summary_id' => array(
  228. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  229. 'identity' => true,
  230. 'unsigned' => true,
  231. 'nullable' => false,
  232. 'primary' => true,
  233. 'comment' => 'Summary ID'
  234. ),
  235. 'store_id' => array(
  236. 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
  237. 'unsigned' => true,
  238. 'nullable' => false,
  239. 'comment' => 'Store ID'
  240. ),
  241. 'type_id' => array(
  242. 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
  243. 'unsigned' => true,
  244. 'comment' => 'Type ID'
  245. ),
  246. 'visitor_count' => array(
  247. 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
  248. 'nullable' => false,
  249. 'default' => '0',
  250. 'comment' => 'Visitor Count'
  251. ),
  252. 'customer_count' => array(
  253. 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
  254. 'nullable' => false,
  255. 'default' => '0',
  256. 'comment' => 'Customer Count'
  257. ),
  258. 'add_date' => array(
  259. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  260. 'nullable' => false,
  261. 'comment' => 'Date'
  262. )
  263. ),
  264. 'comment' => 'Log Summary Table'
  265. ),
  266. $installer->getTable('log/summary_type_table') => array(
  267. 'columns' => array(
  268. 'type_id' => array(
  269. 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
  270. 'identity' => true,
  271. 'unsigned' => true,
  272. 'nullable' => false,
  273. 'primary' => true,
  274. 'comment' => 'Type ID'
  275. ),
  276. 'type_code' => array(
  277. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  278. 'length' => 64,
  279. 'nullable' => false,
  280. 'comment' => 'Type Code'
  281. ),
  282. 'period' => array(
  283. 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
  284. 'unsigned' => true,
  285. 'nullable' => false,
  286. 'default' => '0',
  287. 'comment' => 'Period'
  288. ),
  289. 'period_type' => array(
  290. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  291. 'length' => 6,
  292. 'nullable' => false,
  293. 'default' => 'MINUTE',
  294. 'comment' => 'Period Type'
  295. )
  296. ),
  297. 'comment' => 'Log Summary Types Table'
  298. ),
  299. $installer->getTable('log/quote_table') => array(
  300. 'columns' => array(
  301. 'quote_id' => array(
  302. 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
  303. 'unsigned' => true,
  304. 'nullable' => false,
  305. 'primary' => true,
  306. 'default' => '0',
  307. 'comment' => 'Quote ID'
  308. ),
  309. 'visitor_id' => array(
  310. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  311. 'unsigned' => true,
  312. 'comment' => 'Visitor ID'
  313. ),
  314. 'created_at' => array(
  315. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  316. 'nullable' => false,
  317. 'comment' => 'Creation Time'
  318. ),
  319. 'deleted_at' => array(
  320. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  321. 'comment' => 'Deletion Time'
  322. )
  323. ),
  324. 'comment' => 'Log Quotes Table'
  325. ),
  326. $installer->getTable('log/visitor_online') => array(
  327. 'columns' => array(
  328. 'visitor_id' => array(
  329. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  330. 'identity' => true,
  331. 'unsigned' => true,
  332. 'nullable' => false,
  333. 'primary' => true,
  334. 'comment' => 'Visitor ID'
  335. ),
  336. 'visitor_type' => array(
  337. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  338. 'length' => 1,
  339. 'nullable' => false,
  340. 'comment' => 'Visitor Type'
  341. ),
  342. 'remote_addr' => array(
  343. 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
  344. 'nullable' => false,
  345. 'comment' => 'Remote Address'
  346. ),
  347. 'first_visit_at' => array(
  348. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  349. 'comment' => 'First Visit Time'
  350. ),
  351. 'last_visit_at' => array(
  352. 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
  353. 'comment' => 'Last Visit Time'
  354. ),
  355. 'customer_id' => array(
  356. 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
  357. 'unsigned' => true,
  358. 'comment' => 'Customer ID'
  359. ),
  360. 'last_url' => array(
  361. 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
  362. 'length' => 255,
  363. 'comment' => 'Last URL'
  364. )
  365. ),
  366. 'comment' => 'Log Visitor Online Table'
  367. )
  368. );
  369. $installer->getConnection()->modifyTables($tables);
  370. /**
  371. * Add indexes
  372. */
  373. $installer->getConnection()->addIndex(
  374. $installer->getTable('log/customer'),
  375. $installer->getIdxName('log/customer', array('visitor_id')),
  376. array('visitor_id')
  377. );
  378. $installer->getConnection()->addIndex(
  379. $installer->getTable('log/url_table'),
  380. $installer->getIdxName('log/url_table', array('visitor_id')),
  381. array('visitor_id')
  382. );
  383. $installer->getConnection()->addIndex(
  384. $installer->getTable('log/visitor_online'),
  385. $installer->getIdxName('log/visitor_online', array('visitor_type')),
  386. array('visitor_type')
  387. );
  388. $installer->getConnection()->addIndex(
  389. $installer->getTable('log/visitor_online'),
  390. $installer->getIdxName('log/visitor_online', array('first_visit_at', 'last_visit_at')),
  391. array('first_visit_at', 'last_visit_at')
  392. );
  393. $installer->getConnection()->addIndex(
  394. $installer->getTable('log/visitor_online'),
  395. $installer->getIdxName('log/visitor_online', array('customer_id')),
  396. array('customer_id')
  397. );
  398. $installer->endSetup();