You are here

function advagg_schema in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg.install \advagg_schema()
  2. 7.2 advagg.install \advagg_schema()

Implements hook_schema().

File

./advagg.install, line 596
Handles Advanced Aggregation installation and upgrade tasks.

Code

function advagg_schema() {

  // Create cache tables.
  $schema['cache_advagg'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_advagg']['description'] = t('Cache table for Advanced CSS/JS Aggregation. Used to keep timestamps and if the file exists.');
  $schema['cache_advagg_files_data'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_advagg_files_data']['description'] = t('Cache table for Advanced CSS/JS Aggregation. Used to keep data about files.');
  $schema['cache_advagg_bundle_reuse'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_advagg_bundle_reuse']['description'] = t('Cache table for Advanced CSS/JS Aggregation. Used to keep data about existing bundles that can be reused.');

  // Create database tables.
  $schema['advagg_files'] = array(
    'description' => 'Files used in CSS/JS aggregation.',
    'fields' => array(
      'filename' => array(
        'description' => 'Path of the file relative to Drupal webroot.',
        'type' => 'text',
        'size' => 'normal',
        'not null' => TRUE,
      ),
      'filename_md5' => array(
        'description' => 'MD5 hash of filename',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'checksum' => array(
        'description' => 'mtime or md5 of the files content.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'filetype' => array(
        'description' => 'Filetype.',
        'type' => 'varchar',
        'length' => 8,
        'not null' => TRUE,
        'default' => '',
      ),
      'filesize' => array(
        'description' => 'The file size in bytes.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'counter' => array(
        'description' => 'This is incremented every time a file changes.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'checksum' => array(
        'checksum',
      ),
      'filetype' => array(
        'filetype',
      ),
      'filesize' => array(
        'filesize',
      ),
    ),
    'primary key' => array(
      'filename_md5',
    ),
  );
  $schema['advagg_bundles'] = array(
    'description' => 'What files are used in what bundles.',
    'fields' => array(
      'bundle_md5' => array(
        'description' => 'MD5 hash of the bundles list of files',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'filename_md5' => array(
        'description' => 'MD5 hash of filename source',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'counter' => array(
        'description' => 'This is incremented every time a file in the bundle changes.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'porder' => array(
        'description' => 'Processing order.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'root' => array(
        'description' => 'If 1 then it is a root file. 0 means not root file.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'timestamp' => array(
        'description' => 'Last used timestamp of the bundle.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'root' => array(
        'root',
      ),
      'timestamp' => array(
        'timestamp',
      ),
      'counter' => array(
        'counter',
      ),
      'root_timestamp' => array(
        'root',
        'timestamp',
      ),
    ),
    'primary key' => array(
      'bundle_md5',
      'filename_md5',
    ),
  );
  return $schema;
}