- 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>
66 lines
2.9 KiB
Python
66 lines
2.9 KiB
Python
"""Add capacity_snapshots table
|
|
|
|
Revision ID: l0a1b2c3d4e5
|
|
Revises: k9f0a1b2c3d4
|
|
Create Date: 2025-12-26
|
|
|
|
Adds table for tracking daily platform capacity metrics for growth forecasting.
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "l0a1b2c3d4e5"
|
|
down_revision = "k9f0a1b2c3d4"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"capacity_snapshots",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("snapshot_date", sa.DateTime(timezone=True), nullable=False),
|
|
# Vendor metrics
|
|
sa.Column("total_vendors", sa.Integer(), nullable=False, server_default="0"),
|
|
sa.Column("active_vendors", sa.Integer(), nullable=False, server_default="0"),
|
|
sa.Column("trial_vendors", sa.Integer(), nullable=False, server_default="0"),
|
|
# Subscription metrics
|
|
sa.Column("total_subscriptions", sa.Integer(), nullable=False, server_default="0"),
|
|
sa.Column("active_subscriptions", sa.Integer(), nullable=False, server_default="0"),
|
|
# Resource metrics
|
|
sa.Column("total_products", sa.Integer(), nullable=False, server_default="0"),
|
|
sa.Column("total_orders_month", sa.Integer(), nullable=False, server_default="0"),
|
|
sa.Column("total_team_members", sa.Integer(), nullable=False, server_default="0"),
|
|
# Storage metrics
|
|
sa.Column("storage_used_gb", sa.Numeric(10, 2), nullable=False, server_default="0"),
|
|
sa.Column("db_size_mb", sa.Numeric(10, 2), nullable=False, server_default="0"),
|
|
# Capacity metrics
|
|
sa.Column("theoretical_products_limit", sa.Integer(), nullable=True),
|
|
sa.Column("theoretical_orders_limit", sa.Integer(), nullable=True),
|
|
sa.Column("theoretical_team_limit", sa.Integer(), nullable=True),
|
|
# Tier distribution
|
|
sa.Column("tier_distribution", sa.JSON(), nullable=True),
|
|
# Performance metrics
|
|
sa.Column("avg_response_ms", sa.Integer(), nullable=True),
|
|
sa.Column("peak_cpu_percent", sa.Numeric(5, 2), nullable=True),
|
|
sa.Column("peak_memory_percent", sa.Numeric(5, 2), nullable=True),
|
|
# Timestamps
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
# Primary key
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
|
|
# Create indexes
|
|
op.create_index("ix_capacity_snapshots_id", "capacity_snapshots", ["id"], unique=False)
|
|
op.create_index("ix_capacity_snapshots_date", "capacity_snapshots", ["snapshot_date"], unique=True)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_capacity_snapshots_date", table_name="capacity_snapshots")
|
|
op.drop_index("ix_capacity_snapshots_id", table_name="capacity_snapshots")
|
|
op.drop_table("capacity_snapshots")
|