# Rename\_column breaks tests?

**URL:** <https://www.ruby-forum.com/t/rename-column-breaks-tests/177436>\
**Category:** Rails\
**Created:** [October 17, 2009, 2:39am UTC](https://www.ruby-forum.com/t/rename-column-breaks-tests/177436 "2009-10-17T02:39:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinbot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@pinbot](https://www.ruby-forum.com/u/pinbot)\
**Post date:** [October 17, 2009, 2:39am UTC](https://www.ruby-forum.com/t/rename-column-breaks-tests/177436/1 "2009-10-17T02:39:53Z")

</div>

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’)]

---

<div class="post-metadata">

**Author:** ![pinbot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@pinbot](https://www.ruby-forum.com/u/pinbot)\
**Post date:** [October 17, 2009, 4:33am UTC](https://www.ruby-forum.com/t/rename-column-breaks-tests/177436/2 "2009-10-17T04:33:38Z")

</div>

On Fri, Oct 16, 2009 at 5:39 PM, Erich Cranor  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 🙂

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

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![pinbot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@pinbot](https://www.ruby-forum.com/u/pinbot)\
**Post date:** [October 17, 2009, 7:03am UTC](https://www.ruby-forum.com/t/rename-column-breaks-tests/177436/3 "2009-10-17T07:03:40Z")

</div>

> You might want to grep around there for [oldname], just for fun…
> 
> –  
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

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