Reputation: 2401
I have been getting my application ready for production, and I am struggling with raking my database. It is giving me this error:
PG::UndefinedTable: ERROR: relation "events" does not exist
: ALTER TABLE "events" ADD "code" character varying
Here is my database.yml file:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
production:
<<: *default
database: db/production.postgresql
Here is my events migration file:
class CreateEvents < ActiveRecord::Migration[5.0]
def change
create_table :events do |t|
t.string :name
t.string :partycode
t.references :user, foreign_key: true
t.timestamps
end
end
end
EDIT:
when I run rake db:migrate:status
I get the following result:
Finally, here is my gemfile:
source 'http://rubygems.org'
gem 'bootstrap-sass', '3.2.0.2'
gem 'bcrypt', '3.1.11'
gem 'will_paginate'
gem 'responders'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem "heroku"
gem 'coffee-script-source', '1.8.0'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'sqlite3'
gem 'byebug', platform: :mri
end
group :production do
gem 'web-console'
gem 'pg'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
ruby "2.2.4"
Lemme know if there is anything else you need to solve this issue that I am having. Thanks :D
Upvotes: 0
Views: 512
Reputation: 6418
Seeing your rake db:migrate:status
you have one problem that is a migration Add code to events
should be after Create events
migration because you are making changes in event
but the table for that is being created afterwards. So you should fix this, and for temporary fix what you can do is:
rake db:migrate:up VERSION=20161219214142
20161219214142
is the version of you Create Events
migration, so this will run the specific migration for you and create the events
table then if you will run rake db:migrate
then it will work fine.
Upvotes: 1