我正在尝试将我的表列从整数更改为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)