function views_update_6009

File

./views.install, line 442

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']);
    }
}