function rules_schema

Implements hook_schema().

File

./rules.install, line 51

Code

function rules_schema() {
    $schema['rules_config'] = array(
        'fields' => array(
            'id' => array(
                'type' => 'serial',
                'not null' => TRUE,
                'description' => 'The internal identifier for any configuration.',
            ),
            'name' => array(
                'type' => 'varchar',
                'length' => '64',
                'not null' => TRUE,
                'description' => 'The name of the configuration.',
            ),
            'label' => array(
                'type' => 'varchar',
                'length' => '255',
                'not null' => TRUE,
                'description' => 'The label of the configuration.',
                'default' => 'unlabeled',
            ),
            'plugin' => array(
                'type' => 'varchar',
                'length' => 127,
                'not null' => TRUE,
                'description' => 'The name of the plugin of this configuration.',
            ),
            'active' => array(
                'description' => 'Boolean indicating whether the configuration is active. Usage depends on how the using module makes use of it.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 1,
            ),
            'weight' => array(
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
                'size' => 'tiny',
                'description' => 'Weight of the configuration. Usage depends on how the using module makes use of it.',
            ),
            'status' => array(
                'type' => 'int',
                'not null' => TRUE,
                // Set the default to ENTITY_CUSTOM without using the constant as it is
                // not safe to use it at this point.
'default' => 0x1,
                'size' => 'tiny',
                'description' => 'The exportable status of the entity.',
            ),
            'dirty' => array(
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
                'size' => 'tiny',
                'description' => 'Dirty configurations fail the integrity check, e.g. due to missing dependencies.',
            ),
            'module' => array(
                'description' => 'The name of the providing module if the entity has been defined in code.',
                'type' => 'varchar',
                'length' => 255,
                'not null' => FALSE,
            ),
            'owner' => array(
                'description' => 'The name of the module via which the rule has been configured.',
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => 'rules',
            ),
            'access_exposed' => array(
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
                'size' => 'tiny',
                'description' => 'Whether to use a permission to control access for using components.',
            ),
            'data' => array(
                'type' => 'blob',
                'size' => 'big',
                'not null' => FALSE,
                'serialize' => TRUE,
                'description' => 'Everything else, serialized.',
            ),
        ),
        'primary key' => array(
            'id',
        ),
        'unique keys' => array(
            'name' => array(
                'name',
            ),
        ),
        'indexes' => array(
            'plugin' => array(
                'plugin',
                'active',
            ),
        ),
    );
    $schema['rules_trigger'] = array(
        'fields' => array(
            'id' => array(
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'description' => 'The primary identifier of the configuration.',
            ),
            'event' => array(
                'type' => 'varchar',
                'length' => '127',
                'not null' => TRUE,
                'default' => '',
                'description' => 'The name of the event on which the configuration should be triggered.',
            ),
        ),
        'primary key' => array(
            'id',
            'event',
        ),
        'foreign keys' => array(
            'table' => 'rules_config',
            'columns' => array(
                'id' => 'id',
            ),
        ),
    );
    $schema['rules_tags'] = array(
        'fields' => array(
            'id' => array(
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'description' => 'The primary identifier of the configuration.',
            ),
            'tag' => array(
                'type' => 'varchar',
                'length' => '255',
                'not null' => TRUE,
                'description' => 'The tag string associated with this configuration',
            ),
        ),
        'primary key' => array(
            'id',
            'tag',
        ),
        'foreign keys' => array(
            'table' => 'rules_config',
            'columns' => array(
                'id' => 'id',
            ),
        ),
    );
    $schema['rules_dependencies'] = array(
        'fields' => array(
            'id' => array(
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'description' => 'The primary identifier of the configuration.',
            ),
            'module' => array(
                'type' => 'varchar',
                'length' => '255',
                'not null' => TRUE,
                'description' => 'The name of the module that is required for the configuration.',
            ),
        ),
        'primary key' => array(
            'id',
            'module',
        ),
        'indexes' => array(
            'module' => array(
                'module',
            ),
        ),
        'foreign keys' => array(
            'table' => 'rules_config',
            'columns' => array(
                'id' => 'id',
            ),
        ),
    );
    $schema['cache_rules'] = drupal_get_schema_unprocessed('system', 'cache');
    $schema['cache_rules']['description'] = 'Cache table for the rules engine to store configured items.';
    return $schema;
}