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>"
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??
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.