@@ -284,7 +284,7 @@ func CountRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
284
284
// Only affect action runners were a owner ID is set, as actions runners
285
285
// could also be created on a repository.
286
286
return db .GetEngine (ctx ).Table ("action_runner" ).
287
- Join ("LEFT" , "user" , "`action_runner`.owner_id = `user`.id" ).
287
+ Join ("LEFT" , "` user` " , "`action_runner`.owner_id = `user`.id" ).
288
288
Where ("`action_runner`.owner_id != ?" , 0 ).
289
289
And (builder.IsNull {"`user`.id" }).
290
290
Count (new (ActionRunner ))
@@ -293,7 +293,7 @@ func CountRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
293
293
func FixRunnersWithoutBelongingOwner (ctx context.Context ) (int64 , error ) {
294
294
subQuery := builder .Select ("`action_runner`.id" ).
295
295
From ("`action_runner`" ).
296
- Join ("LEFT" , "user" , "`action_runner`.owner_id = `user`.id" ).
296
+ Join ("LEFT" , "` user` " , "`action_runner`.owner_id = `user`.id" ).
297
297
Where (builder.Neq {"`action_runner`.owner_id" : 0 }).
298
298
And (builder.IsNull {"`user`.id" })
299
299
b := builder .Delete (builder .In ("id" , subQuery )).From ("`action_runner`" )
@@ -303,3 +303,25 @@ func FixRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
303
303
}
304
304
return res .RowsAffected ()
305
305
}
306
+
307
+ func CountRunnersWithoutBelongingRepo (ctx context.Context ) (int64 , error ) {
308
+ return db .GetEngine (ctx ).Table ("action_runner" ).
309
+ Join ("LEFT" , "`repository`" , "`action_runner`.repo_id = `repository`.id" ).
310
+ Where ("`action_runner`.repo_id != ?" , 0 ).
311
+ And (builder.IsNull {"`repository`.id" }).
312
+ Count (new (ActionRunner ))
313
+ }
314
+
315
+ func FixRunnersWithoutBelongingRepo (ctx context.Context ) (int64 , error ) {
316
+ subQuery := builder .Select ("`action_runner`.id" ).
317
+ From ("`action_runner`" ).
318
+ Join ("LEFT" , "`repository`" , "`action_runner`.repo_id = `repository`.id" ).
319
+ Where (builder.Neq {"`action_runner`.repo_id" : 0 }).
320
+ And (builder.IsNull {"`repository`.id" })
321
+ b := builder .Delete (builder .In ("id" , subQuery )).From ("`action_runner`" )
322
+ res , err := db .GetEngine (ctx ).Exec (b )
323
+ if err != nil {
324
+ return 0 , err
325
+ }
326
+ return res .RowsAffected ()
327
+ }
0 commit comments