@@ -0,0 +1,1238 @@
+%22%22%22Adds missing 'niceToHaveRequirements' to old published Brief data blobs.%0A%0ARevision ID: 990%0ARevises: 980%0ACreate Date: 2017-09-05 17:08:57.947569%0A%0A%22%22%22%0Afrom alembic import op%0Aimport sqlalchemy as sa%0A%0A%0A# revision identifiers, used by Alembic.%0Arevision = '990'%0Adown_revision = '980'%0A%0A%0Abriefs_table = sa.Table(%0A    'briefs',%0A    sa.MetaData(),%0A    sa.Column('id', sa.Integer, primary_key=True),%0A    sa.Column('data', sa.JSON, nullable=True),%0A    sa.Column('published_at', sa.DateTime, nullable=True)%0A)%0A%0A%0Adef upgrade():%0A    conn = op.get_bind()%0A    # SELECT id, data FROM briefs WHERE briefs.published_at IS NOT null%0A    query = briefs_table.select(%0A        briefs_table.c.published_at != sa.null()%0A    ).with_only_columns(%0A        (%0A            briefs_table.c.id,%0A            briefs_table.c.data%0A        )%0A    )%0A    results = conn.execute(query).fetchall()%0A    for brief_id, brief_data in results:%0A        if 'niceToHaveRequirements' not in brief_data:%0A            brief_data%5B'niceToHaveRequirements'%5D = %5B%5D%0A            # UPDATE briefs SET data = brief_data WHERE id = brief_id;%0A            query = briefs_table.update().where(briefs_table.c.id == brief_id).values(data=brief_data)%0A            conn.execute(query)%0A%0A%0Adef downgrade():%0A    pass%0A

Fix old Briefs missing niceToHaveRequirements field