将 DB table 列从整数更改为 BigInt 时出错

error changing DB table column from integer to BigInt

我正在尝试将我的 table 列从整数更改为 bigint 我创建了一个迁移,然后将此代码添加到迁移文件中。

class ChangeMileageToBigint < ActiveRecord::Migration
  def change
  execute <<-SQL
    ALTER TABLE posts
    ALTER COLUMN mileage TYPE bigint USING mileage::bigint
  SQL
end
end

但是,当 运行 rake db:migrate

时出现此错误
C:\Sites\jeepjig>rake db:migrate
DL is deprecated, please use Fiddle
== 20150315145856 ChangeMileageToBigint: migrating ============================
-- execute("    ALTER TABLE posts\n    ALTER COLUMN mileage TYPE bigint USING mileage::bigint\n")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: near "ALTER": syntax error:     ALTER TABLE posts
    ALTER COLUMN mileage TYPE bigint USING mileage::bigint
C:/Sites/jeepjig/db/migrate/20150315145856_change_mileage_to_bigint.rb:3:in `change'
C:in `migrate'
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "ALTER": syntax error:     ALTER TABLE posts
    ALTER COLUMN mileage TYPE bigint USING mileage::bigint
C:/Sites/jeepjig/db/migrate/20150315145856_change_mileage_to_bigint.rb:3:in `change'
C:in `migrate'
SQLite3::SQLException: near "ALTER": syntax error
C:/Sites/jeepjig/db/migrate/20150315145856_change_mileage_to_bigint.rb:3:in `change'
C:in `migrate'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

根据文档 sqlite 不支持 您需要将数据复制到 bigint 类型的新列并更改 它的名字