Update the migration for translating queue names to take into account previous migrations.

This commit is contained in:
Jake Moshenko 2014-10-07 15:57:17 -04:00
parent a0d94f9d59
commit c77a3dc6ea

View file

@ -1,6 +1,6 @@
"""Translate the queue names to reference namespace by id, remove the namespace column.
Revision ID: 2fb36d4be80d
Revision ID: 2430f55c41d5
Revises: 9a1087b007d
Create Date: 2014-09-30 17:31:33.308490
@ -8,7 +8,7 @@ Create Date: 2014-09-30 17:31:33.308490
# revision identifiers, used by Alembic.
revision = '2fb36d4be80d'
down_revision = '9a1087b007d'
down_revision = '2430f55c41d5'
from alembic import op
import sqlalchemy as sa
@ -35,16 +35,12 @@ def upgrade(tables):
else:
raise RuntimeError('Invalid queue name: %s' % item.queue_name)
op.drop_index('repository_namespace_name', table_name='repository')
op.drop_column('repository', 'namespace')
def downgrade(tables):
# Add the namespace column back in and fill it in
op.add_column('repository', sa.Column('namespace', sa.String(length=255)))
conn = op.get_bind()
conn.execute('update repository set namespace = (select username from user where user.id = repository.namespace_user_id) where namespace is NULL')
op.create_index('repository_namespace_name', 'repository', ['namespace', 'name'], unique=True)
# Rename the namespace component of existing queue items to reference namespace strings
with app.config['DB_TRANSACTION_FACTORY'](db):