You are here

function ip_geoloc_schema in IP Geolocation Views & Maps 8

Same name and namespace in other branches
  1. 7 ip_geoloc.install \ip_geoloc_schema()

Implements hook_schema().

Smart IP module provides: IP address Latitude/Longitude Country Country Code Region Region Code (usually empty for Australia) City ZIP (which we store under Postal Code)

GeoIP City provides: TBA

Googlee provides: TBA

Note: some of the varchar should be varbinary, see drupal.org/node/1793674

File

./ip_geoloc.install, line 112
Install and uninstall hooks for IP Geolocation Views & Maps.

Code

function ip_geoloc_schema() {
  $schema['ip_geoloc'] = [
    'description' => 'Store visitor IP addresses and geolocation information',
    'fields' => [
      'id' => [
        'description' => 'Unique id',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'ip_address' => [
        'description' => 'IP address',
        'type' => 'varchar',
        'length' => '64',
        'not null' => TRUE,
      ],
      'latitude' => [
        'description' => 'Latitude',
        'type' => 'float',
        'size' => 'big',
        'not null' => FALSE,
      ],
      'longitude' => [
        'description' => 'Longitude',
        'type' => 'float',
        'size' => 'big',
        'not null' => FALSE,
      ],
      'country' => [
        'description' => 'Country',
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'country_code' => [
        'description' => 'ISO 3166 2-Character Country Code',
        'type' => 'varchar',
        'length' => 3,
        'not null' => FALSE,
      ],
      'region' => [
        'description' => 'Region',
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'region_code' => [
        'description' => '2-Character Region Code',
        'type' => 'varchar',
        'length' => 3,
        'not null' => FALSE,
      ],
      'city' => [
        'description' => 'City',
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'postal_code' => [
        'description' => 'Post code',
        'type' => 'varchar',
        'length' => 12,
        'not null' => FALSE,
      ],
      'locality' => [
        'description' => 'Suburb',
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'route' => [
        'description' => 'Street',
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'street_number' => [
        'description' => 'Street number',
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ],
      'administrative_area_level_1' => [
        'description' => 'State or province',
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ],
      'formatted_address' => [
        'description' => 'Address',
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
      ],
    ],
    'primary key' => [
      'id',
    ],
    'indexes' => [
      'ip_address' => [
        'ip_address',
      ],
    ],
  ];
  return $schema;
}