@@ -29,7 +29,11 @@ func DatabaseUpdate_update0020_update0020testdata(db *sql.DB, getInfo bool) (str
2929 // Очистка таблицы team_games
3030 _ , err = tx .Exec (`DELETE FROM team_games` )
3131 if err != nil {
32- tx .Rollback ()
32+ err = tx .Rollback ()
33+ if err != nil {
34+ slog .Error ("Failed to rollback: " + err .Error ())
35+ return fromUpdateId , toUpdateId , description , err
36+ }
3337 slog .Error ("Failed to clear team_games table: " + err .Error ())
3438 return fromUpdateId , toUpdateId , description , err
3539 }
@@ -48,15 +52,23 @@ func DatabaseUpdate_update0020_update0020testdata(db *sql.DB, getInfo bool) (str
4852
4953 _ , err = tx .Exec (query )
5054 if err != nil {
51- tx .Rollback ()
55+ err = tx .Rollback ()
56+ if err != nil {
57+ slog .Error ("Failed to rollback: " + err .Error ())
58+ return fromUpdateId , toUpdateId , description , err
59+ }
5260 slog .Error ("Problem with query execution, query: " + query + "\n error:" + err .Error ())
5361 return fromUpdateId , toUpdateId , description , err
5462 }
5563
5664 // Получение существующих команд из базы данных
5765 teamRows , err := tx .Query (`SELECT id, name FROM teams` )
5866 if err != nil {
59- tx .Rollback ()
67+ err = tx .Rollback ()
68+ if err != nil {
69+ slog .Error ("Failed to rollback: " + err .Error ())
70+ return fromUpdateId , toUpdateId , description , err
71+ }
6072 slog .Error ("Failed to fetch existing teams: " + err .Error ())
6173 return fromUpdateId , toUpdateId , description , err
6274 }
@@ -70,7 +82,11 @@ func DatabaseUpdate_update0020_update0020testdata(db *sql.DB, getInfo bool) (str
7082 for teamRows .Next () {
7183 var id , name string
7284 if err := teamRows .Scan (& id , & name ); err != nil {
73- tx .Rollback ()
85+ err = tx .Rollback ()
86+ if err != nil {
87+ slog .Error ("Failed to rollback: " + err .Error ())
88+ return fromUpdateId , toUpdateId , description , err
89+ }
7490 slog .Error ("Failed to scan team: " + err .Error ())
7591 return fromUpdateId , toUpdateId , description , err
7692 }
@@ -83,7 +99,11 @@ func DatabaseUpdate_update0020_update0020testdata(db *sql.DB, getInfo bool) (str
8399 // Получение существующих игр из базы данных
84100 gameRows , err := tx .Query (`SELECT id, description FROM games` )
85101 if err != nil {
86- tx .Rollback ()
102+ err = tx .Rollback ()
103+ if err != nil {
104+ slog .Error ("Failed to rollback: " + err .Error ())
105+ return fromUpdateId , toUpdateId , description , err
106+ }
87107 slog .Error ("Failed to fetch existing games: " + err .Error ())
88108 return fromUpdateId , toUpdateId , description , err
89109 }
@@ -97,7 +117,11 @@ func DatabaseUpdate_update0020_update0020testdata(db *sql.DB, getInfo bool) (str
97117 for gameRows .Next () {
98118 var id , description string
99119 if err := gameRows .Scan (& id , & description ); err != nil {
100- tx .Rollback ()
120+ err = tx .Rollback ()
121+ if err != nil {
122+ slog .Error ("Failed to rollback: " + err .Error ())
123+ return fromUpdateId , toUpdateId , description , err
124+ }
101125 slog .Error ("Failed to scan game: " + err .Error ())
102126 return fromUpdateId , toUpdateId , description , err
103127 }
@@ -113,7 +137,11 @@ func DatabaseUpdate_update0020_update0020testdata(db *sql.DB, getInfo bool) (str
113137 _ , err = tx .Exec (`INSERT INTO results (score, rank, id, team_id, game_id) VALUES ($1, $2, $3, $4, $5)` ,
114138 score , rank + 1 , uuid .New ().String (), team .ID , game .ID )
115139 if err != nil {
116- tx .Rollback ()
140+ err = tx .Rollback ()
141+ if err != nil {
142+ slog .Error ("Failed to rollback: " + err .Error ())
143+ return fromUpdateId , toUpdateId , description , err
144+ }
117145 slog .Error ("Failed to insert result: " + err .Error ())
118146 return fromUpdateId , toUpdateId , description , err
119147 }
@@ -122,7 +150,11 @@ func DatabaseUpdate_update0020_update0020testdata(db *sql.DB, getInfo bool) (str
122150 _ , err = tx .Exec (`INSERT INTO team_games (team_id, game_id) VALUES ($1, $2)` ,
123151 team .ID , game .ID )
124152 if err != nil {
125- tx .Rollback ()
153+ err = tx .Rollback ()
154+ if err != nil {
155+ slog .Error ("Failed to rollback: " + err .Error ())
156+ return fromUpdateId , toUpdateId , description , err
157+ }
126158 slog .Error ("Failed to insert team_game: " + err .Error ())
127159 return fromUpdateId , toUpdateId , description , err
128160 }
0 commit comments