    # File lib/active_record/connection_adapters/postgresql_adapter.rb, line 804
          def change_column(table_name, column_name, type, options = {})
            quoted_table_name = quote_table_name(table_name)

            begin
              execute "ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"
            rescue ActiveRecord::StatementInvalid => e
              raise e if postgresql_version > 80000
              # This is PostgreSQL 7.x, so we have to use a more arcane way of doing it.
              begin
                begin_db_transaction
                tmp_column_name = "#{column_name}_ar_tmp"
                add_column(table_name, tmp_column_name, type, options)
                execute "UPDATE #{quoted_table_name} SET #{quote_column_name(tmp_column_name)} = CAST(#{quote_column_name(column_name)} AS #{type_to_sql(type, options[:limit], options[:precision], options[:scale])})"
                remove_column(table_name, column_name)
                rename_column(table_name, tmp_column_name, column_name)
                commit_db_transaction
              rescue
                rollback_db_transaction
              end
            end

            change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)
            change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)
          end