[{"content":"# Develop > Python > Workflows > Versioning > Versioning with Patching\n## Adding a patch\n\nA Patch defines a logical branch in a Workflow for a specific change, similar to a feature flag.\nIt applies a code change to new Workflow Executions while avoiding disruptive changes to in-progress Workflow Executions.\nWhen you want to make substantive code changes that may affect existing Workflow Executions, create a patch.\n\nSuppose you have an initial Workflow version called `pre_patch_activity`:\n\n[python-sandbox/workflows/versioning/workflow_1_initial.py](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/python-sandbox/workflows/versioning/workflow_1_initial.py)\n```\nfrom datetime import timedelta  \nfrom temporalio import workflow  \n  \nwith workflow.unsafe.imports_passed_through():  \n    from versioning.activities import pre_patch_activity  \n  \n@workflow.defn  \nclass MyWorkflow:  \n    @workflow.run  \n    async def run(self) -> None:  \n        self._result = await workflow.execute_activity(  \n            pre_patch_activity,  \n            schedule_to_close_timeout=timedelta(minutes=5),  \n        )  \n  \n    @workflow.query  \n    def result(self) -> str:  \n        return self._result\n```\n\nNow, you want to update your code to run `post_patch_activity` instead. This represents your desired end state.\n\n[python-sandbox/workflows/versioning/workflow_2_desired.py](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/python-sandbox/workflows/versioning/workflow_2_desired.py)\n\n```\nfrom datetime import timedelta  \nfrom temporalio import workflow  \n  \nwith workflow.unsafe.imports_passed_through():  \n    from versioning.activities import post_patch_activity  \n  \n@workflow.defn  \nclass MyWorkflow:  \n    @workflow.run  \n    async def run(self) -> None:  \n        self._result = await workflow.execute_activity(  \n            post_patch_activity,  \n            schedule_to_close_timeout=timedelta(minutes=5),  \n        )  \n  \n    @workflow.query  \n    def result(self) -> str:  \n        return self._result\n```\n\nThe problem is that you cannot deploy `post_patch_activity` directly until you're certain there are no more running Workflows created using the `pre_patch_activity` code, otherwise you are likely to cause a nondeterminism error.\nInstead, you'll need to deploy `post_patched_activity` and use the [patched](https://python.temporal.io/temporalio.workflow.html#patched) function to determine which version of the code to execute.\n\nPatching is a three-step process:\n\n1. Patch in any new, updated code using the `patched()` function. Run the new patched code alongside old code.\n1. Remove old code and use `deprecate_patch()` to mark a particular patch as deprecated.\n1. Once there are no longer any open Workflow Executions of the previous version of the code, remove `deprecate_patch()`.\n   Let's walk through this process in sequence.","source_url":"https://docs.temporal.io/develop/python/workflows/versioning.md","page_url":"https://docs.temporal.io/develop/python/workflows/versioning#adding-a-patch"},{"content":"# Develop > Python > Workflows\n## Versioning\n\nSince Workflow Executions in Temporal can run for long periods — sometimes months or even years — it's common to need to make changes to a Workflow Definition, even while a particular Workflow Execution is in progress.\n\nThe Temporal Platform requires that Workflow Definitions are [deterministic](https://docs.temporal.io/workflow-definition#deterministic-constraints). If you make a change to your Workflow code that would cause non-deterministic behavior on Replay, you'll need to use one of our Versioning methods to gracefully update your running Workflows. This only applies to Workflow orchestration logic. Non-deterministic work such as API calls, and database queries should be placed in Activities, which Temporal retries reliably.\n\nWith Versioning, you can modify your Workflow Definition so that new executions use the updated code, while existing ones continue running the original version.\nThere are two primary Versioning methods that you can use:\n\n- [Worker Versioning](https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning). The Worker Versioning feature allows you to tag your Workers and programmatically roll them out in versioned deployments, so that old Workers can run old code paths and new Workers can run new code paths.\n- [Versioning with Patching](https://docs.temporal.io/develop/python/workflows/versioning#patching). This method works by adding branches to your code tied to specific revisions. It applies a code change to new Workflow Executions while avoiding disruptive changes to in-progress Workflow Executions.\n\nSupport for the experimental Worker Versioning method before 2025 was scheduled for removal from Temporal Server in March 2026. Refer to the [latest Worker Versioning docs](https://docs.temporal.io/worker-versioning) for guidance. You can still refer to the [Worker Versioning Legacy](https://docs.temporal.io/develop/python/workflows/worker-versioning-legacy) docs if needed.\n\n### Worker Versioning\n\nTemporal's [Worker Versioning](https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning) feature allows you to tag your Workers and programmatically roll them out in Deployment Versions, so that old Workers can run old code paths and new Workers can run new code paths. This way, you can pin your Workflows to specific revisions, avoiding the need for patching.","source_url":"https://docs.temporal.io/develop/python/workflows/versioning.md","page_url":"https://docs.temporal.io/develop/python/workflows/versioning"},{"content":"# Best-practices > Worker deployment and performance > Deployment and lifecycle management\n## Use Worker Versioning to safely deploy new Workflow code\n\nUse Worker Versioning to deploy new Workflow code without breaking running Executions. Worker Versioning lets you map\neach Workflow Execution to a specific Worker Deployment Version identified by a build ID, which guarantees that pinned\nWorkflows always run on the same Worker version where they started.\n\nFor most teams, Worker Versioning should be the default approach for evolving Workflow code in production. It gives you\nsafer rollouts, clearer rollback behavior, and a cleaner operational model than maintaining multiple code paths inside a\nWorkflow definition.\n\nTo learn more about versioning Workflows, see the\n[Worker Versioning](https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning) guide or take our\n[Worker Versioning course](https://learn.temporal.io/courses/worker_versioning/).\n\nIf your deployment environment cannot yet support Worker Versioning, you can use [Patching](https://docs.temporal.io/patching) to introduce\nchanges to your Workflow code without breaking running Executions. Treat patching as a fallback for environments that\ncannot adopt versioned worker deployments yet, not as the default recommendation.","source_url":"https://docs.temporal.io/best-practices/worker.md","page_url":"https://docs.temporal.io/best-practices/worker#use-worker-versioning-to-safely-deploy-new-workflow-code"},{"content":"# Develop > Python > Workflows > Versioning > Versioning with Patching\n## Workflow cutovers\n\nTo understand why Patching is useful, it's helpful to demonstrate cutting over an entire Workflow.\n\nSince incompatible changes only affect open Workflow Executions of the same type, you can avoid determinism errors by creating a whole new Workflow when making changes.\nTo do this, you can copy the Workflow Definition function, giving it a different name, and register both names with your Workers.\n\nFor example, you would duplicate `PizzaWorkflow` as `PizzaWorkflowV2`:\n\n[python-sandbox/workflows/versioning/pizza_workflows.py](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/python-sandbox/workflows/versioning/pizza_workflows.py)\n```\n@workflow.defn(name=\"PizzaWorkflow\")  \nclass PizzaWorkflow:  \n    @workflow.run  \n    async def run(self, name: str) -> str:  \n        # this function contains the original code  \n        return f\"Pizza for {name}\"  \n  \n@workflow.defn(name=\"PizzaWorkflowV2\")  \nclass PizzaWorkflowV2:  \n    @workflow.run  \n    async def run(self, name: str) -> str:  \n        # this function contains the updated code  \n        return f\"Pizza with extra cheese for {name}\"\n```\n\nYou would then need to update the Worker configuration, and any other identifier strings, to register both Workflow Types:\n\n[python-sandbox/workflows/versioning/pizza_worker.py](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/python-sandbox/workflows/versioning/pizza_worker.py)\n\n```\nworker = Worker(  \n    client,  \n    task_queue=\"your-task-queue\",  \n    workflows=[PizzaWorkflow, PizzaWorkflowV2],  \n)\n```\n\nThe downside of this method is that it requires you to duplicate code and to update any commands used to start the Workflow.\nThis can become impractical over time.\nThis method also does not provide a way to version any still-running Workflows -- it is essentially just a cutover, unlike Patching.","source_url":"https://docs.temporal.io/develop/python/workflows/versioning.md","page_url":"https://docs.temporal.io/develop/python/workflows/versioning#workflow-cutovers"},{"content":"# Blog\n## Upgrading and Versioning (17:59)\n\nHow do you migrate long running workflows that are still in flight? Most developers who hand roll their own job scheduling and orchestration frameworks don’t have anything better than “deploy and pray”, but Temporal offers a first class solution.\n\nTemporal requires that your Workflows must be fully deterministic, and changing Workflow code means potentially breaking determinism. This is where the `getVersion` API is handy because it allows you to make changes in Workflow logic in a deterministic fashion.\n\nTemporal offers a `getVersion` API in the [Go](https://docs.temporal.io/go/versioning/#workflowgetversion), [Java](https://docs.temporal.io/java/versioning/#java-versioning-api), [PHP](https://docs.temporal.io/php/versioning/#workflowgetversion) SDKs, and a [Patching](https://docs.temporal.io/typescript/patching) API in TypeScript, that essentially amounts to feature flagging by start time cohort:\n\n```\nv := workflow.GetVersion(ctx, \"Step1\", 1, 2)\nif v == 1 {\n        err = workflow.ExecuteActivity(ctx, ActivityC, data).Get(ctx, &result1)\n} else {\n        err = workflow.ExecuteActivity(ctx, ActivityD, data).Get(ctx, &result1)\n}\n```\n\nWe have also published a **[30 min tutorial on versioning](https://www.youtube.com/watch?v=kkP899WxgzY&feature=emb_title)** to guide you through this API.\n\n- **How it works**: Temporal internally tracks the version of Workflow code at the time that particular Workflow Execution was started, and uses that to navigate code paths based on these user defined branches. New Workflow Executions take the latest paths by default.\n- **Sample and Replay:** While this is an elegant and powerful API (because it can be used and composed in arbitrary logic), it still needs to be handled carefully. This is why replaying workflow execution is so important. Before migration, take samples of Workflow histories at different stages, and use the replay API.\n- **Use Task Queues for Short-Lived Workflows**: Think through your upgrade strategy - you may not even need versioning if your workflows are short-lived enough! If you just want to cut over to new code, you can run old code on the same Task Queue with a subset of Workers, and run new code on a different set of Workers with a new Task Queue!\n- **Worst Case**: When in doubt - take a breath - because of Temporal’s event sourced nature, if a migration is screwed up, **our worst case is that your Workflows don’t make progress** - latency will spike, but data will not be lost - just make sure you are fully familiar with metrics and logs to investigate issues!","source_url":"https://temporal.io/blog/workers-in-production#upgrading-and-versioning-1759","page_url":"https://temporal.io/blog/workers-in-production#upgrading-and-versioning-1759"},{"content":"# Develop > Python > Workflows > Versioning > Versioning with Patching\n## Removing a patch\n\nOnce your pre-patch Workflows have left retention, you can then safely deploy Workers that no longer use either the `patched()` or `deprecate_patch()` calls:\n\n[python-sandbox/workflows/versioning/workflow_2_desired.py](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/python-sandbox/workflows/versioning/workflow_2_desired.py)\n```\n# ...  \n@workflow.defn  \nclass MyWorkflow:  \n    @workflow.run  \n    async def run(self) -> None:  \n        self._result = await workflow.execute_activity(  \n            post_patch_activity,  \n            schedule_to_close_timeout=timedelta(minutes=5),  \n        )\n```\n\nPatching allows you to make changes to currently running Workflows.\nIt introduces compatible changes without causing non-determinism errors.","source_url":"https://docs.temporal.io/develop/python/workflows/versioning.md","page_url":"https://docs.temporal.io/develop/python/workflows/versioning#deploy-new-code"},{"content":"# Develop > Python > Workflows > Versioning > Versioning with Patching\n## Patching in new code\n\nUsing `patched` inserts a marker into the Event History.\nDuring Replay, if a Worker encounters a history with that marker, it will fail the Workflow task when the Workflow code doesn't produce the same patch marker (in this case, `my-patch`).\nThis ensures you can safely deploy code from `post_patch_activity` as a \"feature flag\" alongside the original version (`pre_patch_activity`).\n\n[python-sandbox/workflows/versioning/workflow_3_patched.py](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/python-sandbox/workflows/versioning/workflow_3_patched.py)\n```\nfrom datetime import timedelta  \nfrom temporalio import workflow  \n  \nwith workflow.unsafe.imports_passed_through():  \n    from versioning.activities import post_patch_activity, pre_patch_activity  \n  \n  \n@workflow.defn  \nclass MyWorkflow:  \n    @workflow.run  \n    async def run(self) -> None:  \n        if workflow.patched(\"my-patch\"):  \n            self._result = await workflow.execute_activity(  \n                post_patch_activity,  \n                schedule_to_close_timeout=timedelta(minutes=5),  \n            )  \n        else:  \n            self._result = await workflow.execute_activity(  \n                pre_patch_activity,  \n                schedule_to_close_timeout=timedelta(minutes=5),  \n            )  \n  \n    @workflow.query  \n    def result(self) -> str:  \n        return self._result\n```","source_url":"https://docs.temporal.io/develop/python/workflows/versioning.md","page_url":"https://docs.temporal.io/develop/python/workflows/versioning#using-patched-for-workflow-history-markers"},{"content":"# Develop > Safely deploying changes to Workflow code\n## Implement a deployment-time replay test\n\nThe key to a successful safe deployment is to break it into two phases: a verification phase, where you’ll run the replay test, followed by the actual deployment of your new Worker code.\n\nYou can accomplish this by wrapping your Worker application with some code that can choose whether it will run in verification mode, or in production. This is most easily done if you do not deploy your Workers side-by-side with other application code, which is a recommended best practice. If you do deploy your Workers as part of some other application, you will likely need to separate out a different entry point specifically for verification.\n\n#### Run a replay and real Worker with the same code\n\nThe following code demonstrates how the same entry point could be used to either verify the new code using replay testing, or to actually run the Worker.\n```\nimport argparse  \nimport asyncio  \nfrom datetime import datetime, timedelta  \n  \nfrom temporalio.client import Client  \nfrom temporalio.worker import Worker, Replayer  \n  \nasync def main():  \n    parser = argparse.ArgumentParser(prog='MyTemporalWorker')  \n    parser.add_argument('mode', choices=['verify', 'run'])  \n    args = parser.parse_args()  \n  \n    temporal_url = \"localhost:7233\"  \n    task_queue = \"your-task-queue\"  \n    my_workflows = [YourWorkflow]  \n    my_activities = [your_activity]  \n  \n    client = await Client.connect(temporal_url)\n```\n\nEverything up to this point is standard. You import the Workflow and Activity code, instantiate a parser with two modes, and create your Task Queue, Workflow, and Activity.\n\nYou can pass in the `args.mode` from any appropriate spot in your code. If the mode is set to `verify`, you conduct the replay testing by specifying the time period to test, and passing in the Workflows corresponding to that time period. Note that the Workflows are consumed as histories, using [the `map_histories()` function](https://python.temporal.io/temporalio.client.WorkflowExecutionAsyncIterator.html#map_histories).\n\n```\nif args.mode == 'verify':  \n    start_time = (datetime.now() - timedelta(hours=10)).isoformat(timespec='seconds')  \n    workflows = client.list_workflows(  \n     f\"TaskQueue={task_queue} and StartTime > '{start_time}'\",  \n    limit = 100)  \n    histories = workflows.map_histories()  \n    replayer = Replayer(  \n        workflows=my_workflows,  \n    )  \n    await replayer.replay_workflows(histories)  \n    return\n```\n\nIf any of the Workflows fail to replay, an error will be thrown. If no errors occur, you can return successfully to indicate success here, or communicate with an endpoint you've defined to indicate success or failure of the verification. You could switch to the `run` mode, and have this Worker transition to a real Worker that will start pulling from the Task Queue and processing Workflows:\n\n```\nelse:  \n        worker = Worker(  \n            client,  \n            task_queue=task_queue,  \n            workflows=my_workflows,  \n            activities=my_activities,  \n        )  \n        await worker.run()  \n  \nif __name__ == \"__main__\":  \n    asyncio.run(main())\n```\n\n#### Use the multi-modal Worker\n\nThe most straightforward way to use this bimodal Worker is to deploy one instance of it at the beginning of your deployment process in verify mode, see that it passes, and then proceed to deploy the rest of your new workers in run mode.","source_url":"https://docs.temporal.io/develop/safe-deployments.md","page_url":"https://docs.temporal.io/develop/safe-deployments#implement-a-deployment-time-replay-test"},{"content":"# Develop > Typescript > Workflows > Versioning\n## Versioning with Patching\n\n#### Adding a patch\n\nA Patch defines a logical branch in a Workflow for a specific change, similar to a feature flag.\nIt applies a code change to new Workflow Executions while avoiding disruptive changes to in-progress Workflow Executions.\nWhen you want to make substantive code changes that may affect existing Workflow Executions, create a patch.\n\nSuppose you have an initial Workflow that runs `activityA`:\n\n[typescript-sandbox/src/workflows/versioning/patching/workflows-v1.ts](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/typescript-sandbox/src/workflows/versioning/patching/workflows-v1.ts)\n```\n// v1  \nexport async function myWorkflow(): Promise<void> {  \n  await activityA();  \n  await sleep('1 days'); // arbitrary long sleep to simulate a long running workflow we need to patch  \n  await activityThatMustRunAfterA();  \n}\n```\n\nNow, you want to update your code to run `activityB` instead. This represents your desired end state.\n\n[typescript-sandbox/src/workflows/versioning/patching/workflows-vFinal.ts](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/typescript-sandbox/src/workflows/versioning/patching/workflows-vFinal.ts)\n\n```\n// vFinal  \nexport async function myWorkflow(): Promise<void> {  \n  await activityB();  \n  await sleep('1 days');  \n}\n```\n\nThe problem is that you cannot deploy this `vFinal` revision directly until you're certain there are no more running Workflows created using the `v1` code, otherwise you are likely to cause a nondeterminism error.\nInstead, you'll need to use the [`patched`](https://typescript.temporal.io/api/namespaces/workflow#patched) function to check which version of the code should be executed.\n\nPatching is a three-step process:\n\n1. Patch in any new, updated code using the `patched()` function. Run the new patched code alongside old code.\n1. Remove old code and use `deprecatePatch()` to mark a particular patch as deprecated.\n1. Once there are no longer any open Workflow Executions of the previous version of the code, remove `deprecatePatch()`.\n   Let's walk through this process in sequence.\n\n#### Patching in new code\n\nUsing `patched` inserts a marker into the Event History.\nDuring Replay, if a Worker encounters a history with that marker, it will fail the Workflow task when the Workflow code doesn't produce the same patch marker (in this case `your-change-id`).\nThis ensures you can safely deploy code from `v2` as a \"feature flag\" alongside the original version (`v1`).\n\n[typescript-sandbox/src/workflows/versioning/patching/workflows-v2.ts](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/typescript-sandbox/src/workflows/versioning/patching/workflows-v2.ts)\n```\n// v2  \nimport { patched } from '@temporalio/workflow';  \nexport async function myWorkflow(): Promise<void> {  \n  if (patched('my-change-id')) {  \n    await activityB();  \n    await sleep('1 days');  \n  } else {  \n    await activityA();  \n    await sleep('1 days');  \n    await activityThatMustRunAfterA();  \n  }  \n}\n```","source_url":"https://docs.temporal.io/develop/typescript/workflows/versioning.md","page_url":"https://docs.temporal.io/develop/typescript/workflows/versioning#patching"},{"content":"# Production-deployment > Worker-deployments\n## Worker Versioning\n\nWorker Versioning is a Temporal feature that allows you to confidently deploy new changes to the Workflows running on\nyour Workers without breaking them. Temporal enables this by helping you manage different builds or versions, formally\ncalled [Worker Deployment Versions](https://docs.temporal.io/worker-versioning#deployment-versions).\n\nFor most teams, Worker Versioning should be the default recommendation for deploying Workflow code changes in\nproduction. If you can run versioned worker deployments, prefer Worker Versioning over patching.\n\nWorker Versioning provides the following benefits for [blue-green or rainbow deployments](https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning#deployment-systems):\n\n- Ramping traffic gradually to a new Worker Deployment Version.\n- Verifying a new Deployment Version with tests before sending production traffic to it.\n- Instant rollback when you detect that a new Deployment Version is broken.\n- Improved error rates when adopting it.\n\nIn addition, Worker Versioning introduces **Workflow Pinning**. For pinned Workflow Types, each execution runs entirely\non the Worker Deployment Version where it started. You need not worry about making breaking code changes to running,\npinned Workflows.\n\nTo use Workflow Pinning, we recommend using [rainbow deployments](https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning#deployment-systems).\n\nWatch this Temporal Replay 2025 talk to learn more about Worker Versioning and see a demo.![](https://i.ytimg.com/vi/rm4BlD9WXqc/hqdefault.jpg)\n\n### Minimum versions\n\n- Go SDK version [v1.35.0](https://github.com/temporalio/sdk-go/releases/tag/v1.35.0)\n- Python [v1.11](https://github.com/temporalio/sdk-python/releases/tag/1.11.0)\n- Java [v1.29](https://github.com/temporalio/sdk-java/releases/tag/v1.29.0)\n- TypeScript [v1.12](https://github.com/temporalio/sdk-typescript/releases/tag/v1.12.0)\n- .NET [v1.7.0](https://github.com/temporalio/sdk-dotnet/releases/tag/1.7.0)\n- Ruby [v0.5.0](https://github.com/temporalio/sdk-ruby/releases/tag/v0.5.0)\n\nSelf-hosted users:\n\n- Minimum Temporal CLI version [v1.4.1](https://github.com/temporalio/cli/releases/tag/v1.4.1)\n- Minimum Temporal Server version: [v1.29.1](https://github.com/temporalio/temporal/releases/tag/v1.29.1)\n- Minimum Temporal UI version [v2.38.0](https://github.com/temporalio/ui/releases/tag/v2.38.0)","source_url":"https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning.md","page_url":"https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning"},{"content":"# Develop > Go > Workflows\n## Versioning\n\nSince Workflow Executions in Temporal can run for long periods — sometimes months or even years — it's common to need to make changes to a Workflow Definition, even while a particular Workflow Execution is in progress.\n\nThe Temporal Platform requires that Workflow Definitions are [deterministic](https://docs.temporal.io/workflow-definition#deterministic-constraints). If you make a change to your Workflow code that would cause non-deterministic behavior on Replay, you'll need to use one of our Versioning methods to gracefully update your running Workflows. This only applies to Workflow orchestration logic. Non-deterministic work such as API calls, and database queries should be placed in Activities, which Temporal retries reliably.\n\nWith Versioning, you can modify your Workflow Definition so that new executions use the updated code, while existing ones continue running the original version.\nThere are two primary Versioning methods that you can use:\n\n- [Worker Versioning](https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning). The Worker Versioning feature allows you to tag your Workers and programmatically roll them out in versioned deployments, so that old Workers can run old code paths and new Workers can run new code paths.\n- [Versioning with Patching](https://docs.temporal.io/develop/go/workflows/versioning#patching). This method works by adding branches to your code tied to specific revisions. It applies a code change to new Workflow Executions while avoiding disruptive changes to in-progress Workflow Executions.\n\nSupport for the experimental Worker Versioning method before 2025 was scheduled for removal from Temporal Server in March 2026. Refer to the [latest Worker Versioning docs](https://docs.temporal.io/worker-versioning) for guidance. You can still refer to the [Worker Versioning Legacy](https://docs.temporal.io/develop/go/worker-versioning-legacy) docs if needed.\n\n### Worker Versioning\n\nTemporal's [Worker Versioning](https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning) feature allows you to tag your Workers and programmatically roll them out in Deployment Versions, so that old Workers can run old code paths and new Workers can run new code paths. This way, you can pin your Workflows to specific revisions, avoiding the need for patching.","source_url":"https://docs.temporal.io/develop/go/workflows/versioning.md","page_url":"https://docs.temporal.io/develop/go/workflows/versioning"},{"content":"# Develop > Typescript > Workflows\n## Versioning\n\nSince Workflow Executions in Temporal can run for long periods — sometimes months or even years — it's common to need to make changes to a Workflow Definition, even while a particular Workflow Execution is in progress.\n\nThe Temporal Platform requires that Workflow Definitions are [deterministic](https://docs.temporal.io/workflow-definition#deterministic-constraints).\nIf you make a change to your Workflow code that would cause non-deterministic behavior on Replay, you'll need to use one of our Versioning methods to gracefully update your running Workflows.\n\nCommon causes include adding, removing, or reordering `await` calls on Command-producing APIs such as Activities and timers. Each `await` is a yield point that affects the Command sequence seen during Replay.\n\nWith Versioning, you can modify your Workflow Definition so that new executions use the updated code, while existing ones continue running the original version.\nThere are two primary Versioning methods that you can use:\n\n- [Worker Versioning](https://docs.temporal.io/production-deployment/worker-deployments/worker-versioning). The Worker Versioning feature allows you to tag your Workers and programmatically roll them out in versioned deployments, so that old Workers can run old code paths and new Workers can run new code paths.\n- [Versioning with Patching](https://docs.temporal.io/develop/typescript/workflows/versioning#patching). This method works by adding branches to your code tied to specific revisions. It applies a code change to new Workflow Executions while avoiding disruptive changes to in-progress Workflow Executions.\n\nSupport for the experimental Worker Versioning method before 2025 was scheduled for removal from Temporal Server in March 2026. Refer to the [latest Worker Versioning docs](https://docs.temporal.io/worker-versioning) for guidance. You can still refer to the [Worker Versioning Legacy](https://docs.temporal.io/develop/typescript/worker-versioning-legacy) docs if needed.","source_url":"https://docs.temporal.io/develop/typescript/workflows/versioning.md","page_url":"https://docs.temporal.io/develop/typescript/workflows/versioning"}]