我之前成功地使用自定义脚本将论坛迁移到了 Discourse,但现在再次执行时,出现了以下导入错误:
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:81:in `rescue in new_client': We could not find your database: discourse. Which can be found in the database configuration file located at config/database.yml. (ActiveRecord::NoDatabaseError)
To resolve this issue:
- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.
To create your database, run:
bin/rails db:create
我的脚本中的以下导入失败:
require File.expand_path(File.dirname(__FILE__) + \"/base.rb\")
我使用以下命令执行脚本:
./launcher enter app
cd /var/www/discourse
bundle exec ruby script/import_scripts/avatar.rb
但我不太明白这个错误:我可以通过 sudo -u postgres psql discourse 访问数据库,这证实了“discourse”数据库确实存在。而且,网站运行正常。当我打开 rails c 时,我也可以访问数据。
你能给我一些关于哪里出错了的提示吗?