Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm attempting to move toward developing WordPress sites locally, rather than on a live server, and as part of that move I'd like the ability to have a local and a remote version of a site, and easily deploy changes made locally the the remote site. That's easy enough for the filesystem changes using something like Git, but I'm not sure how to make database changes easy to transfer.

I understand that it's probably possible to write a script to somewhat automate this process, but I really don't know at all where to start.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Well, I think you've already alluded to the answer. You need to script your database changes. And then run that script on the live database using phpMyAdmin or something like this command if you have terminal access:

mysql db_name < scripted_changes.sql

If, however, you've referring to CONTENT changes then that's a different thing all together. eg If you edit a post on your dev site and want that post change to be applied to your live site, or if you've added and activated a plugin on your devsite. If this is what you want, I am sure there are solutions, but I would recommend you look at your workflow to see if this is necessary.

share|improve this answer
    
I realize I need to script those changes, but I don't have any experience doing that - I'm looking for suggestions on how to go about doing that (basically a high level overview - I'm not expecting anyone to write it out for me). –  tnorthcutt Dec 7 '11 at 12:57
    
Would importing database changes not capture e.g. a new post made? And would that not capture e.g. a plugin activation if the filesystem changes were also deployed? –  tnorthcutt Dec 7 '11 at 12:58
    
Scripting changes to your database STRUCTURE would be a set of SQL statements (eg ALTER TABLE). The problem with scripting changes to CONTENT, eg adding a post, is that you need to know ecxactly what changes to the database Wordpress is making and therefore not really practical. Further if you added a post to your dev site, say a post with ID 100. It might be that that post ID is already in the live site, so you can't simply script that as SQL. –  ZweiBlumen Dec 7 '11 at 13:12
    
Note: for moving posts between sites, you can always use Wordpress's export/import feature. Also, you might well be able to find plugins or online services to achieve what you want - I don't know. –  ZweiBlumen Dec 7 '11 at 13:15
    
Thanks, that clarifies things somewhat. What about scripting a one-time dump of the local DB and import into the remote DB (possibly to include overwriting any existing data in the remote DB)? That would at least allow for having a remote (internet-accessible) site to use for sharing/display purposes, and periodically pushing changes to it from a local site. –  tnorthcutt Dec 7 '11 at 17:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.