39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""outbound click analytics table
|
|
|
|
Revision ID: 20260404_0002
|
|
Revises: 20260404_0001
|
|
Create Date: 2026-04-04
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "20260404_0002"
|
|
down_revision: Union[str, None] = "20260404_0001"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"outbound_clicks",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("link_kind", sa.String(length=64), nullable=False),
|
|
sa.Column("destination_url", sa.String(length=512), nullable=False),
|
|
sa.Column("edition_id", sa.Integer(), nullable=True),
|
|
sa.Column("referrer", sa.String(length=512), nullable=True),
|
|
sa.Column("user_agent", sa.String(length=512), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
|
sa.ForeignKeyConstraint(["edition_id"], ["event_editions.id"], ondelete="SET NULL"),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index("ix_outbound_clicks_link_kind", "outbound_clicks", ["link_kind"])
|
|
op.create_index("ix_outbound_clicks_edition_id", "outbound_clicks", ["edition_id"])
|
|
op.create_index("ix_outbound_clicks_created_at", "outbound_clicks", ["created_at"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("outbound_clicks")
|