I am trying to change my table column from an integer to a bigint I create a migration and then added this code to the migration file.
class ChangeMileageToBigint < ActiveRecord::Migration
def change
execute <<-SQL
ALTER TABLE posts
ALTER COLUMN mileage TYPE bigint USING mileage::bigint
SQL
end
end
However, I am getting this error when running 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)
Aucun commentaire:
Enregistrer un commentaire