# mlmd.downgrade_schema

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/google/ml-metadata/blob/v1.17.1/ml_metadata/metadata_store/metadata_store.py#L1987-L2027) |

Downgrades the db specified in the connection config to a schema version.

    mlmd.downgrade_schema(
        config: proto.ConnectionConfig, downgrade_to_schema_version: int
    ) -> None

If `downgrade_to_schema_version` is greater or equals to zero and less than
the current library's schema version, it runs a downgrade transaction to
revert the db schema and migrate the data. The update is transactional, and
any failure will cause a full rollback of the downgrade. Once the downgrade
is done, the user needs to use the older version of the library to connect to
the database.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `config` | a `proto.ConnectionConfig` having the connection params. |
| `downgrade_to_schema_version` | downgrades the given database to a specific version. For v0.13.2 release, the schema_version is 0. For 0.14.0 and 0.15.0 release, the schema_version is 4. More details are described in g3doc/get_start#upgrade_mlmd_library |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| [`errors.InvalidArgumentError`](https://www.tensorflow.org/api_docs/python/tf/errors/InvalidArgumentError) | if the `downgrade_to_schema_version` is not given or it is negative or greater than the library version. |
| `RuntimeError` | if the downgrade is not finished, return detailed error. |

<br />