tripal_views_setup.install 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. function tripal_views_setup_schema(){
  3. $schema = array();
  4. $schema['tripal_views_setup'] = array(
  5. 'description' => 'contains the setupes, their materialized view id and base table name that was used.',
  6. 'fields' => array(
  7. 'setup_id' => array(
  8. 'description' => 'the id of the setup',
  9. 'type' => 'serial',
  10. 'unsigned' => TRUE,
  11. 'not null' => TRUE,
  12. ),
  13. 'mview_id' => array(
  14. 'description' => 'the materialized view used for this setup',
  15. 'type' => 'int',
  16. 'unsigned' => TRUE,
  17. ),
  18. 'base_table_name' => array(
  19. 'description' => 'the base table name to be used when using this setup',
  20. 'type' => 'varchar',
  21. 'length' => 255,
  22. 'not null' => TRUE,
  23. 'default' => '',
  24. ),
  25. 'status' => array(
  26. 'description' => 'Weather this setup will be used: 0 = inactive, 1 = active.',
  27. 'type' => 'int',
  28. 'unsigned' => TRUE,
  29. 'not null' => TRUE,
  30. 'default' => '0',
  31. ),
  32. 'name' => array(
  33. 'description' => 'Human readable name of this setup',
  34. 'type' => 'varchar',
  35. 'length' => 255,
  36. 'not null' => TRUE,
  37. 'default' => '',
  38. ),
  39. 'description' => array(
  40. 'description' => 'description of this row',
  41. 'type' => 'varchar',
  42. 'length' => 255,
  43. 'not null' => TRUE,
  44. 'default' => '',
  45. ),
  46. ),
  47. 'unique_keys' => array(
  48. 'setup_id' => array('setup_id'),
  49. ),
  50. 'primary key' => array('setup_id'),
  51. );
  52. $schema['tripal_mviews_join'] = array(
  53. 'description' => 'which materialzed views and chado tables to join in a given setup',
  54. 'fields' => array(
  55. 'setup_id' => array(
  56. 'description' => 'tripal setup id from tripal_views_setup table',
  57. 'type' => 'serial',
  58. 'unsigned' => TRUE,
  59. 'not null'=> TRUE,
  60. ),
  61. 'view_column' => array(
  62. 'description' => 'materialized view name and column',
  63. 'type' => 'varchar',
  64. 'length' => '255',
  65. 'not null' => TRUE,
  66. 'default' => '',
  67. ),
  68. 'chado_column' => array(
  69. 'description' => 'which chado table and column is to be linked up to materialized view in this serach',
  70. 'type' => 'varchar',
  71. 'length' => '255',
  72. 'not null' => TRUE,
  73. 'default' => '',
  74. ),
  75. ),
  76. 'unique_keys' => array(
  77. 'setup_id' => array('setup_id'),
  78. ),
  79. 'primary key' => array('setup_id'),
  80. );
  81. $schema['tripal_views_handlers'] = array(
  82. 'description' => 'in formation for views: column and views handler name',
  83. 'fields' => array(
  84. 'setup_id' => array(
  85. 'description' => 'which setup this is used by from tripal_views_setup table',
  86. 'type' => 'serial',
  87. 'unsigned' => TRUE,
  88. 'not null'=> TRUE,
  89. ),
  90. 'column_name' => array(
  91. 'description' => '',
  92. 'type' => 'varchar',
  93. 'length' => '255',
  94. 'not null' => TRUE,
  95. 'default' => '',
  96. ),
  97. 'handler_name' => array(
  98. 'description' => 'name of the views handler to be used for this particular setup',
  99. 'type' => 'varchar',
  100. 'length' => '255',
  101. 'not null' => TRUE,
  102. 'default' => '',
  103. ),
  104. ),
  105. );
  106. return $schema;
  107. }
  108. function tripal_views_setup_install(){
  109. drupal_install_schema('tripal_views_setup');
  110. }
  111. function tripal_views_setup_uninstall(){
  112. drupal_uninstall_schema('tripal_views_setup');
  113. }
  114. /*
  115. * NOTE: when updating schema for this module's tables
  116. * follow api of schema module, otherwise on uninstall
  117. * the tables will not be removed correctly
  118. *
  119. */