function visitors_geoip_install in Visitors 8.2
Same name and namespace in other branches
- 8 visitors_geoip.install \visitors_geoip_install()
- 7.2 visitors_geoip.install \visitors_geoip_install()
- 7 visitors_geoip.install \visitors_geoip_install()
Implements hook_install().
File
- ./
visitors_geoip.install, line 95 - Install/uninstall visitors geoip module.
Code
function visitors_geoip_install() {
$schema = Database::getConnection()
->schema();
if (!$schema
->fieldExists('visitors', 'visitors_continent_code')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_continent_code', array(
'type' => 'varchar',
'length' => 2,
'not null' => TRUE,
'default' => '',
));
}
if (!$schema
->fieldExists('visitors', 'visitors_country_code')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_country_code', array(
'type' => 'varchar',
'length' => 2,
'not null' => TRUE,
'default' => '',
));
}
if (!$schema
->fieldExists('visitors', 'visitors_country_code3')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_country_code3', array(
'type' => 'varchar',
'length' => 3,
'not null' => TRUE,
'default' => '',
));
}
if (!$schema
->fieldExists('visitors', 'visitors_country_name')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_country_name', array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
));
}
if (!$schema
->fieldExists('visitors', 'visitors_region')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_region', array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
));
}
if (!$schema
->fieldExists('visitors', 'visitors_city')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_city', array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
));
}
if (!$schema
->fieldExists('visitors', 'visitors_postal_code')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_postal_code', array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
));
}
if (!$schema
->fieldExists('visitors', 'visitors_latitude')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_latitude', array(
'type' => 'numeric',
'precision' => 13,
'scale' => 10,
'not null' => TRUE,
'default' => 0,
));
}
if (!$schema
->fieldExists('visitors', 'visitors_longitude')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_longitude', array(
'type' => 'numeric',
'precision' => 13,
'scale' => 10,
'not null' => TRUE,
'default' => 0,
));
}
if (!$schema
->fieldExists('visitors', 'visitors_dma_code')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_dma_code', array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
));
}
if (!$schema
->fieldExists('visitors', 'visitors_area_code')) {
\Drupal::database()
->schema()
->addField('visitors', 'visitors_area_code', array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
));
}
}