function views_update_6009

3.x views.install views_update_6009()
2.x views.install views_update_6009()

File

./views.install, line 420
Contains install and update functions for Views.

Code

function views_update_6009() {
  $schema = views_schema_6009();

  if (Database::getConnection()->databaseType() == 'pgsql') {
    db_query('ALTER TABLE {views_display} RENAME "display_options" TO "display_options_old"');
    db_add_field('views_display', 'display_options', $schema['views_display']['fields']['display_options']);

    $sql = "SELECT vid, id, display_options_old FROM {views_display}";
    $result = db_query($sql);
    foreach ($result as $row) {
      $row['display_options_old'] = $row['display_options_old'];
      $sql = "UPDATE {views_display} SET display_options = :display_optons WHERE vid = :vid AND id = :id";
      db_query($sql, array(
        ':display_optons' => $row['display_options_old'],
        ':vid' => $row['vid'],
        ':id' => $row['id'],
      ));
    }

    db_drop_field('views_display', 'display_options_old');
  }
  else {
    db_change_field('views_display', 'display_options', 'display_options', $schema['views_display']['fields']['display_options']);
  }
}