You are here

function location_phone_update_5300 in Location 5.3

Same name and namespace in other branches
  1. 6.3 contrib/location_phone/location_phone.install \location_phone_update_5300()
  2. 7.5 contrib/location_phone/location_phone.install \location_phone_update_5300()
  3. 7.3 contrib/location_phone/location_phone.install \location_phone_update_5300()
  4. 7.4 contrib/location_phone/location_phone.install \location_phone_update_5300()

Location 3.0 update 1. Fix pgsql -- The table definition was broken.

File

contrib/location_phone/location_phone.install, line 51
Installation routines.

Code

function location_phone_update_5300() {
  $ret = array();
  if ($GLOBALS['db_type'] == 'pgsql') {

    // If the table wasn't created (i.e. error from previous install)
    if (!db_table_exists('location_phone')) {
      $ret[] = update_sql("\n        CREATE TABLE {location_phone} (\n          lid int NOT NULL default '0' CHECK (lid >= 0),\n          phone varchar(31) default NULL,\n          PRIMARY KEY (lid)\n        )");
    }
    else {

      // If the table WAS created (i.e. user manually fixed bug and reinstalled), g/c the postal_code column.
      // @@@ @TODO Drupal 6: Change to db_column_exists().
      if (db_result(db_query("SELECT COUNT(pg_attribute.attname) FROM pg_class, pg_attribute WHERE pg_attribute.attrelid = pg_class.oid AND pg_class.relname = '{location_phone}' AND attname = 'postal_code'")) > 0) {
        $ret[] = update_sql("ALTER TABLE {location_phone} DROP COLUMN postal_code");
      }
    }
  }
  return $ret;
}