You are here

function commerce_file_schema in Commerce File 7

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

Implements hook_schema().

File

./commerce_file.install, line 11
Install, update and uninstall functions this module.

Code

function commerce_file_schema() {
  $schema = array();
  $schema['commerce_file_license'] = array(
    'description' => 'The base table for licenses.',
    'fields' => array(
      'license_id' => array(
        'description' => 'The primary identifier for a license.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The type of this license.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'description' => 'The status of this license.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'The {users}.uid that owns this license.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the license was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the license was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'granted' => array(
        'description' => 'The Unix timestamp when the license was initially granted.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'license_id',
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
    ),
    'foreign keys' => array(
      'owner' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  $schema['commerce_file_license_log'] = array(
    'description' => 'Stores file download information for licensed files.',
    'fields' => array(
      'aid' => array(
        'type' => 'serial',
        'description' => 'Primary Key: Unique accesslog ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'license_id' => array(
        'description' => 'The {commerce_file_license}.license_id being referenced in this log.',
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
      ),
      'timestamp' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Timestamp of when the file was downloaded.',
      ),
      'hostname' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
        'description' => 'Hostname of user that downloaded the file.',
      ),
    ),
    'primary key' => array(
      'aid',
    ),
    'indexes' => array(
      'license_id' => array(
        'license_id',
      ),
    ),
    'foreign keys' => array(
      'log_license' => array(
        'table' => 'commerce_file_license',
        'columns' => array(
          'license_id' => 'license_id',
        ),
      ),
    ),
  );
  return $schema;
}