"how to populate production database (heroku) with development data? (rails)" Code Answer


migrations can handle both structure (schema) and data, but once you're rolling, the assumption is that in most cases your production data is the canonical source of information. if there's data needed to set up the database, for example things like lists ("mastercard, visa, amex) or bootstrapping data (e.g. setting up an admin user) this can go in the "seeds .rb" file. there's nothing built in that makes a copy of a database (schema and content) and automatically applied it -- this would typically be a one-time thing.

(going the other direction -- copying the production database to qa or development instances is a common use case. at first, you might think: rails should be able to do this. but copying a typical production database may be fraught with issues. the most important is: copying a production database having user info is a significant security risk; any copy operation should at the very least make users anonymous. a second issue is just database size: a production database is often useful or even necessary to reproduce real-life performance issues or other edge cases, but any large database will end up taking a long time to replicate, and is highly dependent both on the specific database you're using, and on the permissions)

in short, rails does the right thing with migration: assumes structural updates are ok, but requires you to populate data. hope this helps!

By B. Hel on March 1 2022

Answers related to “how to populate production database (heroku) with development data? (rails)”

Only authorized users can answer the Search term. Please sign in first, or register a free account.