在本地测试都很正常,开始部署输入cap production deploy
报错
Caused by:
SSHKit::Command::Failed: rake exit status: 1
rake stdout: == 20190408023032 AddImageToPost: migrating ===================================
-- add_column(:posts, :image, :string)
rake stderr: rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::DuplicateColumn: ERROR: column "image" of relation "posts" already exists
: ALTER TABLE "posts" ADD "image" character varying
我删除了报错的 migrate,上传成功,但是功能丧失。
我在网上寻找了答案,需要rake db:drop
rake db:create
rake db:migrate
,但是我这是远端的重复表格,所以我登录远端切换到 deploy 账户
执行cd ~/项目数据库名称/current
切换到 current,输入RAILS_ENV=production bundle exec rake db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1
报错
ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR: database "rails_recipes" is being accessed by other users
DETAIL: There is 1 other session using the database.