Skip to content

Commit

Permalink
add ModelTableExpr to TruncateTableQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Apr 1, 2024
1 parent 664e2f1 commit d997c65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion migrate/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ func (m *Migrator) MarkUnapplied(ctx context.Context, migration *Migration) erro
}

func (m *Migrator) TruncateTable(ctx context.Context) error {
_, err := m.db.NewTruncateTable().TableExpr(m.table).Exec(ctx)
_, err := m.db.NewTruncateTable().
ModelTableExpr(m.table).
Exec(ctx)
return err
}

Expand Down
5 changes: 5 additions & 0 deletions query_table_truncate.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func (q *TruncateTableQuery) TableExpr(query string, args ...interface{}) *Trunc
return q
}

func (q *TruncateTableQuery) ModelTableExpr(query string, args ...interface{}) *TruncateTableQuery {
q.modelTableName = schema.SafeQuery(query, args)
return q
}

//------------------------------------------------------------------------------

func (q *TruncateTableQuery) ContinueIdentity() *TruncateTableQuery {
Expand Down

0 comments on commit d997c65

Please sign in to comment.