Same name in other branches
  1. 7.x-1.x advagg.install \advagg_schema()

Implements hook_schema().

5 calls to advagg_schema()
advagg_install in ./advagg.install
Implements hook_install().
advagg_update_7200 in ./advagg.install
Upgrade AdvAgg previous versions (6.x-1.x and 7.x-1.x) to 7.x-2.x.
advagg_update_7206 in ./advagg.install
Update the schema making the varchar columns utf8_bin in MySQL.
advagg_update_7207 in ./advagg.install
Update schema making the varchar columns char. Change utf8_bin to ascii_bin.
advagg_update_7209 in ./advagg.install
Update schema making it match the definition.

File

./advagg.install, line 156

Code

function advagg_schema() {
    // Create cache tables.
    $schema['cache_advagg_aggregates'] = drupal_get_schema_unprocessed('system', 'cache');
    $schema['cache_advagg_aggregates']['fields']['cid']['binary'] = TRUE;
    $schema['cache_advagg_aggregates']['description'] = 'Cache table for Advanced CSS/JS Aggregation. Used to keep a cache of the CSS and JS HTML tags.';
    $schema['cache_advagg_info'] = drupal_get_schema_unprocessed('system', 'cache');
    $schema['cache_advagg_info']['fields']['cid']['binary'] = TRUE;
    $schema['cache_advagg_info']['description'] = 'Cache table for Advanced CSS/JS Aggregation. Used to keep a cache of the db and file info.';
    // Create database tables.
    $schema['advagg_files'] = array(
        'description' => 'Files used in CSS/JS aggregation.',
        'fields' => array(
            'filename' => array(
                'description' => 'Path and filename of the file relative to Drupal webroot.',
                'type' => 'text',
                'size' => 'normal',
                'not null' => TRUE,
            ),
            'filename_hash' => array(
                'description' => 'Hash of path and filename. Used to join tables.',
                'type' => 'char',
                'length' => 43,
                'not null' => TRUE,
                'default' => '',
                'binary' => TRUE,
                'collation' => 'ascii_bin',
                'charset' => 'ascii',
                'mysql_character_set' => 'ascii',
            ),
            'content_hash' => array(
                'description' => 'Hash of the file content. Used to see if the file has changed.',
                'type' => 'char',
                'length' => 43,
                'not null' => FALSE,
                'default' => '',
                'binary' => TRUE,
                'collation' => 'ascii_bin',
                'charset' => 'ascii',
                'mysql_character_set' => 'ascii',
            ),
            'filetype' => array(
                'description' => 'Filetype.',
                'type' => 'varchar',
                'length' => 8,
                'not null' => TRUE,
                'default' => '',
                'binary' => TRUE,
            ),
            'filesize' => array(
                'description' => 'The file size in bytes.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'linecount' => array(
                'description' => 'The number of lines in the file.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'mtime' => array(
                'description' => 'The time the file was last modified.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'changes' => array(
                'description' => 'This is incremented every time a file changes.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'filesize_processed' => array(
                'description' => 'The file size in bytes after minification and compression.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'use_strict' => array(
                'description' => 'If 1 then the js file starts with "use strict";. If 0 then it does not.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
        ),
        'indexes' => array(
            'content_hash' => array(
                'content_hash',
            ),
            'filetype' => array(
                'filetype',
            ),
            'filesize' => array(
                'filesize',
            ),
            'use_strict' => array(
                'use_strict',
            ),
        ),
        'primary key' => array(
            'filename_hash',
        ),
    );
    $schema['advagg_aggregates'] = array(
        'description' => 'What files are used in what aggregates.',
        'fields' => array(
            'aggregate_filenames_hash' => array(
                'description' => 'Hash of the aggregates list of files. Keep track of what files are in the aggregate.',
                'type' => 'char',
                'length' => 43,
                'not null' => TRUE,
                'default' => '',
                'binary' => TRUE,
                'collation' => 'ascii_bin',
                'charset' => 'ascii',
                'mysql_character_set' => 'ascii',
            ),
            'filename_hash' => array(
                'description' => 'Hash of path and filename.',
                'type' => 'char',
                'length' => 43,
                'not null' => TRUE,
                'default' => '',
                'binary' => TRUE,
                'collation' => 'ascii_bin',
                'charset' => 'ascii',
                'mysql_character_set' => 'ascii',
            ),
            'porder' => array(
                'description' => 'Processing order.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'settings' => array(
                'description' => 'Extra data about this file and how it is used in this aggregate.',
                'type' => 'blob',
                'not null' => TRUE,
                'size' => 'big',
                'translatable' => TRUE,
                'serialize' => TRUE,
            ),
        ),
        'indexes' => array(
            'porder' => array(
                'porder',
            ),
            'filename_hash' => array(
                'filename_hash',
            ),
            'aggregate_filenames_hash_porder' => array(
                'aggregate_filenames_hash',
                'porder',
            ),
        ),
        'primary key' => array(
            'aggregate_filenames_hash',
            'filename_hash',
        ),
    );
    $schema['advagg_aggregates_versions'] = array(
        'description' => 'What files are used in what aggregates.',
        'fields' => array(
            'aggregate_filenames_hash' => array(
                'description' => 'Hash of the aggregates list of files. Keep track of what files are in the aggregate.',
                'type' => 'char',
                'length' => 43,
                'not null' => TRUE,
                'default' => '',
                'binary' => TRUE,
                'collation' => 'ascii_bin',
                'charset' => 'ascii',
                'mysql_character_set' => 'ascii',
            ),
            'aggregate_contents_hash' => array(
                'description' => 'Hash of all content_hashes in this aggregate. Simple Version control of the aggregate.',
                'type' => 'char',
                'length' => 43,
                'not null' => TRUE,
                'default' => '',
                'binary' => TRUE,
                'collation' => 'ascii_bin',
                'charset' => 'ascii',
                'mysql_character_set' => 'ascii',
            ),
            'atime' => array(
                'description' => 'Last access time for this version of the aggregate. Updated every 12 hours.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'root' => array(
                'description' => 'If 1 then it is a root aggregate. 0 means not root aggregate.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
        ),
        'indexes' => array(
            'root' => array(
                'root',
            ),
            'atime' => array(
                'atime',
            ),
            'root_atime' => array(
                'root',
                'atime',
            ),
        ),
        'primary key' => array(
            'aggregate_filenames_hash',
            'aggregate_contents_hash',
        ),
    );
    // Copy the variable table and change a couple of things.
    $schema['advagg_aggregates_hashes'] = drupal_get_schema_unprocessed('system', 'variable');
    $schema['advagg_aggregates_hashes']['fields']['hash'] = $schema['advagg_aggregates_hashes']['fields']['name'];
    $schema['advagg_aggregates_hashes']['fields']['hash']['length'] = 255;
    $schema['advagg_aggregates_hashes']['fields']['hash']['description'] = 'The name of the hash.';
    $schema['advagg_aggregates_hashes']['fields']['hash']['binary'] = TRUE;
    $schema['advagg_aggregates_hashes']['fields']['settings']['description'] = 'The settings associated with this hash.';
    $schema['advagg_aggregates_hashes']['fields']['settings'] = $schema['advagg_aggregates_hashes']['fields']['value'];
    $schema['advagg_aggregates_hashes']['description'] = 'Key value pairs created by AdvAgg. Stores settings used at the time that the aggregate was created.';
    $schema['advagg_aggregates_hashes']['primary key'][0] = 'hash';
    unset($schema['advagg_aggregates_hashes']['fields']['name'], $schema['advagg_aggregates_hashes']['fields']['value']);
    return $schema;
}