
- Setup project structure with FastAPI - Create user models with SQLAlchemy - Implement JWT authentication - Create auth endpoints (register, login, me) - Add health endpoint - Generate Alembic migrations - Update documentation Generated with BackendIM... (backend.im)
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""initial migration
|
|
|
|
Revision ID: 20250512
|
|
Revises:
|
|
Create Date: 2025-05-12
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '20250512'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Create users table
|
|
op.create_table(
|
|
'users',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('email', sa.String(), nullable=False),
|
|
sa.Column('username', sa.String(), nullable=False),
|
|
sa.Column('hashed_password', sa.String(), nullable=False),
|
|
sa.Column('first_name', sa.String(), nullable=True),
|
|
sa.Column('last_name', sa.String(), nullable=True),
|
|
sa.Column('is_active', sa.Boolean(), default=True),
|
|
sa.Column('is_superuser', sa.Boolean(), default=False),
|
|
sa.Column('created_at', sa.DateTime(), default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), default=sa.func.now(), onupdate=sa.func.now()),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
|
|
op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
|
|
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_users_username'), table_name='users')
|
|
op.drop_index(op.f('ix_users_id'), table_name='users')
|
|
op.drop_index(op.f('ix_users_email'), table_name='users')
|
|
op.drop_table('users') |