Best practice for staging to live database synchronization
#1
Posted 09 May 2012 - 09:03 AM
My team has built a few ProcessWire sites, and we LOVE it - it is now our go to CMS. However, we have come up against the same issue on each site and wonder if/how any of you are managing it.
I don't think the issue is entirely specific to ProcessWire, but due to the structure of the way PW stores data it may require an answer that only applies to PW. It's the issue of keeping a staging site database in synch with a live site.
To illustrate: we start developing a new section, or modifying the functionality of a current section. All the while the client is making content changes on the current site, and in so doing changing the data in many different tables.
Is there an approach, other than manually noting which tables have changed during our update, that people are using to manage this situation?
With WordPress, for example, all of the content ends up in one big table, the structure of which doesn't change, so updates aren't that tricky. With PW data and structure being intermingled, it makes it a bit more tricky to manage.
I'd really appreciate knowing more about how people manage this, even if it's just confirming that there isn't a better way than doing it manually.
Thanks.
#2
Posted 09 May 2012 - 12:42 PM
I use my staging servers for staging things like new template files, modules, new PW versions, etc. I don't usually stage actual content from one server to another. Or if I do, I'm copying and pasting it (in PW admin) from one to the other. But the way I usually stage major content changes is to make them on the live server, but in a staging part of the site (unpublished, hidden or otherwise inaccessible pages). When ready to migrate, I publish or drag the relevant pages to their live home. Note that this is for content, and not for anything that could interfere with the operation of the live site. Anything that could interfere with the live site (templates already in use, modules, versions, etc.) ideally should be staged on a different server. I don't know of a better way than that. It's not perfect, but it's always worked well for me.
Longer term, I want ProcessWire to support a workflow that lets a staging server talk to a live server and publish from one to the other (using web services). I already use this workflow on a lot of sites with custom modules, but they are specific enough to the individual sites that they aren't suitable as a broader solution. However, I do think we'll have a broader solution like this in the next 6 months to a year.
#5
Posted 20 May 2012 - 10:21 PM
or do you copy over the files from the staging root, export the staging database, and import the database into the live database?
(ie: do you skip the installation step?)
I have an issue with my admin section after starting a new live site, where I skipping the pw installation step and am wondering if that could have caused it.
Edit: I usually use the same database name, username and password on staging and live for synchronization convenience.
#6
Posted 21 May 2012 - 12:32 AM
Moving from a subdomain to the site root is the simpler option though: drag and drop
#7
Posted 21 May 2012 - 03:11 AM
#9
Posted 21 May 2012 - 08:00 AM
I'm with stillmovingdesign on this one - that's exactly how I have done it a couple of times with hardly any issues. The only thing last time was images inserted in content through tinymce didn't seem to have the correct path, but as there were only a couple of pages involved it wasn't a big deal.
And even for this issue there's a module http://processwire.c...ink-abstractor/
@somartist | modules created | support me, flattr my work flattr.com
#11
Posted 21 May 2012 - 09:53 PM
And even for this issue there's a module http://processwire.c...ink-abstractor/
I need to get this actually built into the TinyMCE module so that people don't even have to think about it. +1 on the todo list.
#12
Posted 22 May 2012 - 02:43 AM
#13
Posted 24 May 2012 - 03:54 AM
I'm with stillmovingdesign on this one - that's exactly how I have done it a couple of times with hardly any issues. The only thing last time was images inserted in content through tinymce didn't seem to have the correct path, but as there were only a couple of pages involved it wasn't a big deal.
Happened to me too!
#14
Posted 15 June 2012 - 11:27 AM
The root of the problem, is the idea of storing data (content) and meta-data all together in the database - treating it all as "one thing" makes for very efficient and elegant development, but makes it difficult (impossible really) to migrate changes incrementally.
A couple of ideas to address this issue:
1. Separate data from meta-data. In my own CMF architecture that I've been dreaming up for some years now, meta-data is stored in flat files rather than in the database, which means you can check structural changes into a VCS, and deploy those changes easily. In the case of PW, this would mean you could check-in changes to meta-data along with matching changes to template-files, so that there is no chance of inconsistency between those.
2. Have a "recorder mode" that you can switch on during development. This would simply record all insert/update/create/alter SQL statements to a flat file, so you can repeat all the operations by just running that. Not quite as simple as it sounds though, due to primary keys possibly colliding with the same primary keys on the server you're deploying to - the only real way around that, as far as I can figure, is to not use numeric sequential keys, and use GUIDs instead.
3. Record (certain) form-submissions and controller/action, so you can repeat operations by simply running the controllers/actions again, essentially simulating the same sequence of requests that generated the original changes. Again, not necessarily as simple as it sounds, if for instance auto-insert IDs are posted via hidden-fields on a form, it wouldn't "just work".
Clearly neither of these are a "quick fix", but I think it's something we should discuss - it's not a small problem that you can ignore, in my opinon.
#15
Posted 18 June 2012 - 11:43 AM
Something that I've got a higher comfort level with are specific import/export tools. For instance, a tool that enables me to connect my PW install with another, and browse the fields, templates and pages. Then I can click on "import" and have that field, template or page(s) created on my system too. If there's some matter of meta data to be resolved (like a new page reference with non-existing parent), then I know it then and there and can adjust my import sequence accordingly. If I'm modifying data rather than importing, then I can have the opportunity to see and confirm what's going to happen before it takes place. If we're talking about going between two servers that can't talk to each other, then copy/paste of JSON data from one to the other in the developer's browser is another way to accomplish it. This process seems more supportable because the individual site developer still has some ownership over what's happening.
#16
Posted 18 June 2012 - 06:15 PM
The #1 idea sounds interesting and I like where you are going with that, though I don't think it's safe to consider the meta data independent from the content to the point where it would be safe to version them separately.
It's a decision you'd have to make about how you're going to use the framework - for instance, if you decide that all development happens on your local machine, and you set up users/rights on the production site so that metadata (fields and templates) can't be modified, that simplifies things.
I don't necessarily need a solution that enables me to create/change the metadata both on the running server and on my development server and then expect to merge them. That would be an extra benefit - but the key requirement is that I be able to develop the site off-line, and continuously integrate changes to the live site.
#17
Posted 19 June 2012 - 09:13 AM
When it comes to pages, the same concept applies but is a little more complex given the diverse nature of page data that might include page references, file-based assets and so on. For example, with files/images, we can't reasonably encode those in JSON files and import elsewhere, so the dev server would need to be able to talk with the live server via a web service and pull the assets individually.
#18
Posted 19 June 2012 - 09:19 PM
You could encode entire change-sets, including binaries, as JSON if you wanted to - you could base64 encode them. Granted, there's a substantial performance penalty and bandwidth overhead to consider there, but it might be useful to have it as an option for those who do want to archive an entire change-set in a single file.
Phar-archives would be another option - they are self-contained, bandwidth-efficient, and supported on every PHP installation. Worth considering anyhow.
#19
Posted 20 June 2012 - 11:07 AM
Also tagged with one or more of these keywords: database, synch
Community Support →
General Support →
PageListSelect Field Input Type Not Storing DataStarted by tc_855, 09 Jun 2013 |
|
|
||
Community Support →
General Support →
online to local migrationStarted by danielholanda, 14 May 2013 |
|
|
||
Community Support →
Getting Started →
Extending the PW-backend: e.g. CRUD systemStarted by dragan, 07 May 2013 |
|
|
||
Community Support →
Getting Started →
MySQL Database User Privileges?Started by Lance, 27 Mar 2013 |
|
|
||
Community Support →
Getting Started →
Need guidance for UI modules, sortable dataStarted by bongomania, 22 Mar 2013 |
|
|
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













