Skip to content

Commit

Permalink
Merge pull request #2 from alifiroozi80/fix-sequence
Browse files Browse the repository at this point in the history
fix(migrator)!: Use the squence in the table
  • Loading branch information
alifiroozi80 authored Nov 30, 2024
2 parents 2daeeba + 84bc529 commit dda01f8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func (m Migrator) CreateTable(values ...interface{}) (err error) {
field := stmt.Schema.FieldsByDBName[dbName]
if !field.IgnoreMigration {
if dbName == "id" {
s := "{products %!s(bool=false)}"
// s := fmt.Sprintf("{%s %!s(bool=false)}", m.CurrentTable(stmt).(clause.Table).Name)
s := "{" + m.CurrentTable(stmt).(clause.Table).Name + " %!s(bool=false)}"
re := regexp.MustCompile(`\{([^ ]+)`)
match := re.FindStringSubmatch(s)
pk := fmt.Sprintf("? ? DEFAULT nextval('%s')", match[1])
Expand Down

0 comments on commit dda01f8

Please sign in to comment.