From d959b763f089ed4c1087aa4aeb824a8ef6743111 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Jul 2023 10:53:46 +0200 Subject: Avoid duplicate runner names --- server/models/runner/runner.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'server/models/runner/runner.ts') diff --git a/server/models/runner/runner.ts b/server/models/runner/runner.ts index 1ef0018b4..4d07707d8 100644 --- a/server/models/runner/runner.ts +++ b/server/models/runner/runner.ts @@ -16,6 +16,10 @@ import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' }, { fields: [ 'runnerRegistrationTokenId' ] + }, + { + fields: [ 'name' ], + unique: true } ] }) @@ -74,6 +78,14 @@ export class RunnerModel extends Model>> { return RunnerModel.findOne(query) } + static loadByName (name: string) { + const query = { + where: { name } + } + + return RunnerModel.findOne(query) + } + static listForApi (options: { start: number count: number -- cgit v1.2.3