Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
Delete all nodes on a Drupal 8 site. We invoke this using "drush scr" while rolling back migrations as a workaround for migrate-rollback not being fully implemented in D8 yet. Could also be useful for awesome April Fool's Day pranks (just kidding, don't do that).
$query = \Drupal::entityQuery('node');
// Optionally, add the following line to delete only a certain type of node.
//->condition('type', 'event');
$nids = $query->execute();
$storage_handler = \Drupal::entityManager()->getStorage('node');
$entities = $storage_handler->loadMultiple($nids);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment