Files
notifications-api/migrations/versions/0005_add_provider_stats.py

45 lines
1.2 KiB
Python
Raw Normal View History

"""empty message
Revision ID: 0005_add_provider_stats
Revises: 0003_add_service_history
Create Date: 2016-04-20 15:13:42.229197
"""
# revision identifiers, used by Alembic.
2023-08-29 14:54:30 -07:00
revision = "0005_add_provider_stats"
down_revision = "0004_notification_stats_date"
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
2023-07-19 11:46:40 -07:00
2023-08-29 14:54:30 -07:00
def upgrade():
op.create_table(
"provider_statistics",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("day", sa.Date(), nullable=False),
sa.Column("provider", sa.Enum("ses", "sns", name="providers"), nullable=False),
sa.Column("service_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("unit_count", sa.BigInteger(), nullable=False),
sa.ForeignKeyConstraint(
["service_id"],
["services.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_provider_statistics_service_id"),
"provider_statistics",
["service_id"],
unique=False,
)
def downgrade():
2023-08-29 14:54:30 -07:00
op.drop_index(
op.f("ix_provider_statistics_service_id"), table_name="provider_statistics"
)
op.drop_table("provider_statistics")