"""remove the namespace column.

Revision ID: 2430f55c41d5
Revises: 17f11e265e13
Create Date: 2014-09-30 17:31:33.308490

"""

# revision identifiers, used by Alembic.
revision = '2fb36d4be80d'
down_revision = '17f11e265e13'

from alembic import op
import sqlalchemy as sa

import re
from app import app


NAMESPACE_EXTRACTOR = re.compile(r'^([a-z]+/)([a-z0-9_]+)(/.*$)')


def upgrade(tables):
    op.create_index('repository_namespace_user_id', 'repository', ['namespace_user_id'], unique=False)
    op.drop_column('repository', 'namespace')


def downgrade(tables):
    op.add_column('repository', sa.Column('namespace', sa.String(length=255)))
    op.drop_index('repository_namespace_user_id', table_name='repository')
