database_cleaner-sequel icon indicating copy to clipboard operation
database_cleaner-sequel copied to clipboard

Truncation in Sequel + PostgreSQL doesn't restart sequences

Open alexgenco opened this issue 11 years ago • 1 comments

All the tables are properly truncated, but consecutive test runs start auto-incremented sequences where they left off, instead of back at 1.

In lib/database_cleaner/sequel/truncation.rb, changing line 19:

db.run "TRUNCATE TABLE #{all_tables};"

to

db.run "TRUNCATE TABLE #{all_tables} RESTART IDENTITY;"

resolves the issue, but I suppose that could raise some compatibility issues with certain versions of PostgreSQL.

This seems like it would be a fairly simple PR, but I would rather get some insight from the maintainers first as I'm not at all familiar with this codebase. Thanks!

alexgenco avatar Jul 29 '13 06:07 alexgenco

@alexgenco what about having a configuration key to enabled/disable this behaviour?

zedtux avatar Jan 26 '18 09:01 zedtux