You are here

function recipe_schema in Recipe 6

Same name and namespace in other branches
  1. 7.2 recipe.install \recipe_schema()
  2. 7 recipe.install \recipe_schema()

Implementation of hook_schema().

File

./recipe.install, line 36
Install, update and uninstall functions for the recipe module.

Code

function recipe_schema() {
  $schema['recipe'] = array(
    'fields' => array(
      'nid' => array(
        'description' => 'The primary identifier for a recipe.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'source' => array(
        'type' => 'varchar',
        'not null' => FALSE,
        'length' => 255,
      ),
      'yield' => array(
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'yield_unit' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The units for the yield field(servings, people, cans, cookies, etc).',
      ),
      'instructions' => array(
        'type' => 'text',
      ),
      'notes' => array(
        'type' => 'text',
      ),
      'preptime' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  $schema['recipe_node_ingredient'] = array(
    'description' => 'The base table for recipe ingredients.',
    'fields' => array(
      'id' => array(
        'description' => 'The primary identifier for a recipe ingredient.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'unit_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'quantity' => array(
        'type' => 'float',
        'not null' => FALSE,
      ),
      'ingredient_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Ingredient weight within recipe.',
      ),
      'note' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Ingredient processing or notes related to recipe.',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $schema['recipe_ingredient'] = array(
    'description' => 'The base table for recipe ingredients.',
    'fields' => array(
      'id' => array(
        'description' => 'The primary identifier for a recipe ingredient.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 255,
      ),
      'link' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $schema['recipe_unit'] = array(
    'description' => 'The base table for recipe units.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 255,
      ),
      'abbreviation' => array(
        'type' => 'varchar',
        'length' => 8,
      ),
      'metric' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 6,
        'not null' => TRUE,
        'default' => 'Mass',
      ),
      'aliases' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'A common separated list of other names and abbreviations that apply to this unit.',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}