问题
I've noticed some odd behaviour when working with review apps. I created a review app for a pull request I was working on. It's parent was my staging app. As part of the pull request I migrated the database many times and I was testing those migrations with the review app. I'm working with Rails.
I was preparing to merge my changes and deploy to the staging app, but I noticed that the data in my staging app had changed. There have been no deploys to staging since I started this work.
For example, in staging I have a QrCode model, and that model has a user_id. With my review app, I migrated the database to drop the user_id column and create a new Product model that has a user_id instead. Now in my staging app, the user_id column has been dropped from QrCode but the new Product model isn't there. It's as if the existing tables in the database have been updated to the new schema, without the new ones being added.
Has anyone else experienced a similar issue, or know what might be going on? I need to know that all migrations work correctly before deploying to production.
回答1:
Ok I figured out the issue. I had updated my app.json to list DATABASE_URL as a required config variable. That caused my review app to have the same database url as my staging app. Once I removed this from my app.json, the database url config variable is generated automatically each time the review app is built.
来源:https://stackoverflow.com/questions/52302215/do-heroku-staging-apps-share-database-with-review-apps