How To Preset the Next Node Id In Drupal

I needed to predict the NID of certain nodes on a project; I needed to make sure the nid for my next node was x and not y. How to do that? How does Drupal determine the nid of the next created node?

A quick scan of the node module pointed me to the fact that it just grabs the auto_increment value from the node table. Therefore, to predetermine the next created nid, just set the auto_increment value to the desired value. This is easily achieved with phpmyadmin by selecting your table, clicking on operations, and looking in the lower left corner for the box marked "auto_increment".

You can also do it directly in mysql with the following statement (substitute 1000 for the desired next NID):
ALTER TABLE `node` AUTO_INCREMENT =1000

You may want to do the same thing to the table node_revisions since often the vid and nid line up. But it's up to you.

It should be noted that this shouldn't be done on a live site, and you need to make sure that you are the only one creating nodes.

Also, you have to make sure that you are not going to collide with other NIDs already in the system!

I would say this is best done on a clean install at the beginning of your IA.

All of that said, there may be a time and a place for such an endeavor. For me, the client already had department numbers and I needed the nodes representing those departments to match up, to avoid confusion later as to why department 2 was actually department 17 on the website.

This is might be thought of as starting your checks at 1000 instead of 1.