method

rename_column_sql

rails latest stable - Class: ActiveRecord::ConnectionAdapters

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v5.1.7) is shown here.

rename_column_sql(table_name, column_name, new_column_name)
private

No documentation available.

# File activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb, line 741
        def rename_column_sql(table_name, column_name, new_column_name)
          column  = column_for(table_name, column_name)
          options = {
            default: column.default,
            null: column.null,
            auto_increment: column.auto_increment?
          }

          current_type = exec_query("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE #{quote(column_name)}", "SCHEMA").first["Type"]
          td = create_table_definition(table_name)
          cd = td.new_column_definition(new_column_name, current_type, options)
          schema_creation.accept(ChangeColumnDefinition.new(cd, column.name))
        end