tripal.install 22 KB

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