mysql - ActiveRecord::NoDatabaseError: 未知数据库 'db/production' 运行时 "eb deploy"

标签 mysql ruby-on-rails amazon-web-services rds

尊敬的订阅者。

我想使用 amazon RDS mysql 数据库实例创建一个 Rails 项目。

我做了什么。


1) I created amazon RDS mysql instance at first and assigned the full access authority in security group.<br>
2) I have created a rails new project using sqlite and deployed it to amazon elastic beanstalk using "eb deploy". Worked well.<br>
3) In order to use the amazon RDS mysql, I have changed the config/database.yml as the following.<br>

    production:
      adapter: mysql2
      encoding: utf8
      database: <%= ENV['RDS_DB_NAME'] %>
      username: <%= ENV['RDS_USERNAME'] %>
      password: <%= ENV['RDS_PASSWORD'] %>
      host: <%= ENV['RDS_HOSTNAME'] %>
      port: <%= ENV['RDS_PORT'] %>
I have assigned the variables on the tab of configuration in eb instance.<br>
<hr>

使用“eb deploy”再次部署时出错


    ERROR: [Instance: i-0c11ecd4] Command failed on instance. Return code: 1 Output: (TRUNCATED)...options.
    ============= END WARNING FROM mysql2 =========
    rake aborted!
    ActiveRecord::NoDatabaseError: Unknown database 'db/production'

    Mysql2::Error: Unknown database 'db/production'

    Tasks: TOP => db:migrate
    (See full trace by running task with --trace). 
    Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
    INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
    ERROR: Unsuccessful command execution on instance id(s) 'i-0c11ecd4'. Aborting the operation.
    ERROR: Failed to deploy application.                                

    ERROR: Failed to deploy application.

I want to know the quick way to fix.

谢谢

最佳答案

将迁移迁移到 RDS 时发生错误。 这是以前使用 sqlite 的旧项目。 我不确定是否可以将迁移直接迁移到 RDS。 请再次检查错误。

Mysql2::Error: Unknown database 'db/production'

Tasks: TOP => db:migrate
(See full trace by running task with --trace).

因为我之前创建了RDS db,所以不需要再次迁移。 删除 db/migrate 中的迁移后,错误已修复。

关于mysql - ActiveRecord::NoDatabaseError: 未知数据库 'db/production' 运行时 "eb deploy",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35328785/

相关文章:

ruby-on-rails - "[fail] Can' t 查找文件 : config/schedule. rb"rails, 每当 gem

amazon-web-services - AWS CodeBuild- docker :找不到

amazon-web-services - 如果 S3 存储桶在设定的时间内处于非事件状态,请删除该存储桶吗?

Mysql 5.6.12 错误 : error 1356 when using order by alias in a view definition

Mysql 查询缓存无法与 mysql RDS 读复制一起使用

mysql - 表达这段代码的更简洁的方式是什么?

ruby-on-rails - Ruby 入门指南:未初始化常量 PostsController::Posts

ruby-on-rails - render_to_string 找不到部分(PDFKit Controller 响应)

amazon-web-services - 如何降低亚马逊Cloudfront成本?

MySQL 查询按特定类别列出多类别文章,同时仍检索主猫