Update the migration for translating queue names to take into account previous migrations.
This commit is contained in:
parent
a0d94f9d59
commit
c77a3dc6ea
1 changed files with 2 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
||||||
"""Translate the queue names to reference namespace by id, remove the namespace column.
|
"""Translate the queue names to reference namespace by id, remove the namespace column.
|
||||||
|
|
||||||
Revision ID: 2fb36d4be80d
|
Revision ID: 2430f55c41d5
|
||||||
Revises: 9a1087b007d
|
Revises: 9a1087b007d
|
||||||
Create Date: 2014-09-30 17:31:33.308490
|
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 identifiers, used by Alembic.
|
||||||
revision = '2fb36d4be80d'
|
revision = '2fb36d4be80d'
|
||||||
down_revision = '9a1087b007d'
|
down_revision = '2430f55c41d5'
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
@ -35,16 +35,12 @@ def upgrade(tables):
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Invalid queue name: %s' % item.queue_name)
|
raise RuntimeError('Invalid queue name: %s' % item.queue_name)
|
||||||
|
|
||||||
op.drop_index('repository_namespace_name', table_name='repository')
|
|
||||||
op.drop_column('repository', 'namespace')
|
op.drop_column('repository', 'namespace')
|
||||||
|
|
||||||
|
|
||||||
def downgrade(tables):
|
def downgrade(tables):
|
||||||
# Add the namespace column back in and fill it in
|
# Add the namespace column back in and fill it in
|
||||||
op.add_column('repository', sa.Column('namespace', sa.String(length=255)))
|
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
|
# Rename the namespace component of existing queue items to reference namespace strings
|
||||||
with app.config['DB_TRANSACTION_FACTORY'](db):
|
with app.config['DB_TRANSACTION_FACTORY'](db):
|
||||||
|
|
Reference in a new issue