I am cloning my own repo on to my local machine that another developer has done some work on. I am trying to migrate the database and receiving this error:
/Users/lewisfrost/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.0.1/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
DEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped. (called from <top (required)> at /Users/lewisfrost/frostfires/config/application.rb:8)
== AddUploadFileToAnswer: migrating ==========================================
-- add_column(:answers, :upload_file, :string)
-> 0.0006s
-- add_index(:answers, :slug)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column "slug" does not exist
: CREATE INDEX "index_answers_on_slug" ON "answers" ("slug")/Users/lewisfrost/frostfires/db/migrate/20140126204815_add_upload_file_to_answer.rb:4:in `change'
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "slug" does not exist
: CREATE INDEX "index_answers_on_slug" ON "answers" ("slug")
/Users/lewisfrost/frostfires/db/migrate/20140126204815_add_upload_file_to_answer.rb:4:in `change'
PG::UndefinedColumn: ERROR: column "slug" does not exist
/Users/lewisfrost/frostfires/db/migrate/20140126204815_add_upload_file_to_answer.rb:4:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
SCHEMA.rb
create_table "answers", force: true do |t|
t.string "user"
t.text "body"
t.integer "question_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
t.string "upload_file"
t.string "slug"
end
Migration file
class AddUploadFileToAnswer < ActiveRecord::Migration
def change
add_column :answers, :upload_file, :string
add_index :answers, :slug
end
end
Any advice is great
Pretty sure that you don't have slug
column in your answers
table.
So add that using a migration:
rails g migration AddSlugToAnswers slug:string
Then, run the migration:
bundle exec rake db:migrate