无法在PostgreSQL上运行数据库迁移

时间:2011-10-09 19:17:49

标签: ruby-on-rails postgresql pg

我刚刚从sqlite3更改为PG,在通过pgAdmin创建数据库并尝试运行迁移后,我遇到了以下情况,我不明白。

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 个答案:

答案 0 :(得分:3)

我不知道警告,但错误信息显示:

  

关系“用户”不存在

也许您使用的是大写“用户”,其中表的名称为users?只要它们不是双引号,Identifiers in PostgreSQL就不区分大小写。

答案 1 :(得分:1)

似乎迁移假设已经存在Users表,而不是全新的PostgreSQL数据库...

您是否忘记将一些启动架构添加到数据库中?