You are here

function uc_store_schema in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_store/uc_store.install \uc_store_schema()

Implements hook_schema().

File

uc_store/uc_store.install, line 38
Install, update, and uninstall functions for the uc_store module.

Code

function uc_store_schema() {
  $schema = array();
  $schema['uc_countries'] = array(
    'description' => 'Stores country information.',
    'fields' => array(
      'country_id' => array(
        'description' => 'Primary key: numeric ISO country code.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'country_name' => array(
        'description' => 'The country name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'country_iso_code_2' => array(
        'description' => 'The two-character ISO country code.',
        'type' => 'char',
        'length' => 2,
        'not null' => TRUE,
        'default' => '',
      ),
      'country_iso_code_3' => array(
        'description' => 'The three-character ISO country code.',
        'type' => 'char',
        'length' => 3,
        'not null' => TRUE,
        'default' => '',
      ),
      'version' => array(
        'description' => 'The version of the CIF that loaded the country information.',
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'country_name' => array(
        'country_name',
      ),
    ),
    'primary key' => array(
      'country_id',
    ),
  );
  $schema['uc_zones'] = array(
    'description' => 'Stores state/province information within a country.',
    'fields' => array(
      'zone_id' => array(
        'description' => 'Primary key: the unique zone id.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'zone_country_id' => array(
        'description' => 'The {uc_countries}.country_id to which this zone belongs.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'zone_code' => array(
        'description' => 'Standard abbreviation of the zone name.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'zone_name' => array(
        'description' => 'The zone name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'indexes' => array(
      'zone_code' => array(
        'zone_code',
      ),
      'zone_country_id' => array(
        'zone_country_id',
      ),
    ),
    'primary key' => array(
      'zone_id',
    ),
    'foreign keys' => array(
      'uc_countries' => array(
        'table' => 'uc_countries',
        'columns' => array(
          'zone_country_id' => 'country_id',
        ),
      ),
    ),
  );
  return $schema;
}