Skip to content

Fix Alembic role migration truncation when renaming to worker_owner#33

Merged
chrystianmartins merged 1 commit into
mainfrom
codex/fix-user-role-update-migration-error
Feb 9, 2026
Merged

Fix Alembic role migration truncation when renaming to worker_owner#33
chrystianmartins merged 1 commit into
mainfrom
codex/fix-user-role-update-migration-error

Conversation

@chrystianmartins

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a DataError: value too long for type character varying(8) when the migration updates users.role to worker_owner because the pre-migration enum/check constrained stored values to shorter length.
  • Make the migration robust by widening the role column temporarily so data updates do not get truncated.

Description

  • Updated pool-coordinator/alembic/versions/0003_update_user_role_enum_for_new_auth_flow.py to remove client and worker_owner from old_role_enum so it reflects the actual pre-migration enum (admin, operator, user).
  • Added a temporary op.batch_alter_table in upgrade() that alters role to sa.String(length=32) before performing the UPDATE statements.
  • Left the subsequent conversion to the new enum (client, worker_owner) intact so the column becomes the intended enum after data migration.

Testing

  • Ran the test suite with cd pool-coordinator && python -m pytest -q, which completed successfully with 39 passed, 3 skipped.
  • Executed the migration integration test with cd pool-coordinator && python -m pytest tests/integration/test_migrations_apply.py -q, which ran in this environment and reported 1 skipped.

Codex Task

@chrystianmartins
chrystianmartins merged commit e9c51cf into main Feb 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant