start project
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""Add ip_path_stats_daily and ip_status_stats_daily (bounded per-IP
|
||||
traffic rollup, explicit follow-up to Chapter 10)."""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "0005_ip_traffic_stats"
|
||||
down_revision = "0004_human_path_stats"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
"ip_path_stats_daily",
|
||||
sa.Column("date", sa.Date, primary_key=True),
|
||||
sa.Column("ip", sa.String(45), primary_key=True),
|
||||
sa.Column("path", sa.String(2048), primary_key=True),
|
||||
sa.Column("count", sa.Integer, nullable=False, server_default="0"),
|
||||
)
|
||||
op.create_index("ix_ip_path_stats_ip", "ip_path_stats_daily", ["ip"])
|
||||
|
||||
op.create_table(
|
||||
"ip_status_stats_daily",
|
||||
sa.Column("date", sa.Date, primary_key=True),
|
||||
sa.Column("ip", sa.String(45), primary_key=True),
|
||||
sa.Column("status_bucket", sa.String(8), primary_key=True),
|
||||
sa.Column("count", sa.Integer, nullable=False, server_default="0"),
|
||||
)
|
||||
op.create_index("ix_ip_status_stats_ip", "ip_status_stats_daily", ["ip"])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table("ip_status_stats_daily")
|
||||
op.drop_table("ip_path_stats_daily")
|
||||
Reference in New Issue
Block a user