"""DOS is coming

Revision ID: 420
Revises: 410_remove_empty_drafts
Create Date: 2015-11-16 14:10:35.814066

"""

# revision identifiers, used by Alembic.
revision = '420'
down_revision = '410_remove_empty_drafts'

from alembic import op
import sqlalchemy as sa
from app.models import Framework


def upgrade():
    op.execute("COMMIT")
    op.execute("ALTER TYPE framework_enum ADD VALUE IF NOT EXISTS 'dos' after 'gcloud'")

    framework = Framework.query.filter(Framework.slug == 'digital-outcomes-and-specialists').first()

    if not framework:
        op.execute("""
            INSERT INTO frameworks (name, framework, status, slug)
                values('Digital Outcomes and Specialists', 'dos', 'coming', 'digital-outcomes-and-specialists')
        """)


def downgrade():
    op.execute("""
        DELETE FROM frameworks where slug='digital-outcomes-and-specialists'
    """)

@@ -235,65 +235,8 @@
  op%0A
-import sqlalchemy as sa%0Afrom app.models import Framework%0A
 %0A%0Ade
@@ -371,60 +371,90 @@
     
-framework = Framework.query.filter(Framework.
+conn = op.get_bind()%0A    res = conn.execute(%22SELECT * FROM frameworks WHERE 
 slug =
-=
  'di
@@ -488,15 +488,37 @@
 sts'
-).first
+%22)%0A    results = res.fetchall
 ()%0A%0A
@@ -528,25 +528,23 @@
  if not 
-framework
+results
 :%0A      

Use `op` instead of `app` so that `list_migrations` still works