Allow duplicate lease names
A unique constraint currently restricts two leases from having the same name, even if they belong to different projects. This patch removes this constraint in order to allow duplicate lease names, even within the same project, to match the behavior of Nova with instances and Glance with images. Change-Id: I89d358e35e57edbff1d841df96ce705455b1cd11 Closes-Bug: #1711076
This commit is contained in:
parent
cb187056f8
commit
3018e70d34
@ -0,0 +1,42 @@
|
||||
# Copyright 2017 OpenStack Foundation.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Allow duplicate lease names
|
||||
|
||||
Revision ID: 6bfd1c23aa18
|
||||
Revises: ba75b766b64e
|
||||
Create Date: 2017-08-16 08:49:15.307072
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6bfd1c23aa18'
|
||||
down_revision = 'ba75b766b64e'
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy.engine import reflection
|
||||
|
||||
|
||||
def upgrade():
|
||||
inspector = reflection.Inspector.from_engine(op.get_bind())
|
||||
unique_constraints = inspector.get_unique_constraints('leases')
|
||||
for constraint in unique_constraints:
|
||||
if constraint['column_names'] == ['name']:
|
||||
op.drop_constraint(constraint['name'], 'leases', type_='unique')
|
||||
break
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.create_unique_constraint('uniq_leases0name', 'leases', ['name'])
|
@ -49,10 +49,6 @@ class Lease(mb.BlazarBase):
|
||||
|
||||
__tablename__ = 'leases'
|
||||
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('name'),
|
||||
)
|
||||
|
||||
id = _id_column()
|
||||
name = sa.Column(sa.String(80), nullable=False)
|
||||
user_id = sa.Column(sa.String(255), nullable=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user