Drupal 5 cant submit nodes (duplicate entry) and I used prefixes

Posted by: 
Dominique De Cooman

In one of my posts I told about a technique to use multiple drupals in one database using prefixes http://dominiquedecooman.com/blog/how-run-multiple-drupal-installations-...

There is nothing wrong with this technique IF you start off with that setup.

But if you have multiple sites and you ve ALLREADY developed your sites using multiple databases and you want them REUNITED in one database. You should be aware of the following issue:
Drupal 5 uses the sequences table to keep track of autoincrement of node ids user ids, etc...

What happens when you prefix a drupal database AFTER installation?
For example when you create a new node the field in node_nid in the sequences table doesnt increment the origial field node_nid, instead a new entry is inserted in the table and the new entry is yourprefix_node_nid. Probably the node with the id 1 is allready deleted because you used it for testing. But when the yourprefix_node_nid reaches a node id that allready exists it gives a sql 'warning duplicate entry'.

Example your node_nid field has a value of 23 and your yourprefix_node_nid field has a value of 9 which is coincidentaly a node id which allready exists, your sql statement gives you a duplicate entry.

What is the SOLUTION? You dont want to lose content.
Rename every field entry in your sequences table to: prefix_originalname
You ll rename your node_nid to prefix_node_nid.
And that's it :)! Your database will work fine.

Best practice is you have to start of with this setup before installing a drupal. But when a miscommiucation happens and a client wants multiple databases when you have multiple be aware of this problem.

Add new comment