Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change integer to float column table Rails

I need to change t.integer :mark_up to a float How can I do this? I have tried in my terminal rails g migration change_column(:stakes, :mark_up, :float) by keep getting a syntax error near unexpected token ('

like image 360
Neil Murphy Avatar asked Mar 17 '15 21:03

Neil Murphy


1 Answers

In your terminal:

rails generate migration ChangeMarkUpToFloat

and in the file that is created: db/migrate/2015xxxxxxxxxx/change_mark_up_to_float.rb

edit it to:

class ChangeMarkUpToFloat < ActiveRecord::Migration
  def change
    change_column :stakes, :mark_up, :float
  end
end

and then back in your terminal:

rake db:migrate
like image 128
Nosajool Avatar answered Sep 23 '22 06:09

Nosajool