add content to broadcast_message and make template fields nullable

we want to be able to create broadcast messages without templates. To
start with, these will come from the API, but in future we may want to
let people create via the admin interface without creating a template
too.

populate a non-nullable content field with the values supplied via the
template (or supplied directly if via api).
This commit is contained in:
Leo Hemsted
2021-01-08 16:38:51 +00:00
parent 88a6b7729e
commit 2e929754ff
6 changed files with 188 additions and 24 deletions

View File

@@ -0,0 +1,27 @@
"""
Revision ID: 0335_broadcast_msg_content
Revises: 0334_broadcast_message_number
Create Date: 2020-12-04 15:06:22.544803
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '0335_broadcast_msg_content'
down_revision = '0334_broadcast_message_number'
def upgrade():
op.add_column('broadcast_message', sa.Column('content', sa.Text(), nullable=False))
op.alter_column('broadcast_message', 'template_id', nullable=True)
op.alter_column('broadcast_message', 'template_version', nullable=True)
def downgrade():
# downgrade fails if there are broadcasts without a template. This is deliberate cos I don't feel comfortable
# deleting broadcasts.
op.alter_column('broadcast_message', 'template_id', nullable=False)
op.alter_column('broadcast_message', 'template_version', nullable=False)
op.drop_column('broadcast_message', 'content')