Merge "Make some build_requests columns nullable"
This commit is contained in:
commit
c127d1bdce
@ -0,0 +1,48 @@
|
||||
# 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.
|
||||
|
||||
from migrate.changeset.constraint import ForeignKeyConstraint
|
||||
from migrate import UniqueConstraint
|
||||
from sqlalchemy.engine import reflection
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
build_requests = Table('build_requests', meta, autoload=True)
|
||||
request_specs = Table('request_specs', meta, autoload=True)
|
||||
|
||||
for fkey in build_requests.foreign_keys:
|
||||
if fkey.target_fullname == 'request_specs.id':
|
||||
ForeignKeyConstraint(columns=['request_spec_id'],
|
||||
refcolumns=[request_specs.c.id],
|
||||
table=build_requests,
|
||||
name=fkey.name).drop()
|
||||
break
|
||||
|
||||
# These are being made nullable because they are no longer used after the
|
||||
# addition of the instance column. However they need a deprecation period
|
||||
# before they can be dropped.
|
||||
columns_to_nullify = ['request_spec_id', 'user_id', 'security_groups',
|
||||
'config_drive']
|
||||
for column in columns_to_nullify:
|
||||
getattr(build_requests.c, column).alter(nullable=True)
|
||||
|
||||
inspector = reflection.Inspector.from_engine(migrate_engine)
|
||||
constrs = inspector.get_unique_constraints('build_requests')
|
||||
constr_names = [constr['name'] for constr in constrs]
|
||||
if 'uniq_build_requests0request_spec_id' in constr_names:
|
||||
UniqueConstraint('request_spec_id', table=build_requests,
|
||||
name='uniq_build_requests0request_spec_id').drop()
|
@ -172,20 +172,17 @@ class BuildRequest(API_BASE):
|
||||
Index('build_requests_project_id_idx', 'project_id'),
|
||||
schema.UniqueConstraint('instance_uuid',
|
||||
name='uniq_build_requests0instance_uuid'),
|
||||
schema.UniqueConstraint('request_spec_id',
|
||||
name='uniq_build_requests0request_spec_id')
|
||||
)
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
request_spec_id = Column(Integer, ForeignKey('request_specs.id'),
|
||||
nullable=False)
|
||||
request_spec_id = Column(Integer, ForeignKey('request_specs.id'))
|
||||
request_spec = orm.relationship(RequestSpec,
|
||||
foreign_keys=request_spec_id,
|
||||
back_populates='build_request',
|
||||
primaryjoin=request_spec_id == RequestSpec.id)
|
||||
instance_uuid = Column(String(36))
|
||||
project_id = Column(String(255), nullable=False)
|
||||
user_id = Column(String(255), nullable=False)
|
||||
user_id = Column(String(255))
|
||||
display_name = Column(String(255))
|
||||
instance_metadata = Column(Text)
|
||||
progress = Column(Integer)
|
||||
@ -195,8 +192,8 @@ class BuildRequest(API_BASE):
|
||||
access_ip_v4 = Column(types.IPAddress())
|
||||
access_ip_v6 = Column(types.IPAddress())
|
||||
info_cache = Column(Text)
|
||||
security_groups = Column(Text, nullable=False)
|
||||
config_drive = Column(Boolean, default=False, nullable=False)
|
||||
security_groups = Column(Text)
|
||||
config_drive = Column(Boolean, default=False)
|
||||
key_name = Column(String(255))
|
||||
locked_by = Column(Enum('owner', 'admin'))
|
||||
instance = Column(Text)
|
||||
|
Loading…
x
Reference in New Issue
Block a user