# Error in Migration

**URL:** <https://www.ruby-forum.com/t/error-in-migration/147075>\
**Category:** Rails\
**Created:** [August 28, 2008, 9:57am UTC](https://www.ruby-forum.com/t/error-in-migration/147075 "2008-08-28T09:57:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naga\_harish\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/90ced4/32.png) [@Naga\_harish\_K](https://www.ruby-forum.com/u/Naga_harish_K)\
**Post date:** [August 28, 2008, 9:57am UTC](https://www.ruby-forum.com/t/error-in-migration/147075/1 "2008-08-28T09:57:15Z")

</div>

Hi all,  
I have an error while running the migration. The following is the  
problem.  
I have a table called sequences. Am adding a column called ‘seq\_type’  
in migration Version 79. and after adding am also inserting a row in the  
table, then its throwing an error called “undefined method seq\_type= for  
Sequence:0x4cab0f8”

This is my code.

def self.up  
add\_column :sequences, :seq\_type, :integer, :limit =\> 1  
Sequence.create(:user\_id =\> 1, :seq\_type =\> 2)  
end

Column is getting added, but the row is not getting created. when I run  
the migration again by commenting the first line , then its working  
properly.  
Why it is not working for the first time?  
I also tried to put the row creation in the next migration, even then  
its failing.

What could be the reason?? It it not detecting the column? If not what  
to do??

Kindly please help me…

---

<div class="post-metadata">

**Author:** ![Naga\_harish\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/90ced4/32.png) [@Naga\_harish\_K](https://www.ruby-forum.com/u/Naga_harish_K)\
**Post date:** [August 28, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/error-in-migration/147075/2 "2008-08-28T14:34:29Z")

</div>

I don’t think that ActiveRecord, of which your Sequence is a subclass,  
knows  
yet about the new column. Anyway, it’s a good idea to use models in  
migrations as little as possible so that changes in models don’t break  
older  
migrations. I’d recommend using SQL to add the data if you want to add  
it in  
this migration. If the data is seed data, i.e., it’s basic data that  
needs  
to be there for your application to run, I’d recommend using one of the  
many  
data seeding techniques that have been discussed/announced in the group  
before.

Regards,  
Craig

---

<div class="post-metadata">

**Author:** ![Naga\_harish\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/90ced4/32.png) [@Naga\_harish\_K](https://www.ruby-forum.com/u/Naga_harish_K)\
**Post date:** [August 28, 2008, 2:51pm UTC](https://www.ruby-forum.com/t/error-in-migration/147075/3 "2008-08-28T14:51:29Z")

</div>

On 28 Aug 2008, at 13:33, Craig D. wrote:

> I don’t think that ActiveRecord, of which your Sequence is a  
> subclass, knows yet about the new column.  
> If that’s the case, Sequence.reset\_column\_information should sort  
> things out.

Fred

---

<div class="post-metadata">

**Author:** ![Naga\_harish\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/90ced4/32.png) [@Naga\_harish\_K](https://www.ruby-forum.com/u/Naga_harish_K)\
**Post date:** [August 28, 2008, 3:04pm UTC](https://www.ruby-forum.com/t/error-in-migration/147075/4 "2008-08-28T15:04:19Z")

</div>

Hi,  
Thanks a lot… I used Sequence.reset\_column\_information and its  
working perfectly…  
Cheers…  
Naga Harish K.

Frederick C. wrote:

> On 28 Aug 2008, at 13:33, Craig D. wrote:
> 
> > I don’t think that ActiveRecord, of which your Sequence is a  
> > subclass, knows yet about the new column.  
> > If that’s the case, Sequence.reset\_column\_information should sort  
> > things out.
> 
> Fred
