Skip to content

Commit

Permalink
add fk constraint param
Browse files Browse the repository at this point in the history
  • Loading branch information
Zagarazhi committed Aug 16, 2024
1 parent 2adbc97 commit 43d1448
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"gorm.io/gorm/schema"
)

func NewGormConn(db, dbschema, user, pswd, host string, port int) (conn *gorm.DB, err error) {
func NewGormConn(db, dbschema, user, pswd, host string, port int, disableForeignKeyConstraintWhenMigrating bool) (conn *gorm.DB, err error) {

if len(dbschema) == 0 {
dbschema = "public"
Expand All @@ -22,6 +22,7 @@ func NewGormConn(db, dbschema, user, pswd, host string, port int) (conn *gorm.DB
TablePrefix: fmt.Sprintf("%s.", dbschema),
SingularTable: false,
},
DisableForeignKeyConstraintWhenMigrating: disableForeignKeyConstraintWhenMigrating,
})

if err != nil {
Expand All @@ -43,4 +44,4 @@ func CloseGormConn(conn *gorm.DB) error {
}

return nil
}
}

0 comments on commit 43d1448

Please sign in to comment.