Drupal: Renumbering node ids
Having spent some time migrating old data 开发者_开发技巧into a new drupal site, my first node id is already into the 4 digit territory.
Has anyone had any experience in this position of renumbering node ids starting from #1? Maybe using direct queries on the database, or a module that traverses and renumbers all the nodes?
Of course, nodereferences have to be preserved... are there any other potential hangups if I try to script this?
There's no general-purpose solution for this. You could do this for your specific Drupal setup with a bunch of direct queries, and possibly a mess of PHP for anything that stores node IDs as serialized data. But that would take a long time and wouldn't work on any site running different modules. Which brings us to Kevin's question: why?
High node IDs don't cause technical problems, and even if they did, 4 digit node IDs aren't even high.
You'd be better off writing a procedure for your data import. Capture the process in code. If you find some bugs, trash your install and start again. An install profile would do this for you.
You should be able to start with a clean install and repeat the process as many times as you like. You wouldn't need to run the process twice on the same install. This means your problem (which isn't really a problem) would never happen. It also means you could manage the import process with a version control system.
You could further automate this process with something like selenium IDE.
Querying the database directly, for something like this (and most other things) is a terrible idea. Node IDs are distributed through several tables so you'd need to be very careful. The node API would be a much safer and saner solution. When editing nodes, use the API because that's what it's meant for.
Otherwise, I would strongly recommend not altering node IDs unless you could justify the risk. Making the right decision here is more important than your node IDs.
精彩评论