Rename sessions/kernels.user_uuid to owner_id and drop access_key columns
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
Part of BA-5609. Depends on BA-5650 and BA-5651. Final sub-PR of the session owner_id migration.
## Objective
Schema cleanup: rename sessions.user_uuid and kernels.user_uuid to owner_id, then drop sessions.access_key and kernels.access_key columns. This is the destructive schema change; must land after BA-5650 and BA-5651 so that every reader has already been migrated off the dropped column.
## Scope
- New Alembic revision: rename sessions.user_uuid -> owner_id, rename kernels.user_uuid -> owner_id, rename partial unique index ix_sessions_unique_name_per_user_nonterminal -> ix_sessions_unique_name_per_owner_nonterminal, drop sessions.access_key, drop kernels.access_key. Downgrade is lossy (access_key recreated nullable, no backfill).
- models/session/row.py, models/kernel/row.py: rename Mapped attribute user_uuid -> owner_id, update UserRow relationship foreign_keys, update RBAC query builders, rename delegate_ownership(owner_id) and delete_by_owner_id. Drop access_key Mapped column and access_key_row relationship. Drop ConcurrencyUsed redis-key builder properties (dead code).
- models/session/conditions.py: delete by_access_key_\* QueryCondition factories; rename by_user_uuid_\* -> by_owner_id_\*.
- models/keypair/row.py: delete reverse relationships to SessionRow / KernelRow and _get_session_row_join_condition helper.
- Propagate the user_uuid -> owner_id rename through data types (data/, sokovan/data/, repositories/scheduler/types/), repositories (session, scheduler, export), services, sokovan, scheduler, API (GraphQL + REST), and all tests.
- PendingSessions.user_uuids -> owner_ids.
- Remove now-dead AccessKey imports and the TODO(phase D) markers left by BA-5651.
## Acceptance Criteria
- pants fmt / fix / lint / check clean.
- Alembic upgrade and downgrade both execute cleanly on a realistic DB snapshot.
- External wire schemas (GraphQL field names, REST response keys, agent env vars, event payload keys) unchanged.
- No remaining references to SessionRow.user_uuid / SessionRow.access_key / KernelRow.user_uuid / KernelRow.access_key anywhere.
- Unit tests pass.
JIRA Issue: BA-5653
Contributor guide
Assessment
This issue has not been assessed yet.