uc_quote.install 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the uc_quote module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function uc_quote_schema() {
  10. $schema = array();
  11. $schema['uc_quote_shipping_types'] = array(
  12. 'description' => 'Stores shipping information of products.',
  13. 'fields' => array(
  14. 'id_type' => array(
  15. 'description' => 'Determines the table that id references. "product" => {uc_products}.nid.',
  16. 'type' => 'varchar',
  17. 'length' => 127,
  18. 'not null' => TRUE,
  19. 'default' => '',
  20. ),
  21. 'id' => array(
  22. 'description' => 'The entity ID.',
  23. 'type' => 'int',
  24. 'unsigned' => TRUE,
  25. 'not null' => TRUE,
  26. 'default' => 0,
  27. ),
  28. 'shipping_type' => array(
  29. 'description' => 'The basic type of shipment, e.g.: small package, freight.',
  30. 'type' => 'varchar',
  31. 'length' => 64,
  32. 'not null' => TRUE,
  33. 'default' => '',
  34. ),
  35. ),
  36. 'primary key' => array('id_type', 'id'),
  37. );
  38. $schema['uc_quote_product_locations'] = array(
  39. 'description' => 'Stores default product origin addresses.',
  40. 'fields' => array(
  41. 'nid' => array(
  42. 'description' => 'The {uc_products}.nid.',
  43. 'type' => 'int',
  44. 'unsigned' => TRUE,
  45. 'not null' => TRUE,
  46. 'default' => 0,
  47. ),
  48. 'first_name' => array(
  49. 'description' => 'The address first name.',
  50. 'type' => 'varchar',
  51. 'length' => 255,
  52. 'not null' => TRUE,
  53. 'default' => '',
  54. ),
  55. 'last_name' => array(
  56. 'description' => 'The address last name.',
  57. 'type' => 'varchar',
  58. 'length' => 255,
  59. 'not null' => TRUE,
  60. 'default' => '',
  61. ),
  62. 'company' => array(
  63. 'description' => 'The address company.',
  64. 'type' => 'varchar',
  65. 'length' => 255,
  66. 'not null' => TRUE,
  67. 'default' => '',
  68. ),
  69. 'street1' => array(
  70. 'description' => 'The address street line 1.',
  71. 'type' => 'varchar',
  72. 'length' => 255,
  73. 'not null' => TRUE,
  74. 'default' => '',
  75. ),
  76. 'street2' => array(
  77. 'description' => 'The address street line 2.',
  78. 'type' => 'varchar',
  79. 'length' => 255,
  80. 'not null' => TRUE,
  81. 'default' => '',
  82. ),
  83. 'city' => array(
  84. 'description' => 'The address city.',
  85. 'type' => 'varchar',
  86. 'length' => 255,
  87. 'not null' => TRUE,
  88. 'default' => '',
  89. ),
  90. 'zone' => array(
  91. 'description' => 'The address state/province, from {uc_zones}.zone_id.',
  92. 'type' => 'int',
  93. 'unsigned' => TRUE,
  94. 'not null' => TRUE,
  95. 'default' => 0,
  96. ),
  97. 'postal_code' => array(
  98. 'description' => 'The address postal code.',
  99. 'type' => 'varchar',
  100. 'length' => 255,
  101. 'not null' => TRUE,
  102. 'default' => '',
  103. ),
  104. 'country' => array(
  105. 'description' => 'The address country, from {uc_countries}.country_id.',
  106. 'type' => 'int',
  107. 'unsigned' => TRUE,
  108. 'not null' => TRUE,
  109. 'default' => 0,
  110. ),
  111. 'phone' => array(
  112. 'description' => 'The address phone number.',
  113. 'type' => 'varchar',
  114. 'length' => 255,
  115. 'not null' => TRUE,
  116. 'default' => '',
  117. ),
  118. ),
  119. 'primary key' => array('nid'),
  120. 'foreign keys' => array(
  121. 'uc_products' => array(
  122. 'table' => 'uc_products',
  123. 'columns' => array('nid' => 'nid'),
  124. ),
  125. ),
  126. );
  127. $schema['uc_order_quotes'] = array(
  128. 'description' => 'Stores shipping quotes.',
  129. 'fields' => array(
  130. 'order_id' => array(
  131. 'description' => 'The {uc_orders}.order_id.',
  132. 'type' => 'int',
  133. 'unsigned' => TRUE,
  134. 'not null' => TRUE,
  135. 'default' => 0,
  136. ),
  137. 'method' => array(
  138. 'description' => 'The quoted shipping method.',
  139. 'type' => 'varchar',
  140. 'length' => 25,
  141. 'not null' => TRUE,
  142. 'default' => '',
  143. ),
  144. 'accessorials' => array(
  145. 'description' => 'Additional services or special instructions.',
  146. 'type' => 'varchar',
  147. 'length' => 255,
  148. 'not null' => TRUE,
  149. 'default' => '',
  150. ),
  151. 'rate' => array(
  152. 'description' => 'The quoted shipping rate.',
  153. 'type' => 'numeric',
  154. 'precision' => 16,
  155. 'scale' => 5,
  156. 'not null' => TRUE,
  157. 'default' => 0,
  158. ),
  159. ),
  160. 'primary key' => array('order_id'),
  161. 'unique keys' => array(
  162. 'order_id_quote_method' => array('order_id', 'method'),
  163. ),
  164. 'foreign keys' => array(
  165. 'uc_orders' => array(
  166. 'table' => 'uc_orders',
  167. 'columns' => array('order_id' => 'order_id'),
  168. ),
  169. ),
  170. );
  171. return $schema;
  172. }
  173. /**
  174. * Implements hook_uninstall().
  175. */
  176. function uc_quote_uninstall() {
  177. db_delete('variable')
  178. ->condition('name', 'uc_quote_%', 'LIKE')
  179. ->execute();
  180. variable_del('uc_store_shipping_type');
  181. }
  182. /**
  183. * Implements hook_update_last_removed().
  184. */
  185. function uc_quote_update_last_removed() {
  186. return 6004;
  187. }
  188. /**
  189. * Drops {uc_order_quotes}.quote_form.
  190. */
  191. function uc_quote_update_7001() {
  192. db_drop_field('uc_order_quotes', 'quote_form');
  193. }