我可以成功运行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
有什么帮助吗?
问题是我的Gemfile上列出了gem activeadmin
,而这个gem在config/routes.rb
文件上添加了一个唯一的行。
解决方案是注释activeadmin
添加的行,运行迁移,然后取消注释。
在之前的一次迁移中,您应该有create_table :posts
,但似乎没有。所以您尝试更改不存在的表,这正是Postgres所抱怨的。