"""Add gid attribute to modules

Revision ID: 4d88e470c876
Revises: 252cee80e23e
Create Date: 2014-04-29 10:20:39.616113

"""

# revision identifiers, used by Alembic.
revision = '4d88e470c876'
down_revision = '252cee80e23e'

from alembic import op
import sqlalchemy as sa


INSERTS = """
UPDATE modules set gid=2 where name = 'news';
"""
DELETES = """"""


def iter_statements(stmts):
    for st in [x for x in stmts.split('\n') if x]:
        op.execute(st)


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('modules', sa.Column('gid', sa.Integer(), nullable=True))
    ### end Alembic commands ###
    iter_statements(INSERTS)


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('modules', 'gid')
    ### end Alembic commands ###
    iter_statements(DELETES)
