// ExecSQL executes a SQL code
ExecSQL executes a SQL code
// ExecSQL executes a SQL code
func (r MigrationRepository) ExecSQL(ctx context.Context, sql string) error {
	tx, err := r.db.DB().BeginTxx(ctx, nil)
	if err != nil {
		return errors.Wrapf(err, "MigrationRepository.ExecSQL: transaction begin error")
	}
	_, err = tx.ExecContext(ctx, sql)
	if err != nil {
		er := errors.Wrapf(apperror.ErrUsersSQL, "MigrationRepository.ExecSQL error: %v", err)
		err = tx.Rollback()
		if err != nil {
			r.logger.Print(er)
			return errors.Wrapf(err, "MigrationRepository.ExecSQL tx.Rollback() error")
		}
		return er
	}
	err = tx.Commit()
	if err != nil {
		return errors.Wrapf(err, "MigrationRepository.ExecSQL tx.Commit() error")
	}
	return nil
}
func ( r MigrationRepository ) ExecSQL ( ctx context . Context , sql string ) error { tx , err := r . db . DB ( ) . BeginTxx ( ctx , nil ) if err != nil { return errors . Wrapf ( err , " " ) } _ , err = tx . ExecContext ( ctx , sql ) if err != nil { er := errors . Wrapf ( apperror . ErrUsersSQL , " " , err ) err = tx . Rollback ( ) if err != nil { r . logger . Print ( er ) return errors . Wrapf ( err , " " ) } return er } err = tx . Commit ( ) if err != nil { return errors . Wrapf ( err , " " ) } return nil }
ExecSQL executes a SQL code
ExecSQL executes a SQL code