<@ULVA73B9P> How to migrate our old deployments an...
# ask-marvin
v
@Marvin How to migrate our old deployments and their tags and parameters with value ? is there better way to update dpeloyment name and paramters or should we have to create it again or any way of migrating this deployments ?
m
thought for 154.8 seconds
Yes — in most cases you do not need to recreate deployments just to change tags or default parameter values. Short answer: - Tags and default parameters: update and redeploy - Deployment name: generally treat it as create a new deployment - Bulk migration from an old environment/workspace: use
prefect transfer
if that fits your setup - If you're moving from Prefect 2-style deployment definitions to Prefect 3: recreate them in 3 using
prefect deploy
or
flow.deploy()
Recommended docs / references: - Deployments docs - Deploy via Python - prefect.yaml deployments - Migration docs Best practice 1. Keep the same deployment name if possible 2. Update its config (
tags
,
parameters
, schedules, work pool, etc.) 3. Run
prefect deploy
again 4. Prefect will update the existing deployment if the flow + deployment name matches Example `prefect.yaml`:
Copy code
yaml
deployments:
  - name: my-deployment
    entrypoint: flows/my_flow.py:my_flow
    tags:
      - prod
      - etl
    parameters:
      country: us
      full_refresh: false
Then redeploy:
Copy code
bash
prefect deploy
That is the normal way to update: - default parameter values - tags - schedules - infra/work pool settings If you want to rename a deployment There is not really a “rename in place” workflow I’d recommend. The safe approach is: 1. Create a new deployment with the new name 2. Verify it works 3. Delete the old deployment when ready So for name changes, assume: create again If you want to migrate old deployments There are 2 different meanings of “migrate”: 1. Migrate deployments between Prefect environments/workspaces Use
prefect transfer
if you're moving resources between profiles/environments. 2. Migrate old Prefect 2 deployment definitions to Prefect 3 You should move them to Prefect 3 deployment patterns: -
prefect deploy
-
flow.deploy()
-
flow.from_source(...).deploy(...)
Important: in Prefect 3.x, do not use old 2.x patterns like: -
Deployment.build_from_flow()
-
prefect deployment build
Practical recommendation for your case - If only tags and parameter values changed: update existing deployment and redeploy - If deployment name changed: create a new deployment - If you have many old deployments and want to preserve as much config as possible: check whether
prefect transfer
works for your source/destination setup If you want, I can help you with either of these next: 1. convert one of your old deployment configs to Prefect 3 2. show how to bulk update tags/parameters in
prefect.yaml
3. show a migration script using the Python client/API If you paste one old deployment example, I can rewrite it for you.