我可以成功运行cap deploy
但是当我尝试运行cap deploy:migrate
时,我收到以下错误:
*** [err :: domain.com.br] rake aborted!
*** [err :: domain.com.br] PG::Error: ERROR: Relation"posts"does not exist
*** [err :: domain.com.br] LINE 4: WHERE a.attrelid = '"posts"'::regclass
*** [err :: domain.com.br] ^
*** [err :: domain.com.br] : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
*** [err :: domain.com.br] FROM pg_attribute a LEFT JOIN pg_attrdef d
*** [err :: domain.com.br] ON a.attrelid = d.adrelid AND a.attnum = d.adnum
*** [err :: domain.com.br] WHERE a.attrelid = '"posts"'::regclass
*** [err :: domain.com.br] AND a.attnum > 0 AND NOT a.attisdropped
*** [err :: domain.com.br] ORDER BY a.attnum
*** [err :: domain.com.br]
*** [err :: domain.com.br] Tasks: TOP => db:migrate => environment
*** [err :: domain.com.br] (See full trace by running task with --trace)
command finished in 8091ms
我已经在运行的服务器上创建了数据库:
create database <databasename>;
修改 添加迁移样本:
class AddStatusTagsViewsToPosts < ActiveRecord::Migration
def change
change_table :posts do |p|
p.string :status, default: 'pending'
p.string :tags
p.integer :views
end
end
end
任何帮助?
答案 0 :(得分:2)
问题是我的Gemfile上列出了gem activeadmin
,这个Gem在config/routes.rb
文件中添加了一个唯一的行。
解决方案是评论activeadmin
添加的行,运行迁移,然后取消注释。
答案 1 :(得分:0)
在之前的一项迁移中,您应该拥有create_table :posts
,但似乎没有。因此,您尝试更改不存在的表,即Postgres抱怨的内容。