- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.) - Added ignore rules for patterns intentional in this codebase: E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from), SIM108/SIM105/SIM117 (readability preferences) - Added per-file ignores for tests and scripts - Excluded broken scripts/rename_terminology.py (has curly quotes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
"""cart initial - cart items
|
|
|
|
Revision ID: cart_001
|
|
Revises: inventory_001
|
|
Create Date: 2026-02-07
|
|
"""
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
revision = "cart_001"
|
|
down_revision = "inventory_001"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# --- cart_items ---
|
|
op.create_table(
|
|
"cart_items",
|
|
sa.Column("id", sa.Integer(), primary_key=True, index=True),
|
|
sa.Column("store_id", sa.Integer(), sa.ForeignKey("stores.id"), nullable=False),
|
|
sa.Column("product_id", sa.Integer(), sa.ForeignKey("products.id"), nullable=False),
|
|
sa.Column("session_id", sa.String(255), nullable=False, index=True),
|
|
sa.Column("quantity", sa.Integer(), nullable=False, server_default="1"),
|
|
sa.Column("price_at_add_cents", sa.Integer(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(), server_default=sa.func.now(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(), server_default=sa.func.now(), nullable=False),
|
|
sa.UniqueConstraint("store_id", "session_id", "product_id", name="uq_cart_item"),
|
|
)
|
|
op.create_index("idx_cart_session", "cart_items", ["store_id", "session_id"])
|
|
op.create_index("idx_cart_created", "cart_items", ["created_at"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("cart_items")
|