Search code examples
ruby-on-railspostgresqlpg

Can't run DB migration on PostgreSQL


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) 

Solution

  • 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.