fix: add migration for missing users.email, last_login_at, login_count columns
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
"""add email last_login_at login_count to users
|
||||||
|
|
||||||
|
Revision ID: eee1d35c9b88
|
||||||
|
Revises: 005
|
||||||
|
Create Date: 2026-05-14 16:53:20.614892
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
revision: str = 'eee1d35c9b88'
|
||||||
|
down_revision: Union[str, None] = '005'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('system_configs',
|
||||||
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column('key', sa.String(length=100), nullable=False),
|
||||||
|
sa.Column('value', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
|
||||||
|
sa.Column('description', sa.Text(), nullable=True),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(op.f('ix_system_configs_key'), 'system_configs', ['key'], unique=True)
|
||||||
|
op.drop_index('ix_preference_analyses_user_id', table_name='preference_analyses')
|
||||||
|
op.create_index(op.f('ix_preference_analyses_user_id'), 'preference_analyses', ['user_id'], unique=True)
|
||||||
|
op.add_column('users', sa.Column('email', sa.String(length=255), nullable=True))
|
||||||
|
op.add_column('users', sa.Column('last_login_at', sa.DateTime(), nullable=True))
|
||||||
|
op.add_column('users', sa.Column('login_count', sa.Integer(), nullable=True))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('users', 'login_count')
|
||||||
|
op.drop_column('users', 'last_login_at')
|
||||||
|
op.drop_column('users', 'email')
|
||||||
|
op.drop_index(op.f('ix_preference_analyses_user_id'), table_name='preference_analyses')
|
||||||
|
op.create_index('ix_preference_analyses_user_id', 'preference_analyses', ['user_id'], unique=False)
|
||||||
|
op.drop_index(op.f('ix_system_configs_key'), table_name='system_configs')
|
||||||
|
op.drop_table('system_configs')
|
||||||
|
# ### end Alembic commands ###
|
||||||
Reference in New Issue
Block a user