feat: implement database wrapper interfaces for MSSQL and Postgres; enhance migration job processing with pre and post SQL execution
This commit is contained in:
@@ -26,3 +26,22 @@ func Close(pool *pgxpool.Pool) {
|
||||
pool.Close()
|
||||
}
|
||||
}
|
||||
|
||||
type PostgresDbWrapper struct {
|
||||
db *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewPostgresDbWrapper(db *pgxpool.Pool) DbWrapper {
|
||||
return &PostgresDbWrapper{db: db}
|
||||
}
|
||||
|
||||
func (wrapper *PostgresDbWrapper) Exec(ctx context.Context, query string, args ...any) (DbWrapperResult, error) {
|
||||
result, err := wrapper.db.Exec(ctx, query, args...)
|
||||
if err != nil {
|
||||
return DbWrapperResult{}, err
|
||||
}
|
||||
|
||||
return DbWrapperResult{
|
||||
AffectedRows: result.RowsAffected(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user