@@ -311,28 +311,37 @@ export class TriggerTaskService extends BaseService {
311
311
? Math . max ( 0 , body . options . queue . concurrencyLimit )
312
312
: undefined ;
313
313
314
- const taskQueue = await tx . taskQueue . upsert ( {
314
+ let taskQueue = await tx . taskQueue . findFirst ( {
315
315
where : {
316
- runtimeEnvironmentId_name : {
317
- runtimeEnvironmentId : environment . id ,
318
- name : queueName ,
319
- } ,
320
- } ,
321
- update : {
322
- concurrencyLimit,
323
- rateLimit : body . options . queue . rateLimit ,
324
- } ,
325
- create : {
326
- friendlyId : generateFriendlyId ( "queue" ) ,
327
- name : queueName ,
328
- concurrencyLimit,
329
316
runtimeEnvironmentId : environment . id ,
330
- projectId : environment . projectId ,
331
- rateLimit : body . options . queue . rateLimit ,
332
- type : "NAMED" ,
317
+ name : queueName ,
333
318
} ,
334
319
} ) ;
335
320
321
+ if ( taskQueue ) {
322
+ taskQueue = await tx . taskQueue . update ( {
323
+ where : {
324
+ id : taskQueue . id ,
325
+ } ,
326
+ data : {
327
+ concurrencyLimit,
328
+ rateLimit : body . options . queue . rateLimit ,
329
+ } ,
330
+ } ) ;
331
+ } else {
332
+ taskQueue = await tx . taskQueue . create ( {
333
+ data : {
334
+ friendlyId : generateFriendlyId ( "queue" ) ,
335
+ name : queueName ,
336
+ concurrencyLimit,
337
+ runtimeEnvironmentId : environment . id ,
338
+ projectId : environment . projectId ,
339
+ rateLimit : body . options . queue . rateLimit ,
340
+ type : "NAMED" ,
341
+ } ,
342
+ } ) ;
343
+ }
344
+
336
345
if ( typeof taskQueue . concurrencyLimit === "number" ) {
337
346
await marqs ?. updateQueueConcurrencyLimits (
338
347
environment ,
0 commit comments