0

I am learning Ruby on Rails, an am getting an error creating the database. I run the following command from console:

rake db:create db:migrate db:seed

And get:

== 20140328232600 AddAuthLevelToUser: migrating ===============================
-- add_column(:users, :auth_level, :Integer)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedTable: ERROR:  relation "users" does not exist

I looked at the error message on the webpage, and tried running:

'bin/rake db:migrate RAILS_ENV=development'

As suggested, but had little luck.

The project I am working on had been started by another team of developers, so I pulled it off git... Any suggestions?

Cheers

2 Answers 2

3

As per the error, you are running the migration AddAuthLevelToUser when you don't even have users table in database.

Firstly, verify if you have migration for users table, if not then create one.

If yes, then check that migration for users table has a VERSION NUMBER lower than that of AddAuthLevelToUser. Fix it and run the migrations.

Sign up to request clarification or add additional context in comments.

Comments

1

Try running just rake db:create at first. What database is your project using? Work this out and use the database client to connect to the database on your local system, and verify whether the users table exists on the database. It's possible that the db:create job is not correctly creating all the tables necessary for the database schema.

1 Comment

I've temporarily solved by destroying and re-creating the database, although this isn't ideal, thanks :)

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.