This page describes how to perform in-place upgrades and downgrades of your
Cloud SQL instances.

## Make in-place changes to a Cloud SQL instance

You can use in-place changes to upgrade or downgrade the edition, machine type,
or storage type of your Cloud SQL instance, or to upgrade its database
version.
Making in-place changes is the easiest and least error-prone way to re-configure
an instance.

## Before you begin

Before you make in-place changes to your instance, do the following:

- Ensure that your instance is running on SQL Server Enterprise 2019 or SQL
  Server Enterprise 2022.

  > [!NOTE]
  > **Note:** If you have the [`max server memory (mb)`](https://docs.cloud.google.com/sql/docs/sqlserver/flags.md.txt) flag set, then we suggest removing the flag after you upgrade your instance to Cloud SQL Enterprise Plus edition so that Cloud SQL can manage the value for the flag automatically. However, if you prefer to set the value, you can revisit the flag value after you upgrade your instance and adjust the value according to the size of the VM.

- Ensure that your network project is created after August 2021 or is fully
  [upgraded](https://docs.cloud.google.com/sql/docs/sqlserver/upgrade-cloud-sql-instance-new-network-architecture.md.txt)
  to the new network architecture.

<!-- -->

- Ensure that your instance is running on the latest maintenance version.

  If your instance is on an older maintenance version, then you must update
  to the latest maintenance version before you upgrade your instance to
  Cloud SQL Enterprise Plus edition. For more information about checking and updating the
  maintenance version, see
  [Perform self-service maintenance](https://docs.cloud.google.com/sql/docs/sqlserver/self-service-maintenance.md.txt).

### Be aware of potential storage changes related to machine type

Different editions support different machine types which use different storage
options. High-performance C4, C4A, and C4D machine types use
[Google Cloud Hyperdisk Balanced](https://docs.cloud.google.com/compute/docs/disks/hd-types/hyperdisk-balanced.md.txt)
storage rather than one of the
[persistent disk](https://docs.cloud.google.com/compute/docs/disks/persistent-disks.md.txt) options used by older
machine types.

When you make a change to the edition or machine type you're using, your
storage type may also change, which may result in some downtime and a change in
storage costs. When moving to Google Cloud Hyperdisk Balanced, there are
additional configuration options that you can specify. For more information, see
[Storage changes](https://docs.cloud.google.com/sql/docs/sqlserver/upgrade-in-place.md.txt#storage-changes).

## Change the edition of an instance in place

This section shows you how to change the edition of your Cloud SQL instance
in place to or from Cloud SQL Enterprise Plus edition. Cloud SQL Enterprise Plus edition offers some benefits and
performance enhancements that Cloud SQL Enterprise edition does not. For more information
about Cloud SQL editions, see
[Cloud SQL editions overview](https://docs.cloud.google.com/sql/docs/sqlserver/editions-intro.md.txt).

Upgrading to Cloud SQL Enterprise Plus edition takes a few minutes to complete
.
Neither process requires changing the endpoints that your applications connect to.

Use the procedure in this section to upgrade a Cloud SQL Enterprise edition instance
to Cloud SQL Enterprise Plus edition, or to downgrade a Cloud SQL Enterprise Plus edition instance to Cloud SQL Enterprise edition.

### Console

1. In the Google Cloud console, go to the **Cloud SQL Instances** page.

   [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)
2. To open the **Overview** page of an instance, click the instance name.
3. Click **Edit**.
4. In the **Choose a Cloud SQL edition** section, click **Upgrade** if your instance is using the Cloud SQL Enterprise edition, or **Switch to Enterprise** if your instance is using Cloud SQL Enterprise Plus edition.
5. Use the panel that opens to specify the configuration of your instance using the new edition. See \[Options when making in-place changes\](#change-options).
6. Enter your instance ID to confirm these choices and then click either **Upgrade edition** or **Switch edition** depending on whether you're upgrading or downgrading.

You can also start an edition change in the **Instances** page if you
select **Edit** in the **Actions** column of the instance.

In addition, if your instance is on Cloud SQL Enterprise edition, you can start an upgrade
by clicking the **Upgrade** link beside the edition field in the
**Configuration** section of the instance page.

### gcloud

The following \[\`gcloud sql instance patch\`\](/sdk/gcloud/reference/sql/instances/patch)
code sample shows how to upgrade your instance to Cloud SQL Enterprise Plus edition:

```bash
gcloud sql instances patch INSTANCE_ID \
  --edition=enterprise-plus \
  --tier=MACHINE_TYPE \
  --project=PROJECT_ID
```

Replace the following:

- <var translate="no">PROJECT_ID</var>: the project ID of the instance that you want to upgrade.
- <var translate="no">INSTANCE_ID</var>: name of the instance that you want to upgrade.
- <var translate="no">MACHINE_TYPE</var>: the machine type of the instance that you want to upgrade to. For more information about machine types for Cloud SQL Enterprise Plus edition, see [Machine types
  for Cloud SQL Enterprise Plus edition instances](https://docs.cloud.google.com/sql/docs/sqlserver/create-instance#enterprise-plus).

### REST

The following command upgrades your instance to Cloud SQL Enterprise Plus edition and triggers
a restart operation.


Before using any of the request data,
make the following replacements:

- <var translate="no">PROJECT_ID</var>: the project ID of the instance that you want to upgrade.
- <var translate="no">INSTANCE_ID</var>: the instance ID of the instance that you want to upgrade.
- <var translate="no">MACHINE_TYPE</var>: the machine type of the instance that you want to upgrade to. For more information about machine types for Cloud SQL Enterprise Plus edition, see [Machine types for Cloud SQL Enterprise Plus edition instances](https://docs.cloud.google.com/sql/docs/sqlserver/create-instance.md.txt#enterprise-plus).


HTTP method and URL:

```
PATCH https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID
```


Request JSON body:

```
{
  "settings": {
      "tier": "MACHINE_TYPE",
      "edition": "ENTERPRISE_PLUS",
      "dataCacheConfig": {
        "dataCacheEnabled": true
      },
  }
}
```

To send your request, expand one of these options:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs.md.txt), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Save the request body in a file named `request.json`,
and execute the following command:

```
curl -X PATCH \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d @request.json \
     "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Save the request body in a file named `request.json`,
and execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method PATCH `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID" | Select-Object -Expand Content
```

You should receive a JSON response similar to the following:

```
{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID",
  "status": "PENDING",
  "user": "user@example.com",
  "insertTime": "2020-01-16T02:32:12.281Z",
  "operationType": "UPDATE",
  "name": "OPERATION_ID",
  "targetId": "INSTANCE_ID",
  "selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID",
  "targetProject": "PROJECT_ID"
}
```

### REST v1beta4

The following command upgrades your instance to Cloud SQL Enterprise Plus edition and triggers
a restart operation.


Before using any of the request data,
make the following replacements:

- <var translate="no">PROJECT_ID</var>: the project ID of the instance that you want to upgrade.
- <var translate="no">INSTANCE_ID</var>: the instance ID of the instance that you want to upgrade.
- <var translate="no">MACHINE_TYPE</var>: the machine type of the instance that you want to upgrade to. For more information about machine types for Cloud SQL Enterprise Plus edition, see [Machine types for Cloud SQL Enterprise Plus edition instances](https://docs.cloud.google.com/sql/docs/sqlserver/create-instance.md.txt#enterprise-plus).


HTTP method and URL:

```
PATCH https://sqladmin.googleapis.com/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID
```


Request JSON body:

```
{
  "settings": {
      "tier": "MACHINE_TYPE",
      "edition": "ENTERPRISE_PLUS",
      "dataCacheConfig": {
        "dataCacheEnabled": true
      },
  }
}
```

To send your request, expand one of these options:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs.md.txt), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Save the request body in a file named `request.json`,
and execute the following command:

```
curl -X PATCH \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d @request.json \
     "https://sqladmin.googleapis.com/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Save the request body in a file named `request.json`,
and execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method PATCH `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://sqladmin.googleapis.com/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID" | Select-Object -Expand Content
```

You should receive a JSON response similar to the following:

```
{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID",
  "status": "PENDING",
  "user": "user@example.com",
  "insertTime": "2020-01-16T02:32:12.281Z",
  "operationType": "UPDATE",
  "name": "OPERATION_ID",
  "targetId": "INSTANCE_ID",
  "selfLink": "https://sqladmin.googleapis.com/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID",
  "targetProject": "PROJECT_ID"
}
```

## Options for in-place changes

Changing the edition of your Cloud SQL instance can require changing its
machine series, which in turn affects its storage type.

### Machine changes

When you change editions, you have to change machine type, too. See
[Choose a machine series](https://docs.cloud.google.com/sql/docs/sqlserver/machine-series-overview.md.txt) for
more information about the machine series that Cloud SQL supports.

When upgrading from Cloud SQL Enterprise edition to Cloud SQL Enterprise Plus edition, you can choose between the
[N2](https://docs.cloud.google.com/sql/docs/sqlserver/machine-series-overview.md.txt#n2),
[Memory-optimized N2](https://docs.cloud.google.com/sql/docs/sqlserver/machine-series-overview.md.txt#memory-optimized-N2),
[C4](https://docs.cloud.google.com/sql/docs/sqlserver/machine-series-overview.md.txt#c4), and
[C4D](https://docs.cloud.google.com/sql/docs/sqlserver/machine-series-overview.md.txt#c4d) machine series.

When downgrading from Cloud SQL Enterprise Plus edition to Cloud SQL Enterprise edition, you can choose between a
[general purpose dedicated-core](https://docs.cloud.google.com/sql/docs/sqlserver/machine-series-overview.md.txt#gp-dedicated-core),
and an [N4](https://docs.cloud.google.com/sql/docs/sqlserver/machine-series-overview.md.txt#n4) machine series.

You can also change machine type without changing edition. After choosing to
edit your instance, go to the **Machine** sub-section of
**Machine Configuration** in the **Customize your instance** area.
Using the drop-down, you can select a different machine type. You can also
choose a different number of VCPUs, and enable or disable the
[data cache](https://docs.cloud.google.com/sql/docs/sqlserver/data-cache.md.txt) if appropriate.

> [!NOTE]
> **Note:** Data cache isn't supported for the C4D machine series. If you change an instance that has data cache enabled to a C4D machine type, or if you upgrade an instance to Cloud SQL Enterprise Plus edition with a C4D machine type (8 vCPUs or larger), you must explicitly disable data cache (for example, by adding `--no-enable-data-cache` for the [gcloud CLI](https://docs.cloud.google.com/sdk/gcloud.md.txt)).

For more general information, see also
[Compute Engine documentation](https://docs.cloud.google.com/compute/docs/overview.md.txt) for the
[N2](https://docs.cloud.google.com/compute/docs/general-purpose-machines.md.txt#n2_series),
[C4](https://docs.cloud.google.com/compute/docs/general-purpose-machines.md.txt#c4_series),
[C4D](https://docs.cloud.google.com/compute/docs/general-purpose-machines.md.txt#c4d_series), and
[N4](https://docs.cloud.google.com/compute/docs/general-purpose-machines.md.txt#n4_series) machine series.

### Storage changes

If you are changing from a general purpose or an N2 machine series to an N4, C4, or C4D machine series,
your storage is migrated from
[Solid-state drive (SSD)](https://docs.cloud.google.com/sql/docs/sqlserver/storage-options-overview.md.txt#ssd)
to [Google Cloud Hyperdisk
Balanced](https://docs.cloud.google.com/sql/docs/sqlserver/storage-options-overview#hyperdisk)
storage. This upgrade generally requires minimal downtime.

> [!IMPORTANT]
> **Important:** If you switch from an N4, C4, C4A, or C4D machine series back to a general purpose dedicated-core or N2 machine series, moving your data from Google Cloud Hyperdisk Balanced storage to solid-state drive (SSD) storage can incur significant downtime. You cannot move to or from Hard-disk drive (HDD) storage.

Google Cloud Hyperdisk Balanced storage can be customized for your use case by
setting the following:

- Storage capacity
- Provisioned IOPS
- Provisioned throughput

Google Cloud Hyperdisk Balanced sets default IOPS and throughput values and
limits based on your instance's configuration, which includes the machine type
and storage capacity. Storage capacity limits the default value, and the
machine type sets the maximum value for both IOPS and throughput. See
[Choose a storage option](https://docs.cloud.google.com/sql/docs/sqlserver/storage-options-overview.md.txt#hyperdisk)
for details.