0

I've just changed from sqlite3 to PG and after creating a database via pgAdmin and trying to run a migration, I run into the following, which I don't understand.

Pawel:bodb pawel$ rake db:create
DEPRECATION WARNING: Rake tasks in /Users/pawel/Ruby/apps/bodb/vendor/plugins/google_charts_on_rails/tasks/google_charts_on_rails_tasks.rake are deprecated. Use lib/tasks instead. (called from /Users/pawel/Ruby/apps/bodb/Rakefile:7)

firstdb already exists
Pawel:bodb pawel$ rake db:migrate
DEPRECATION WARNING: Rake tasks in /Users/pawel/Ruby/apps/bodb/vendor/plugins/google_charts_on_rails/tasks/google_charts_on_rails_tasks.rake are deprecated. Use lib/tasks instead. (called from /Users/pawel/Ruby/apps/bodb/Rakefile:7)
==  AddLikesToUsers: migrating ================================================
-- add_column(:Users, :likes, :string)
rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR:  relation "Users" does not exist
: ALTER TABLE "Users" ADD COLUMN "likes" character varying(255)

Tasks: TOP => db:migrate
(See full trace by running task with --trace) 

2 Answers 2

3

I don't know about the warnings, but the error message says:

relation "Users" does not exist

Maybe you are using upper case "Users", where the table's name is users? Identifiers in PostgreSQL are case insensitive as long as they are not double-quoted.

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

5 Comments

Rails is creating all my tables and schema.rb shows them as lower case so can't be that.
@Simpleton: if they are lower case, then this is the problem. The query reads ALTER "Users", not ALTER users or ALTER Users.
@Simpleton: add_column(:Users, :likes, :string) isn't right, it should be add_column(:users, :likes, :string) so Erwin is on the right track.
Correct. That did seem to be the problem in the "likes" migration. Thanks
what about this error , can it be solved ? == AddColumn1: migrating ===================================================== -- add_column(:users, :first_name, :string) rake aborted! An error has occurred, this and all later migrations canceled: PG::Error: ERROR: relation "users" does not exist
1

It appear that the migration assumes that an Users table already exists which is not the case with a completely new PostgreSQL database...

Did you forget to add some start schema to the database?

3 Comments

Perhaps, nothing of the sort came up in the guides.
Ah, I can read from the other answer that you took out something from the migration output - it looked like AddLikesToUsers was the first migration you ran :-)
Yep, small things. Thanks though.

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.