tripal.install 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. <?php
  2. /**
  3. * @file
  4. * Contains functions used to install/uninstall tripal.
  5. */
  6. /**
  7. * Implementation of hook_install().
  8. *
  9. * @ingroup tripal
  10. */
  11. function tripal_install() {
  12. // On upgrade from Tv2 to Tv3 we need to add a new field to the tripal_jobs
  13. // table it's missing.
  14. if (!db_field_exists('tripal_jobs', 'includes')) {
  15. db_add_field('tripal_jobs', 'includes', array(
  16. 'type' => 'text',
  17. 'description' => 'A serialized array of file paths that should be included prior to executing the job.',
  18. 'not NULL' => FALSE,
  19. ));
  20. }
  21. }
  22. /**
  23. * Adds variables for bundles.
  24. */
  25. function tripal_add_variables() {
  26. // Add tripal bundle variables needed for storing additional settings for
  27. // Tripal Bundles.
  28. tripal_insert_variable(
  29. 'title_format',
  30. 'A pattern including tokens that can be used to generate tripal entity titles.'
  31. );
  32. tripal_insert_variable(
  33. 'url_format',
  34. 'A pattern including tokens that can be used to generate tripal entity url aliases.'
  35. );
  36. tripal_insert_variable(
  37. 'description',
  38. 'The description of a Tripal Entity type/bundle.'
  39. );
  40. }
  41. /**
  42. *
  43. */
  44. function tripal_uninstall() {
  45. /*
  46. // So somehow I was able to uninstall this module without deleting the bundles. This
  47. // caused aweful errors because fields weren't deleted so when I re-installed, the code
  48. // tried to create fields that were inactive (despite checking if the field exists
  49. // before creating). The following code was meant to ensure that all content was deleted
  50. // before uninstall so these errors would not occur. Unfortunatly I am now unable to
  51. // test this because the Field API module is disabling uninstall of Tripal Chado until
  52. // all the content is deleted. Thus ensuring the errors described above don't occur.
  53. // But I'm Sure I was able to uninstall with content before...
  54. // **I am slowly going crazy; Crazy going slowly am I**
  55. // Anyway, I'll leaving the solution code here in case I am able to repeat it in
  56. // the future.
  57. // @see https://www.drupal.org/node/1262092
  58. // @see https://www.drupal.org/node/1861710
  59. // First delete all TripalEntities.
  60. $entity_ids = (new EntityFieldQuery)->entityCondition("entity_type", "TripalEntity")->execute();
  61. $entity_ids = reset($entity_ids);
  62. entity_delete_multiple("TripalEntity", array_keys($entity_ids));
  63. // Then delete all TripalBundles.
  64. $bundle_ids = (new EntityFieldQuery)->entityCondition("entity_type", "TripalBundle")->execute();
  65. $bundle_ids = reset($bundle_ids);
  66. entity_delete_multiple("TripalBundle", array_keys($bundle_ids));
  67. // @TODO: Should we delete all TripalVocabularies and TripalTerms?
  68. // Finally purge all fields that are no longer used.
  69. field_purge_batch(100);
  70. */
  71. }
  72. /**
  73. *
  74. */
  75. function tripal_enable() {
  76. // If Tripal v2 is already installed, the installation of this module
  77. // will try and recreate some of the tables created with tripal_core and the
  78. // installation will fail. Therefore, in the install we renamed it. Now
  79. // we want to move it back.
  80. if (db_table_exists('tripal_jobs2')) {
  81. $sql = "DROP TABLE tripal_jobs";
  82. db_query($sql);
  83. $sql = "ALTER TABLE tripal_jobs2 RENAME to tripal_jobs";
  84. db_query($sql);
  85. $sql = "ALTER INDEX tripal_jobs_job_id_idx2 RENAME TO tripal_jobs_job_id_idx";
  86. db_query($sql);
  87. $sql = "ALTER INDEX tripal_jobs_job_name_idx2 RENAME TO tripal_jobs_job_name_idx";
  88. db_query($sql);
  89. $sql = "ALTER INDEX tripal_jobs_pkey2 RENAME TO tripal_jobs_pkey";
  90. db_query($sql);
  91. // schema change
  92. $sql = "ALTER TABLE tripal_jobs ADD COLUMN includes text";
  93. db_query($sql);
  94. }
  95. if (db_table_exists('tripal_token_formats2')) {
  96. $sql = "DROP TABLE tripal_token_formats";
  97. db_query($sql);
  98. $sql = "ALTER TABLE tripal_token_formats2 RENAME TO tripal_token_formats";
  99. db_query($sql);
  100. $sql = "ALTER INDEX tripal_token_formats_pkey2 RENAME TO tripal_token_formats_pkey";
  101. db_query($sql);
  102. $sql = "ALTER INDEX tripal_token_formats_type_application_key2 RENAME TO tripal_token_formats_type_application_key";
  103. db_query($sql);
  104. }
  105. if (db_table_exists('tripal_variables2')) {
  106. $sql = "DROP TABLE tripal_variables";
  107. db_query($sql);
  108. $sql = "ALTER TABLE tripal_variables2 RENAME TO tripal_variables";
  109. db_query($sql);
  110. $sql = "ALTER INDEX tripal_variables_pkey2 RENAME TO tripal_variables_pkey";
  111. db_query($sql);
  112. $sql = "ALTER INDEX tripal_variables_tripal_variable_names_idx1_idx2 RENAME TO tripal_variables_tripal_variable_names_idx1_idx";
  113. db_query($sql);
  114. $sql = "ALTER INDEX tripal_variables_tripal_variables_c1_key2 RENAME TO tripal_variables_tripal_variables_c1_key";
  115. db_query($sql);
  116. }
  117. tripal_add_variables();
  118. }
  119. /**
  120. * Implementation of hook_schema().
  121. *
  122. * @ingroup tripal
  123. */
  124. function tripal_schema() {
  125. // If Tripal v2 is already installed, the installation of this module
  126. // will try and recreate some of the tables created with tripal_core and the
  127. // installation will fail. Therefore, we need to temporarily move those
  128. // tables out of the way, let the module install and then move them back.
  129. $migrated = variable_get ('tripal_v2_upgrade_v3_check', FALSE);
  130. if (!$migrated) {
  131. if (db_table_exists('tripal_jobs')) {
  132. // Move the tripal_jobs table out of the way.
  133. $sql = "ALTER TABLE tripal_jobs RENAME TO tripal_jobs2";
  134. db_query($sql);
  135. $sql = "ALTER INDEX tripal_jobs_job_id_idx RENAME TO tripal_jobs_job_id_idx2";
  136. db_query($sql);
  137. $sql = "ALTER INDEX tripal_jobs_job_name_idx RENAME TO tripal_jobs_job_name_idx2";
  138. db_query($sql);
  139. $sql = "ALTER INDEX tripal_jobs_pkey RENAME TO tripal_jobs_pkey2";
  140. db_query($sql);
  141. }
  142. if (db_table_exists('tripal_token_formats')) {
  143. // Move the tripal_token_formats table out of the way.
  144. $sql = "ALTER TABLE tripal_token_formats RENAME TO tripal_token_formats2";
  145. db_query($sql);
  146. $sql = "ALTER INDEX tripal_token_formats_pkey RENAME TO tripal_token_formats_pkey2";
  147. db_query($sql);
  148. $sql = "ALTER INDEX tripal_token_formats_type_application_key RENAME TO tripal_token_formats_type_application_key2";
  149. db_query($sql);
  150. }
  151. if (db_table_exists('tripal_variables')) {
  152. // Move the tripal_variables table out of the way.
  153. $sql = "ALTER TABLE tripal_variables RENAME TO tripal_variables2";
  154. db_query($sql);
  155. $sql = "ALTER INDEX tripal_variables_pkey RENAME TO tripal_variables_pkey2";
  156. db_query($sql);
  157. $sql = "ALTER INDEX tripal_variables_tripal_variable_names_idx1_idx RENAME TO tripal_variables_tripal_variable_names_idx1_idx2";
  158. db_query($sql);
  159. $sql = "ALTER INDEX tripal_variables_tripal_variables_c1_key RENAME TO tripal_variables_tripal_variables_c1_key2";
  160. db_query($sql);
  161. }
  162. variable_set ('tripal_v2_upgrade_v3_check', TRUE);
  163. }
  164. $schema = array();
  165. $schema['tripal_jobs'] = tripal_tripal_jobs_schema();
  166. $schema['tripal_token_formats'] = tripal_tripal_token_formats_schema();
  167. $schema['tripal_variables'] = tripal_tripal_variables_schema();
  168. // Adds a table for managing TripalEntity entities.
  169. $schema['tripal_vocab'] = tripal_tripal_vocab_schema();
  170. $schema['tripal_term'] = tripal_tripal_term_schema();
  171. $schema['tripal_entity'] = tripal_tripal_entity_schema();
  172. $schema['tripal_bundle'] = tripal_tripal_bundle_schema();
  173. // Adds a table for additional information related to bundles.
  174. $schema['tripal_bundle_variables'] = tripal_tripal_bundle_variables_schema();
  175. return $schema;
  176. }
  177. function tripal_tripal_jobs_schema() {
  178. return array(
  179. 'fields' => array(
  180. 'job_id' => array(
  181. 'type' => 'serial',
  182. 'unsigned' => TRUE,
  183. 'not NULL' => TRUE
  184. ),
  185. 'uid' => array(
  186. 'type' => 'int',
  187. 'unsigned' => TRUE,
  188. 'not NULL' => TRUE,
  189. 'description' => 'The Drupal userid of the submitee'
  190. ),
  191. 'job_name' => array(
  192. 'type' => 'varchar',
  193. 'length' => 255,
  194. 'not NULL' => TRUE
  195. ),
  196. 'modulename' => array(
  197. 'type' => 'varchar',
  198. 'length' => 50,
  199. 'not NULL' => TRUE,
  200. 'description' => 'The module name that provides the callback for this job'
  201. ),
  202. 'callback' => array(
  203. 'type' => 'varchar',
  204. 'length' => 255,
  205. 'not NULL' => TRUE
  206. ),
  207. 'arguments' => array(
  208. 'type' => 'text',
  209. 'size' => 'normal',
  210. 'not NULL' => FALSE
  211. ),
  212. 'progress' => array(
  213. 'type' => 'int',
  214. 'unsigned' => TRUE,
  215. 'default' => 0,
  216. 'not NULL' => FALSE,
  217. 'description' => 'a value from 0 to 100 indicating percent complete'
  218. ),
  219. 'status' => array(
  220. 'type' => 'varchar',
  221. 'length' => 50,
  222. 'not NULL' => TRUE
  223. ),
  224. 'submit_date' => array(
  225. 'type' => 'int',
  226. 'not NULL' => TRUE,
  227. 'description' => 'UNIX integer submit time'
  228. ),
  229. 'start_time' => array(
  230. 'type' => 'int',
  231. 'not NULL' => FALSE,
  232. 'description' => 'UNIX integer start time'
  233. ),
  234. 'end_time' => array(
  235. 'type' => 'int',
  236. 'not NULL' => FALSE,
  237. 'description' => 'UNIX integer end time'
  238. ),
  239. 'error_msg' => array(
  240. 'type' => 'text',
  241. 'size' => 'normal',
  242. 'not NULL' => FALSE
  243. ),
  244. 'pid' => array(
  245. 'type' => 'int',
  246. 'unsigned' => TRUE,
  247. 'not NULL' => FALSE,
  248. 'description' => 'The process id for the job'
  249. ),
  250. 'priority' => array(
  251. 'type' => 'int',
  252. 'unsigned' => TRUE,
  253. 'not NULL' => TRUE,
  254. 'default' => '0',
  255. 'description' => 'The job priority'
  256. ),
  257. 'mlock' => array(
  258. 'type' => 'int',
  259. 'unsigned' => TRUE,
  260. 'not NULL' => FALSE,
  261. 'description' => 'If set to 1 then all jobs for the module are held until this one finishes'
  262. ),
  263. 'lock' => array(
  264. 'type' => 'int',
  265. 'unsigned' => TRUE,
  266. 'not NULL' => FALSE,
  267. 'description' => 'If set to 1 then all jobs are held until this one finishes'
  268. ),
  269. 'includes' => array(
  270. 'type' => 'text',
  271. 'description' => 'A serialized array of file paths that should be included prior to executing the job.',
  272. 'not NULL' => FALSE,
  273. )
  274. ),
  275. 'indexes' => array(
  276. 'job_id' => array('job_id'),
  277. 'job_name' => array('job_name')
  278. ),
  279. 'primary key' => array('job_id'),
  280. );
  281. }
  282. /**
  283. *
  284. * @return
  285. */
  286. function tripal_tripal_token_formats_schema() {
  287. return array(
  288. 'fields' => array(
  289. 'tripal_format_id' => array(
  290. 'type' => 'serial',
  291. 'unsigned' => TRUE,
  292. 'not null' => TRUE
  293. ),
  294. 'content_type' => array(
  295. 'type' => 'varchar',
  296. 'length' => 255,
  297. 'not null' => TRUE
  298. ),
  299. 'application' => array(
  300. 'type' => 'varchar',
  301. 'length' => 255,
  302. 'not null' => TRUE
  303. ),
  304. 'format' => array(
  305. 'type' => 'text',
  306. 'not null' => TRUE
  307. ),
  308. 'tokens' => array(
  309. 'type' => 'text',
  310. 'not null' => TRUE
  311. ),
  312. ),
  313. 'unique keys' => array(
  314. 'type_application' => array('content_type', 'application'),
  315. ),
  316. 'primary key' => array('tripal_format_id'),
  317. );
  318. }
  319. function tripal_tripal_variables_schema() {
  320. return array(
  321. 'description' => 'This table houses a list of unique variable names that ' .
  322. 'can be used in the tripal_node_variables table.',
  323. 'fields' => array(
  324. 'variable_id' => array (
  325. 'type' => 'serial',
  326. 'not null' => TRUE,
  327. ),
  328. 'name' => array(
  329. 'type' => 'varchar',
  330. 'length' => 255,
  331. 'not null' => TRUE,
  332. ),
  333. 'description' => array(
  334. 'type' => 'text',
  335. 'not null' => TRUE,
  336. ),
  337. ),
  338. 'primary key' => array (
  339. 0 => 'variable_id',
  340. ),
  341. 'unique keys' => array (
  342. 'tripal_variables_c1' => array (
  343. 0 => 'name',
  344. ),
  345. ),
  346. 'indexes' => array (
  347. 'tripal_variable_names_idx1' => array (
  348. 0 => 'variable_id',
  349. ),
  350. ),
  351. );
  352. return $schema;
  353. }
  354. /**
  355. * @section
  356. * Schema Definitions.
  357. */
  358. /**
  359. * The base table for Biological Data Entities.
  360. *
  361. * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
  362. * this table will have 15 records and include both genes and mRNA's.
  363. */
  364. function tripal_tripal_entity_schema() {
  365. $schema = array(
  366. 'description' => 'The base table for Tripal Vocabulary-based entities.',
  367. 'fields' => array(
  368. 'id' => array(
  369. 'description' => 'The primary identifier for a vocabulary entity.',
  370. 'type' => 'serial',
  371. 'unsigned' => TRUE,
  372. 'not null' => TRUE,
  373. ),
  374. 'type' => array(
  375. 'description' => 'The type of entity. This should be an official vocabulary ID (e.g. SO, RO, GO).',
  376. 'type' => 'varchar',
  377. 'length' => 64,
  378. 'not null' => TRUE,
  379. 'default' => '',
  380. ),
  381. 'bundle' => array(
  382. 'description' => 'The type of bundle. This should be an official vocabulary ID (e.g. SO, RO, GO) followed by an underscore and the term accession.',
  383. 'type' => 'varchar',
  384. 'length' => 1024,
  385. 'not null' => TRUE,
  386. 'default' => '',
  387. ),
  388. 'term_id' => array(
  389. 'description' => 'The term_id for the type of entity. This term_id corresponds to a TripalTerm record.',
  390. 'type' => 'int',
  391. 'not null' => TRUE,
  392. ),
  393. 'title' => array(
  394. 'description' => 'The title of this node, always treated as non-markup plain text.',
  395. 'type' => 'text',
  396. 'not null' => TRUE,
  397. 'default' => '',
  398. ),
  399. 'uid' => array(
  400. 'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
  401. 'type' => 'int',
  402. 'not null' => TRUE,
  403. 'default' => 0,
  404. ),
  405. 'status' => array(
  406. 'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
  407. 'type' => 'int',
  408. 'not null' => TRUE,
  409. 'default' => 1,
  410. ),
  411. 'created' => array(
  412. 'description' => 'The Unix timestamp when the node was created.',
  413. 'type' => 'int',
  414. 'not null' => TRUE,
  415. 'default' => 0,
  416. ),
  417. 'changed' => array(
  418. 'description' => 'The Unix timestamp when the node was most recently saved.',
  419. 'type' => 'int',
  420. 'not null' => TRUE,
  421. 'default' => 0,
  422. ),
  423. ),
  424. 'indexes' => array(
  425. 'term_id' => array('term_id'),
  426. 'entity_changed' => array('changed'),
  427. 'entity_created' => array('created'),
  428. 'type' => array('type'),
  429. 'uid' => array('uid'),
  430. 'bundle' => array('bundle'),
  431. ),
  432. 'unique keys' => array(),
  433. 'primary key' => array('id'),
  434. );
  435. return $schema;
  436. }
  437. /**
  438. * The base table for TripalVocab schema.
  439. *
  440. * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
  441. * this table will have 15 records and include both genes and mRNA's.
  442. */
  443. function tripal_tripal_vocab_schema() {
  444. // This schema only provides enough information to assign a unique ID
  445. // to the vocabulary. Any additonal information is added to the Entity object
  446. // by the selected database back-end.
  447. $schema = array(
  448. 'description' => 'The base table for TripalVocab entities.',
  449. 'fields' => array(
  450. 'id' => array(
  451. 'description' => 'The primary identifier for a vocab entity.',
  452. 'type' => 'serial',
  453. 'unsigned' => TRUE,
  454. 'not null' => TRUE,
  455. ),
  456. 'vocabulary' => array(
  457. 'description' => 'The short name for the vocabulary (e.g. SO, PATO, etc.).',
  458. 'type' => 'varchar',
  459. 'length' => 10,
  460. 'not null' => TRUE,
  461. ),
  462. 'created' => array(
  463. 'description' => 'The Unix timestamp when the entity was created.',
  464. 'type' => 'int',
  465. 'not null' => TRUE,
  466. 'default' => 0,
  467. ),
  468. 'changed' => array(
  469. 'description' => 'The Unix timestamp when the entity was most recently saved.',
  470. 'type' => 'int',
  471. 'not null' => TRUE,
  472. 'default' => 0,
  473. ),
  474. ),
  475. 'indexes' => array(
  476. 'vocabulary' => array('vocabulary'),
  477. 'entity_changed' => array('changed'),
  478. 'entity_created' => array('created'),
  479. ),
  480. 'unique keys' => array('vocabulary' => array('vocabulary')),
  481. 'primary key' => array('id'),
  482. );
  483. return $schema;
  484. }
  485. /**
  486. * The base table for TripalTerm entities.
  487. *
  488. * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
  489. * this table will have 15 records and include both genes and mRNA's.
  490. */
  491. function tripal_tripal_term_schema() {
  492. // This schema only provides enough information to assign a unique ID
  493. // to the term and associate it to it's vocabulary. Any additonal information
  494. // is added to the Entity object by the selected database back-end.
  495. $schema = array(
  496. 'description' => 'The base table for TripalTerm entities.',
  497. 'fields' => array(
  498. 'id' => array(
  499. 'description' => 'The primary identifier for a term entity.',
  500. 'type' => 'serial',
  501. 'unsigned' => TRUE,
  502. 'not null' => TRUE,
  503. ),
  504. 'vocab_id' => array(
  505. 'description' => 'The vocabulary_id of the TripalVocab entity to which this term belongs.',
  506. 'type' => 'int',
  507. 'not null' => TRUE,
  508. ),
  509. 'accession' => array(
  510. 'description' => 'The id (or accession) of this term in the vocabulary.',
  511. 'type' => 'varchar',
  512. 'length' => 1024,
  513. 'not null' => TRUE,
  514. 'default' => '',
  515. ),
  516. 'name' => array(
  517. 'description' => 'The human readable name for this term.',
  518. 'type' => 'varchar',
  519. 'length' => 1024,
  520. 'not null' => TRUE,
  521. 'default' => '',
  522. ),
  523. 'created' => array(
  524. 'description' => 'The Unix timestamp when the entity was created.',
  525. 'type' => 'int',
  526. 'not null' => TRUE,
  527. 'default' => 0,
  528. ),
  529. 'changed' => array(
  530. 'description' => 'The Unix timestamp when the entity was most recently saved.',
  531. 'type' => 'int',
  532. 'not null' => TRUE,
  533. 'default' => 0,
  534. ),
  535. ),
  536. 'indexes' => array(
  537. 'vocab_id' => array('vocab_id'),
  538. 'accession' => array('accession'),
  539. 'entity_changed' => array('changed'),
  540. 'entity_created' => array('created'),
  541. ),
  542. 'foreign keys' => array(
  543. 'tripal_vocab' => array(
  544. 'table' => 'tripal_vocab',
  545. 'columns' => array(
  546. 'vocab_id' => 'vocab_id',
  547. ),
  548. ),
  549. ),
  550. 'unique keys' => array('vocab_term' => array('vocab_id', 'accession')),
  551. 'primary key' => array('id'),
  552. );
  553. return $schema;
  554. }
  555. /**
  556. * The base table for TripalEntity entities.
  557. *
  558. * This table contains a list of Biological Data Types.
  559. * For the example above (5 genes and 10 mRNAs), there would only be two records in
  560. * this table one for "gene" and another for "mRNA".
  561. */
  562. function tripal_tripal_bundle_schema() {
  563. $schema = array(
  564. 'description' => 'Stores information about defined tripal data types.',
  565. 'fields' => array(
  566. 'id' => array(
  567. 'type' => 'serial',
  568. 'not null' => TRUE,
  569. 'description' => 'Primary Key: Unique numeric ID.',
  570. ),
  571. 'type' => array(
  572. 'description' => 'The type of entity (e.g. TripalEntity).',
  573. 'type' => 'varchar',
  574. 'length' => 64,
  575. 'not null' => TRUE,
  576. 'default' => '',
  577. ),
  578. 'term_id' => array(
  579. 'description' => 'The term_id for the type of entity. This term_id corresponds to a TripalTerm record.',
  580. 'type' => 'int',
  581. 'not null' => TRUE,
  582. ),
  583. 'name' => array(
  584. 'description' => 'The name of the bundle. This should be an official vocabulary ID (e.g. SO, RO, GO) followed by an underscore and the term accession.',
  585. 'type' => 'varchar',
  586. 'length' => 1024,
  587. 'not null' => TRUE,
  588. 'default' => '',
  589. ),
  590. 'label' => array(
  591. 'description' => 'The human-readable name of this bundle.',
  592. 'type' => 'varchar',
  593. 'length' => 255,
  594. 'not null' => TRUE,
  595. 'default' => '',
  596. ),
  597. ),
  598. 'indexes' => array(
  599. 'name' => array('name'),
  600. 'term_id' => array('term_id'),
  601. 'label' => array('label'),
  602. ),
  603. 'primary key' => array('id'),
  604. 'unique keys' => array(
  605. 'name' => array('name'),
  606. ),
  607. );
  608. return $schema;
  609. }
  610. /**
  611. * Additional Tripal Bundle Information.
  612. *
  613. * This table is used for storing any additonal information describing
  614. * a tripal bundle. For example, this is a good place to store title/url formats.
  615. */
  616. function tripal_tripal_bundle_variables_schema() {
  617. $schema = array(
  618. 'description' => 'This table is used for storing any additonal information describing
  619. a tripal bundle. For example, this is a good place to store title/url formats.',
  620. 'fields' => array (
  621. 'bundle_variable_id' => array (
  622. 'type' => 'serial',
  623. 'not null' => TRUE,
  624. ),
  625. 'bundle_id' => array (
  626. 'type' => 'int',
  627. 'not null' => TRUE,
  628. ),
  629. 'variable_id' => array (
  630. 'type' => 'int',
  631. 'not null' => TRUE,
  632. ),
  633. 'value' => array (
  634. 'type' => 'text',
  635. 'not null' => FALSE,
  636. ),
  637. 'rank' => array (
  638. 'type' => 'int',
  639. 'not null' => TRUE,
  640. 'default' => 0,
  641. ),
  642. ),
  643. 'primary key' => array (
  644. 0 => 'bundle_variable_id',
  645. ),
  646. 'unique keys' => array (
  647. 'tripal_bundle_variables_c1' => array (
  648. 0 => 'bundle_id',
  649. 1 => 'variable_id',
  650. 2 => 'rank',
  651. ),
  652. ),
  653. 'indexes' => array (
  654. 'tripal_bundle_variables_idx1' => array (
  655. 0 => 'variable_id',
  656. ),
  657. ),
  658. 'foreign keys' => array (
  659. 'tripal_variables' => array (
  660. 'table' => 'tripal_variables',
  661. 'columns' => array (
  662. 'variable_id' => 'variable_id',
  663. ),
  664. ),
  665. ),
  666. );
  667. return $schema;
  668. }