tripal_stock.install 1.3 KB

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