Add ruff config to exclude alembic E402, SQLAlchemy F821, and pre-existing E501 line-length issues. Auto-fix 69 unused imports and 2 f-strings without placeholders. Manually fix 8 unused variables. Apply ruff format to 127 files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
"""Deprecate bcrypt: add must_upgrade_auth flag and make hashed_password nullable.
|
|
|
|
Revision ID: 019
|
|
Revises: 018
|
|
Create Date: 2026-03-03
|
|
|
|
Conservative migration that flags legacy bcrypt users for SRP upgrade
|
|
rather than dropping data. hashed_password is made nullable so SRP-only
|
|
users no longer need a dummy value. A future migration (post-v6.0) can
|
|
drop hashed_password once all users have upgraded.
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "019"
|
|
down_revision = "018"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Add must_upgrade_auth flag
|
|
op.add_column(
|
|
"users",
|
|
sa.Column(
|
|
"must_upgrade_auth",
|
|
sa.Boolean(),
|
|
server_default="false",
|
|
nullable=False,
|
|
),
|
|
)
|
|
|
|
# Flag all bcrypt-only users for upgrade (auth_version=1 and no SRP verifier)
|
|
op.execute(
|
|
"UPDATE users SET must_upgrade_auth = true WHERE auth_version = 1 AND srp_verifier IS NULL"
|
|
)
|
|
|
|
# Make hashed_password nullable (SRP users don't need it)
|
|
op.alter_column("users", "hashed_password", nullable=True)
|
|
|
|
|
|
def downgrade() -> None:
|
|
# Restore NOT NULL (set a dummy value for any NULLs first)
|
|
op.execute(
|
|
"UPDATE users SET hashed_password = '$2b$12$placeholder' WHERE hashed_password IS NULL"
|
|
)
|
|
op.alter_column("users", "hashed_password", nullable=False)
|
|
|
|
op.drop_column("users", "must_upgrade_auth")
|