You are here

function location_update_5 in Location 5

Same name and namespace in other branches
  1. 5.3 location.install \location_update_5()
  2. 6.3 location.install \location_update_5()
  3. 7.5 location.install \location_update_5()
  4. 7.3 location.install \location_update_5()
  5. 7.4 location.install \location_update_5()

File

./location.install, line 171

Code

function location_update_5() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'pgsql':
      $ret[] = update_sql("ALTER TABLE {location} DROP CONSTRAINT {location}_pkey");
      $ret[] = update_sql("ALTER TABLE {location} RENAME TO {location}_old");
      $ret[] = update_sql("CREATE TABLE {location} (\n        lid serial CHECK (lid >= 0),\n        eid int NOT NULL default '0' CHECK (eid >= 0),\n        type varchar(6) NOT NULL default '',\n        name varchar(255) default NULL,\n        street varchar(255) default NULL,\n        additional varchar(255) default NULL,\n        city varchar(255) default NULL,\n        province varchar(16) default NULL,\n        postal_code varchar(16) default NULL,\n        country char(2) default NULL,\n        latitude decimal(10,6) default NULL,\n        longitude decimal(10,6) default NULL,\n        source smallint default '0',\n        is_primary smallint default '0',\n        PRIMARY KEY (lid)\n      )");
      $ret[] = update_sql("INSERT INTO {location}\n      \t(eid, type, name, street, additional, city, province, postal_code, country, latitude, \n      \tlongitude, source) SELECT eid, type, name, street, additional, city, province,\n      \tpostal_code, country, latitude, longitude, source FROM {location}_old");
      $ret[] = update_sql("DROP TABLE {location}_old");
      $ret[] = update_sql("UPDATE {location} SET is_primary = 1 WHERE type = 'user'");
      break;
  }
  return $ret;
}