tripal_chado.chado_v1.2.inc 7.2 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 = array (
  10. 'table' => 'contactprop',
  11. 'fields' => array (
  12. 'contactprop_id' => array (
  13. 'type' => 'serial',
  14. 'not null' => true,
  15. ),
  16. 'contact_id' => array (
  17. 'type' => 'int',
  18. 'not null' => true,
  19. ),
  20. 'type_id' => array (
  21. 'type' => 'int',
  22. 'not null' => true,
  23. ),
  24. 'value' => array (
  25. 'type' => 'text',
  26. 'not null' => false,
  27. ),
  28. 'rank' => array (
  29. 'type' => 'int',
  30. 'not null' => true,
  31. 'default' => 0,
  32. ),
  33. ),
  34. 'primary key' => array (
  35. 0 => 'contactprop_id',
  36. ),
  37. 'unique keys' => array (
  38. 'contactprop_c1' => array (
  39. 0 => 'contact_id',
  40. 1 => 'type_id',
  41. 2 => 'rank',
  42. ),
  43. ),
  44. 'indexes' => array (
  45. 'contactprop_idx1' => array (
  46. 0 => 'contact_id',
  47. ),
  48. 'contactprop_idx2' => array (
  49. 0 => 'type_id',
  50. ),
  51. ),
  52. 'foreign keys' => array (
  53. 'cvterm' => array (
  54. 'table' => 'cvterm',
  55. 'columns' => array (
  56. 'type_id' => 'cvterm_id',
  57. ),
  58. ),
  59. 'contact' => array (
  60. 'table' => 'contact',
  61. 'columns' => array (
  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 = array (
  75. 'table' => 'featuremap_dbxref',
  76. 'fields' => array (
  77. 'featuremap_dbxref_id' => array (
  78. 'type' => 'serial',
  79. 'not null' => true,
  80. ),
  81. 'featuremap_id' => array (
  82. 'type' => 'int',
  83. 'not null' => true,
  84. ),
  85. 'dbxref_id' => array (
  86. 'type' => 'int',
  87. 'not null' => true,
  88. ),
  89. 'is_current' => array (
  90. 'type' => 'int',
  91. 'size' => 'tiny',
  92. 'not null' => true,
  93. 'default' => 1,
  94. ),
  95. ),
  96. 'primary key' => array (
  97. 0 => 'featuremap_dbxref_id',
  98. ),
  99. 'unique keys' => array (
  100. 'featuremap_dbxref_c1' => array (
  101. 0 => 'featuremap_id',
  102. 1 => 'dbxref_id',
  103. ),
  104. ),
  105. 'indexes' => array (
  106. 'featuremap_dbxref_idx1' => array (
  107. 0 => 'featuremap_dbxref_id',
  108. ),
  109. 'featuremap_dbxref_idx2' => array (
  110. 0 => 'dbxref_id',
  111. ),
  112. ),
  113. 'foreign keys' => array (
  114. 'dbxref' => array (
  115. 'table' => 'dbxref',
  116. 'columns' => array (
  117. 'dbxref_id' => 'dbxref_id',
  118. ),
  119. ),
  120. 'featuremap' => array (
  121. 'table' => 'featuremap',
  122. 'columns' => array (
  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 = array (
  142. 'table' => 'featuremapprop',
  143. 'fields' => array (
  144. 'featuremapprop_id' => array (
  145. 'type' => 'serial',
  146. 'not null' => true,
  147. ),
  148. 'featuremap_id' => array (
  149. 'type' => 'int',
  150. 'not null' => true,
  151. ),
  152. 'type_id' => array (
  153. 'type' => 'int',
  154. 'not null' => true,
  155. ),
  156. 'value' => array (
  157. 'type' => 'text',
  158. 'not null' => false,
  159. ),
  160. 'rank' => array (
  161. 'type' => 'int',
  162. 'not null' => true,
  163. 'default' => 0,
  164. ),
  165. ),
  166. 'primary key' => array (
  167. 0 => 'featuremapprop_id',
  168. ),
  169. 'unique keys' => array (
  170. 'featuremapprop_c1' => array (
  171. 0 => 'featuremap_id',
  172. 1 => 'type_id',
  173. 2 => 'rank',
  174. ),
  175. ),
  176. 'indexes' => array (
  177. 'featuremapprop_idx1' => array (
  178. 0 => 'featuremap_id',
  179. ),
  180. 'featuremapprop_idx2' => array (
  181. 0 => 'type_id',
  182. ),
  183. ),
  184. 'foreign keys' => array (
  185. 'cvterm' => array (
  186. 'table' => 'cvterm',
  187. 'columns' => array (
  188. 'type_id' => 'cvterm_id',
  189. ),
  190. ),
  191. 'featuremap' => array (
  192. 'table' => 'featuremap',
  193. 'columns' => array (
  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 = array (
  206. 'table' => 'featureposprop',
  207. 'fields' => array (
  208. 'featureposprop_id' => array (
  209. 'type' => 'serial',
  210. 'not null' => true,
  211. ),
  212. 'featurepos_id' => array (
  213. 'type' => 'int',
  214. 'not null' => true,
  215. ),
  216. 'type_id' => array (
  217. 'type' => 'int',
  218. 'not null' => true,
  219. ),
  220. 'value' => array (
  221. 'type' => 'text',
  222. 'not null' => false,
  223. ),
  224. 'rank' => array (
  225. 'type' => 'int',
  226. 'not null' => true,
  227. 'default' => 0,
  228. ),
  229. ),
  230. 'primary key' => array (
  231. 0 => 'featureposprop_id',
  232. ),
  233. 'unique keys' => array (
  234. 'featureposprop_id' => array (
  235. 0 => 'featurepos_id',
  236. 1 => 'type_id',
  237. 2 => 'rank',
  238. ),
  239. ),
  240. 'indexes' => array (
  241. 'featureposprop_c1' => array (
  242. 0 => 'featurepos_id',
  243. ),
  244. 'featureposprop_idx2' => array (
  245. 0 => 'type_id',
  246. ),
  247. ),
  248. 'foreign keys' => array (
  249. 'cvterm' => array (
  250. 'table' => 'cvterm',
  251. 'columns' => array (
  252. 'type_id' => 'cvterm_id',
  253. ),
  254. ),
  255. 'featurepos' => array (
  256. 'table' => 'featurepos',
  257. 'columns' => array (
  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 = array (
  273. 'table' => 'pubauthor_contact',
  274. 'fields' => array (
  275. 'pubauthor_contact_id' => array (
  276. 'type' => 'serial',
  277. 'not null' => true,
  278. ),
  279. 'contact_id' => array (
  280. 'type' => 'int',
  281. 'not null' => true,
  282. ),
  283. 'pubauthor_id' => array (
  284. 'type' => 'int',
  285. 'not null' => true,
  286. ),
  287. ),
  288. 'primary key' => array (
  289. 0 => 'pubauthor_contact_id',
  290. ),
  291. 'unique keys' => array (
  292. 'pubauthor_contact_c1' => array (
  293. 0 => 'contact_id',
  294. 1 => 'pubauthor_id',
  295. ),
  296. ),
  297. 'foreign keys' => array (
  298. 'contact' => array (
  299. 'table' => 'contact',
  300. 'columns' => array (
  301. 'contact_id' => 'contact_id',
  302. ),
  303. ),
  304. 'pubauthor' => array (
  305. 'table' => 'pubauthor',
  306. 'columns' => array (
  307. 'pubauthor_id' => 'pubauthor_id',
  308. ),
  309. ),
  310. ),
  311. );
  312. chado_create_custom_table('pubauthor_contact', $schema, TRUE, NULL, FALSE);
  313. }