问题
My openshift drupal gear has live customer data, but my test site has just test data. When I develop a new feature, fix a bug, add a view or change a field in a content type (on test site), it will makes changes to the mysql database. How do I upload these changes to the gear w/o wiping out the tables that hold customer data? So far I have not had to write any custom code, just added modules and configured them. So I'd rather avoid a PHP solution. Thanks.
回答1:
You will either have to write some kind of migration scripts, or you will have to manually make the changes on your production instance that you made on the development instance. Doing a "git push" should not modify your production database, it should only upload your code changes.
回答2:
developercorey has it pretty much nailed.
To expand a bit though, this has very little to do with Openshift, and everything to do with Drupal (you will typically encounter this with Drupal regardless of what service you run it on). You would, for example, have trouble bringing the live data down to your test site too.
The problem is that Drupal does a poor job of separating configuration and content in the database. Drupal 8's CMI should solve this for most cases, but for site not running Drupal 8, there are really only two options:
- Track and recreate dev database changes manually on the remote site and use git to manage the addition of new modules, libraries, themes etc; this is tedious and error prone.
- Use the Features module to keep all your important configuration in code. This way is fairly reliable, though Features can, at times, be finicky.
Features workflow
Caveats
- You don't have to be able to code to use features, though it does help
- Features can only help you with those bits of Drupal that are exportable--there are some parts that just aren't
Anyhow, to use features to manage changes, you follow a procedure something like what follows. For the purposes of this post, I'm going to imaging that your feature contains a single view and nothing else. The principles are the same for more complex features, but discussing a really complex feature would make this too long. I'm also not going into the nuts and bolts of which link to click and button to press in the UI--there's documentation of that kind of thing on the Features project page, linked above. I'm also going to assume that after the initial creation of the feature you'll be using drush
and git
on the command line for management.
Creating a feature on the dev site
- back up your database :)
- in the Drupal admin area, create a new feature containing exactly one view
- export the feature/write it to the file system
- delete the view from the Views UI
- enable the feature using
drush en
- add, commit, and push the new feature using
git
Deploying the feature on production
- back up your database :)
- get the new feature using
git pull
- repeat steps 4-5 from above
Modifying the feature on the dev site
Say your view now needs changes. You'd follow these steps to get those changes into code via your existing feature:
- back up your database :)
- make changes to the view in the Views UI
- in a terminal, navigate to the directory of your feature
- run
drush fu
- run
git status
(this should show you whether anything has changed in your feature) - commit and push your code changes using
git
Deploying the changed feature on the dev site
- back up your database :)
- get the changes to your feature using
git pull
- navigate to your feature in the Features UI
- revert the feature (this will change the feature settings in the database to match what's in the code)
That's it.
回答3:
As you have not mention the Drupal Version but You can use wonderful feature provide in Drupal 8 i.e. Synchronize
URL : admin/config/development/configuration
Using this feature you will able to export the views, content type with its field and imported it another server and code via GIT or any other revision control.
NOTE: Make sure uuid will be the same of both the instance(Source & Destination)
来源:https://stackoverflow.com/questions/26123876/how-can-i-deploy-changes-to-my-drupal-gear-when-the-mysql-db-holds-customer-data