Clean up subports model

First, the nullable attribute on port_id was redundant because it is
in the primary key.

Second, trunk_id shouldn't be in the primary key.  Since port_id was
already marked unique, it didn't add any extra uniqueness constraint
and it doesn't help to have it in a primary key index either since
we'll either search the table for a given port_id *or* search for
subports with a given trunk_id.

The original model was not released in Mitaka.  Also, this is
effectively a cosmetic change, it doesn't really effect the operation
of the DB.  So, developers and trunk chasers who have deployed with
the previous model will still work.

Change-Id: Ia43a2a772f654e26c3234e153fd8a5501e585c9b
Partially-Implements: blueprint vlan-aware-vms
This commit is contained in:
Carl Baldwin 2016-06-08 09:33:28 -06:00 committed by Carl Baldwin
parent 6d8d00fea1
commit eb0861135b
2 changed files with 3 additions and 7 deletions

View File

@ -37,15 +37,14 @@ def upgrade():
sa.UniqueConstraint('standard_attr_id')
)
op.create_table('subports',
sa.Column('port_id', sa.String(length=36), nullable=False),
sa.Column('port_id', sa.String(length=36)),
sa.Column('trunk_id', sa.String(length=36), nullable=False),
sa.Column('segmentation_type', sa.String(length=32), nullable=False),
sa.Column('segmentation_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['trunk_id'], ['trunks.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('port_id', 'trunk_id'),
sa.UniqueConstraint('port_id'),
sa.PrimaryKeyConstraint('port_id'),
sa.UniqueConstraint('trunk_id', 'segmentation_type', 'segmentation_id',
name='uniq_subport0trunk_id0segmentation_type0segmentation_id')
)

View File

@ -38,8 +38,6 @@ class SubPort(model_base.BASEV2):
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id',
ondelete='CASCADE'),
nullable=False,
unique=True,
primary_key=True)
port = sa.orm.relationship(
models_v2.Port,
@ -49,8 +47,7 @@ class SubPort(model_base.BASEV2):
trunk_id = sa.Column(sa.String(36),
sa.ForeignKey('trunks.id',
ondelete='CASCADE'),
nullable=False,
primary_key=True)
nullable=False)
segmentation_type = sa.Column(sa.String(32), nullable=False)
segmentation_id = sa.Column(sa.Integer, nullable=False)