Files
notifications-api/migrations/versions/0418_user_state_enum.py

43 lines
886 B
Python
Raw Normal View History

2025-08-28 11:12:49 -07:00
"""
Revision ID: 0418_user_state_enum
Revises: 0417_change_total_message_limit
Create Date: 2025-08-28 12:34:32.857422
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
2025-08-28 12:27:45 -07:00
2025-08-28 11:39:08 -07:00
revision = "0418_user_state_enum"
down_revision = "0417_change_total_message_limit"
2025-08-28 11:12:49 -07:00
user_state_enum = postgresql.ENUM(
"active", "pending", "inactive", name="user_states", create_type=False
)
def upgrade():
2025-08-28 12:27:45 -07:00
user_state_enum.create(op.get_bind(), checkfirst=True)
op.alter_column(
"users",
"state",
existing_type=sa.String(),
type_=user_state_enum,
existing_nullable=False,
)
2025-08-28 11:12:49 -07:00
def downgrade():
2025-08-28 12:27:45 -07:00
op.alter_column(
"users",
"state",
existing_type=user_state_enum,
type_=sa.String,
existing_nullable=False,
)
user_state_enum.drop(op.get_bind(), checkfirst=True)