"""drop users.password_hash — D13 / T10.3 Authentication moved to an LDAPS simple bind against the domain (see server/ldap_auth.py), so the suite no longer holds a credential of any kind. THIS MIGRATION DESTROYS DATA AND CANNOT BE UNDONE IN ANY MEANINGFUL SENSE. `downgrade()` recreates the column, but every hash in it is gone — and even a restored hash would be useless, because nothing reads the column any more. The downgrade exists so the revision is well-formed and so an operator can step back past it, not because stepping back restores the old login. To actually revert to local passwords you have to revert the application code and reset every password by hand. The column is recreated NULLABLE on downgrade, deliberately. The baseline schema declared it NOT NULL, but there are no values to put back, so a NOT NULL column with no server default would refuse to add itself on any table that has rows. Revision ID: b7e4f1a20c93 Revises: a1b8c6d4e2f9 Create Date: 2026-08-21 """ import sqlalchemy as sa from alembic import op revision = 'b7e4f1a20c93' down_revision = 'a1b8c6d4e2f9' branch_labels = None depends_on = None def upgrade(): # batch_alter_table for SQLite's benefit: it has no DROP COLUMN before 3.35, # so alembic rebuilds the table. Postgres drops it directly. Local dev runs on # SQLite and production on Postgres, so this has to work on both. with op.batch_alter_table('users') as batch: batch.drop_column('password_hash') def downgrade(): with op.batch_alter_table('users') as batch: batch.add_column(sa.Column('password_hash', sa.String(length=200), nullable=True))