You are here

function ip2country_schema in IP-based Determination of a Visitor's Country 6

Same name and namespace in other branches
  1. 8 ip2country.install \ip2country_schema()
  2. 7 ip2country.install \ip2country_schema()

Implements hook_schema().

File

./ip2country.install, line 35
Install, update, and uninstall functions for the ip2country module.

Code

function ip2country_schema() {
  $schema['ip2country'] = array(
    'description' => 'Association between IP range and Country',
    'fields' => array(
      'ip2country_id' => array(
        'description' => 'Row number (why is this needed?)',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'country' => array(
        'description' => 'ISO 3166 2-character country code',
        'type' => 'char',
        'length' => 3,
        'not null' => TRUE,
      ),
      'registry' => array(
        'description' => 'Regional Internet Registry',
        'type' => 'char',
        'length' => 10,
        'not null' => TRUE,
      ),
      'ip_range_first' => array(
        'description' => 'Lowest IP address in range',
        'type' => 'int',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'ip_range_last' => array(
        'description' => 'Highest IP address in range',
        'type' => 'int',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'ip_range_length' => array(
        'description' => 'Size of IP address block',
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'indexes' => array(
      'country_registry' => array(
        'country',
        'registry',
      ),
    ),
    'primary key' => array(
      'ip2country_id',
    ),
  );
  return $schema;
}