MergeDB.php: merging the development and the production databases
-----------------------------------------------------------------

Tested on: Drupal 4.7.x

This script takes two Drupal databases as the input (the development and the production databases) and generates a third database with the results of the
merge operation. The options of the merge operation can be configured in the companion MergeDB.xml file.

WARNING: although the script is not supposed to make any change in the input databases, making a backup before the execution of the script is strongly recommended.

The script needs to take some special actions for certain database tables, therefore it cannot work if the database contains any table which is "unknown" for it. It is probably quite straighforward to extend the MergeDB.php and the MergeDB.xml files in order to add new tables for your own needs, but it will require more in-depth understanding of the script which is not docummented here. Sorry!

Currently the script "knows" about the tables in the standard distribution of Drupal, plus the tables which are added by the following contributed modules:

- autologout
- cck
- commentaproval
- contemplate
- gmap
- i18n
- image
- legal
- location
- nodegoto
- nodewords
- postcard
- views

Following there is a description of the options that can be configured in the MergeDB.xml file:

- LogFile: the name of a log file for debugging purposes; please take in mind that uncommenting this line will produce a huge file (directly proportional on the size of the database tables) as well as paying a penalty on performance.
- DBServer: the type of the DBMS (currently only mysql supported), the directory where databases reside, the host that runs the DBMS and the username and password of a user with enough privileges to create databases and tables.
- Databases: do not change the 'aliasName' of the databases; in the 'realName' attribute, provide the name of the development database (better a copy of it), the production database (better a copy of it) and the results database. WARNING: the results database will be deleted during the operation, please double-check the name specified in order to prevent accidental data loss.
- Content-type-tables: the name of the tables which store information related to a content-type. They usually have a field called 'nid'. You do not need to change this configuration unless you are trying to extend the script functionality.
- Imports: specifies where the results database imports its data from. It is composed of two parts, importing regular tables and importing content-types (the latter being more complex as it involves copying/renumbering rows from several tables at the same time).
	- Tables: for each table, specify whether you would like the data being imported from 'db1', from 'db2' or left 'empty'. The 'mandatory' attribute will cause the process being interrupted if any of the required tables do not exist.
	- Content-types: for each content-type, specify whether you would like the data being imported from 'db1', from 'db2' or left 'empty'. As content-types can have associated comments, specify whether you would like the comments being imported from 'db2' or left 'empty'. The 'mandatory' attribute will cause the process being interrupted if any of the required content-types do not exist. You can specify your own content-types besides the ones predefined in the standard distribution of Drupal (forum, page, story).

Once finished configuring the MergeDB.xml file, run the script:

php MergeDB.php
