You are here

function node_gallery_api_schema in Node Gallery 7

Implements hook_schema().

File

./node_gallery_api.install, line 11
Install, update and uninstall functions for the node_gallery_api module.

Code

function node_gallery_api_schema() {
  $schema = array();
  $schema['node_gallery_relationship_type'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Node Gallery Relationship Type ID',
      ),
      'label' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => 'Node Gallery Relationship Type Label',
      ),
      'filefield_name' => array(
        'type' => 'varchar',
        'not null' => TRUE,
        'length' => 255,
        'description' => 'The name of the file field that contains the media file on an item node.',
      ),
      'settings' => array(
        'type' => 'text',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $schema['node_gallery_relationship'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Node Gallery Relationship ID',
      ),
      'relationship_type' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Relationship type ID.',
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Image node id.',
      ),
      'ngid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Gallery node id.',
      ),
      'weight' => array(
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      // For quick finding of the contents of a gallery.
      'gallery' => array(
        'ngid',
      ),
    ),
  );
  $schema['node_gallery_galleries'] = array(
    'fields' => array(
      'ngid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Gallery node id.',
      ),
      'cover_item' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'Node Id of the Cover Item',
      ),
      'item_count' => array(
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Gallery items count.',
      ),
      'pub_item_count' => array(
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Gallery published item count.',
      ),
    ),
    'primary key' => array(
      'ngid',
    ),
    'indexes' => array(
      'item_count' => array(
        'item_count',
      ),
      'pub_item_count' => array(
        'pub_item_count',
      ),
      // To quickly answer, is this image the cover image?
      'cover_item' => array(
        'cover_item',
      ),
    ),
  );
  return $schema;
}