Skip to content

Commit

Permalink
add an option to the postgresql helper to not reset sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsb committed Oct 26, 2018
1 parent fa3fb89 commit 6eaebd7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
DontResetSequences bool

tables []string
sequences []string
nonDeferrableConstraints []pgConstraint
Expand Down Expand Up @@ -217,6 +221,9 @@ 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 h.DontResetSequences {
return
}
if err2 := h.resetSequences(db); err2 != nil && err == nil {
err = err2
}
Expand Down

0 comments on commit 6eaebd7

Please sign in to comment.