如何编写迁移以将 Rails 中的表列从 float 更改为 bigint

che*_*ell 3 migration ruby-on-rails-3

我的用户表中有数据。一列名为 :provider_user_id,数据类型为 float。

我想将其更改为bigint数据类型。

我应该如何在 Rails 3 中编写此迁移

原始列是通过以下迁移创建的:

class AddFbuidToUsers < ActiveRecord::Migration
  def self.up
    add_column :users, :provider_user_id, :float
  end

  def self.down
    remove_column :users, :provider_user_id
  end
end
Run Code Online (Sandbox Code Playgroud)

sos*_*xme 5

change_column :users, :provider_user_id, :bigint
Run Code Online (Sandbox Code Playgroud)