tripal_project.install 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * @file
  4. * This file contains all the functions which describe and implement drupal database tables
  5. * needed by this module. This module was developed by Chad N.A. Krilow and Lacey-Anne Sanderson,
  6. * University of Saskatchewan.
  7. *
  8. * The project manamgenet module allows you to sync data in a chado/Tripal instance with
  9. * multiple project/mysql instances as well as manage and create such project instances
  10. */
  11. /**
  12. * Implementation of hook_install().
  13. */
  14. function tripal_project_install() {
  15. drupal_install_schema('tripal_project');
  16. }
  17. /**
  18. * Implementation of hook_uninstall().
  19. */
  20. function tripal_project_uninstall() {
  21. drupal_uninstall_schema('tripal_project');
  22. }
  23. /**
  24. * Implementation of hook_schema().
  25. */
  26. function tripal_project_schema() {
  27. //specification for 'tripal_project_instances'
  28. $schema['chado_project'] = array(
  29. 'fields' => array(
  30. //a int field that cannot be null and acts as a unique identifier for all nid's
  31. 'nid' => array(
  32. 'type' => 'int',
  33. 'unsigned' => TRUE,
  34. 'not null' => TRUE,
  35. ),
  36. //a int field that cannot be null and is vid
  37. 'vid' => array(
  38. 'type' => 'int',
  39. 'not null' => TRUE,
  40. ),
  41. //a intfield, not null and project_id is the unique_id of the project in chado
  42. 'project_id' => array(
  43. 'type' => 'int',
  44. 'unsigned' => TRUE,
  45. 'not null' => TRUE,
  46. ),
  47. ),//end of shema
  48. 'primary key' => array('nid', 'vid', 'project_id'),
  49. );
  50. return $schema;
  51. }
  52. /**
  53. * Implementation of hook_requirements().
  54. *
  55. */
  56. function tripal_project_requirements($phase) {
  57. $requirements = array();
  58. if ($phase == 'install') {
  59. // make sure chado is installed
  60. $version = tripal_core_set_chado_version();
  61. if ($version == 'not installed') {
  62. $requirements ['tripal_project'] = array(
  63. 'title' => "tripal_project",
  64. 'value' => "ERROR: Chado most be installed before this module can be enabled",
  65. 'severity' => REQUIREMENT_ERROR,
  66. );
  67. }
  68. }
  69. return $requirements;
  70. }