
- Set up FastAPI application with CORS support - Implement SQLite database with SQLAlchemy ORM - Create User model with CRUD operations - Add Alembic for database migrations - Include health check and documentation endpoints - Set up proper project structure with organized modules - Add comprehensive README with setup instructions - Configure Ruff for code linting and formatting
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""Initial migration
|
|
|
|
Revision ID: 001
|
|
Revises:
|
|
Create Date: 2024-01-01 00:00:00.000000
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "001"
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Create users table
|
|
op.create_table(
|
|
"users",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("email", sa.String(), nullable=False),
|
|
sa.Column("name", sa.String(), nullable=False),
|
|
sa.Column("is_active", sa.Boolean(), nullable=True),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
|
nullable=True,
|
|
),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True),
|
|
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)
|
|
|
|
|
|
def downgrade() -> None:
|
|
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")
|