upload.install 2.34 KB
Newer Older
1 2 3
<?php
// $Id$

4 5 6 7 8
/**
 * @file
 * Install, update and uninstall functions for the upload module.
 */

9 10 11 12 13
/**
 * @file
 * This is the install file for the upload module.
 */

14 15 16 17
/**
 * Implementation of hook_install().
 */
function upload_install() {
18 19 20 21 22 23
  // Create table. The upload table might have been created in the Drupal 5
  // to Drupal 6 upgrade, and was migrated from the file_revisions table. So
  // in this case, there is no need to create the table, it is already there.
  if (!db_table_exists('upload')) {
    drupal_install_schema('upload');
  }
24 25 26 27 28 29 30 31 32
}

/**
 * Implementation of hook_uninstall().
 */
function upload_uninstall() {
  // Remove tables.
  drupal_uninstall_schema('upload');
}
33 34 35 36 37 38

/**
 * Implementation of hook_schema().
 */
function upload_schema() {
  $schema['upload'] = array(
39
    'description' => 'Stores uploaded file information and table associations.',
40
    'fields' => array(
41 42 43 44 45
      'fid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
46
        'description' => 'Primary Key: The {files}.fid.',
47 48 49 50 51 52
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
53
        'description' => 'The {node}.nid associated with the uploaded file.',
54 55 56 57 58 59
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
60
        'description' => 'Primary Key: The {node}.vid associated with the uploaded file.',
61 62 63 64 65 66
      ),
      'description' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
67
        'description' => 'Description of the uploaded file.',
68 69 70 71 72 73 74
      ),
      'list' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
75
        'description' => 'Whether the file should be visibly listed on the node: yes(1) or no(0).',
76
      ),
77 78 79 80 81
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
82
        'description' => 'Weight of this upload in relation to other uploads in this node.',
83
      ),
84
    ),
85 86 87 88 89
    'primary key' => array('vid', 'fid'),
    'indexes' => array(
      'fid' => array('fid'),
      'nid' => array('nid'),
    ),
90 91 92 93 94
  );

  return $schema;
}

95