rubyonrailsin

A Ruby and Rails talk

Saturday, March 13, 2010


[Rails] Re: Coding a migration to change a column's attribute

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Hi Colin,

Thanks for some additional guidance. I know I appear to be a
blithering idiot by virtue of my myriad mistakes, misunderstandings
and apparent stupidity.

> Why not try it and see? Provided you have a dump of the database (and
> you do have your code under source control in git (or svn) don't you)

I didn't try it because I have enough trouble going forward. I don't
want to again suffer the burden of 2 days to recover from stupid
mistakes, like changing MySQL versions as I just did unnecessarily.

Dump of DB unnecessary: I only have a little toy data created by
testing.
SVN backup: I will get to that in a few weeks; right now I make
date&time-named backups of my project daily to an external hard-drive:
code and documentation.

> Did you check the params required for change_column from the docs
> (http://api.rubyonrails.org/classes/ActiveRecord/Migration.html)? 
< It looks to me like you have a missing parameter.

Good site, but I didn't find my exact requirement. Yes, I was
missing the table-name parm. Here's my current incarnation:

class ChangeExpenseTblAmountCol < ActiveRecord::Migration
def self.up
change_column :expense, :amount, :decimal :precision =>
10, :scale => 2
end

def self.down
end
end

No matter what permutation I try, the db:migrate task finds an error
(usually syntax).

When I was in USAF Radio School at the beginning of the Korean "Police
Action", I discovered the Cryptographic School next door and "knew" I
belonged there. But the effort to crack the code proves I was wrong
those many years ago, 'cause I can't crack this code.

Does anything leap out at you?

As usual, thanks for the gift of your time and expertise,
Richard

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive