views:

33

answers:

1

I have a rails project that uses an old versions of the FlexImage plug-in to handle images.

In the old version that image data was stored in a column called "data", in the new version that column must be named "image_file_data".

I wrote a migration to rename the column, but when I try to run the migration, my guess is that rails tries to load the models, which then automatically check to see if the valid column is there (which it isn't) and that throws an error which halts the migration.

I would guess that my problems would be solved if I never loaded the model classes in question and just wrote some sql to rename the columns. But the following line doesn't work, since rails still tries to load the model.

Apartment.connection.execute "ALTER TABLE logos CHANGE DATA image_file_data MEDIUMBLOB;"

A: 

Oops, I figured it out. I was calling

model = (table_name.to_s).classify.constantize

Earlier, and this was causing the model to load

Janak