fix: make users.phone nullable to allow admin creation without phone
Phone is optional — admin users created via script don't have one. Added migration 0010 to alter the column, updated create_admin.py to pass None instead of empty string. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
17
web/migrations/versions/0010_users_phone_nullable.py
Normal file
17
web/migrations/versions/0010_users_phone_nullable.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
"""Make users.phone nullable."""
|
||||||
|
revision = "0010"
|
||||||
|
down_revision = "0009"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.alter_column("users", "phone", existing_type=sa.String(20), nullable=True)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.execute("UPDATE users SET phone = '' WHERE phone IS NULL")
|
||||||
|
op.alter_column("users", "phone", existing_type=sa.String(20), nullable=False)
|
||||||
@@ -24,7 +24,7 @@ class User(Base):
|
|||||||
first_name = Column(String(100), nullable=False)
|
first_name = Column(String(100), nullable=False)
|
||||||
last_name = Column(String(100), nullable=False)
|
last_name = Column(String(100), nullable=False)
|
||||||
email = Column(String(255), nullable=False)
|
email = Column(String(255), nullable=False)
|
||||||
phone = Column(String(20), nullable=False)
|
phone = Column(String(20), nullable=True)
|
||||||
password_hash = Column(String(255), nullable=True)
|
password_hash = Column(String(255), nullable=True)
|
||||||
is_email_confirmed = Column(Boolean, nullable=False, default=False)
|
is_email_confirmed = Column(Boolean, nullable=False, default=False)
|
||||||
email_confirm_token = Column(String(255), nullable=True)
|
email_confirm_token = Column(String(255), nullable=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user