Skip to content

Truncation in Sequel + PostgreSQL doesn't restart sequencesΒ #8

@alexgenco

Description

@alexgenco

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions