I've been working on a Ruby on Rails API and I'm using Google Cloud Platform, specifically Google App Engine, to deploy my app. I followed the instructions here. So far so good. My app was successfully deployed and I could successfully run the migrations. Let's call this environment production.
我一直在研究Ruby on Rails API,我正在使用Google Cloud Platform,特别是Google App Engine来部署我的应用程序。我按照这里的说明操作。到现在为止还挺好。我的应用程序已成功部署,我可以成功运行迁移。我们称之为环境生产。
The thing is I need to deploy a sort of staging environment. For the moment I had to create another project to solve my problem and consider that as my staging environment. Now, I don't think this is necessary, actually seems to be redundant.
问题是我需要部署一种暂存环境。目前我不得不创建另一个项目来解决我的问题,并将其视为我的临时环境。现在,我不认为这是必要的,实际上似乎是多余的。
I've prepared another database my_app_db_staging
. And I created a staging.yaml
file stating to run as another instance with the service name staging. The service was successfully deployed. Where is the problem? Well, running the migration. I'm using the appengine
gem. So, to run the migrations you're supposed to run:
我准备了另一个数据库my_app_db_staging。我创建了一个staging.yaml文件,声明要作为另一个具有服务名称staging的实例运行。该服务已成功部署。哪里有问题?好吧,运行迁移。我正在使用appengine gem。因此,要运行您应该运行的迁移:
bundle exec rake appengine:exec -- bundle exec rake db:migrate
But as the documentation states:
但正如文件所述:
The
appengine
gem provides the Rake taskappengine:exec
to run a command against the most recent deployed version of your app in the production App Engine environment.appengine gem提供Rake任务appengine:exec,用于在生产App Engine环境中针对应用程序的最新部署版本运行命令。
So, no clue on how to run the migrations against my recently created staging service.
因此,没有关于如何针对我最近创建的临时服务运行迁移的线索。
1 个解决方案
#1
1
I looked deeper into the appengine
gem, and it has an option. It lacks more documentation so you don't have to waste time looking for an answer:
我深入研究了appengine gem,它有一个选项。它缺少更多文档,因此您不必浪费时间寻找答案:
rake appengine:exec GAE_CONFIG=staging.yaml -- bundle exec rake db:migrate
The options can work together with GAE_SERVICE
, but the yaml file has to have the same name, otherwise you'll get an error.
这些选项可以与GAE_SERVICE一起使用,但是yaml文件必须具有相同的名称,否则您将收到错误。
#1
1
I looked deeper into the appengine
gem, and it has an option. It lacks more documentation so you don't have to waste time looking for an answer:
我深入研究了appengine gem,它有一个选项。它缺少更多文档,因此您不必浪费时间寻找答案:
rake appengine:exec GAE_CONFIG=staging.yaml -- bundle exec rake db:migrate
The options can work together with GAE_SERVICE
, but the yaml file has to have the same name, otherwise you'll get an error.
这些选项可以与GAE_SERVICE一起使用,但是yaml文件必须具有相同的名称,否则您将收到错误。