You are here

function library_schema in Library 6

Same name and namespace in other branches
  1. 5.2 library.install \library_schema()
  2. 6.2 library.install \library_schema()
  3. 7 library.install \library_schema()

@author Jess Straatmann @file library.install Install and uninstall all required databases. Also do incremental database updates.

File

./library.install, line 10
@author Jess Straatmann library.install Install and uninstall all required databases. Also do incremental database updates.

Code

function library_schema() {
  $schema['library'] = array(
    'description' => t('Determines if a library item may be checked out.'),
    'fields' => array(
      'id' => array(
        'description' => t('The primary identifier for a library item.'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'barcode' => array(
        'description' => t('The barcode/identifier for this item.'),
        'type' => 'varchar',
        'length' => 60,
        'not null' => FALSE,
        'default' => '',
      ),
      'nid' => array(
        'description' => t('The node identifier.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'in_circulation' => array(
        'description' => t('Boolean indicating whether the item is in circulation.'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'library_status' => array(
        'description' => t('Boolean indicating whether the item is available. Not directly editable.'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'notes' => array(
        'description' => t('Short description field for additional comments about the item.'),
        'type' => 'varchar',
        'length' => 256,
        'not null' => FALSE,
        'default' => '',
      ),
      'created' => array(
        'type' => 'int',
        'description' => t('Timestamp for when the item was created.'),
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $schema['library_transactions'] = array(
    'description' => t('The table where library transactions are stored.'),
    'fields' => array(
      'tid' => array(
        'description' => t('The primary identifier for a transaction.'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'item_id' => array(
        'description' => t('The associated library item.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => t('The associated library node.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'patron_id' => array(
        'description' => t('The associated customer.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'action_aid' => array(
        'description' => t('The action performed.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'duedate' => array(
        'type' => 'int',
        'description' => t('Timestamp for the current duedate.'),
        'not null' => FALSE,
        'default' => NULL,
      ),
      'notes' => array(
        'description' => t('Short description field for additional comments about the transaction.'),
        'type' => 'varchar',
        'length' => 256,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'created' => array(
        'type' => 'int',
        'description' => t('Timestamp for when transaction occurred.'),
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'item_id' => array(
        'item_id',
      ),
      'patron_id' => array(
        'patron_id',
      ),
      'action_aid' => array(
        'action_aid',
      ),
    ),
    'primary key' => array(
      'tid',
    ),
  );
  $schema['library_actions'] = array(
    'description' => t('The table where library transactions are stored.'),
    'fields' => array(
      'aid' => array(
        'description' => t('The unique identifier of this action.'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => t('The name of this action.'),
        'type' => 'varchar',
        'length' => 60,
        'not null' => TRUE,
        'default' => '',
      ),
      'status_change' => array(
        'description' => t('Indicates if the action changes item status.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'aid',
    ),
  );
  return $schema;
}