
- Set up project structure - Configure SQLite database with SQLAlchemy - Create item model and schema - Set up Alembic for database migrations - Implement CRUD operations for items - Add health check endpoint - Add API documentation - Configure Ruff for linting - Update README with project information
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
"""create items table
|
|
|
|
Revision ID: f4b99ba39dc1
|
|
Revises:
|
|
Create Date: 2023-07-01 00:00:00.000000
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "f4b99ba39dc1"
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"item",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("title", sa.String(255), nullable=False, index=True),
|
|
sa.Column("description", sa.Text(), nullable=True),
|
|
sa.Column("is_active", sa.Boolean(), default=True),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
|
),
|
|
sa.Column(
|
|
"updated_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
|
onupdate=sa.text("(CURRENT_TIMESTAMP)"),
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_item_id"), "item", ["id"], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(op.f("ix_item_id"), table_name="item")
|
|
op.drop_table("item") |