You are here

function smart_ip_check_fix_local_db in Smart IP 7

Same name and namespace in other branches
  1. 6.2 smart_ip.module \smart_ip_check_fix_local_db()
  2. 6 smart_ip.module \smart_ip_check_fix_local_db()
  3. 7.2 smart_ip.module \smart_ip_check_fix_local_db()

Ensure smart_ip table exist

2 calls to smart_ip_check_fix_local_db()
smart_ip_get_count in ./smart_ip.module
Get the total count of IP ranges in database
smart_ip_get_location in ./smart_ip.module
Get the geo location from the IP address

File

./smart_ip.module, line 737
Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address

Code

function smart_ip_check_fix_local_db() {
  if (!db_table_exists('smart_ip')) {
    if (db_table_exists('smart_ip_update_table')) {

      // Database update was broken in the middle and smart_ip table was dropped but
      // staging smart_ip_update_table failed to rename to production smart_ip table
      db_rename_table('smart_ip_update_table', 'smart_ip');
    }
    else {

      // smart_ip table dropped then re-create one
      module_load_install('smart_ip');
      db_create_table('smart_ip', smart_ip_schema_definition_array());
    }
  }
}