How to have Database Cleaner reset the insert ID to 1?

479 views Asked by At

I switched from using truncation to transaction strategy for Database Cleaner. It is much faster (2.5x, to be precise).

The issue now is that I have some tests that expect the first insert ID to be 1. These tests are for paging responses. They expect 11 records in the database, starting at id 1.

Is it possible to configure Database Cleaner to use transactions but also set the insert ID to 1?

Using Postgres.

1

There are 1 answers

1
jurhas On

Mhh Try with:

ALTER SEQUENCE seq_name RESTART WITH 1

where seq_name is the name of the sequnce bound to your serial.If you have pgAdmin, and click in the column, you will read id integer defaul next_val('seq_name')