From: darius Date: 2007-11-11T02:30:03+09:00 Subject: why this rake db:migrate error hello I'm getting a rake db:migrate error which I can't understand (newbie). -- add_column(:stories, :votes_count, :integer, {:default=>0}) rake aborted! Mysql::Error: #42S21Duplicate column name 'votes_count': ALTER TABLE stories ADD `votes_count` int(11) DEFAULT 0 (See full trace by running task with --trace) the error is in 005_add_counter_cache_to_stories.rb class AddCounterCacheToStories < ActiveRecord::Migration add_column :stories, :votes_count, :integer, :default => 0 def self.up Story.find(:all).each do |s| s.update_attribute :votes_count, s.votes.length end end def self.down remove_column :stories, :votes_count end end the latest migration file is 006_add_story_creation_date_and_description.rb class AddStoryCreationDateAndDescription < ActiveRecord::Migration def self.up add_column :stories, :created_at, :datetime add_column :stories, :description, :text end def self.down remove_column :stories, :created_at remove_column :stories, :description end end here's schema.db, which I have not touched ActiveRecord::Schema.define(:version => 5) do create_table "stories", :force => true do |t| t.column "name", :string t.column "link", :string t.column "permalink", :string t.column "user_id", :integer t.column "votes_count", :integer, :default => 0 end create_table "users", :force => true do |t| t.column "login", :string t.column "password", :string t.column "name", :string t.column "email", :string end create_table "votes", :force => true do |t| t.column "story_id", :integer t.column "created_at", :datetime t.column "user_id", :integer end end (if this looks familiar, it's b/c I'm working through the examples in a RoR book) In an earlier migration file (003) I also have an add_column but rake doesn't give me an error. That add_column however does not have a default value option. any help is appreciated. thanks in advance.