From c3566fceba8edfce4875f85fc1872ae40d72a3cc Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Tue, 10 Mar 2015 17:13:18 +0100 Subject: [PATCH] Livesync: Fix intermediate alembic steps --- .../201410311223_1c2b0e17447d_create_tables.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/livesync/indico_livesync/migrations/201410311223_1c2b0e17447d_create_tables.py b/livesync/indico_livesync/migrations/201410311223_1c2b0e17447d_create_tables.py index ab39115..01b0876 100644 --- a/livesync/indico_livesync/migrations/201410311223_1c2b0e17447d_create_tables.py +++ b/livesync/indico_livesync/migrations/201410311223_1c2b0e17447d_create_tables.py @@ -11,6 +11,7 @@ from sqlalchemy.dialects import postgresql from sqlalchemy.sql.ddl import CreateSchema, DropSchema from indico.core.db.sqlalchemy import UTCDateTime, PyIntEnum +from indico.core.db.sqlalchemy.util.bulk_rename import _rename_constraint from indico_livesync.models.queue import ChangeType @@ -29,11 +30,11 @@ def upgrade(): sa.Column('initial_data_exported', sa.Boolean(), nullable=False), sa.Column('last_run', UTCDateTime(), nullable=False), sa.Column('settings', postgresql.JSON(), nullable=False), - sa.PrimaryKeyConstraint('id'), + sa.PrimaryKeyConstraint('id', name='agents_pkey'), schema='plugin_livesync') op.create_table('queues', sa.Column('id', sa.Integer(), nullable=False), - sa.Column('agent_id', sa.Integer(), nullable=False, index=True), + sa.Column('agent_id', sa.Integer(), nullable=False), sa.Column('timestamp', UTCDateTime(), nullable=False), sa.Column('processed', sa.Boolean(), nullable=False), sa.Column('change', PyIntEnum(ChangeType), nullable=False), @@ -42,9 +43,12 @@ def upgrade(): sa.Column('event_id', sa.String()), sa.Column('contrib_id', sa.String()), sa.Column('subcontrib_id', sa.String()), - sa.ForeignKeyConstraint(['agent_id'], ['plugin_livesync.agents.id']), - sa.PrimaryKeyConstraint('id'), + sa.ForeignKeyConstraint(['agent_id'], ['plugin_livesync.agents.id'], name='queues_agent_id_fkey'), + sa.PrimaryKeyConstraint('id', name='queues_pkey'), + sa.Index('ix_plugin_livesync_queues_agent_id', 'agent_id'), schema='plugin_livesync') + # later migrations expect the old name... + op.execute(_rename_constraint('plugin_livesync', 'queues', 'ck_queues_valid_enum_change', 'queues_change_check')) def downgrade():