You are here

function countries_schema in Countries 7

Same name and namespace in other branches
  1. 8 countries.install \countries_schema()
  2. 7.2 countries.install \countries_schema()

Implementation of hook_schema().

File

./countries.install, line 11
Install file for Countries API.

Code

function countries_schema() {
  $schema['countries_country'] = array(
    'description' => 'Maintains a country database.',
    'fields' => array(
      'cid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Primary Key: Unique country ID. Required for the country bundle.',
      ),
      'iso2' => array(
        'description' => 'ISO2 country code.',
        'type' => 'char',
        'length' => 2,
        'not null' => TRUE,
      ),
      'iso3' => array(
        'description' => 'ISO3 country code.',
        'type' => 'char',
        'length' => 3,
        'not null' => FALSE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 95,
        'not null' => TRUE,
      ),
      'official_name' => array(
        'type' => 'varchar',
        'length' => 127,
        'not null' => TRUE,
      ),
      'numcode' => array(
        'type' => 'int',
        'size' => 'small',
        'not null' => FALSE,
      ),
      'continent' => array(
        'description' => 'Continent code.',
        'type' => 'char',
        'length' => 2,
        'not null' => TRUE,
      ),
      'enabled' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'description' => 'Whether the country is enabled.',
      ),
    ),
    'primary key' => array(
      'cid',
    ),
    'unique keys' => array(
      'iso2' => array(
        'iso2',
      ),
      'iso3' => array(
        'iso3',
      ),
      'numcode' => array(
        'numcode',
      ),
      'name' => array(
        'name',
      ),
      'official_name' => array(
        'official_name',
      ),
    ),
    'indexes' => array(
      'enabled' => array(
        'enabled',
      ),
      'continent' => array(
        'continent',
      ),
    ),
  );
  return $schema;
}