6
Answers
Vote up!
0
Vote down!

synchronize data between development and live database drupal commerce

Hi all,

I suppose that almost everybody should have to deal with my question but yet I am unable to find any topics on this one. So the answer might be very obvious.

I have a drupal commerce site which is live but in order to increase sales I make changes now and then including adding new functionality. This means other modules, new settings etc. In order to work with the same starting point I copy my mysql database to a development database. So at t=0 we have to identical database, the live one and the test one.

As soon I start developing on the test database the test database starts to change but so is the live database because of sales, customer profile changes etc.

My question is, how do I add the changes made in my development environment to the live database without overwriting changes made in the live database such as customer profiles, orders etc.

I am sure that somehow this can be done with some smart mysql/php queries. However, I am not that familiar with programming other than some simple copy and paste ;)

Asked by: Sem
on December 8, 2012

6 Answers

Vote up!
0
Vote down!

After modules are changin the behavior of the database, including structure changes, you have to do the setup process an the life system as well.

Copying the database only works once, as initial setup.

After the life site is running, and dynamicly changing, you will never by synchronous anymore.

If you have changes to modules, installed new modules etc., you have to do these changes to the life site as well - upload the files via FTP, run the update procedure and do the configuration.

For more automation, you can use drush

Answer by: ronald
Posted: Dec 10, 2012
Vote up!
0
Vote down!

Thank you Ronald for your answer,

Than again, what do you have to upload? I understand that you have to upload any new modules but suppose you have changed the configuration of existing modules? Or when you have added new nodes?

File system is not the biggest problem, but how to know which tables for example in the database need to be exported and imported without overwriting vital information such as customers and orders?

Answer by: Sem
Posted: Dec 10, 2012
Vote up!
0
Vote down!

You have to do the same things at the life site, to make the engine write the tables.
You propably had a look into the tables of Drupal, and fount out, that this is quite a complex relational system.
Therefor ist is not possible, to just replace a table, or even just insert rows, to adapt changes.

If you are creating nodes on your offline site, you have to import them on the target site.
Just inserting records could cause troubles with the numbering in the life site.

For this purpose there is the feeds module with some additions for importing users, nodes, products (if you run a shop), Taxonomies etc.

Answer by: ronald
Posted: Dec 11, 2012
Vote up!
0
Vote down!

Understand your point but then again, Feeds is also importing nodes so updating certain tables should be possible since that is what feeds is doing.

It seems a difficult task to export and import every item with feeds and I am not sure if it is even possible to export and import everyting with feeds. Do you know? Things like blocks, configuration settings etc?

It just seems impossible to develop a website that is already live. I mean, pick a large drupal commerce website that is live at the moment. I just cant believe that the developers write down every click on the development website, then take down their live website (no traffic, no revenue, no profit) and start clicking on the live website.

Somehow there should be a solution...it should be possible to develop changes on a development server and update the live website within a minutes rather then days (in case you have to mimic everyting on the live website what you have done in the development environment by hand)

Answer by: Sem
Posted: Dec 11, 2012
Vote up!
0
Vote down!

It depends, what you are changing.

Answer by: ronald
Posted: Dec 11, 2012
Vote up!
0
Vote down!

Looking for an answer? This is what I did and it worked. If it is correct or that its just worked in my case...I am not sure but for me after rigorous testing it did. First I will explain my reasoning and then the solution.

My idea was that you could say that in general the Drupal database consists out of two ingredients

- nodes and related content (pages, products etc)
- configuration settings (block settings, theme settings, boost, cache etc)

Since in my case, my online shop is generating mainly shopping carts, orders, users during the time that I spend developing on another server. So as soon as my development cycle is over I have:

1 An production environment with NEW:nodes and related content (compared to the development environment on which I use a production snapshot taken days or weeks ago) OLD:configuration settings (compared to the development environment)

2 An development environment with NEW:configuration settings and OLD: nodes and related content

In my case all the changes where strictly related to the commerce part of my site. So products, commerce modules, checkout settings etc. Therefore, I copied all the tables in my live database that I also use in my development environment to the development database.

The end result was that my database had the NEW nodes and content from the live database and the NEW configuration settings of the development database.

It worked out very well. The only drawback was that because I removed products I ran into entity errors on the order page. When I selected cart or checkout as a status the error occurred. Not on completed and pending orders. In my case, all cart and checkout orders where from anonymous visiters so I decided to delete those orders directly from the database.

If have used the following field when I copied the nodes and content from one database to another:
`commerce_calculated_price`;
`commerce_customer_profile`;
`commerce_customer_profile_revision`;
`commerce_line_item`;
`commerce_order`;
`commerce_order_revision`;
`commerce_payment_transaction`;
`commerce_payment_transaction_revision`;
`commerce_paypal_ipn`;
`commerce_tax_rate`;
`commerce_tax_type`;
`field_data_commerce_customer_address`;
`field_data_commerce_customer_billing`;
`field_data_commerce_display_path`;
`field_data_commerce_line_items`;
`field_data_commerce_order_total`;
`field_data_commerce_parent_line_item`;
`field_data_commerce_price`;
`field_data_commerce_price_aud`;
`field_data_commerce_price_cny`;
`field_data_commerce_price_eur`;
`field_data_commerce_price_gbp`;
`field_data_commerce_price_inr`;
`field_data_commerce_price_jpy`;
`field_data_commerce_price_rub`;
`field_data_commerce_price_usd`;
`field_data_commerce_total`;
`field_data_commerce_unit_price`;
`field_revision_commerce_customer_address`;
`field_revision_commerce_customer_billing`;
`field_revision_commerce_display_path`;
`field_revision_commerce_line_items`;
`field_revision_commerce_order_total`;
`field_revision_commerce_parent_line_item`;
`field_revision_commerce_price`;
`field_revision_commerce_price_aud`;
`field_revision_commerce_price_cny`;
`field_revision_commerce_price_eur`;
`field_revision_commerce_price_gbp`;
`field_revision_commerce_price_inr`;
`field_revision_commerce_price_jpy`;
`field_revision_commerce_price_rub`;
`field_revision_commerce_price_usd`;
`field_revision_commerce_total`;
`field_revision_commerce_unit_price`;
`users`;

To remove the cart and checkout orders I used:
DELETE FROM `commerce_order` WHERE `status` IN ('checkout_checkout','checkout_payment','checkout_review','cart')

Answer by: Sem
Posted: Jan 7, 2013