simpletodoapi-4qyz36/migrations/versions/20231031_010000_create_todos_table.py
Automated Action bf1393d643 Create Simple Todo API with FastAPI and SQLite
- Set up FastAPI project structure
- Configure SQLAlchemy with SQLite
- Create Todo model and schemas
- Implement CRUD operations
- Add API endpoints for Todo management
- Configure Alembic for database migrations
- Add health check endpoint
- Add comprehensive documentation
2025-05-17 20:16:30 +00:00

51 lines
1.3 KiB
Python

"""create todos table
Revision ID: 20231031_010000
Revises:
Create Date: 2023-10-31 01:00:00
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "20231031_010000"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"todos",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("title", sa.String(), nullable=False),
sa.Column("description", sa.String(), nullable=True),
sa.Column(
"completed", sa.Boolean(), server_default=sa.text("0"), nullable=False
),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("(CURRENT_TIMESTAMP)"),
nullable=True,
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
server_default=sa.text("(CURRENT_TIMESTAMP)"),
nullable=True,
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f("ix_todos_id"), "todos", ["id"], unique=False)
def downgrade() -> None:
op.drop_index(op.f("ix_todos_id"), table_name="todos")
op.drop_table("todos")