diff --git a/postgresql.go b/postgresql.go index 5386cac..7093835 100644 --- a/postgresql.go +++ b/postgresql.go @@ -16,6 +16,10 @@ type PostgreSQL struct { // which requires SUPERUSER privileges. UseAlterConstraint bool + // DontResetSequences prevents the reset of the databases + // sequences after load fixtures time + SkipResetSequences bool + tables []string sequences []string nonDeferrableConstraints []pgConstraint @@ -216,11 +220,13 @@ func (h *PostgreSQL) makeConstraintsDeferrable(db *sql.DB, loadFn loadFunction) func (h *PostgreSQL) disableReferentialIntegrity(db *sql.DB, loadFn loadFunction) (err error) { // ensure sequences being reset after load - defer func() { - if err2 := h.resetSequences(db); err2 != nil && err == nil { - err = err2 - } - }() + if !h.SkipResetSequences { + defer func() { + if err2 := h.resetSequences(db); err2 != nil && err == nil { + err = err2 + } + }() + } if h.UseAlterConstraint { return h.makeConstraintsDeferrable(db, loadFn)