Files
notifications-api/migrations/versions/0044_add_template_stats.py
Adam Shimali ca9c886c3e [WIP] On create of notification. Upsert record for template stats
recording usages of template by day.
2016-03-31 15:57:50 +01:00

43 lines
1.7 KiB
Python

"""empty message
Revision ID: 0044_add_template_stats
Revises: 0043_add_view_activity
Create Date: 2016-03-31 12:05:19.630792
"""
# revision identifiers, used by Alembic.
revision = '0044_add_template_stats'
down_revision = '0043_add_view_activity'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('template_statistics',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('template_id', sa.BigInteger(), nullable=False),
sa.Column('usage_count', sa.BigInteger(), nullable=False),
sa.Column('day', sa.Date(), nullable=False),
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_template_statistics_day'), 'template_statistics', ['day'], unique=False)
op.create_index(op.f('ix_template_statistics_service_id'), 'template_statistics', ['service_id'], unique=False)
op.create_index(op.f('ix_template_statistics_template_id'), 'template_statistics', ['template_id'], unique=False)
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_template_statistics_template_id'), table_name='template_statistics')
op.drop_index(op.f('ix_template_statistics_service_id'), table_name='template_statistics')
op.drop_index(op.f('ix_template_statistics_day'), table_name='template_statistics')
op.drop_table('template_statistics')
### end Alembic commands ###