database_cleaner-sequel
database_cleaner-sequel copied to clipboard
Truncation in Sequel + PostgreSQL doesn't restart sequences
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 what about having a configuration key to enabled/disable this behaviour?