tripal_views.install 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. /************************************************************************
  3. * Implementation of hook_install();
  4. *
  5. * @ingroup tripal_views
  6. */
  7. function tripal_views_install(){
  8. // create the module's data directory
  9. tripal_create_moddir('tripal_views');
  10. // create the tables that manage materialized views and jobs
  11. drupal_install_schema('tripal_views');
  12. }
  13. /************************************************************************
  14. * Implementation of hook_schema().
  15. *
  16. * @ingroup tripal_views
  17. */
  18. function tripal_views_schema() {
  19. $schema = tripal_views_get_schemas();
  20. return $schema;
  21. }
  22. /************************************************************************
  23. * Implementation of hook_uninstall()
  24. *
  25. * @ingroup tripal_views
  26. */
  27. function tripal_views_uninstall(){
  28. drupal_uninstall_schema('tripal_views');
  29. }
  30. /************************************************************************
  31. * This function simply defines all tables needed for the module to work
  32. * correctly. By putting the table definitions in a separate function we
  33. * can easily provide the entire list for hook_install or individual
  34. * tables for an update.
  35. *
  36. * @ingroup tripal_views
  37. */
  38. function tripal_views_get_schemas (){
  39. $schema = array();
  40. $temp = tripal_views_views_schema();
  41. foreach ($temp as $table => $arr){
  42. $schema[$table] = $arr;
  43. }
  44. return $schema;
  45. }
  46. /************************************************************************
  47. *
  48. *
  49. * @ingroup tripal_views
  50. */
  51. function tripal_views_views_schema(){
  52. $schema = array();
  53. $schema['tripal_views'] = array(
  54. 'description' => 'contains the setupes, their materialized view id and base table name that was used.',
  55. 'fields' => array(
  56. 'setup_id' => array(
  57. 'description' => 'the id of the setup',
  58. 'type' => 'serial',
  59. 'unsigned' => TRUE,
  60. 'not null' => TRUE,
  61. ),
  62. 'mview_id' => array(
  63. 'description' => 'the materialized view used for this setup',
  64. 'type' => 'int',
  65. 'unsigned' => TRUE,
  66. ),
  67. 'table_name' => array(
  68. 'description' => 'the base table name to be used when using this setup. Use this field when not using a materialized view',
  69. 'type' => 'varchar',
  70. 'length' => 255,
  71. 'not null' => TRUE,
  72. 'default' => '',
  73. ),
  74. 'name' => array(
  75. 'description' => 'Human readable name of this setup',
  76. 'type' => 'varchar',
  77. 'length' => 255,
  78. 'not null' => TRUE,
  79. 'default' => '',
  80. ),
  81. 'comment' => array(
  82. 'description' => 'add notes about this views setup',
  83. 'type' => 'text',
  84. 'size' => 'normal',
  85. 'not null' => FALSE,
  86. 'default' => '',
  87. ),
  88. ),
  89. 'unique_keys' => array(
  90. 'setup_id' => array('setup_id'),
  91. ),
  92. 'primary key' => array('setup_id'),
  93. );
  94. $schema['tripal_views_join'] = array(
  95. 'description' => 'coordinate the joining of tables',
  96. 'fields' => array(
  97. 'view_join_id' => array(
  98. 'description' => 'the id of the join',
  99. 'type' => 'serial',
  100. 'unsigned' => TRUE,
  101. 'not null' => TRUE,
  102. ),
  103. 'setup_id' => array(
  104. 'description' => 'setup id from tripal_views table',
  105. 'type' => 'int',
  106. 'unsigned' => TRUE,
  107. 'not null'=> TRUE,
  108. ),
  109. 'base_table' => array(
  110. 'description' => 'the name of the base table',
  111. 'type' => 'varchar',
  112. 'length' => '255',
  113. 'not null' => TRUE,
  114. 'default' => '',
  115. ),
  116. 'base_field' => array(
  117. 'description' => 'the name of the base table column that will be joined',
  118. 'type' => 'varchar',
  119. 'length' => '255',
  120. 'not null' => TRUE,
  121. 'default' => '',
  122. ),
  123. 'left_table' => array(
  124. 'description' => 'the table on which to perform a left join',
  125. 'type' => 'varchar',
  126. 'length' => '255',
  127. 'not null' => TRUE,
  128. 'default' => '',
  129. ),
  130. 'left_field' => array(
  131. 'description' => 'the column on which to perform a left join',
  132. 'type' => 'varchar',
  133. 'length' => '255',
  134. 'not null' => TRUE,
  135. 'default' => '',
  136. ),
  137. ),
  138. 'unique_keys' => array(
  139. 'setup_id' => array('view_join_id'),
  140. ),
  141. 'primary key' => array('view_join_id'),
  142. );
  143. $schema['tripal_views_handlers'] = array(
  144. 'description' => 'in formation for views: column and views handler name',
  145. 'fields' => array(
  146. 'handler_id' => array(
  147. 'description' => 'the id of the handler',
  148. 'type' => 'serial',
  149. 'unsigned' => TRUE,
  150. 'not null' => TRUE,
  151. ),
  152. 'setup_id' => array(
  153. 'description' => 'setup id from the tripal_views table',
  154. 'type' => 'int',
  155. 'unsigned' => TRUE,
  156. 'not null'=> TRUE,
  157. ),
  158. 'column_name' => array(
  159. 'description' => '',
  160. 'type' => 'varchar',
  161. 'length' => '255',
  162. 'not null' => TRUE,
  163. 'default' => '',
  164. ),
  165. 'handler_type' => array(
  166. 'description' => 'identifies the type of hander (e.g. field, filter, sort, argument, relationship, etc.)',
  167. 'type' => 'varchar',
  168. 'length' => '50',
  169. 'not null' => TRUE,
  170. 'default' => '',
  171. ),
  172. 'handler_name' => array(
  173. 'description' => 'the name of the handler',
  174. 'type' => 'varchar',
  175. 'length' => '255',
  176. 'not null' => TRUE,
  177. 'default' => '',
  178. ),
  179. 'arguments' => array(
  180. 'description' => 'arguments that may get passed to the handler',
  181. 'type' => 'text',
  182. 'size' => 'normal',
  183. 'not null' => FALSE,
  184. 'default' => '',
  185. ),
  186. ),
  187. 'unique_keys' => array(
  188. 'setup_id' => array('handler_id'),
  189. ),
  190. 'primary key' => array('handler_id'),
  191. );
  192. return $schema;
  193. }
  194. ?>