old_contents: from alembic import op
  import sqlalchemy as sa
  
  
  """add due field to questionnaire_banks
  
  Revision ID: 50c447197b26
  Revises: 9ebdfeb28bef
  Create Date: 2017-10-13 09:41:49.941838
  
  """
  
  # revision identifiers, used by Alembic.
  revision = '50c447197b26'
  down_revision = '9ebdfeb28bef'
  
  
  def upgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.add_column('questionnaire_banks', sa.Column('due', sa.Text(), nullable=True))
      # ### end Alembic commands ###
  
  
  def downgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.drop_column('questionnaire_banks', 'due')
      # ### end Alembic commands ###
  
new_contents: from alembic import op
  import sqlalchemy as sa
  from sqlalchemy.orm import sessionmaker
  
  
  """add due field to questionnaire_banks
  
  Revision ID: 50c447197b26
  Revises: 9ebdfeb28bef
  Create Date: 2017-10-13 09:41:49.941838
  
  """
  
  # revision identifiers, used by Alembic.
  revision = '50c447197b26'
  down_revision = '9ebdfeb28bef'
  
  Session = sessionmaker()
  
  
  def upgrade():
      op.add_column('questionnaire_banks', sa.Column('due', sa.Text(), nullable=True))
  
      bind = op.get_bind()
      session = Session(bind=bind)
  
      to_update = ('IRONMAN_recurring_3mo_pattern',
                   'IRONMAN_recurring_6mo_pattern',
                  'IRONMAN_recurring_annual_pattern')
  
      new_due = "{\"days\": 14}"
  
      session.execute("UPDATE questionnaire_banks SET due = '{}' "
                      "WHERE name IN {}".format(new_due, to_update))
  
  
  def downgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.drop_column('questionnaire_banks', 'due')
      # ### end Alembic commands ###
  
subject: update migration to modify specific QB dues as needed