You are here

function filehash_schema in File Hash 7

Same name and namespace in other branches
  1. 8 filehash.install \filehash_schema()

Implements hook_schema().

File

./filehash.install, line 11
Install and uninstall functions for the filehash module.

Code

function filehash_schema() {
  $schema['filehash'] = array(
    'description' => 'Store hashes for each uploaded file.',
    'fields' => array(
      'fid' => array(
        'description' => 'Primary key: {file_managed}.fid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'md5' => array(
        'description' => 'MD5 hash for this file.',
        'type' => 'char',
        'length' => 32,
        'not null' => FALSE,
      ),
      'sha1' => array(
        'description' => 'SHA-1 hash for this file.',
        'type' => 'char',
        'length' => 40,
        'not null' => FALSE,
      ),
      'sha256' => array(
        'description' => 'SHA-256 hash for this file.',
        'type' => 'char',
        'length' => 64,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'fid',
    ),
    'indexes' => array(
      'md5_idx' => array(
        'md5',
      ),
      'sha1_idx' => array(
        'sha1',
      ),
      'sha256_idx' => array(
        'sha256',
      ),
    ),
    'foreign keys' => array(
      'fid' => array(
        'table' => 'file_managed',
        'columns' => array(
          'fid' => 'fid',
        ),
      ),
    ),
  );
  return $schema;
}