You are here

function download_count_update_7301 in Download Count 7.3

Create download count cache table.

File

./download_count.install, line 217
Installation code for the download_count module.

Code

function download_count_update_7301() {

  // Do not create download_count_cache table after module installation.
  if (!db_table_exists('download_count_cache')) {
    $schema['download_count_cache'] = array(
      'fields' => array(
        'dcc_id' => array(
          'description' => 'Primary Key: Unique download count cache id.',
          'type' => 'serial',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ),
        'fid' => array(
          'description' => t('The id from the drupal files table of the file downloaded.'),
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'type' => array(
          'description' => 'The name of the entity type to which the file was attached when downloaded.',
          'type' => 'varchar',
          'length' => 64,
          'not null' => TRUE,
          'default' => '',
        ),
        'id' => array(
          'description' => 'The primary key of the entity to which the file was attached when downloaded.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'date' => array(
          'description' => t('The date the file was downloaded.'),
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'count' => array(
          'description' => t('Number of times a file was downloaded in one day.'),
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
      ),
      'primary key' => array(
        'dcc_id',
      ),
      'indexes' => array(
        'dcc_fid' => array(
          'fid',
        ),
        'dcc_type' => array(
          'type',
        ),
        'dcc_id' => array(
          'id',
        ),
        'dcc_timestamp' => array(
          'date',
        ),
        'dcc_fid_type_id' => array(
          'fid',
          'type',
          'id',
          'date',
        ),
      ),
    );
    db_create_table('download_count_cache', $schema['download_count_cache']);
  }
}