upload.install

File

drupal-6.x/modules/upload/upload.install
View source
  1. <?php
  2. /**
  3. * Implementation of hook_install().
  4. */
  5. function upload_install() {
  6. // Create table. The upload table might have been created in the Drupal 5
  7. // to Drupal 6 upgrade, and was migrated from the file_revisions table. So
  8. // in this case, there is no need to create the table, it is already there.
  9. if (!db_table_exists('upload')) {
  10. drupal_install_schema('upload');
  11. }
  12. }
  13. /**
  14. * Implementation of hook_uninstall().
  15. */
  16. function upload_uninstall() {
  17. // Remove tables.
  18. drupal_uninstall_schema('upload');
  19. }
  20. /**
  21. * Implementation of hook_schema().
  22. */
  23. function upload_schema() {
  24. $schema['upload'] = array(
  25. 'description' => 'Stores uploaded file information and table associations.',
  26. 'fields' => array(
  27. 'fid' => array(
  28. 'type' => 'int',
  29. 'unsigned' => TRUE,
  30. 'not null' => TRUE,
  31. 'default' => 0,
  32. 'description' => 'Primary Key: The {files}.fid.',
  33. ),
  34. 'nid' => array(
  35. 'type' => 'int',
  36. 'unsigned' => TRUE,
  37. 'not null' => TRUE,
  38. 'default' => 0,
  39. 'description' => 'The {node}.nid associated with the uploaded file.',
  40. ),
  41. 'vid' => array(
  42. 'type' => 'int',
  43. 'unsigned' => TRUE,
  44. 'not null' => TRUE,
  45. 'default' => 0,
  46. 'description' => 'Primary Key: The {node}.vid associated with the uploaded file.',
  47. ),
  48. 'description' => array(
  49. 'type' => 'varchar',
  50. 'length' => 255,
  51. 'not null' => TRUE,
  52. 'default' => '',
  53. 'description' => 'Description of the uploaded file.',
  54. ),
  55. 'list' => array(
  56. 'type' => 'int',
  57. 'unsigned' => TRUE,
  58. 'not null' => TRUE,
  59. 'default' => 0,
  60. 'size' => 'tiny',
  61. 'description' => 'Whether the file should be visibly listed on the node: yes(1) or no(0).',
  62. ),
  63. 'weight' => array(
  64. 'type' => 'int',
  65. 'not null' => TRUE,
  66. 'default' => 0,
  67. 'size' => 'tiny',
  68. 'description' => 'Weight of this upload in relation to other uploads in this node.',
  69. ),
  70. ),
  71. 'primary key' => array('vid', 'fid'),
  72. 'indexes' => array(
  73. 'fid' => array('fid'),
  74. 'nid' => array('nid'),
  75. ),
  76. );
  77. return $schema;
  78. }