diff --git a/migrate/migrator.go b/migrate/migrator.go index 33c5bd16f..e6d70e39f 100644 --- a/migrate/migrator.go +++ b/migrate/migrator.go @@ -362,7 +362,10 @@ 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(). + Model((*Migration)(nil)). + ModelTableExpr(m.table). + Exec(ctx) return err } diff --git a/query_table_truncate.go b/query_table_truncate.go index a704b7b10..9ac5599d9 100644 --- a/query_table_truncate.go +++ b/query_table_truncate.go @@ -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 {