tripal_stock.install 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Install the tripal stock module including it's content type
  4. * @file
  5. */
  6. /**
  7. * Implementation of hook_install().
  8. */
  9. function tripal_stock_install() {
  10. drupal_install_schema('tripal_stock');
  11. }
  12. /**
  13. * Implementation of hook_uninstall().
  14. */
  15. function tripal_stock_uninstall() {
  16. drupal_uninstall_schema('tripal_stock');
  17. // Get the list of nodes to remove
  18. $sql_lib_id = "SELECT nid, vid ".
  19. "FROM {node} ".
  20. "WHERE type='chado_stock'";
  21. $result = db_query($sql_lib_id);
  22. //delete all nodes
  23. while ($node = db_fetch_object($result)) {
  24. node_delete($node->nid);
  25. }
  26. }
  27. /**
  28. * Implementation of hook_schema().
  29. */
  30. function tripal_stock_schema() {
  31. $schema['chado_stock'] = array(
  32. 'fields' => array(
  33. 'vid' => array(
  34. 'type' => 'int',
  35. 'unsigned' => TRUE,
  36. 'not null' => TRUE,
  37. ),
  38. 'nid' => array(
  39. 'type' => 'int',
  40. 'unsigned' => TRUE,
  41. 'not null' => TRUE,
  42. ),
  43. 'stock_id' => array(
  44. 'type' => 'int',
  45. 'unsigned' => TRUE,
  46. 'not null' => TRUE,
  47. ),
  48. ),
  49. 'indexes' => array(
  50. 'stock_id' => array('stock_id'),
  51. 'nid' => array('nid'),
  52. ),
  53. 'unique' => array(
  54. 'stock_id' => array('stock_id'),
  55. ),
  56. 'primary key' => array('vid'),
  57. );
  58. return $schema;
  59. }