gpt4 book ai didi

ruby-on-rails - 为什么不同的 rake 命令会影响不同的数据库?

转载 作者:行者123 更新时间:2023-12-04 06:30:58 24 4
gpt4 key购买 nike

当未指定RAILS_ENV 时,db:createdb:drop 会同时影响开发和测试。然而在同样的情况下,db:migrate 只影响开发。这是为什么?

最佳答案

这是因为 test 数据库仅在测试运行时通过 schema.rb 更新。

参见 here :

In order to run your tests, your test database will need to have the current structure. The test helper checks whether your test database has any pending migrations. If so, it will try to load your db/schema.rb or db/structure.sql into the test database. If migrations are still pending, an error will be raised. Usually this indicates that your schema is not fully migrated. Running the migrations against the development database (bin/rake db:migrate) will bring the schema up to date.

关于ruby-on-rails - 为什么不同的 rake 命令会影响不同的数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32978409/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com