uc_restrict_qty.install 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @file
  4. * uc_restrict_qty module install file.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. *
  9. * @return
  10. * The schema which contains the structure for the uc_restrict_qty module's tables.
  11. */
  12. function uc_restrict_qty_schema() {
  13. $schema['uc_restrict_qty_products'] = array(
  14. 'fields' => array(
  15. 'rqpid' => array(
  16. 'type' => 'serial',
  17. 'unsigned' => TRUE,
  18. 'not null' => TRUE,
  19. ),
  20. 'pfid' => array(
  21. 'description' => t('The ID of the product feature this is attached to.'),
  22. 'type' => 'int',
  23. 'unsigned' => TRUE,
  24. 'not null' => TRUE,
  25. 'default' => 0,
  26. ),
  27. 'nid' => array(
  28. 'description' => t('The ID of the node this role feature is attached to.'),
  29. 'type' => 'int',
  30. 'unsigned' => TRUE,
  31. 'not null' => TRUE,
  32. 'default' => 0,
  33. ),
  34. 'model' => array(
  35. 'description' => t('The product model.'),
  36. 'type' => 'varchar',
  37. 'length' => 255,
  38. 'default' => NULL,
  39. ),
  40. 'qty' => array(
  41. 'description' => t('The quantity restriction.'),
  42. 'type' => 'int',
  43. 'unsigned' => TRUE,
  44. 'not null' => TRUE,
  45. 'default' => 0,
  46. ),
  47. 'lifetime' => array(
  48. 'description' => t('Is restriction lifetime?'),
  49. 'type' => 'int',
  50. 'size' => 'tiny',
  51. 'unsigned' => TRUE,
  52. 'not null' => TRUE,
  53. 'default' => 1,
  54. ),
  55. ),
  56. 'indexes' => array(
  57. 'nid' => array('nid'),
  58. 'model' => array('model')
  59. ),
  60. 'primary key' => array('rqpid'),
  61. );
  62. return $schema;
  63. }
  64. /**
  65. * Implements hook_uninstall().
  66. *
  67. * Remove the variables and schema corresponding to the uc_restrict_qty module.
  68. */
  69. function uc_restrict_qty_uninstall() {
  70. db_query("DELETE FROM {variable} WHERE name LIKE 'uc_restrict_qty_%%'");
  71. }
  72. /**
  73. * Implements hook_update_N().
  74. *
  75. * If updating from an earlier version than 6.x-2.0, the database needs to be installed.
  76. */
  77. function uc_restrict_qty_update_6200() {
  78. $ret = array();
  79. uc_restrict_qty_install();
  80. return $ret;
  81. }
  82. /**
  83. * Add lifetime value to the scheme.
  84. */
  85. function uc_restrict_qty_update_6201() {
  86. $ret = array();
  87. db_add_field($ret, 'uc_restrict_qty_products', 'lifetime', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1));
  88. return $ret;
  89. }