mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Merge pull request #2306 from alphagov/drop-stats_template_usage_by_month
Drop stats_template_usage_by_month table as it is no longer needed.
This commit is contained in:
@@ -1834,48 +1834,6 @@ class AuthType(db.Model):
|
||||
name = db.Column(db.String, primary_key=True)
|
||||
|
||||
|
||||
class StatsTemplateUsageByMonth(db.Model):
|
||||
__tablename__ = "stats_template_usage_by_month"
|
||||
|
||||
template_id = db.Column(
|
||||
UUID(as_uuid=True),
|
||||
db.ForeignKey('templates.id'),
|
||||
unique=False,
|
||||
index=True,
|
||||
nullable=False,
|
||||
primary_key=True
|
||||
)
|
||||
month = db.Column(
|
||||
db.Integer,
|
||||
nullable=False,
|
||||
index=True,
|
||||
unique=False,
|
||||
primary_key=True,
|
||||
default=datetime.datetime.month
|
||||
)
|
||||
year = db.Column(
|
||||
db.Integer,
|
||||
nullable=False,
|
||||
index=True,
|
||||
unique=False,
|
||||
primary_key=True,
|
||||
default=datetime.datetime.year
|
||||
)
|
||||
count = db.Column(
|
||||
db.Integer,
|
||||
nullable=False,
|
||||
default=0
|
||||
)
|
||||
|
||||
def serialize(self):
|
||||
return {
|
||||
'template_id': str(self.template_id),
|
||||
'month': self.month,
|
||||
'year': self.year,
|
||||
'count': self.count
|
||||
}
|
||||
|
||||
|
||||
class DailySortedLetter(db.Model):
|
||||
__tablename__ = "daily_sorted_letter"
|
||||
|
||||
|
||||
36
migrations/versions/0250_drop_stats_template_table.py
Normal file
36
migrations/versions/0250_drop_stats_template_table.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0250_drop_stats_template_table
|
||||
Revises: 0249_another_letter_org
|
||||
Create Date: 2019-01-15 16:47:08.049369
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0250_drop_stats_template_table'
|
||||
down_revision = '0249_another_letter_org'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_index('ix_stats_template_usage_by_month_month', table_name='stats_template_usage_by_month')
|
||||
op.drop_index('ix_stats_template_usage_by_month_template_id', table_name='stats_template_usage_by_month')
|
||||
op.drop_index('ix_stats_template_usage_by_month_year', table_name='stats_template_usage_by_month')
|
||||
op.drop_table('stats_template_usage_by_month')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.create_table('stats_template_usage_by_month',
|
||||
sa.Column('template_id', postgresql.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('count', sa.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'],
|
||||
name='stats_template_usage_by_month_template_id_fkey'),
|
||||
sa.PrimaryKeyConstraint('template_id', 'month', 'year', name='stats_template_usage_by_month_pkey')
|
||||
)
|
||||
op.create_index('ix_stats_template_usage_by_month_year', 'stats_template_usage_by_month', ['year'], unique=False)
|
||||
op.create_index('ix_stats_template_usage_by_month_template_id', 'stats_template_usage_by_month', ['template_id'],
|
||||
unique=False)
|
||||
op.create_index('ix_stats_template_usage_by_month_month', 'stats_template_usage_by_month', ['month'], unique=False)
|
||||
Reference in New Issue
Block a user