We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] Alembic migration for metrics table uses incorrect server default
## MLflow Roadmap Item

This is an MLflow Roadmap item that has been prioritized by the MLflow maintainers. We're seeking help with the implementation of roadmap items tagged with the `help wanted` label.

For requirements clarifications and implementation questions, or to request a PR review, please tag @harupy in your communications related to this issue.

### System information
- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**: No
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: miniconda container - debian buster
- **MLflow installed from (source or binary)**:  mflow from pypi
- **MLflow version (run ``mlflow --version``)**: mlflow 1.14.1  trying to upgrade to 1.16 or 1.17
- **Python version**:  Python 3.9.2
- **npm version, if running the dev UI**: NA
- **Exact command to reproduce**: mlflow db upgrade <MSSQL connection string >
-  Tracking server DB: Azure Microsoft SQL DB

### Describe the problem
When I upgrade the database from 1.14.1 to a higher version I get an error. Currently use an Azure MSFT DB. Would like to upgrade to 1.16 or 1.17

### Code to reproduce issue
mlflow db upgrade "mssql+pyodbc://_rest_of_conn_string"

### Other info / logs
sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Column already has a DEFAULT bound to it. (1781) (SQLExecDirectW)')
[SQL: ALTER TABLE metrics ADD DEFAULT '0' FOR is_nan]
(Background on this error at: http://sqlalche.me/e/14/f405)


### What component(s), interfaces, languages, and integrations does this bug affect?
Components 
- [ ] `area/artifacts`: Artifact stores and artifact logging
- [ ] `area/build`: Build and test infrastructure for MLflow
- [ ] `area/docs`: MLflow documentation pages
- [ ] `area/examples`: Example code
- [x] `area/model-registry`: Model Registry service, APIs, and the fluent client calls for Model Registry
- [ ] `area/models`: MLmodel format, model serialization/deserialization, flavors
- [ ] `area/projects`: MLproject format, project running backends
- [ ] `area/scoring`: Local serving, model deployment tools, spark UDFs
- [ ] `area/server-infra`: MLflow server, JavaScript dev server
- [ ] `area/tracking`: Tracking Service, tracking client APIs, autologging

Interface 
- [ ] `area/uiux`: Front-end, user experience, JavaScript, plotting
- [ ] `area/docker`: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
- [x] `area/sqlalchemy`: Use of SQLAlchemy in the Tracking Service or Model Registry
- [ ] `area/windows`: Windows support

Language 
- [ ] `language/r`: R APIs and clients
- [ ] `language/java`: Java APIs and clients
- [ ] `language/new`: Proposals for new client languages

Integrations
- [ ] `integrations/azure`: Azure and Azure ML integrations
- [ ] `integrations/sagemaker`: SageMaker integrations
- [ ] `integrations/databricks`: Databricks integrations


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py`
Content:
```
1 """reset_default_value_for_is_nan_in_metrics_table_for_mysql
2 
3 Revision ID: c48cb773bb87
4 Revises: 39d1c3be5f05
5 Create Date: 2021-04-02 15:43:28.466043
6 
7 """
8 from alembic import op
9 import sqlalchemy as sa
10 
11 
12 # revision identifiers, used by Alembic.
13 revision = "c48cb773bb87"
14 down_revision = "39d1c3be5f05"
15 branch_labels = None
16 depends_on = None
17 
18 
19 def upgrade():
20     # This part of the migration is only relevant for MySQL.
21     # In 39d1c3be5f05_add_is_nan_constraint_for_metrics_tables_if_necessary.py
22     # (added in MLflow 1.15.0), `alter_column` is called on the `is_nan` column in the `metrics`
23     # table without specifying `existing_server_default`. This alters the column default value to
24     # NULL in MySQL (see the doc below).
25     #
26     # https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.alter_column
27     #
28     # To revert this change, set the default column value to "0" by specifying `server_default`
29     with op.batch_alter_table("metrics") as batch_op:
30         batch_op.alter_column(
31             "is_nan",
32             type_=sa.types.Boolean(create_constraint=True),
33             nullable=False,
34             server_default="0",
35         )
36 
37 
38 def downgrade():
39     pass
40
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py b/mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py
--- a/mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py
+++ b/mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py
@@ -26,13 +26,15 @@
     # https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.alter_column
     #
     # To revert this change, set the default column value to "0" by specifying `server_default`
-    with op.batch_alter_table("metrics") as batch_op:
-        batch_op.alter_column(
-            "is_nan",
-            type_=sa.types.Boolean(create_constraint=True),
-            nullable=False,
-            server_default="0",
-        )
+    bind = op.get_bind()
+    if bind.engine.name == "mysql":
+        with op.batch_alter_table("metrics") as batch_op:
+            batch_op.alter_column(
+                "is_nan",
+                type_=sa.types.Boolean(create_constraint=True),
+                nullable=False,
+                server_default="0",
+            )
 
 
 def downgrade():

{"golden_diff": "diff --git a/mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py b/mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py\n--- a/mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py\n+++ b/mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py\n@@ -26,13 +26,15 @@\n     # https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.alter_column\n     #\n     # To revert this change, set the default column value to \"0\" by specifying `server_default`\n-    with op.batch_alter_table(\"metrics\") as batch_op:\n-        batch_op.alter_column(\n-            \"is_nan\",\n-            type_=sa.types.Boolean(create_constraint=True),\n-            nullable=False,\n-            server_default=\"0\",\n-        )\n+    bind = op.get_bind()\n+    if bind.engine.name == \"mysql\":\n+        with op.batch_alter_table(\"metrics\") as batch_op:\n+            batch_op.alter_column(\n+                \"is_nan\",\n+                type_=sa.types.Boolean(create_constraint=True),\n+                nullable=False,\n+                server_default=\"0\",\n+            )\n \n \n def downgrade():\n", "issue": "[BUG] Alembic migration for metrics table uses incorrect server default\n## MLflow Roadmap Item\r\n\r\nThis is an MLflow Roadmap item that has been prioritized by the MLflow maintainers. We're seeking help with the implementation of roadmap items tagged with the `help wanted` label.\r\n\r\nFor requirements clarifications and implementation questions, or to request a PR review, please tag @harupy in your communications related to this issue.\r\n\r\n### System information\r\n- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**: No\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: miniconda container - debian buster\r\n- **MLflow installed from (source or binary)**:  mflow from pypi\r\n- **MLflow version (run ``mlflow --version``)**: mlflow 1.14.1  trying to upgrade to 1.16 or 1.17\r\n- **Python version**:  Python 3.9.2\r\n- **npm version, if running the dev UI**: NA\r\n- **Exact command to reproduce**: mlflow db upgrade <MSSQL connection string >\r\n-  Tracking server DB: Azure Microsoft SQL DB\r\n\r\n### Describe the problem\r\nWhen I upgrade the database from 1.14.1 to a higher version I get an error. Currently use an Azure MSFT DB. Would like to upgrade to 1.16 or 1.17\r\n\r\n### Code to reproduce issue\r\nmlflow db upgrade \"mssql+pyodbc://_rest_of_conn_string\"\r\n\r\n### Other info / logs\r\nsqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Column already has a DEFAULT bound to it. (1781) (SQLExecDirectW)')\r\n[SQL: ALTER TABLE metrics ADD DEFAULT '0' FOR is_nan]\r\n(Background on this error at: http://sqlalche.me/e/14/f405)\r\n\r\n\r\n### What component(s), interfaces, languages, and integrations does this bug affect?\r\nComponents \r\n- [ ] `area/artifacts`: Artifact stores and artifact logging\r\n- [ ] `area/build`: Build and test infrastructure for MLflow\r\n- [ ] `area/docs`: MLflow documentation pages\r\n- [ ] `area/examples`: Example code\r\n- [x] `area/model-registry`: Model Registry service, APIs, and the fluent client calls for Model Registry\r\n- [ ] `area/models`: MLmodel format, model serialization/deserialization, flavors\r\n- [ ] `area/projects`: MLproject format, project running backends\r\n- [ ] `area/scoring`: Local serving, model deployment tools, spark UDFs\r\n- [ ] `area/server-infra`: MLflow server, JavaScript dev server\r\n- [ ] `area/tracking`: Tracking Service, tracking client APIs, autologging\r\n\r\nInterface \r\n- [ ] `area/uiux`: Front-end, user experience, JavaScript, plotting\r\n- [ ] `area/docker`: Docker use across MLflow's components, such as MLflow Projects and MLflow Models\r\n- [x] `area/sqlalchemy`: Use of SQLAlchemy in the Tracking Service or Model Registry\r\n- [ ] `area/windows`: Windows support\r\n\r\nLanguage \r\n- [ ] `language/r`: R APIs and clients\r\n- [ ] `language/java`: Java APIs and clients\r\n- [ ] `language/new`: Proposals for new client languages\r\n\r\nIntegrations\r\n- [ ] `integrations/azure`: Azure and Azure ML integrations\r\n- [ ] `integrations/sagemaker`: SageMaker integrations\r\n- [ ] `integrations/databricks`: Databricks integrations\r\n\n", "before_files": [{"content": "\"\"\"reset_default_value_for_is_nan_in_metrics_table_for_mysql\n\nRevision ID: c48cb773bb87\nRevises: 39d1c3be5f05\nCreate Date: 2021-04-02 15:43:28.466043\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = \"c48cb773bb87\"\ndown_revision = \"39d1c3be5f05\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n    # This part of the migration is only relevant for MySQL.\n    # In 39d1c3be5f05_add_is_nan_constraint_for_metrics_tables_if_necessary.py\n    # (added in MLflow 1.15.0), `alter_column` is called on the `is_nan` column in the `metrics`\n    # table without specifying `existing_server_default`. This alters the column default value to\n    # NULL in MySQL (see the doc below).\n    #\n    # https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.alter_column\n    #\n    # To revert this change, set the default column value to \"0\" by specifying `server_default`\n    with op.batch_alter_table(\"metrics\") as batch_op:\n        batch_op.alter_column(\n            \"is_nan\",\n            type_=sa.types.Boolean(create_constraint=True),\n            nullable=False,\n            server_default=\"0\",\n        )\n\n\ndef downgrade():\n    pass\n", "path": "mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py"}], "after_files": [{"content": "\"\"\"reset_default_value_for_is_nan_in_metrics_table_for_mysql\n\nRevision ID: c48cb773bb87\nRevises: 39d1c3be5f05\nCreate Date: 2021-04-02 15:43:28.466043\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = \"c48cb773bb87\"\ndown_revision = \"39d1c3be5f05\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n    # This part of the migration is only relevant for MySQL.\n    # In 39d1c3be5f05_add_is_nan_constraint_for_metrics_tables_if_necessary.py\n    # (added in MLflow 1.15.0), `alter_column` is called on the `is_nan` column in the `metrics`\n    # table without specifying `existing_server_default`. This alters the column default value to\n    # NULL in MySQL (see the doc below).\n    #\n    # https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.alter_column\n    #\n    # To revert this change, set the default column value to \"0\" by specifying `server_default`\n    bind = op.get_bind()\n    if bind.engine.name == \"mysql\":\n        with op.batch_alter_table(\"metrics\") as batch_op:\n            batch_op.alter_column(\n                \"is_nan\",\n                type_=sa.types.Boolean(create_constraint=True),\n                nullable=False,\n                server_default=\"0\",\n            )\n\n\ndef downgrade():\n    pass\n", "path": "mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py"}]}