You are here

function asset_schema in Asset 7

Same name and namespace in other branches
  1. 6 asset.install \asset_schema()

Implements hook_schema().

File

./asset.install, line 10
Install, update and uninstall functions for the assets module.

Code

function asset_schema() {
  $schema['asset'] = array(
    'description' => 'Stores assets.',
    'fields' => array(
      'aid' => array(
        'description' => 'Primary Key: Unique asset item ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => "The {users}.uid of the associated user.",
      ),
      'type' => array(
        'description' => 'The {asset_type}.type of the asset.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'title' => array(
        'description' => 'The title of the asset.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the asset was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the asset was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'uuid' => array(
        'type' => 'char',
        'length' => 36,
        'default' => '',
        'description' => 'The Universally Unique Identifier.',
      ),
    ),
    'indexes' => array(
      'asset_type' => array(
        array(
          'type',
          4,
        ),
      ),
      'asset_title_type' => array(
        'title',
        array(
          'type',
          4,
        ),
      ),
      'asset_changed' => array(
        'changed',
      ),
      'asset_created' => array(
        'created',
      ),
    ),
    'foreign keys' => array(
      'uid' => array(
        'users' => 'uid',
      ),
      'type' => array(
        'asset_types' => 'type',
      ),
    ),
    'primary key' => array(
      'aid',
    ),
  );
  $schema['asset_type'] = array(
    'description' => 'Stores information about all defined asset types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique asset type ID.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this asset type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The human-readable name of this asset type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'translatable' => TRUE,
      ),
      'description' => array(
        'description' => 'A brief description of this asset type.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'medium',
        'translatable' => TRUE,
      ),
      'locked' => array(
        'description' => 'A boolean indicating whether the administrator may delete this asset type.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'help' => array(
        'description' => 'Help information shown to the user when creating an asset of this type.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'medium',
        'translatable' => TRUE,
      ),
      'icon' => array(
        'description' => 'WYSIWYG button image path.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
      ),
      'weight' => array(
        'description' => 'The weight of this asset type in relation to others.',
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'uuid' => array(
        'type' => 'char',
        'length' => 36,
        'default' => '',
        'description' => 'The Universally Unique Identifier.',
      ),
      '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.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'type' => array(
        'type',
      ),
    ),
  );
  return $schema;
}