From c77a3dc6eae0dd485de7b3cc34008679fe3cb85a Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Tue, 7 Oct 2014 15:57:17 -0400 Subject: [PATCH] Update the migration for translating queue names to take into account previous migrations. --- ...fb36d4be80d_translate_the_queue_names_to_reference_.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/data/migrations/versions/2fb36d4be80d_translate_the_queue_names_to_reference_.py b/data/migrations/versions/2fb36d4be80d_translate_the_queue_names_to_reference_.py index 53b43a4ec..bdeb3345f 100644 --- a/data/migrations/versions/2fb36d4be80d_translate_the_queue_names_to_reference_.py +++ b/data/migrations/versions/2fb36d4be80d_translate_the_queue_names_to_reference_.py @@ -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):