tripal_bulk_loader.install 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /*******************************************************************************
  3. * tripal_bulk_loader_install
  4. */
  5. function tripal_bulk_loader_install(){
  6. drupal_install_schema('tripal_bulk_loader');
  7. }
  8. /*******************************************************************************
  9. * tripal_bulk_loader_uninstall
  10. */
  11. function tripal_bulk_loader_uninstall(){
  12. drupal_uninstall_schema('tripal_bulk_loader');
  13. }
  14. /**
  15. * Update
  16. * Add status, file_has_header columns to tripal_bulk_loader
  17. */
  18. function tripal_bulk_loader_update_1 () {
  19. $update = array();
  20. $update[] = update_sql("ALTER TABLE {tripal_bulk_loader} ADD COLUMN job_status varchar(500) DEFAULT 'initialized'");
  21. $update[] = update_sql("ALTER TABLE {tripal_bulk_loader} ADD COLUMN file_has_header boolean DEFAULT TRUE");
  22. return $update;
  23. }
  24. /**
  25. * Update
  26. * Add job_id column to tripal_bulk_loader
  27. */
  28. function tripal_bulk_loader_update_2 () {
  29. $update = array();
  30. $update[] = update_sql("ALTER TABLE {tripal_bulk_loader} ADD COLUMN job_id int");
  31. return $update;
  32. }
  33. /*******************************************************************************
  34. * tripal_bulk_loader_schema
  35. */
  36. function tripal_bulk_loader_schema() {
  37. $schema = array();
  38. $schema['tripal_bulk_loader'] = array(
  39. 'fields' => array(
  40. 'nid' => array(
  41. 'type' => 'int',
  42. 'unsigned' => TRUE,
  43. 'not null' => TRUE,
  44. ),
  45. 'loader_name' => array(
  46. 'type' => 'varchar',
  47. ),
  48. 'template_id' => array(
  49. 'type' => 'varchar',
  50. ),
  51. 'file' => array(
  52. 'type' => 'varchar',
  53. )
  54. ),
  55. 'primary key' => array('nid'),
  56. 'unique keys' => array(
  57. 'name' => array('loader_name')
  58. ),
  59. );
  60. $schema['tripal_bulk_loader_template'] = array(
  61. 'fields' => array(
  62. 'template_id' => array(
  63. 'type' => 'serial',
  64. 'unsigned' => TRUE,
  65. 'not null' => TRUE,
  66. ),
  67. 'name' => array(
  68. 'type' => 'varchar',
  69. ),
  70. 'template_array' => array(
  71. 'type' => 'varchar',
  72. )
  73. ),
  74. 'primary key' => array('template_id'),
  75. 'unique keys' => array(
  76. 'name' => array('name')
  77. ),
  78. );
  79. return $schema;
  80. }