diff --git a/ironic/db/sqlalchemy/alembic/versions/4c8356c965f1_index_on_ports_node_id.py b/ironic/db/sqlalchemy/alembic/versions/4c8356c965f1_index_on_ports_node_id.py new file mode 100644 index 0000000000..adf8637253 --- /dev/null +++ b/ironic/db/sqlalchemy/alembic/versions/4c8356c965f1_index_on_ports_node_id.py @@ -0,0 +1,27 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +"""Add index on ports.node_id + +Revision ID: 4c8356c965f1 +Revises: 1c14278d6e33 +Create Date: 2025-04-29 13:26:23.089464 + +""" +from alembic import op + +# revision identifiers, used by Alembic. +revision = '4c8356c965f1' +down_revision = '1c14278d6e33' + + +def upgrade(): + op.create_index('ports_node_id_idx', 'ports', ['node_id']) diff --git a/ironic/db/sqlalchemy/models.py b/ironic/db/sqlalchemy/models.py index e5ecc8fc58..49404e4a7b 100644 --- a/ironic/db/sqlalchemy/models.py +++ b/ironic/db/sqlalchemy/models.py @@ -256,6 +256,7 @@ class Port(Base): schema.UniqueConstraint('address', name='uniq_ports0address'), schema.UniqueConstraint('uuid', name='uniq_ports0uuid'), schema.UniqueConstraint('name', name='uniq_ports0name'), + Index('ports_node_id_idx', 'node_id'), table_args()) id = Column(Integer, primary_key=True) uuid = Column(String(36))