Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add total message limit default to existing services #476

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions migrations/versions/0402_total_message_limit_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""

Revision ID: 0402_total_message_limit_default
Revises: 0401_add_e2e_test_user
Create Date: 2023-09-18 10:04:58.957374

"""
from alembic import op
from flask import current_app
import sqlalchemy as sa


revision = '0402_total_message_limit_default'
down_revision = '0401_add_e2e_test_user'


def upgrade():
# Set a default value for the total_message_limit column in the
# services table to match the current TOTAL_MESSAGE_LIMIT app
# config.
op.execute(
"UPDATE services SET total_message_limit = {total_message_limit} WHERE total_message_limit IS NULL".format(
total_message_limit=current_app.config["TOTAL_MESSAGE_LIMIT"]
)
)


def downgrade():
# There is no downgrade from this migration as it would cause a bug
# in the app; if it needs to be removed, then you have to remove the
# column added in migration 0400.
pass