# MD_UPDATE_FLIGHT
> Update a Flight's source code, requirements, config, token, secrets, name, or schedule.
Updates an existing [Flight](/concepts/flights). Behaves as a PATCH: only the parameters you pass are modified, and unspecified fields are left unchanged.

Updates to `source_code`, `requirements_txt`, `config`, `access_token_name`, or `flight_secret_names` produce a fresh `FlightVersion`. Updates to `name` or `schedule_cron` are metadata-only and do not bump the version.

## Syntax

```sql
CALL MD_UPDATE_FLIGHT(
    flight_id := '<flight_id>',
    name := '<updated_name>',
    schedule_cron := '0 0 * * *',
    source_code := '<updated_python>',
    requirements_txt := '<updated_requirements>',
    config := MAP {'KEY': 'value'},
    access_token_name := '<updated_token_name>',
    flight_secret_names := ['secret_name']
);
```

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flight_id` | `UUID` | Yes | Identifier of the Flight to update. |
| `name` | `VARCHAR` | No | New Flight name. Must be non-empty when provided. Metadata-only. |
| `schedule_cron` | `VARCHAR` | No | New cron expression (UTC, 5 fields). Pass `''` (empty string) to clear the schedule. Metadata-only. |
| `source_code` | `VARCHAR` | No | New Python source. Bumps the version. |
| `requirements_txt` | `VARCHAR` | No | New `requirements.txt` contents. Bumps the version. |
| `config` | `MAP(VARCHAR, VARCHAR)` | No | Replacement config map (full replace, not merge). Bumps the version. |
| `access_token_name` | `VARCHAR` | No | New access token label. Bumps the version. |
| `flight_secret_names` | `LIST(VARCHAR)` | No | Replacement secret names list (full replace). Bumps the version. |

At least one of the above (besides `flight_id`) must be set.

## Return columns

`MD_UPDATE_FLIGHT` returns the updated `FlightSummary`:

| Column | Type | Description |
|---|---|---|
| `flight_id` | `UUID` | The Flight identifier. |
| `flight_name` | `VARCHAR` | The current name. |
| `schedule_cron` | `VARCHAR` | The current cron expression, or `NULL`. |
| `status` | `VARCHAR` | Schedule status. |
| `current_version` | `INTEGER` | The current version (incremented for content updates). |
| `created_at` | `TIMESTAMP WITH TIME ZONE` | Original creation timestamp. |
| `updated_at` | `TIMESTAMP WITH TIME ZONE` | Most recent update timestamp. |

## Behavior

- **Full-replace semantics.** `config` and `flight_secret_names` are replaced, not merged. To change one entry, send the full updated map or list.
- **Carry-forward semantics.** When you patch one content field, the resulting version carries unchanged content fields forward from the previous version.
- **Empty schedule.** `schedule_cron := ''` clears the schedule; omit it to leave the existing schedule untouched.

## Examples

Rename a Flight (metadata-only, no new version):

```sql
CALL MD_UPDATE_FLIGHT(
    flight_id := '<flight_id>',
    name := 'analytics_hourly_sync'
);
```

Update the source (bumps the version):

```sql
CALL MD_UPDATE_FLIGHT(
    flight_id := '<flight_id>',
    source_code := $$
def main():
    print("v2")
$$
);
```

Clear the schedule, leave everything else:

```sql
CALL MD_UPDATE_FLIGHT(
    flight_id := '<flight_id>',
    schedule_cron := ''
);
```

## Related

- [`MD_CREATE_FLIGHT`](../md-create-flight) — Create a Flight.
- [`MD_GET_FLIGHT`](../md-get-flight) — Inspect the current Flight summary.
- [`MD_FLIGHT_VERSIONS`](../md-flight-versions) — List historical versions.
- [`update_flight` MCP tool](/sql-reference/mcp/) — AI-agent equivalent (uses `md_token_name` / `md_secret_names`).


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/sql-reference/motherduck-sql-reference/flights/md-update-flight/",
  "page_title": "MD_UPDATE_FLIGHT",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
