Files
orion/alembic/versions_backup/l0a1b2c3d4e5_add_capacity_snapshots_table.py
Samir Boulahtit 68493dc6cb feat(subscriptions): migrate subscription management to merchant level and seed tiers
Move subscription create/edit from store detail (broken endpoint) to merchant
detail page with proper modal UI. Seed 4 subscription tiers (Essential,
Professional, Business, Enterprise) in init_production.py. Also includes
cross-module dependency declarations, store domain platform_id migration,
platform context middleware, CMS route fixes, and migration backups.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:04:04 +01:00

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.
"""
from alembic import op
import sqlalchemy as sa
# 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")