upload.install 1.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?php
// $Id$

/**
 * Implementation of hook_install().
 */
function upload_install() {
  // Create tables.
  drupal_install_schema('upload');
}

/**
 * Implementation of hook_uninstall().
 */
function upload_uninstall() {
  // Remove tables.
  drupal_uninstall_schema('upload');
}
19 20 21 22 23 24

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

  return $schema;
}

81