I generated tons of dummy content for testing, and then deleted them all. As nid is auto-increment, newly created node will have a nid of last created nid +1.
How can I make nid start from 1 again?
I generated tons of dummy content for testing, and then deleted them all. As nid is auto-increment, newly created node will have a nid of last created nid +1.
How can I make nid start from 1 again?
Plase don't truncate the node table just like that, there are some other tables connected to the node table, like node_revisions, sequences, fields tables, taxonomy tables, and many more.
There is no secure way to do this, it really depends on your site, you'll have to truncate and adjust all tables that have an nid including the sequences table. Remember, it is highly probable that your site become unusable, so don't start without a backup first.
ALTER TABLE `node` AUTO_INCREMENT = 1;
P.S - Others who have replied on this question: I just did a small check after deleting content and the associated content is indeed deleted, node_revisions and field_* tables are empty. node_delete says the same - http://api.drupal.org/api/drupal/modules--node--node.module/function/node_delete_multiple/7
Sometimes on migrations projects when you migrate from other platforms (ex. ASP + MSSQL), sometimes it becomes unavoidable to reset the nid due to lot of factors. I am sure it could be avoided but time/code tradeoff is always there.
You can use the module Delete all with the following drush commands:
Drupal 7
Delete nodes of all types, and reset node, revision and comment counters.
drush delete-all --reset
Drupal 8
Deletes all content of all types.
drush delete-all-delete-content
And then:
ALTER TABLE `node` AUTO_INCREMENT=1;
ALTER TABLE `node_revision` AUTO_INCREMENT=1;
ALTER TABLE `node_field_data` AUTO_INCREMENT=1;
ALTER TABLE `node_field_revision` AUTO_INCREMENT=1;
SQL Query: ALTER TABLE 'node' AUTO_INCREMENT=1;
Make sure you have deleted all nodes before doing this.
you can truncate node table but, pay attention you must truncate relational field table, if you just want to start increment id from 1 you can use of
ALTER TABLE `node` AUTO_INCREMENT=1