"""Migrate draft DOS1 briefs to draft DOS2 briefs

Revision ID: 840
Revises: 830
Create Date: 2017-02-07 15:31:50.715832

"""

# revision identifiers, used by Alembic.
revision = '840'
down_revision = '830'

from alembic import op

def upgrade():
    # Change framework of draft DOS1 briefs from DOS1 (framework_id == 5) to DOS2 (framework_id == 7)
    op.execute("""
        UPDATE briefs
        SET framework_id = 7
        WHERE framework_id = 5 AND published_at IS NULL
    """)


def downgrade():
    # No downgrade
    pass

Create migration for draft dos1 briefs to dos2
Create migration for draft dos1 briefs to dos2

When DOS1 is closed for brief submissions and DOS2 opened, any supplier
who has a draft DOS1 brief will effectively lose it, as they'll be
unable to publish it.

This migration will move all draft DOS1 briefs to be draft DOS2 briefs,
allowing them to be published. Which framework version the brief
goes into doesn't affect buyers - they are eligible by default.

This will need to be run immediately after DOS1 is closed so that no
buyer attempt to publish their DOS1 brief in the period between DOS1
closing and the migration happening.
