49 lines
2.1 KiB
Python
49 lines
2.1 KiB
Python
"""add analytics events
|
|
|
|
Revision ID: 4f2e3f915e09
|
|
Revises: 5881f111a194
|
|
Create Date: 2026-03-29 23:22:22.884950
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '4f2e3f915e09'
|
|
down_revision: Union[str, None] = '5881f111a194'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('analytics_events',
|
|
sa.Column('event_type', sa.String(length=64), nullable=False),
|
|
sa.Column('page', sa.String(length=255), nullable=False),
|
|
sa.Column('element', sa.String(length=255), nullable=True),
|
|
sa.Column('metadata', sa.JSON(), nullable=True),
|
|
sa.Column('session_id', sa.String(length=64), nullable=False),
|
|
sa.Column('ip_hash', sa.String(length=64), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.Column('id', sa.Uuid(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_analytics_events_created_at'), 'analytics_events', ['created_at'], unique=False)
|
|
op.create_index(op.f('ix_analytics_events_event_type'), 'analytics_events', ['event_type'], unique=False)
|
|
op.create_index(op.f('ix_analytics_events_page'), 'analytics_events', ['page'], unique=False)
|
|
op.create_index(op.f('ix_analytics_events_session_id'), 'analytics_events', ['session_id'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_analytics_events_session_id'), table_name='analytics_events')
|
|
op.drop_index(op.f('ix_analytics_events_page'), table_name='analytics_events')
|
|
op.drop_index(op.f('ix_analytics_events_event_type'), table_name='analytics_events')
|
|
op.drop_index(op.f('ix_analytics_events_created_at'), table_name='analytics_events')
|
|
op.drop_table('analytics_events')
|
|
# ### end Alembic commands ###
|