You are here

merci_reservation.install in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Sets up the base table for our entity and a table to store information about the entity types.

File

merci_reservation/merci_reservation.install
View source
<?php

/**
 * @file
 * Sets up the base table for our entity and a table to store information about
 * the entity types.
 */

/**
 * Implements hook_schema().
 */
function merci_reservation_schema() {
  $schema = array();
  $schema['merci_reservation'] = array(
    'description' => 'The base table for merci_reservation entities.',
    'fields' => array(
      'id' => array(
        'description' => 'Primary Key: Identifier for a merci_reservation.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The {merci_reservation_type}.type of this merci_reservation.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the merci_reservation was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the merci_reservation was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'uid' => array(
        'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data.',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'type' => array(
        'type',
      ),
      'uid' => array(
        'uid',
      ),
    ),
    'foreign keys' => array(
      'node_author' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  $schema['merci_reservation_type'] = array(
    'description' => 'Stores information about defined merci_reservation types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique merci_reservation type identifier.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this merci_reservation type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The human-readable name of this merci_reservation type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The weight of this merci_reservation type in relation to others.',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data related to this merci_reservation type.',
      ),
    ) + entity_exportable_schema_fields(),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'type' => array(
        'type',
      ),
    ),
  );
  return $schema;
}
function merci_reservation_enable() {
  $options = array(
    'label' => 'Checkout',
    'type' => 'checkout',
  );
  $entity = entity_create('merci_reservation_type', $options);
  entity_save('merci_reservation_type', $entity);
}
function merci_reservation_uninstall() {

  // Delete any line item reference fields.
  merci_core_delete_fields('merci_line_item');
}