Posted 12/16/2007 - 22:06 by Dirk
Recently I had to migrate two drupal instances running on different servers into one drupal instance with exactly one MySQL database as backend. I started both installations without databse prefix (see your site’s settings.php for details). Now I had to change this. The first site should get the prefix ‘www_’, the second site ‘o4e_’.
First I exported both database schemas and it’s contents via mysqldump into files. Then I opened the files with vim (I cannot imagine one can live without this "swiss army knife"
) and applied a simple substitution:
%s;\(CREATE TABLE\|INSERT INTO\) `;&www_;
and
%s;\(CREATE TABLE\|INSERT INTO\) `;&o4e_;
respectivly.
Then I imported both dump files into the new database. Everything worked fine. Until I created the first new node. I realized, that the next node id was 1! After some investigatons I found the source of my trouble in the table {sequences}, where all counter names are prepended by the $db_prefix value, as this fragment of a mysqldump shows:
INSERT INTO `tpl_sequences` (`name`, `id`) VALUES<br />('tpl_users_uid', 1),<br />('tpl_menu_mid', 74),<br />('tpl_node_nid', 15),<br />('tpl_node_revisions_vid', 15);After renaming the counter names everything worked well again.
And I hope I didn’t miss anything.
