progress.install 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * @file
  4. *
  5. * Installation file for the Progress module
  6. *
  7. */
  8. function progress_schema() {
  9. $schema = array();
  10. $schema['progress'] = array(
  11. 'description' => 'Progress',
  12. 'fields' => array(
  13. 'name' => array(
  14. 'description' => 'Name of progress',
  15. 'type' => 'varchar',
  16. 'length' => 255,
  17. 'not null' => TRUE,
  18. 'default' => '',
  19. ),
  20. 'progress' => array(
  21. 'description' => 'Progress status',
  22. 'type' => 'float',
  23. 'size' => 'big',
  24. 'not null' => TRUE,
  25. 'default' => 0,
  26. ),
  27. 'message' => array(
  28. 'description' => 'Message for current progress',
  29. 'type' => 'text',
  30. 'not null' => TRUE,
  31. ),
  32. 'start_stamp' => array(
  33. 'description' => 'Start time in unix timestamp',
  34. 'type' => 'float',
  35. 'size' => 'big',
  36. 'not null' => TRUE,
  37. 'default' => 0,
  38. ),
  39. 'end_stamp' => array(
  40. 'description' => 'End time in unix timestamp',
  41. 'type' => 'float',
  42. 'size' => 'big',
  43. 'not null' => TRUE,
  44. 'default' => 0,
  45. ),
  46. 'current_stamp' => array(
  47. 'description' => 'Current time in unix timestamp',
  48. 'type' => 'float',
  49. 'size' => 'big',
  50. 'not null' => TRUE,
  51. 'default' => 0,
  52. ),
  53. ),
  54. 'primary key' => array('name'),
  55. );
  56. return $schema;
  57. }
  58. /**
  59. * Major version upgrade of Drupal
  60. */
  61. function progress_update_7000(&$context) {
  62. $schema_version = db_query("SELECT schema_version FROM {system} WHERE name = 'progress'")->fetchField();
  63. if ($schema_version > 0 && $schema_version < 7000) {
  64. $context['sandbox']['major_version_upgrade'] = array(
  65. 7101 => TRUE,
  66. );
  67. }
  68. }
  69. /**
  70. * Change schema to SQL 99 compliance
  71. */
  72. function progress_update_7101(&$context) {
  73. if (!empty($context['sandbox']['major_version_upgrade'][7101])) {
  74. // This udate is already part of latest 6.x
  75. return;
  76. }
  77. db_change_field('progress', 'start', 'start_stamp', array(
  78. 'description' => 'Start time in unix timestamp',
  79. 'type' => 'float',
  80. 'size' => 'big',
  81. 'not null' => TRUE,
  82. 'default' => 0
  83. ));
  84. db_change_field('progress', 'end', 'end_stamp', array(
  85. 'description' => 'End time in unix timestamp',
  86. 'type' => 'float',
  87. 'size' => 'big',
  88. 'not null' => TRUE,
  89. 'default' => 0
  90. ));
  91. db_change_field('progress', 'current', 'current_stamp', array(
  92. 'description' => 'Current time in unix timestamp',
  93. 'type' => 'float',
  94. 'size' => 'big',
  95. 'not null' => TRUE,
  96. 'default' => 0
  97. ));
  98. }