tripal_entities.install 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * @file
  4. * Install for a chado data entity - creates the base table for our entity.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. *
  9. * @ingroup entity_example
  10. */
  11. function tripal_entities_schema() {
  12. $schema['chado_data'] = array(
  13. 'description' => 'The base table for Tripal Vocabulary-based entities.',
  14. 'fields' => array(
  15. 'entity_id' => array(
  16. 'description' => 'The primary identifier for a vocabulary entity.',
  17. 'type' => 'serial',
  18. 'unsigned' => TRUE,
  19. 'not null' => TRUE,
  20. ),
  21. 'type' => array(
  22. 'description' => 'The type of entity. This should be an official term ID.',
  23. 'type' => 'varchar',
  24. 'length' => 64,
  25. 'not null' => TRUE,
  26. 'default' => '',
  27. ),
  28. 'cvterm_id' => array(
  29. 'description' => 'The cvterm_id for the type of entity. This cvterm_id should match a record in the Chado cvterm table.',
  30. 'type' => 'varchar',
  31. 'length' => 32,
  32. 'not null' => TRUE,
  33. 'default' => '',
  34. ),
  35. 'tablename' => array(
  36. 'description' => 'The Chado table that contains the record that this entity is associated with.',
  37. 'type' => 'varchar',
  38. 'length' => 128,
  39. 'not null' => TRUE,
  40. 'default' => ''
  41. ),
  42. 'record_id' => array(
  43. 'description' => 'The unique numerical identifier for the record that this entity is associated with (e.g. feature_id, stock_id, library_id, etc.).',
  44. 'type' => 'int',
  45. 'not null' => TRUE,
  46. ),
  47. 'title' => array(
  48. 'description' => 'The title of this node, always treated as non-markup plain text.',
  49. 'type' => 'text',
  50. 'not null' => TRUE,
  51. 'default' => '',
  52. ),
  53. 'uid' => array(
  54. 'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
  55. 'type' => 'int',
  56. 'not null' => TRUE,
  57. 'default' => 0,
  58. ),
  59. 'status' => array(
  60. 'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
  61. 'type' => 'int',
  62. 'not null' => TRUE,
  63. 'default' => 1,
  64. ),
  65. 'created' => array(
  66. 'description' => 'The Unix timestamp when the node was created.',
  67. 'type' => 'int',
  68. 'not null' => TRUE,
  69. 'default' => 0,
  70. ),
  71. 'changed' => array(
  72. 'description' => 'The Unix timestamp when the node was most recently saved.',
  73. 'type' => 'int',
  74. 'not null' => TRUE,
  75. 'default' => 0,
  76. ),
  77. ),
  78. 'indexes' => array(
  79. 'entity_changed' => array('changed'),
  80. 'entity_created' => array('created'),
  81. 'tablename' => array('tablename'),
  82. 'record_id' => array('record_id'),
  83. 'chado_record' => array('tablename', 'record_id'),
  84. 'type' => array('type'),
  85. 'cvterm_id' => array('cvterm_id'),
  86. 'uid' => array('uid'),
  87. ),
  88. 'unique keys' => array(
  89. 'record' => array('tablename', 'record_id'),
  90. ),
  91. 'primary key' => array('entity_id'),
  92. );
  93. return $schema;
  94. }
  95. /**
  96. * Implements hook_uninstall().
  97. *
  98. * At uninstall time we'll notify field.module that the entity was deleted
  99. * so that attached fields can be cleaned up.
  100. *
  101. * @ingroup entity_example
  102. */
  103. function tripal_entities_uninstall() {
  104. // TODO: make this dynamic (not hardcoded bundle).
  105. field_attach_delete_bundle('chado_data', 'gene');
  106. }