tripal_jbrowse_mgmt.install 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /**
  3. * Create the schema.
  4. *
  5. * @return array
  6. */
  7. function tripal_jbrowse_mgmt_schema() {
  8. $schema = [];
  9. $schema['tripal_jbrowse_mgmt_instances'] = [
  10. 'description' => 'JBrowse instances.',
  11. 'fields' => [
  12. 'id' => [
  13. 'type' => 'serial',
  14. 'description' => 'Primary key',
  15. 'not null' => TRUE,
  16. ],
  17. 'uid' => [
  18. 'type' => 'int',
  19. 'description' => 'Submitter\'s User id',
  20. 'not null' => TRUE,
  21. ],
  22. 'organism_id' => [
  23. 'type' => 'int',
  24. 'not null' => TRUE,
  25. ],
  26. 'analysis_id' => [
  27. 'type' => 'int',
  28. 'not null' => FALSE,
  29. ],
  30. 'title' => [
  31. 'type' => 'varchar',
  32. 'length' => 255,
  33. ],
  34. 'description' => [
  35. 'type' => 'text',
  36. 'not null' => FALSE,
  37. ],
  38. 'file' => [
  39. 'type' => 'text',
  40. 'not null' => FALSE,
  41. ],
  42. 'created_at' => [
  43. 'type' => 'int',
  44. 'not null' => 'true',
  45. ],
  46. ],
  47. 'primary key' => [
  48. 'id',
  49. ],
  50. ];
  51. $schema['tripal_jbrowse_mgmt_tracks'] = [
  52. 'description' => 'JBrowse tracks.',
  53. 'fields' => [
  54. 'id' => [
  55. 'type' => 'serial',
  56. 'description' => 'Primary key',
  57. 'not null' => TRUE,
  58. ],
  59. 'uid' => [
  60. 'type' => 'int',
  61. 'description' => 'Submitter\'s User id',
  62. 'not null' => TRUE,
  63. ],
  64. 'instance_id' => [
  65. 'type' => 'int',
  66. 'not null' => TRUE,
  67. ],
  68. 'organism_id' => [
  69. 'type' => 'int',
  70. 'not null' => FALSE,
  71. ],
  72. 'label' => [
  73. 'type' => 'varchar',
  74. 'length' => 255,
  75. ],
  76. 'track_type' => [
  77. 'type' => 'varchar',
  78. 'length' => 255,
  79. ],
  80. 'file_type' => [
  81. 'type' => 'varchar',
  82. 'length' => 255,
  83. ],
  84. 'file' => [
  85. 'type' => 'text',
  86. ],
  87. 'created_at' => [
  88. 'type' => 'int',
  89. 'not null' => TRUE,
  90. ],
  91. 'is_deleted' => [
  92. 'type' => 'int',
  93. 'not null' => FALSE,
  94. 'default' => 0,
  95. ],
  96. ],
  97. 'primary key' => [
  98. 'id',
  99. ],
  100. ];
  101. $schema['tripal_jbrowse_mgmt_instanceprop'] = [
  102. 'description' => 'JBrowse Instance Metadata.',
  103. 'fields' => [
  104. 'instance_id' => [
  105. 'type' => 'int',
  106. 'not null' => TRUE,
  107. ],
  108. 'property_type' => [
  109. 'type' => 'varchar',
  110. 'length' => 255,
  111. 'not null' => TRUE,
  112. ],
  113. 'value' => [
  114. 'type' => 'text',
  115. ],
  116. ]
  117. ];
  118. return $schema;
  119. }
  120. /**
  121. * Create instance metadata table.
  122. */
  123. function tripal_jbrowse_mgmt_update_7001(&$sandbox) {
  124. $schema = tripal_jbrowse_mgmt_schema();
  125. $name = "tripal_jbrowse_mgmt_instanceprop";
  126. $table = $schema[$name];
  127. db_create_table($name, $table);
  128. }
  129. /**
  130. * adding a new column analysis_id to table tripal_jbrowse_mgmt_instances
  131. */
  132. function tripal_jbrowse_mgmt_update_7002(&$sandbox){
  133. $new_col_spec = [
  134. 'type' => 'int',
  135. 'not null' => FALSE,
  136. ];
  137. $schema = Database::getConnection()->schema();
  138. $schema->addField('tripal_jbrowse_mgmt_instances', 'analysis_id', $new_col_spec);
  139. }