"""add metadata field to external logins

Revision ID: 1594a74a74ca
Revises: f42b0ea7a4d
Create Date: 2014-09-04 18:17:35.205698

"""

# revision identifiers, used by Alembic.
revision = '1594a74a74ca'
down_revision = 'f42b0ea7a4d'

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

def upgrade(tables):
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('federatedlogin', sa.Column('metadata_json', sa.Text(), nullable=False))
    ### end Alembic commands ###

    op.bulk_insert(tables.loginservice,
    [
        {'id':4, 'name':'google'},
    ])

def downgrade(tables):
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('federatedlogin', 'metadata_json')
    ### end Alembic commands ###

    op.execute(
        (tables.loginservice.delete()
            .where(tables.loginservice.c.name == op.inline_literal('google')))
    )
