Rename_column breaks tests?

Apologies for what is probably a very basic question–but whatever
obvious thing I’m missing continues to elude me.

Rails 2.3.2 and SQLite3

I create a new project with a single basic scaffold, migrate the
database, and run test. Everything passes. Create a migration that
does a single rename_column operation, and migrate again. Now test
fails with an SQLException Table X has no column named [oldname]. I
don’t believe it is a reserved name situation, and I cannot tell what
else might be going on. This test case is boiled down so much I just
don’t see where I’m doing anything weird. Help?

Step by Step:

rails testBreaker
cd TestBreaker (yeah windows, I know…)
ruby script/generate scaffold safeName testOne:string testTwo:string
rake db:migrate
rake test:units

[success]

ruby script/generate migration break_it_with_rename
[edit to include rename_column :safe_names, :testTwo, :broken]
rake db:migrate
rake test:units

[FAIL like this:
test_the_truth(SafeNameTest): ActiveRecord::StatementInvalid:
SQLite3::SQLException: table safe_names has no column named testTwo:
INSERT INTO “safe_names” (“updated_at”, “testOne”, “id”, “testTwo”,
“created_at”) VALUES (‘2009-10-17 00:27:32’, ‘MyString’, 996332877,
‘MyString’, ‘2009-10-17 00:27:32’)]

On Fri, Oct 16, 2009 at 5:39 PM, Erich Cranor
[email protected] wrote:

Rails 2.3.2 and SQLite3

I create a new project with a single basic scaffold, migrate the
database, and run test. Everything passes. Create a migration that
does a single rename_column operation, and migrate again. Now test
fails with an SQLException Table X has no column named [oldname].

Uh, yeah. That’ll do it.

Have you looked at the files created in that “test” directory when
you generate a model with basic scaffold? Recommended :slight_smile:

You might want to grep around there for [oldname], just for fun…


Hassan S. ------------------------ [email protected]
twitter: @hassan

You might want to grep around there for [oldname], just for fun…


Hassan S. ------------------------ [email protected]
twitter: @hassan

Doh…I thought I had done that. But I missed the fixtures. Many
thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs