mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-25 12:01:38 -05:00
Make stubbed column on broadcast_message non-nullable
But first set any null values there to False.
This commit is contained in:
@@ -2281,7 +2281,7 @@ class BroadcastMessage(db.Model):
|
||||
|
||||
reference = db.Column(db.String(255), nullable=True)
|
||||
|
||||
stubbed = db.Column(db.Boolean, nullable=True)
|
||||
stubbed = db.Column(db.Boolean, nullable=False)
|
||||
|
||||
CheckConstraint("created_by_id is not null or api_key_id is not null")
|
||||
|
||||
|
||||
36
migrations/versions/0344_stubbed_not_nullable.py
Normal file
36
migrations/versions/0344_stubbed_not_nullable.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0344_stubbed_not_nullable
|
||||
Revises: 0343_org_billing_details
|
||||
Create Date: 2021-02-08 18:10:15.533279
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0344_stubbed_not_nullable'
|
||||
down_revision = '0343_org_billing_details'
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute("UPDATE broadcast_message SET stubbed = False WHERE stubbed is null")
|
||||
op.alter_column(
|
||||
'broadcast_message',
|
||||
'stubbed',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
nullable=False
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column(
|
||||
'broadcast_message',
|
||||
'stubbed',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
nullable=True
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user