user3608473
user3608473

Reputation: 1

Magento sync orders on staging and live databases

So I have a Staging and Live Magento site. I want to do thing things like theming, installing extensions, Magento upgrades etc. on the staging site and then push it to the live server.

Problem is that while i am working on the changes, there are live orders coming into the live site. So I cannot simply copy the files and database to the live server. I will be missing orders and customers and all my order numbers will be screwed up.

So what is the correct way to keep both databases in sync ? Something like a Magento upgrade or extension install will make changes to the database, so I can't just use the live database for both.

I saw someone mention using GIT / GitHub, not sure how it works but will that all you to push only new database changes to the live server, along with changed files ?

Thanks

Upvotes: 0

Views: 922

Answers (1)

scrowler
scrowler

Reputation: 24425

You shouldn't need to keep your staging and production databases in sync when it comes to variable data such as customers, orders etc.

Instead, you should have a dev-stripped database (no logs, customers, orders etc) from production which you use in staging. You can place all the test orders you want to re-populate that data. This also means you don't have the risk of emailing live customers from your staging database.

In terms if updating your database, design etc, you need to track two areas of change:

  1. File changes (templates, CSS, Javascript, modules, core Magento updated code...)
  2. Configuration changes (database)

For file changes, you should be using a version control system (Git, Subversion, etc) and tracking your changes as you make them. When they're tested and ready to deploy to production, then you can merge them into master.

For database changes, the only way you can really ensure that when you deploy your code to production that everything just switches over is if you use Magento setup/upgrade scripts to add your configuration to the database. If you haven't used them before, they're basically a PHP file and a version number in your config.xml for a module that you bump up, add a new install script and tell it what you want to change, whether that be creating new tables or data, saving or changing configuration values, etc.

The major benefits of tracking all your configuration changes in installer scripts (I mean all of it, literally), is:

  1. When you deploy your source code and reindex, Magento will update your production database with all the new configuration it needs
  2. You don't have to worry about managing database changes separately
  3. It's all versioned - each module version increment can have a new install script, so you can see what's changed in the module over time.

For more information, Alan Storm has a great article on them.

Upvotes: 2

Related Questions