"""extend size of eas_folder_id and eas_parent_id

Revision ID: 211e93aff1e1
Revises: 2493281d621
Create Date: 2015-03-20 18:50:29.961734

"""

# revision identifiers, used by Alembic.
revision = '69e93aef3e9'
down_revision = '691fa97024d'

from alembic import op
from sqlalchemy.sql import text
from sqlalchemy.ext.declarative import declarative_base


def upgrade():
    conn = op.get_bind()
    conn.execute(text("set @@lock_wait_timeout = 20;"))

    from inbox.ignition import main_engine
    engine = main_engine(pool_size=1, max_overflow=0)
    Base = declarative_base()
    Base.metadata.reflect(engine)

    if 'easfoldersyncstatus' in Base.metadata.tables:
        conn.execute(text("ALTER TABLE easfoldersyncstatus MODIFY eas_folder_id VARCHAR(191),"
                          "                                MODIFY eas_parent_id VARCHAR(191)"))


def downgrade():
    conn = op.get_bind()
    conn.execute(text("set @@lock_wait_timeout = 20;"))

    from inbox.ignition import main_engine
    engine = main_engine(pool_size=1, max_overflow=0)
    Base = declarative_base()
    Base.metadata.reflect(engine)

    if 'easfoldersyncstatus' in Base.metadata.tables:
        conn.execute(text("ALTER TABLE easfoldersyncstatus MODIFY eas_folder_id VARCHAR(64),"
                          "                                MODIFY eas_parent_id VARCHAR(64)"))

Fix EAS folder id length
Fix EAS folder id length

Summary:
Fixes T2458. Note that because we're using MySQL 5.6, the migration happens offline and locks the table. However, since we only have about 20k columns, it shouldn't take too long.

Test Plan: Upgraded a db dump.

Reviewers: kav-ya, emfree

Reviewed By: emfree

Subscribers: spang

Maniphest Tasks: T2458

Differential Revision: https://phab.nylas.com/D1827
