tripal_stock.install 1.3 KB

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