0

I have created a migration to add a column named blurb to a table with only one other column called full_name. After I run my migrations, this new column appears to be added when I check from the database console of postgresql database, but not from the Rails app console. Then after a period of time, it vanishes from the postgresql console as well.

I don't know how to account for this. My migration was created using the rails migration generator and it's a :text field.

class AddBlurbToPeople < ActiveRecord::Migration
  def self.up
    add_column :people, :blurb, :text
  end

  def self.down
    remove_column :people, :blurb
  end
end

Any help would be much appreciated.

EDIT: PostgreSQL version number is 9.0.4

4
  • What are you doing during this "period of time"? Are your dev/production/test databases all different? Commented Dec 9, 2011 at 5:33
  • I am literally doing nothing. I am testing this in the development environment and all environments are on a different database.
    – picardo
    Commented Dec 9, 2011 at 5:37
  • What is the exact sequence of events? Stop server, run migrations, check \d in psql, ... Commented Dec 9, 2011 at 5:43
  • Correction: actually I should add that I am restarting the Rails console in that period of time, and I think the column is getting lost right after the console gets loaded. (I verified this by querying the schema on postgresql console as the Rails console was starting.)
    – picardo
    Commented Dec 9, 2011 at 5:45

1 Answer 1

1

You have to run reload! on console after "rake db:migrate". Or simply restart console.

1
  • Wow! reload! worked. I am amazed. My question is why did that work? It's weird that a column in the database would disappear by itself unless you restart the console...
    – picardo
    Commented Dec 10, 2011 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.