3

I have a node whose ID is 548754. I need it to be 301.

Is there a safe way to do this? There are a lot of tables related to 548754.
What if I export the database, open the SQL file, replace the number, and then import the database. Will this work?

11
  • Why do you need to change the nid? It's better don't do that imho, if you explain the problem because you want to change maybe we can find a workaround. Read this
    – backit
    Commented Oct 20, 2015 at 15:01
  • it should work if you change nid and entity_id in all tables, but you can not know if some modules didn't named it just id. There yould be a problem if you replace it in editor like a string. Commented Oct 20, 2015 at 15:02
  • I understand...
    – chefnelone
    Commented Oct 20, 2015 at 15:05
  • Not possible, unless want to re-import/re-write your whole database. If you consider that, I could answer how potentially this can be done in few commands.
    – kenorb
    Commented Oct 20, 2015 at 15:42
  • 1
    The easiest would be something like: drush sql-dump --ordered-dump | sed s/548754/301/g > new.sql; cat new.sql | drush sqlc (assuming 301 doesn't exist and nothing else conflicts with 548754). This won't be bullet-proof for serialized data which would break in that case (if serialized data is cache, can be removed).
    – kenorb
    Commented Oct 20, 2015 at 15:57

1 Answer 1

2

A solution is using these two contrib modules:

They turn out to work together nicely. "Custom nid" only works for new nodes.. however "Quick node clone" takes you to an unsubmitted "new node" form... as such you can change the nid of the clone before saving it. After cloning you can throw away the original.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.