statistics.install

  1. 7.x drupal-7.x/modules/statistics/statistics.install
  2. 6.x drupal-6.x/modules/statistics/statistics.install

File

drupal-6.x/modules/statistics/statistics.install
View source
  1. <?php
  2. /**
  3. * Implementation of hook_install().
  4. */
  5. function statistics_install() {
  6. // Create tables.
  7. drupal_install_schema('statistics');
  8. }
  9. /**
  10. * Changes session ID field to VARCHAR(64) to add support for SHA-1 hashes.
  11. */
  12. function statistics_update_1000() {
  13. $ret = array();
  14. switch ($GLOBALS['db_type']) {
  15. case 'mysql':
  16. case 'mysqli':
  17. $ret[] = update_sql("ALTER TABLE {accesslog} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''");
  18. break;
  19. case 'pgsql':
  20. db_change_column($ret, 'accesslog', 'sid', 'sid', 'varchar(64)', array('not null' => TRUE, 'default' => "''"));
  21. break;
  22. }
  23. return $ret;
  24. }
  25. /**
  26. * Implementation of hook_uninstall().
  27. */
  28. function statistics_uninstall() {
  29. // Remove tables.
  30. drupal_uninstall_schema('statistics');
  31. variable_del('statistics_count_content_views');
  32. variable_del('statistics_enable_access_log');
  33. variable_del('statistics_flush_accesslog_timer');
  34. variable_del('statistics_day_timestamp');
  35. variable_del('statistics_block_top_day_num');
  36. variable_del('statistics_block_top_all_num');
  37. variable_del('statistics_block_top_last_num');
  38. }
  39. /**
  40. * Implementation of hook_schema().
  41. */
  42. function statistics_schema() {
  43. $schema['accesslog'] = array(
  44. 'description' => 'Stores site access information for statistics.',
  45. 'fields' => array(
  46. 'aid' => array(
  47. 'type' => 'serial',
  48. 'not null' => TRUE,
  49. 'description' => 'Primary Key: Unique accesslog ID.',
  50. ),
  51. 'sid' => array(
  52. 'type' => 'varchar',
  53. 'length' => 64,
  54. 'not null' => TRUE,
  55. 'default' => '',
  56. 'description' => 'Browser session ID of user that visited page.',
  57. ),
  58. 'title' => array(
  59. 'type' => 'varchar',
  60. 'length' => 255,
  61. 'not null' => FALSE,
  62. 'description' => 'Title of page visited.',
  63. ),
  64. 'path' => array(
  65. 'type' => 'varchar',
  66. 'length' => 255,
  67. 'not null' => FALSE,
  68. 'description' => 'Internal path to page visited (relative to Drupal root.)',
  69. ),
  70. 'url' => array(
  71. 'type' => 'text',
  72. 'not null' => FALSE,
  73. 'description' => 'Referrer URI.',
  74. ),
  75. 'hostname' => array(
  76. 'type' => 'varchar',
  77. 'length' => 128,
  78. 'not null' => FALSE,
  79. 'description' => 'Hostname of user that visited the page.',
  80. ),
  81. 'uid' => array(
  82. 'type' => 'int',
  83. 'unsigned' => TRUE,
  84. 'not null' => FALSE,
  85. 'default' => 0,
  86. 'description' => 'User {users}.uid that visited the page.',
  87. ),
  88. 'timer' => array(
  89. 'type' => 'int',
  90. 'unsigned' => TRUE,
  91. 'not null' => TRUE,
  92. 'default' => 0,
  93. 'description' => 'Time in milliseconds that the page took to load.',
  94. ),
  95. 'timestamp' => array(
  96. 'type' => 'int',
  97. 'unsigned' => TRUE,
  98. 'not null' => TRUE,
  99. 'default' => 0,
  100. 'description' => 'Timestamp of when the page was visited.',
  101. ),
  102. ),
  103. 'indexes' => array(
  104. 'accesslog_timestamp' => array('timestamp'),
  105. 'uid' => array('uid'),
  106. ),
  107. 'primary key' => array('aid'),
  108. );
  109. return $schema;
  110. }
  111. /**
  112. * @addtogroup updates-6.x-extra
  113. * @{
  114. */
  115. /**
  116. * Allow longer referrers.
  117. */
  118. function statistics_update_6000() {
  119. $ret = array();
  120. db_change_field($ret, 'accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE));
  121. return $ret;
  122. }
  123. /**
  124. * @} End of "addtogroup updates-6.x-extra".
  125. * The next series of updates should start at 7000.
  126. */