You are here

function reviews_schema in Reviews 7

Implements hook_schema().

File

./reviews.install, line 12
Defines database schema for reviews and installs/uninstalls all necessary settings.

Code

function reviews_schema() {
  $schema['reviews_count'] = array(
    'description' => 'This table holds count of reviews per node.',
    'fields' => array(
      'nid' => array(
        'description' => 'The primary ID of the node',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'count' => array(
        'description' => 'The count of reviews for the node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
  );
  $schema['reviews'] = array(
    'description' => 'This table holds content reviews.',
    'fields' => array(
      'rid' => array(
        'description' => 'The primary ID of the review',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => 'The ID of the node being reviewed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'The ID of the user authoring the review.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'review' => array(
        'description' => 'The review content.',
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'rating' => array(
        'description' => 'The review rating.',
        'type' => 'int',
      ),
      'status' => array(
        'description' => 'The current status of the review 0=New, 1=Approved, 2=Rejected.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the review was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'review_created' => array(
        'created',
      ),
    ),
    'unique keys' => array(
      'nid_vid' => array(
        'rid',
      ),
    ),
    'foreign keys' => array(
      'review_author' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
    'primary key' => array(
      'rid',
    ),
  );
  return $schema;
}