线上购物订单暂存和实时数据库同步 - Magento sync orders on staging and live databases

- 此内容更新于:2016-02-03
主题:

所以我有一个临时和生活线上购物网站。我想做的事比如主题、安装扩展,线上购物在测试站点升级等,然后把它活的服务器。问题是,当我在改变,生活有订单进入现场。所以我不能简单地复制文件和数据库现场服务器。我将丢失的订单和客户和我所有的订单数量会搞砸了。什么是正确的方法在同步两个数据库吗?线上购物升级或扩展安装将更改数据库,所以我不能使用的实时数据库。我看到有人提到使用GIT/GitHub,不知道它是如何工作的,但将所有你只将新数据库更改现场服务器,以及改变了文件?谢谢

原文:

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

解决方案:
你不需要让你登台和生产数据库同步时变量数据,如客户、订单等。相反,你应该dev-stripped数据库(没有日志、客户、订单等)在分段生产你使用。你可以把所有的测试订单你想重新填充数据。这也意味着你没有发邮件的风险客户从你的临时数据库。如果更新数据库,设计等,你需要跟踪两个领域的变化:文件更改(模板、CSS、Javascript、模块核心线上购物更新代码…)文件更改配置更改(数据库),你应该使用一个版本控制系统(Git,Subversion等)和跟踪你的变化,你把它们。当他们测试和准备部署到生产环境,那么你可以将它们合并到主。数据库更改,只有这样你可以确保当你将代码部署到生产,一切只是切换如果使用线上购物安装/升级脚本配置添加到数据库中。如果你还没有使用过,他们基本上一个PHP文件,并在你的配置版本号。xml对于你提高的一个模块,添加一个新的安装脚本,告诉它你想要改变什么,不管是创建新表或数据,节省或更改配置值,等。主要跟踪所有配置更改安装程序脚本的好处(我的意思是,从字面上)是:当您部署你的源代码和重建索引,线上购物将更新你的生产数据库所需的所有新配置你不必担心单独管理数据库更改的所有版本——每个模块版本增量可以有一个新的安装脚本,所以你可以看到什么改变的模块。更多信息,艾伦风暴有很大的文章。
原文:

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.

楼主:感谢罗比,伟大的回答。我将读艾伦的文章,但我想我仍然有担忧的数据库同步。如果我安装一个新的扩展(比如经销商定位器)在分段,然后我去和设置所有的设置扩展,导入所有数据(经销商位置)等。有很多新表和数据库中的数据。从我收集,安装/升级脚本只会安装模块基础设置。所以我必须再虽然和重做所有的设置和导入模块的所有数据,在现场。那是正确的吗?

(原文:Thanks Robbie, great answer. I will read Alan's article now but I guess I still have an area of concern about the database syncing. If I install a new extension (say a dealer locator) in staging, then I go though and setup all the settings for the extension, import all the data (dealer locations) etc. There is a lot of new tables and data in the database. From what I gather, the setup/upgrade script will only install the module base setup. So I have to go though and redo all the setup again and import all the module data again, on the live site. Is that correct?)

楼主:它看起来像我寻找的是你如何创建一个数据升级脚本从现有模块。有办法的数据导出到一个脚本,我可以推动现场服务器?

(原文:It looks like what I am looking for is how you create a data upgrade script from an existing module. Is there a way to export the data to a script that I can push to the live server ?)