Rails: Cannot add :precision or :scale options with change_column in a migration?

Posted by Josh Pinter on Stack Overflow See other posts from Stack Overflow or by Josh Pinter
Published on 2010-03-15T21:07:07Z Indexed on 2010/03/15 21:09 UTC
Read the original article Hit count: 419

This seems to have been asked before: http://stackoverflow.com/questions/1402547/rails-decimal-precision-and-scale

But when running a change_column migration for :precision or :scale they don't actually affect the schema or database, but db:migrate runs without errors.

My migration file looks like this:

class ChangePrecisionAndScaleOfPaybackPeriodInTags < ActiveRecord::Migration
  def self.up
    change_column :tags, :payback_period, :decimal, { :scale => 3, :precision => 10 }
  end

  def self.down
    change_column :tags, :payback_period, :decimal
  end
end

But my schema (and the data) remains as:

t.decimal  "rate"  # previous column
t.decimal  "payback_period"
t.string   "component_type"  # next column

Anybody else have this issue?

Thanks,

Josh

© Stack Overflow or respective owner

Related posts about migration

Related posts about ruby-on-rails