uc_coupon.install 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /**
  3. * @file
  4. * Ubercart uc_coupon.module schema
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function uc_coupon_schema() {
  10. $schema = array();
  11. $schema['uc_coupons'] = array(
  12. 'description' => 'Ubercart Coupons',
  13. 'fields' => array(
  14. 'cid' => array(
  15. 'type' => 'serial',
  16. 'unsigned' => TRUE,
  17. 'not null' => TRUE,
  18. ),
  19. 'name' => array(
  20. 'type' => 'varchar',
  21. 'length' => 255,
  22. 'not null' => TRUE,
  23. 'default' => '',
  24. 'description' => 'The coupon name',
  25. ),
  26. 'code' => array(
  27. 'type' => 'varchar',
  28. 'length' => 100,
  29. 'not null' => TRUE,
  30. 'default' => '',
  31. 'description' => 'The coupon code (or base code for bulk coupons)',
  32. ),
  33. 'value' => array(
  34. 'type' => 'numeric',
  35. 'precision' => 10,
  36. 'scale' => 2,
  37. 'not null' => TRUE,
  38. 'default' => 0,
  39. 'description' => 'The value of the coupon as currency or percent',
  40. ),
  41. 'type' => array(
  42. 'type' => 'varchar',
  43. 'length' => '12',
  44. 'not null' => TRUE,
  45. 'default' => 'price',
  46. 'description' => 'The type of the coupon (price, percent, set_price or store credit)',
  47. ),
  48. 'status' => array(
  49. 'type' => 'int',
  50. 'size' => 'tiny',
  51. 'not null' => TRUE,
  52. 'default' => 1,
  53. 'description' => 'Whether or not the coupon is active',
  54. ),
  55. 'valid_from' => array(
  56. 'type' => 'int',
  57. 'description' => 'The date from which the coupon is valid',
  58. ),
  59. 'valid_until' => array(
  60. 'type' => 'int',
  61. 'description' => 'The date until which the coupon is valid',
  62. ),
  63. 'max_uses' => array(
  64. 'type' => 'int',
  65. 'size' => 'small',
  66. 'not null' => TRUE,
  67. 'default' => 0,
  68. 'description' => 'The maximum number of uses allowed for this coupon',
  69. ),
  70. 'minimum_order' => array(
  71. 'type' => 'numeric',
  72. 'precision' => 10,
  73. 'scale' => 2,
  74. 'not null' => TRUE,
  75. 'default' => 0,
  76. 'description' => 'The minimum order value to which this coupon will apply',
  77. ),
  78. 'data' => array(
  79. 'type' => 'text',
  80. 'serialize' => TRUE,
  81. ),
  82. 'bulk' => array(
  83. 'type' => 'int',
  84. 'size' => 'tiny',
  85. 'not null' => TRUE,
  86. 'default' => 0,
  87. 'description' => 'Whether or not this is a bulk coupon',
  88. ),
  89. 'bulk_seed' => array(
  90. 'type' => 'char',
  91. 'length' => 32,
  92. 'not null' => TRUE,
  93. 'default' => '',
  94. 'description' => 'The unique seed used to genrerate bulk coupon codes',
  95. ),
  96. 'created' => array(
  97. 'type' => 'int',
  98. 'not null' => TRUE,
  99. 'default' => 0,
  100. 'description' => 'The date when this coupon was created',
  101. ),
  102. ),
  103. 'primary key' => array('cid'),
  104. );
  105. $schema['uc_coupons_orders'] = array(
  106. 'description' => 'Ubercart Coupons used on Orders',
  107. 'fields' => array(
  108. 'cuid' => array(
  109. 'type' => 'serial',
  110. 'unsigned' => TRUE,
  111. 'not null' => TRUE,
  112. ),
  113. 'cid' => array(
  114. 'type' => 'int',
  115. 'unsigned' => TRUE,
  116. 'not null' => TRUE,
  117. 'default' => 0,
  118. ),
  119. 'oid' => array(
  120. 'type' => 'int',
  121. 'unsigned' => TRUE,
  122. 'not null' => TRUE,
  123. 'default' => 0,
  124. ),
  125. 'value' => array(
  126. 'type' => 'numeric',
  127. 'precision' => 10,
  128. 'scale' => 2,
  129. 'not null' => TRUE,
  130. 'default' => 0,
  131. ),
  132. 'code' => array(
  133. 'type' => 'varchar',
  134. 'length' => 100,
  135. 'not null' => TRUE,
  136. 'default' => '',
  137. ),
  138. ),
  139. 'primary key' => array('cuid'),
  140. );
  141. return $schema;
  142. }
  143. /**
  144. * Implements hook_uninstall().
  145. */
  146. function uc_coupon_uninstall() {
  147. variable_del('uc_coupon_collapse_pane');
  148. variable_del('uc_coupon_default_usage');
  149. variable_del('uc_coupon_pane_description');
  150. variable_del('uc_coupon_purchase_order_status');
  151. variable_del('uc_coupon_querystring');
  152. variable_del('uc_coupon_show_in_cart');
  153. variable_del('uc_coupon_line_item_format');
  154. variable_del('uc_coupon_line_item_weight');
  155. variable_del('uc_coupon_form_components');
  156. variable_del('uc_coupon_allow_multiple');
  157. variable_del('uc_coupon_used_order_status');
  158. }
  159. /**
  160. * Implements hook_update_last_removed().
  161. *
  162. */
  163. function uc_coupon_update_last_removed() {
  164. return 6006;
  165. }