---
# System prepended metadata

title: Restart Identity

---

# Restart Identity

What does it do? Well, it ensures that the ids that are autoincremented in database tables will be reset so that you don't have to drop your tables every time you're ready to reseed them.

In the python project starter, we've got this convenient bit of code:

```python
def undo_users():
    db.session.execute('TRUNCATE users RESTART IDENTITY CASCADE;')
    db.session.commit()
```

Essentially just raw SQL code. Because it's in raw SQL, I wanted to see if I could find something in the Sequelize documentation that did something similar.

I couldn't.

But that doesn't mean it doesn't exist. After some googling and testing, I found a bulkDelete that will delete every record in a table *and* reset the autoincrementing id to 1 for future seeding, thus allowing for easier hardcoded seed data (which I still detest but will admit is perfectly fine).

```javascript
return queryInterface.bulkDelete('Users', null, {truncate: true, cascade: true, restartIdentity: true});
```

Please note that the `restartIdentity: true` is the ticket here. However, it relies on `truncate: true` to work and if any other tables rely on the current table you're working with, you'll need that `cascade: true` as well. 