You are here

function commerce_file_schema in Commerce File 8.2

Same name and namespace in other branches
  1. 7.2 commerce_file.install \commerce_file_schema()
  2. 7 commerce_file.install \commerce_file_schema()

Implements hook_schema().

File

./commerce_file.install, line 11
Install, update and uninstall functions for Commerce File module.

Code

function commerce_file_schema() {

  // Provides a temporary download log, used for setting download limits.
  // Not meant to be user viewable.
  $schema['commerce_file_download_log'] = [
    'fields' => [
      'log_id' => [
        'description' => 'The primary key.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'license_id' => [
        'description' => 'The {commerce_license}.license_id of the downloaded file.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'fid' => [
        'description' => 'The {file_managed}.fid of the downloaded file.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'uid' => [
        'description' => 'The {users}.uid of the user that downloaded the file.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'timestamp' => [
        'description' => 'The UNIX timestamp of the date the file was downloaded.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'ip_address' => [
        'description' => 'The IP address of the user that downloaded the file.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'log_id',
    ],
    'indexes' => [
      'license_id' => [
        'license_id',
      ],
      'fid' => [
        'fid',
      ],
      'uid' => [
        'uid',
      ],
    ],
    'foreign keys' => [
      'licenses' => [
        'table' => 'commerce_license',
        'columns' => [
          'license_id' => 'license_id',
        ],
      ],
      'file_managed' => [
        'table' => 'file_managed',
        'columns' => [
          'fid' => 'fid',
        ],
      ],
      'users' => [
        'table' => 'users',
        'columns' => [
          'uid' => 'uid',
        ],
      ],
    ],
  ];
  return $schema;
}