@@ -7,7 +7,11 @@ import { CURRENT_DEPLOYMENT_LABEL } from "@trigger.dev/core/v3/isomorphic";
77export type ChangeCurrentDeploymentDirection = "promote" | "rollback" ;
88
99export class ChangeCurrentDeploymentService extends BaseService {
10- public async call ( deployment : WorkerDeployment , direction : ChangeCurrentDeploymentDirection ) {
10+ public async call (
11+ deployment : WorkerDeployment ,
12+ direction : ChangeCurrentDeploymentDirection ,
13+ disableVersionCheck ?: boolean
14+ ) {
1115 if ( ! deployment . workerId ) {
1216 throw new ServiceValidationError (
1317 direction === "promote"
@@ -42,26 +46,34 @@ export class ChangeCurrentDeploymentService extends BaseService {
4246 }
4347
4448 // if there is a current promotion, we have to validate we are moving in the right direction based on the deployment versions
45- switch ( direction ) {
46- case "promote" : {
47- if (
48- compareDeploymentVersions ( currentPromotion . deployment . version , deployment . version ) >= 0
49- ) {
50- throw new ServiceValidationError (
51- "Cannot promote a deployment that is older than the current deployment."
52- ) ;
49+ if ( ! disableVersionCheck ) {
50+ switch ( direction ) {
51+ case "promote" : {
52+ if (
53+ compareDeploymentVersions (
54+ currentPromotion . deployment . version ,
55+ deployment . version
56+ ) >= 0
57+ ) {
58+ throw new ServiceValidationError (
59+ "Cannot promote a deployment that is older than the current deployment."
60+ ) ;
61+ }
62+ break ;
5363 }
54- break ;
55- }
56- case "rollback" : {
57- if (
58- compareDeploymentVersions ( currentPromotion . deployment . version , deployment . version ) <= 0
59- ) {
60- throw new ServiceValidationError (
61- "Cannot rollback to a deployment that is newer than the current deployment."
62- ) ;
64+ case "rollback" : {
65+ if (
66+ compareDeploymentVersions (
67+ currentPromotion . deployment . version ,
68+ deployment . version
69+ ) <= 0
70+ ) {
71+ throw new ServiceValidationError (
72+ "Cannot rollback to a deployment that is newer than the current deployment."
73+ ) ;
74+ }
75+ break ;
6376 }
64- break ;
6577 }
6678 }
6779 }
0 commit comments