From 0f3dac324424dd6fd9bd66e81bf377ed57d8c1cc Mon Sep 17 00:00:00 2001 From: Randy Barlow Date: Wed, 20 Feb 2019 15:19:16 -0500 Subject: [PATCH] Add an index on builds.update_id. Signed-off-by: Randy Barlow --- ...7ab3a_index_the_builds_update_id_column.py | 40 +++++++++++++++++++ bodhi/server/models.py | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 bodhi/server/migrations/versions/eec610d7ab3a_index_the_builds_update_id_column.py diff --git a/bodhi/server/migrations/versions/eec610d7ab3a_index_the_builds_update_id_column.py b/bodhi/server/migrations/versions/eec610d7ab3a_index_the_builds_update_id_column.py new file mode 100644 index 0000000000..b607d6ce1e --- /dev/null +++ b/bodhi/server/migrations/versions/eec610d7ab3a_index_the_builds_update_id_column.py @@ -0,0 +1,40 @@ +# Copyright (c) 2019 Red Hat, Inc. +# +# This file is part of Bodhi. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +""" +Index the builds.update_id column. + +Revision ID: eec610d7ab3a +Revises: aae0d29d49b7 +Create Date: 2019-02-20 20:18:02.474734 +""" +from alembic import op + + +# revision identifiers, used by Alembic. +revision = 'eec610d7ab3a' +down_revision = 'aae0d29d49b7' + + +def upgrade(): + """Add an index on builds.update_id.""" + op.create_index(op.f('ix_builds_update_id'), 'builds', ['update_id'], unique=False) + + +def downgrade(): + """Drop the index on builds.update_id.""" + op.drop_index(op.f('ix_builds_update_id'), table_name='builds') diff --git a/bodhi/server/models.py b/bodhi/server/models.py index 040dd2394a..860cd70ca1 100644 --- a/bodhi/server/models.py +++ b/bodhi/server/models.py @@ -1255,7 +1255,7 @@ class Build(Base): package_id = Column(Integer, ForeignKey('packages.id'), nullable=False) release_id = Column(Integer, ForeignKey('releases.id')) signed = Column(Boolean, default=False, nullable=False) - update_id = Column(Integer, ForeignKey('updates.id')) + update_id = Column(Integer, ForeignKey('updates.id'), index=True) release = relationship('Release', backref='builds', lazy=False)