You are here

function filehash_schema in File Hash 8

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

Implements hook_schema().

File

./filehash.install, line 11
Schema function for file hash module.

Code

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