tripal_chado.chado_v1.2.inc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <?php
  2. /**
  3. * Add any custom tables needed by this module.
  4. * - Contactprop: keep track of properties of contact
  5. *
  6. * @ingroup tripal_contact
  7. */
  8. function tripal_chado_add_contactprop_table() {
  9. $schema = [
  10. 'table' => 'contactprop',
  11. 'fields' => [
  12. 'contactprop_id' => [
  13. 'type' => 'serial',
  14. 'not null' => TRUE,
  15. ],
  16. 'contact_id' => [
  17. 'type' => 'int',
  18. 'not null' => TRUE,
  19. ],
  20. 'type_id' => [
  21. 'type' => 'int',
  22. 'not null' => TRUE,
  23. ],
  24. 'value' => [
  25. 'type' => 'text',
  26. 'not null' => FALSE,
  27. ],
  28. 'rank' => [
  29. 'type' => 'int',
  30. 'not null' => TRUE,
  31. 'default' => 0,
  32. ],
  33. ],
  34. 'primary key' => [
  35. 0 => 'contactprop_id',
  36. ],
  37. 'unique keys' => [
  38. 'contactprop_c1' => [
  39. 0 => 'contact_id',
  40. 1 => 'type_id',
  41. 2 => 'rank',
  42. ],
  43. ],
  44. 'indexes' => [
  45. 'contactprop_idx1' => [
  46. 0 => 'contact_id',
  47. ],
  48. 'contactprop_idx2' => [
  49. 0 => 'type_id',
  50. ],
  51. ],
  52. 'foreign keys' => [
  53. 'cvterm' => [
  54. 'table' => 'cvterm',
  55. 'columns' => [
  56. 'type_id' => 'cvterm_id',
  57. ],
  58. ],
  59. 'contact' => [
  60. 'table' => 'contact',
  61. 'columns' => [
  62. 'contact_id' => 'contact_id',
  63. ],
  64. ],
  65. ],
  66. ];
  67. chado_create_custom_table('contactprop', $schema, TRUE, NULL, FALSE);
  68. }
  69. /**
  70. * Adds the featuremap_dbxref table to Chado v1.2.
  71. */
  72. function tripal_chado_add_featuremap_dbxref_table() {
  73. // add the featuremap_dbxref table to Chado
  74. $schema = [
  75. 'table' => 'featuremap_dbxref',
  76. 'fields' => [
  77. 'featuremap_dbxref_id' => [
  78. 'type' => 'serial',
  79. 'not null' => TRUE,
  80. ],
  81. 'featuremap_id' => [
  82. 'type' => 'int',
  83. 'not null' => TRUE,
  84. ],
  85. 'dbxref_id' => [
  86. 'type' => 'int',
  87. 'not null' => TRUE,
  88. ],
  89. 'is_current' => [
  90. 'type' => 'int',
  91. 'size' => 'tiny',
  92. 'not null' => TRUE,
  93. 'default' => 1,
  94. ],
  95. ],
  96. 'primary key' => [
  97. 0 => 'featuremap_dbxref_id',
  98. ],
  99. 'unique keys' => [
  100. 'featuremap_dbxref_c1' => [
  101. 0 => 'featuremap_id',
  102. 1 => 'dbxref_id',
  103. ],
  104. ],
  105. 'indexes' => [
  106. 'featuremap_dbxref_idx1' => [
  107. 0 => 'featuremap_dbxref_id',
  108. ],
  109. 'featuremap_dbxref_idx2' => [
  110. 0 => 'dbxref_id',
  111. ],
  112. ],
  113. 'foreign keys' => [
  114. 'dbxref' => [
  115. 'table' => 'dbxref',
  116. 'columns' => [
  117. 'dbxref_id' => 'dbxref_id',
  118. ],
  119. ],
  120. 'featuremap' => [
  121. 'table' => 'featuremap',
  122. 'columns' => [
  123. 'featuremap_id' => 'featuremap_id',
  124. ],
  125. ],
  126. ],
  127. 'referring_tables' => NULL,
  128. ];
  129. chado_create_custom_table('featuremap_dbxref', $schema, TRUE, NULL, FALSE);
  130. }
  131. /**
  132. * Add custom tables needed by the feature map module
  133. * - featuremapprop
  134. * - featuremap_dbxref
  135. * - featureposprop
  136. *
  137. * @ingroup tripal_featuremap
  138. */
  139. function tripal_chado_add_featuremapprop_table() {
  140. // add the featuremaprop table to Chado
  141. $schema = [
  142. 'table' => 'featuremapprop',
  143. 'fields' => [
  144. 'featuremapprop_id' => [
  145. 'type' => 'serial',
  146. 'not null' => TRUE,
  147. ],
  148. 'featuremap_id' => [
  149. 'type' => 'int',
  150. 'not null' => TRUE,
  151. ],
  152. 'type_id' => [
  153. 'type' => 'int',
  154. 'not null' => TRUE,
  155. ],
  156. 'value' => [
  157. 'type' => 'text',
  158. 'not null' => FALSE,
  159. ],
  160. 'rank' => [
  161. 'type' => 'int',
  162. 'not null' => TRUE,
  163. 'default' => 0,
  164. ],
  165. ],
  166. 'primary key' => [
  167. 0 => 'featuremapprop_id',
  168. ],
  169. 'unique keys' => [
  170. 'featuremapprop_c1' => [
  171. 0 => 'featuremap_id',
  172. 1 => 'type_id',
  173. 2 => 'rank',
  174. ],
  175. ],
  176. 'indexes' => [
  177. 'featuremapprop_idx1' => [
  178. 0 => 'featuremap_id',
  179. ],
  180. 'featuremapprop_idx2' => [
  181. 0 => 'type_id',
  182. ],
  183. ],
  184. 'foreign keys' => [
  185. 'cvterm' => [
  186. 'table' => 'cvterm',
  187. 'columns' => [
  188. 'type_id' => 'cvterm_id',
  189. ],
  190. ],
  191. 'featuremap' => [
  192. 'table' => 'featuremap',
  193. 'columns' => [
  194. 'featuremap_id' => 'featuremap_id',
  195. ],
  196. ],
  197. ],
  198. ];
  199. chado_create_custom_table('featuremapprop', $schema, TRUE, NULL, FALSE);
  200. }
  201. /**
  202. *
  203. */
  204. function tripal_chado_add_featureposprop_table() {
  205. $schema = [
  206. 'table' => 'featureposprop',
  207. 'fields' => [
  208. 'featureposprop_id' => [
  209. 'type' => 'serial',
  210. 'not null' => TRUE,
  211. ],
  212. 'featurepos_id' => [
  213. 'type' => 'int',
  214. 'not null' => TRUE,
  215. ],
  216. 'type_id' => [
  217. 'type' => 'int',
  218. 'not null' => TRUE,
  219. ],
  220. 'value' => [
  221. 'type' => 'text',
  222. 'not null' => FALSE,
  223. ],
  224. 'rank' => [
  225. 'type' => 'int',
  226. 'not null' => TRUE,
  227. 'default' => 0,
  228. ],
  229. ],
  230. 'primary key' => [
  231. 0 => 'featureposprop_id',
  232. ],
  233. 'unique keys' => [
  234. 'featureposprop_id' => [
  235. 0 => 'featurepos_id',
  236. 1 => 'type_id',
  237. 2 => 'rank',
  238. ],
  239. ],
  240. 'indexes' => [
  241. 'featureposprop_c1' => [
  242. 0 => 'featurepos_id',
  243. ],
  244. 'featureposprop_idx2' => [
  245. 0 => 'type_id',
  246. ],
  247. ],
  248. 'foreign keys' => [
  249. 'cvterm' => [
  250. 'table' => 'cvterm',
  251. 'columns' => [
  252. 'type_id' => 'cvterm_id',
  253. ],
  254. ],
  255. 'featurepos' => [
  256. 'table' => 'featurepos',
  257. 'columns' => [
  258. 'featurepos_id' => 'featurepos_id',
  259. ],
  260. ],
  261. ],
  262. ];
  263. chado_create_custom_table('featureposprop', $schema, TRUE, NULL, FALSE);
  264. }
  265. /**
  266. * Add custom table related to publications
  267. * - pubauthor_contact
  268. *
  269. * @ingroup tripal_pub
  270. */
  271. function tripal_chado_add_pubauthor_contact_table() {
  272. $schema = [
  273. 'table' => 'pubauthor_contact',
  274. 'fields' => [
  275. 'pubauthor_contact_id' => [
  276. 'type' => 'serial',
  277. 'not null' => TRUE,
  278. ],
  279. 'contact_id' => [
  280. 'type' => 'int',
  281. 'not null' => TRUE,
  282. ],
  283. 'pubauthor_id' => [
  284. 'type' => 'int',
  285. 'not null' => TRUE,
  286. ],
  287. ],
  288. 'primary key' => [
  289. 0 => 'pubauthor_contact_id',
  290. ],
  291. 'unique keys' => [
  292. 'pubauthor_contact_c1' => [
  293. 0 => 'contact_id',
  294. 1 => 'pubauthor_id',
  295. ],
  296. ],
  297. 'foreign keys' => [
  298. 'contact' => [
  299. 'table' => 'contact',
  300. 'columns' => [
  301. 'contact_id' => 'contact_id',
  302. ],
  303. ],
  304. 'pubauthor' => [
  305. 'table' => 'pubauthor',
  306. 'columns' => [
  307. 'pubauthor_id' => 'pubauthor_id',
  308. ],
  309. ],
  310. ],
  311. ];
  312. chado_create_custom_table('pubauthor_contact', $schema, TRUE, NULL, FALSE);
  313. }