Pushing CMS/static content from staging to production database?
Most Rails database-deployment discussions assume there are two facets of a database: the schema, which is handled in code via migrations, and the data, which is all user-generated and never needs to move from test to production. What about the stuff that lies in between?
For example, we have a number of mostly-static tables that contain complex surveys our users can take: questions, choices, branching. We want to be able to edit those surveys via our web app, but we want to be able to test changes on the staging server before we push them to production.
What's a good way to handle this in Rails, which wants all the models to exist in one database, and certainly wouldn't like the same model (with different contents) to exist in two databases? Are there any good discussions online, or any gems that have abstracted out this type of functionality?
I'v开发者_JS百科e worked with a large, complex CMS system that had its own multi-environment version control and deployment, so you could deploy your change to the test system (without riskily linking the test and production databases), test it thoroughly, and then do a one-click deploy to production. I guess I'm looking for something like that on a smaller scale.
I would use ActiveResource to pull the desired records from the staging environment to production. Alternatively, you could create a name-spaced set of ActiveRecord models to connect to the staging database directly. Either way, the implementation is roughly the same, but ActiveResource allows more flexibility with changing deployment details and the ActiveRecord method requires less setup code.
The actual implementation code should be fairly simple - pull a list of un-imported records from staging (you'll probably want to map the production records to their source staging records to easily prevent duplication) and copy the data.
Not sure about Rails but I am using one python script called Migraine, its useful to synchronizing development, staging, and live (production) sites' databases for Drupal CMS. For more info refer this :
- Presentation
- Get Migraine script here
精彩评论