@@ -270,7 +270,7 @@ func CountRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
270
270
// Only affect action runners were a owner ID is set, as actions runners
271
271
// could also be created on a repository.
272
272
return db .GetEngine (ctx ).Table ("action_runner" ).
273
- Join ("LEFT" , "user" , "`action_runner`.owner_id = `user`.id" ).
273
+ Join ("LEFT" , "` user` " , "`action_runner`.owner_id = `user`.id" ).
274
274
Where ("`action_runner`.owner_id != ?" , 0 ).
275
275
And (builder.IsNull {"`user`.id" }).
276
276
Count (new (ActionRunner ))
@@ -279,7 +279,7 @@ func CountRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
279
279
func FixRunnersWithoutBelongingOwner (ctx context.Context ) (int64 , error ) {
280
280
subQuery := builder .Select ("`action_runner`.id" ).
281
281
From ("`action_runner`" ).
282
- Join ("LEFT" , "user" , "`action_runner`.owner_id = `user`.id" ).
282
+ Join ("LEFT" , "` user` " , "`action_runner`.owner_id = `user`.id" ).
283
283
Where (builder.Neq {"`action_runner`.owner_id" : 0 }).
284
284
And (builder.IsNull {"`user`.id" })
285
285
b := builder .Delete (builder .In ("id" , subQuery )).From ("`action_runner`" )
@@ -289,3 +289,25 @@ func FixRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
289
289
}
290
290
return res .RowsAffected ()
291
291
}
292
+
293
+ func CountRunnersWithoutBelongingRepo (ctx context.Context ) (int64 , error ) {
294
+ return db .GetEngine (ctx ).Table ("action_runner" ).
295
+ Join ("LEFT" , "`repository`" , "`action_runner`.repo_id = `repository`.id" ).
296
+ Where ("`action_runner`.repo_id != ?" , 0 ).
297
+ And (builder.IsNull {"`repository`.id" }).
298
+ Count (new (ActionRunner ))
299
+ }
300
+
301
+ func FixRunnersWithoutBelongingRepo (ctx context.Context ) (int64 , error ) {
302
+ subQuery := builder .Select ("`action_runner`.id" ).
303
+ From ("`action_runner`" ).
304
+ Join ("LEFT" , "`repository`" , "`action_runner`.repo_id = `repository`.id" ).
305
+ Where (builder.Neq {"`action_runner`.repo_id" : 0 }).
306
+ And (builder.IsNull {"`repository`.id" })
307
+ b := builder .Delete (builder .In ("id" , subQuery )).From ("`action_runner`" )
308
+ res , err := db .GetEngine (ctx ).Exec (b )
309
+ if err != nil {
310
+ return 0 , err
311
+ }
312
+ return res .RowsAffected ()
313
+ }
0 commit comments