mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat!: Migrate DatabaseSessionService to use JSON serialization schema
Also provide a command line tool `adk migrate session` for DB migration Addresses https://github.com/google/adk-python/discussions/3605 Addresses https://github.com/google/adk-python/issues/3681 To verify: ``` # Start one postgres DB docker run --name my-postgres -d -e POSTGRES_DB=agent -e POSTGRES_USER=agent -e POSTGRES_PASSWORD=agent -e PGDATA=/var/lib/postgresql/data/pgdata -v pgvolume:/var/lib/postgresql/data -p 5532:5432 postgres # Connect to an old version of ADK and produce some query data adk web --session_service_uri=postgresql://agent:agent@localhost:5532/agent # Check out to the latest branch and restart ADK web # You should see error log ask you to migrate the DB # Start a new DB docker run --name migration-test-db \ -d \ --rm \ -e POSTGRES_DB=agent \ -e POSTGRES_USER=agent \ -e POSTGRES_PASSWORD=agent -e PGDATA=/var/lib/postgresql/data/pgdata -v migration_test_vol:/var/lib/postgresql/data -p 5533:5432 postgres # DB Migration adk migrate session \ --source_db_url="postgresql://agent:agent@localhost:5532/agent" \ --dest_db_url="postgresql://agent:agent@localhost:5533/agent" # Run ADK web with the new DB adk web --session_service_uri=postgresql+asyncpg://agent:agent@localhost:5533/agent # You should see the data from old DB is migrated ``` Co-authored-by: Shangjie Chen <deanchen@google.com> PiperOrigin-RevId: 837341139
This commit is contained in:
committed by
Copybara-Service
parent
786aaed335
commit
0094eea3ca
@@ -107,7 +107,7 @@ class SqliteSessionService(BaseSessionService):
|
||||
f"Database {db_path} seems to use an old schema."
|
||||
" Please run the migration command to"
|
||||
" migrate it to the new schema. Example: `python -m"
|
||||
" google.adk.sessions.migrate_from_sqlalchemy_sqlite"
|
||||
" google.adk.sessions.migration.migrate_from_sqlalchemy_sqlite"
|
||||
f" --source_db_path {db_path} --dest_db_path"
|
||||
f" {db_path}.new` then backup {db_path} and rename"
|
||||
f" {db_path}.new to {db_path}."
|
||||
|
||||
Reference in New Issue
Block a user