simplefastapiapplication-ia.../migrations/versions/47e3b63e1a20_create_items_table.py
Automated Action 852e0a32b1 Create simple FastAPI application with SQLite and Alembic
- Set up project structure
- Create FastAPI app with health endpoint
- Implement SQLAlchemy with SQLite database
- Set up Alembic for database migrations
- Create CRUD operations for items
- Add comprehensive documentation
2025-05-20 14:20:21 +00:00

45 lines
1.2 KiB
Python

"""create items table
Revision ID: 47e3b63e1a20
Revises:
Create Date: 2023-10-12 10:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "47e3b63e1a20"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
"items",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("name", sa.String(), nullable=True),
sa.Column("description", sa.String(), nullable=True),
sa.Column("price", sa.Integer(), nullable=True),
sa.Column("is_active", sa.Boolean(), nullable=True, default=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_items_id"), "items", ["id"], unique=False)
op.create_index(op.f("ix_items_name"), "items", ["name"], unique=False)
def downgrade():
op.drop_index(op.f("ix_items_name"), table_name="items")
op.drop_index(op.f("ix_items_id"), table_name="items")
op.drop_table("items")