uc_restrict_qty.install 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }