Skip to content

Commit 8fb2be2

Browse files
wuliang229copybara-github
authored andcommitted
chore: Add back adk migrate session CLI
It was accidentally deleted in a previous PR. Closes #4107. Co-authored-by: Liang Wu <wuliang@google.com> PiperOrigin-RevId: 854339442
1 parent 6b241f5 commit 8fb2be2

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/google/adk/cli/cli_tools_click.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,47 @@ def cli_deploy_cloud_run(
15531553
click.secho(f"Deploy failed: {e}", fg="red", err=True)
15541554

15551555

1556+
@main.group()
1557+
def migrate():
1558+
"""ADK migration commands."""
1559+
pass
1560+
1561+
1562+
@migrate.command("session", cls=HelpfulCommand)
1563+
@click.option(
1564+
"--source_db_url",
1565+
required=True,
1566+
help=(
1567+
"SQLAlchemy URL of source database in database session service, e.g."
1568+
" sqlite:///source.db."
1569+
),
1570+
)
1571+
@click.option(
1572+
"--dest_db_url",
1573+
required=True,
1574+
help=(
1575+
"SQLAlchemy URL of destination database in database session service,"
1576+
" e.g. sqlite:///dest.db."
1577+
),
1578+
)
1579+
@click.option(
1580+
"--log_level",
1581+
type=LOG_LEVELS,
1582+
default="INFO",
1583+
help="Optional. Set the logging level",
1584+
)
1585+
def cli_migrate_session(
1586+
*, source_db_url: str, dest_db_url: str, log_level: str
1587+
):
1588+
"""Migrates a session database to the latest schema version."""
1589+
logs.setup_adk_logger(getattr(logging, log_level.upper()))
1590+
try:
1591+
migration_runner.upgrade(source_db_url, dest_db_url)
1592+
click.secho("Migration check and upgrade process finished.", fg="green")
1593+
except Exception as e:
1594+
click.secho(f"Migration failed: {e}", fg="red", err=True)
1595+
1596+
15561597
@deploy.command("agent_engine")
15571598
@click.option(
15581599
"--api_key",

0 commit comments

Comments
 (0)