feat: uniq tenant_users
This commit is contained in:
@@ -3,6 +3,7 @@ package db
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"backend/common/consts"
|
||||
|
||||
@@ -15,3 +16,13 @@ func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
func TruncateAllTables(ctx context.Context, db *sql.DB, tableName ...string) error {
|
||||
for _, name := range tableName {
|
||||
sql := fmt.Sprintf("TRUNCATE TABLE %s CASCADE", name)
|
||||
if _, err := db.ExecContext(ctx, sql); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user