tripal.install 21 KB

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