mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
[WIP] On create of notification. Upsert record for template stats
recording usages of template by day.
This commit is contained in:
42
migrations/versions/0044_add_template_stats.py
Normal file
42
migrations/versions/0044_add_template_stats.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""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 ###
|
||||
Reference in New Issue
Block a user