Merge "Add indexes to SQLAlchemy models"
This commit is contained in:
commit
1ae98160a2
@ -111,7 +111,8 @@ class Cluster(BASE, CinderBase):
|
|||||||
# change this field to the same value as the id which will be unique and
|
# change this field to the same value as the id which will be unique and
|
||||||
# will not conflict with the creation of another cluster with the same
|
# will not conflict with the creation of another cluster with the same
|
||||||
# name.
|
# name.
|
||||||
__table_args__ = (UniqueConstraint('name', 'binary', 'race_preventer'),)
|
__table_args__ = (UniqueConstraint('name', 'binary', 'race_preventer'),
|
||||||
|
CinderBase.__table_args__)
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
# NOTE(geguileo): Name is constructed in the same way that Server.host but
|
# NOTE(geguileo): Name is constructed in the same way that Server.host but
|
||||||
@ -201,7 +202,7 @@ class Cgsnapshot(BASE, CinderBase):
|
|||||||
__tablename__ = 'cgsnapshots'
|
__tablename__ = 'cgsnapshots'
|
||||||
id = Column(String(36), primary_key=True)
|
id = Column(String(36), primary_key=True)
|
||||||
|
|
||||||
consistencygroup_id = Column(String(36))
|
consistencygroup_id = Column(String(36), index=True)
|
||||||
user_id = Column(String(255), nullable=False)
|
user_id = Column(String(255), nullable=False)
|
||||||
project_id = Column(String(255), nullable=False)
|
project_id = Column(String(255), nullable=False)
|
||||||
|
|
||||||
@ -221,7 +222,7 @@ class GroupSnapshot(BASE, CinderBase):
|
|||||||
__tablename__ = 'group_snapshots'
|
__tablename__ = 'group_snapshots'
|
||||||
id = Column(String(36), primary_key=True)
|
id = Column(String(36), primary_key=True)
|
||||||
|
|
||||||
group_id = Column(String(36), nullable=False)
|
group_id = Column(String(36), nullable=False, index=True)
|
||||||
user_id = Column(String(255))
|
user_id = Column(String(255))
|
||||||
project_id = Column(String(255))
|
project_id = Column(String(255))
|
||||||
|
|
||||||
@ -285,8 +286,8 @@ class Volume(BASE, CinderBase):
|
|||||||
source_volid = Column(String(36))
|
source_volid = Column(String(36))
|
||||||
encryption_key_id = Column(String(36))
|
encryption_key_id = Column(String(36))
|
||||||
|
|
||||||
consistencygroup_id = Column(String(36))
|
consistencygroup_id = Column(String(36), index=True)
|
||||||
group_id = Column(String(36))
|
group_id = Column(String(36), index=True)
|
||||||
|
|
||||||
bootable = Column(Boolean, default=False)
|
bootable = Column(Boolean, default=False)
|
||||||
multiattach = Column(Boolean, default=False)
|
multiattach = Column(Boolean, default=False)
|
||||||
@ -316,7 +317,8 @@ class VolumeMetadata(BASE, CinderBase):
|
|||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
key = Column(String(255))
|
key = Column(String(255))
|
||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
volume_id = Column(String(36), ForeignKey('volumes.id'), nullable=False)
|
volume_id = Column(String(36), ForeignKey('volumes.id'), nullable=False,
|
||||||
|
index=True)
|
||||||
volume = relationship(Volume, backref="volume_metadata",
|
volume = relationship(Volume, backref="volume_metadata",
|
||||||
foreign_keys=volume_id,
|
foreign_keys=volume_id,
|
||||||
primaryjoin='and_('
|
primaryjoin='and_('
|
||||||
@ -330,7 +332,8 @@ class VolumeAdminMetadata(BASE, CinderBase):
|
|||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
key = Column(String(255))
|
key = Column(String(255))
|
||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
volume_id = Column(String(36), ForeignKey('volumes.id'), nullable=False)
|
volume_id = Column(String(36), ForeignKey('volumes.id'), nullable=False,
|
||||||
|
index=True)
|
||||||
volume = relationship(Volume, backref="volume_admin_metadata",
|
volume = relationship(Volume, backref="volume_admin_metadata",
|
||||||
foreign_keys=volume_id,
|
foreign_keys=volume_id,
|
||||||
primaryjoin='and_('
|
primaryjoin='and_('
|
||||||
@ -343,7 +346,8 @@ class VolumeAttachment(BASE, CinderBase):
|
|||||||
__tablename__ = 'volume_attachment'
|
__tablename__ = 'volume_attachment'
|
||||||
id = Column(String(36), primary_key=True)
|
id = Column(String(36), primary_key=True)
|
||||||
|
|
||||||
volume_id = Column(String(36), ForeignKey('volumes.id'), nullable=False)
|
volume_id = Column(String(36), ForeignKey('volumes.id'), nullable=False,
|
||||||
|
index=True)
|
||||||
volume = relationship(Volume, backref="volume_attachment",
|
volume = relationship(Volume, backref="volume_attachment",
|
||||||
foreign_keys=volume_id,
|
foreign_keys=volume_id,
|
||||||
primaryjoin='and_('
|
primaryjoin='and_('
|
||||||
@ -367,7 +371,8 @@ class VolumeTypes(BASE, CinderBase):
|
|||||||
description = Column(String(255))
|
description = Column(String(255))
|
||||||
# A reference to qos_specs entity
|
# A reference to qos_specs entity
|
||||||
qos_specs_id = Column(String(36),
|
qos_specs_id = Column(String(36),
|
||||||
ForeignKey('quality_of_service_specs.id'))
|
ForeignKey('quality_of_service_specs.id'),
|
||||||
|
index=True)
|
||||||
is_public = Column(Boolean, default=True)
|
is_public = Column(Boolean, default=True)
|
||||||
volumes = relationship(Volume,
|
volumes = relationship(Volume,
|
||||||
backref=backref('volume_type', uselist=False),
|
backref=backref('volume_type', uselist=False),
|
||||||
@ -398,10 +403,10 @@ class GroupVolumeTypeMapping(BASE, CinderBase):
|
|||||||
id = Column(Integer, primary_key=True, nullable=False)
|
id = Column(Integer, primary_key=True, nullable=False)
|
||||||
volume_type_id = Column(String(36),
|
volume_type_id = Column(String(36),
|
||||||
ForeignKey('volume_types.id'),
|
ForeignKey('volume_types.id'),
|
||||||
nullable=False)
|
nullable=False, index=True)
|
||||||
group_id = Column(String(36),
|
group_id = Column(String(36),
|
||||||
ForeignKey('groups.id'),
|
ForeignKey('groups.id'),
|
||||||
nullable=False)
|
nullable=False, index=True)
|
||||||
|
|
||||||
group = relationship(
|
group = relationship(
|
||||||
Group,
|
Group,
|
||||||
@ -419,7 +424,7 @@ class VolumeTypeProjects(BASE, CinderBase):
|
|||||||
__table_args__ = (schema.UniqueConstraint(
|
__table_args__ = (schema.UniqueConstraint(
|
||||||
"volume_type_id", "project_id", "deleted",
|
"volume_type_id", "project_id", "deleted",
|
||||||
name="uniq_volume_type_projects0volume_type_id0project_id0deleted"),
|
name="uniq_volume_type_projects0volume_type_id0project_id0deleted"),
|
||||||
)
|
CinderBase.__table_args__)
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
volume_type_id = Column(String, ForeignKey('volume_types.id'),
|
volume_type_id = Column(String, ForeignKey('volume_types.id'),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
@ -441,7 +446,7 @@ class GroupTypeProjects(BASE, CinderBase):
|
|||||||
__table_args__ = (schema.UniqueConstraint(
|
__table_args__ = (schema.UniqueConstraint(
|
||||||
"group_type_id", "project_id", "deleted",
|
"group_type_id", "project_id", "deleted",
|
||||||
name="uniq_group_type_projects0group_type_id0project_id0deleted"),
|
name="uniq_group_type_projects0group_type_id0project_id0deleted"),
|
||||||
)
|
CinderBase.__table_args__)
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
group_type_id = Column(String, ForeignKey('group_types.id'),
|
group_type_id = Column(String, ForeignKey('group_types.id'),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
@ -464,7 +469,7 @@ class VolumeTypeExtraSpecs(BASE, CinderBase):
|
|||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
volume_type_id = Column(String(36),
|
volume_type_id = Column(String(36),
|
||||||
ForeignKey('volume_types.id'),
|
ForeignKey('volume_types.id'),
|
||||||
nullable=False)
|
nullable=False, index=True)
|
||||||
volume_type = relationship(
|
volume_type = relationship(
|
||||||
VolumeTypes,
|
VolumeTypes,
|
||||||
backref="extra_specs",
|
backref="extra_specs",
|
||||||
@ -483,7 +488,7 @@ class GroupTypeSpecs(BASE, CinderBase):
|
|||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
group_type_id = Column(String(36),
|
group_type_id = Column(String(36),
|
||||||
ForeignKey('group_types.id'),
|
ForeignKey('group_types.id'),
|
||||||
nullable=False)
|
nullable=False, index=True)
|
||||||
group_type = relationship(
|
group_type = relationship(
|
||||||
GroupTypes,
|
GroupTypes,
|
||||||
backref="group_specs",
|
backref="group_specs",
|
||||||
@ -531,7 +536,7 @@ class QualityOfServiceSpecs(BASE, CinderBase):
|
|||||||
"""
|
"""
|
||||||
__tablename__ = 'quality_of_service_specs'
|
__tablename__ = 'quality_of_service_specs'
|
||||||
id = Column(String(36), primary_key=True)
|
id = Column(String(36), primary_key=True)
|
||||||
specs_id = Column(String(36), ForeignKey(id))
|
specs_id = Column(String(36), ForeignKey(id), index=True)
|
||||||
key = Column(String(255))
|
key = Column(String(255))
|
||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
|
|
||||||
@ -557,8 +562,8 @@ class VolumeGlanceMetadata(BASE, CinderBase):
|
|||||||
"""Glance metadata for a bootable volume."""
|
"""Glance metadata for a bootable volume."""
|
||||||
__tablename__ = 'volume_glance_metadata'
|
__tablename__ = 'volume_glance_metadata'
|
||||||
id = Column(Integer, primary_key=True, nullable=False)
|
id = Column(Integer, primary_key=True, nullable=False)
|
||||||
volume_id = Column(String(36), ForeignKey('volumes.id'))
|
volume_id = Column(String(36), ForeignKey('volumes.id'), index=True)
|
||||||
snapshot_id = Column(String(36), ForeignKey('snapshots.id'))
|
snapshot_id = Column(String(36), ForeignKey('snapshots.id'), index=True)
|
||||||
key = Column(String(255))
|
key = Column(String(255))
|
||||||
value = Column(Text)
|
value = Column(Text)
|
||||||
volume = relationship(Volume, backref="volume_glance_metadata",
|
volume = relationship(Volume, backref="volume_glance_metadata",
|
||||||
@ -609,12 +614,10 @@ class QuotaUsage(BASE, CinderBase):
|
|||||||
"""Represents the current usage for a given resource."""
|
"""Represents the current usage for a given resource."""
|
||||||
|
|
||||||
__tablename__ = 'quota_usages'
|
__tablename__ = 'quota_usages'
|
||||||
__table_args__ = (Index('quota_usage_project_resource_idx', 'project_id',
|
|
||||||
'resource'), CinderBase.__table_args__)
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
|
|
||||||
project_id = Column(String(255), index=True)
|
project_id = Column(String(255), index=True)
|
||||||
resource = Column(String(255))
|
resource = Column(String(255), index=True)
|
||||||
|
|
||||||
in_use = Column(Integer)
|
in_use = Column(Integer)
|
||||||
reserved = Column(Integer)
|
reserved = Column(Integer)
|
||||||
@ -630,11 +633,17 @@ class Reservation(BASE, CinderBase):
|
|||||||
"""Represents a resource reservation for quotas."""
|
"""Represents a resource reservation for quotas."""
|
||||||
|
|
||||||
__tablename__ = 'reservations'
|
__tablename__ = 'reservations'
|
||||||
|
__table_args__ = (Index('reservations_deleted_expire_idx',
|
||||||
|
'deleted', 'expire'),
|
||||||
|
CinderBase.__table_args__)
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
uuid = Column(String(36), nullable=False)
|
uuid = Column(String(36), nullable=False)
|
||||||
|
|
||||||
usage_id = Column(Integer, ForeignKey('quota_usages.id'), nullable=True)
|
usage_id = Column(Integer, ForeignKey('quota_usages.id'), nullable=True,
|
||||||
allocated_id = Column(Integer, ForeignKey('quotas.id'), nullable=True)
|
index=True)
|
||||||
|
allocated_id = Column(Integer, ForeignKey('quotas.id'), nullable=True,
|
||||||
|
index=True)
|
||||||
|
|
||||||
project_id = Column(String(255), index=True)
|
project_id = Column(String(255), index=True)
|
||||||
resource = Column(String(255))
|
resource = Column(String(255))
|
||||||
@ -669,9 +678,9 @@ class Snapshot(BASE, CinderBase):
|
|||||||
user_id = Column(String(255))
|
user_id = Column(String(255))
|
||||||
project_id = Column(String(255))
|
project_id = Column(String(255))
|
||||||
|
|
||||||
volume_id = Column(String(36))
|
volume_id = Column(String(36), index=True)
|
||||||
cgsnapshot_id = Column(String(36))
|
cgsnapshot_id = Column(String(36), index=True)
|
||||||
group_snapshot_id = Column(String(36))
|
group_snapshot_id = Column(String(36), index=True)
|
||||||
status = Column(String(255))
|
status = Column(String(255))
|
||||||
progress = Column(String(255))
|
progress = Column(String(255))
|
||||||
volume_size = Column(Integer)
|
volume_size = Column(Integer)
|
||||||
@ -711,7 +720,7 @@ class SnapshotMetadata(BASE, CinderBase):
|
|||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
snapshot_id = Column(String(36),
|
snapshot_id = Column(String(36),
|
||||||
ForeignKey('snapshots.id'),
|
ForeignKey('snapshots.id'),
|
||||||
nullable=False)
|
nullable=False, index=True)
|
||||||
snapshot = relationship(Snapshot, backref="snapshot_metadata",
|
snapshot = relationship(Snapshot, backref="snapshot_metadata",
|
||||||
foreign_keys=snapshot_id,
|
foreign_keys=snapshot_id,
|
||||||
primaryjoin='and_('
|
primaryjoin='and_('
|
||||||
@ -762,7 +771,8 @@ class BackupMetadata(BASE, CinderBase):
|
|||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
key = Column(String(255))
|
key = Column(String(255))
|
||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
backup_id = Column(String(36), ForeignKey('backups.id'), nullable=False)
|
backup_id = Column(String(36), ForeignKey('backups.id'), nullable=False,
|
||||||
|
index=True)
|
||||||
backup = relationship(Backup, backref="backup_metadata",
|
backup = relationship(Backup, backref="backup_metadata",
|
||||||
foreign_keys=backup_id,
|
foreign_keys=backup_id,
|
||||||
primaryjoin='and_('
|
primaryjoin='and_('
|
||||||
@ -798,7 +808,7 @@ class Transfer(BASE, CinderBase):
|
|||||||
"""Represents a volume transfer request."""
|
"""Represents a volume transfer request."""
|
||||||
__tablename__ = 'transfers'
|
__tablename__ = 'transfers'
|
||||||
id = Column(String(36), primary_key=True)
|
id = Column(String(36), primary_key=True)
|
||||||
volume_id = Column(String(36), ForeignKey('volumes.id'))
|
volume_id = Column(String(36), ForeignKey('volumes.id'), index=True)
|
||||||
display_name = Column(String(255))
|
display_name = Column(String(255))
|
||||||
salt = Column(String(255))
|
salt = Column(String(255))
|
||||||
crypt_hash = Column(String(255))
|
crypt_hash = Column(String(255))
|
||||||
@ -815,8 +825,8 @@ class DriverInitiatorData(BASE, models.TimestampMixin, models.ModelBase):
|
|||||||
__tablename__ = 'driver_initiator_data'
|
__tablename__ = 'driver_initiator_data'
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
schema.UniqueConstraint("initiator", "namespace", "key"),
|
schema.UniqueConstraint("initiator", "namespace", "key"),
|
||||||
{'mysql_engine': 'InnoDB'}
|
CinderBase.__table_args__)
|
||||||
)
|
|
||||||
id = Column(Integer, primary_key=True, nullable=False)
|
id = Column(Integer, primary_key=True, nullable=False)
|
||||||
initiator = Column(String(255), index=True, nullable=False)
|
initiator = Column(String(255), index=True, nullable=False)
|
||||||
namespace = Column(String(255), nullable=False)
|
namespace = Column(String(255), nullable=False)
|
||||||
@ -842,12 +852,13 @@ class Message(BASE, CinderBase):
|
|||||||
# Operation specific action.
|
# Operation specific action.
|
||||||
action_id = Column(String(10), nullable=True)
|
action_id = Column(String(10), nullable=True)
|
||||||
# After this time the message may no longer exist
|
# After this time the message may no longer exist
|
||||||
expires_at = Column(DateTime, nullable=True)
|
expires_at = Column(DateTime, nullable=True, index=True)
|
||||||
|
|
||||||
|
|
||||||
class ImageVolumeCacheEntry(BASE, models.ModelBase):
|
class ImageVolumeCacheEntry(BASE, models.ModelBase):
|
||||||
"""Represents an image volume cache entry"""
|
"""Represents an image volume cache entry"""
|
||||||
__tablename__ = 'image_volume_cache_entries'
|
__tablename__ = 'image_volume_cache_entries'
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, nullable=False)
|
id = Column(Integer, primary_key=True, nullable=False)
|
||||||
host = Column(String(255), index=True, nullable=False)
|
host = Column(String(255), index=True, nullable=False)
|
||||||
cluster_name = Column(String(255), nullable=True)
|
cluster_name = Column(String(255), nullable=True)
|
||||||
@ -862,7 +873,7 @@ class Worker(BASE, CinderBase):
|
|||||||
"""Represents all resources that are being worked on by a node."""
|
"""Represents all resources that are being worked on by a node."""
|
||||||
__tablename__ = 'workers'
|
__tablename__ = 'workers'
|
||||||
__table_args__ = (schema.UniqueConstraint('resource_type', 'resource_id'),
|
__table_args__ = (schema.UniqueConstraint('resource_type', 'resource_id'),
|
||||||
{'mysql_engine': 'InnoDB'})
|
CinderBase.__table_args__)
|
||||||
|
|
||||||
# We want to overwrite default updated_at definition so we timestamp at
|
# We want to overwrite default updated_at definition so we timestamp at
|
||||||
# creation as well
|
# creation as well
|
||||||
@ -882,7 +893,7 @@ class Worker(BASE, CinderBase):
|
|||||||
status = Column(String(255), nullable=False)
|
status = Column(String(255), nullable=False)
|
||||||
|
|
||||||
# Service that is currently processing the operation
|
# Service that is currently processing the operation
|
||||||
service_id = Column(Integer, nullable=True)
|
service_id = Column(Integer, nullable=True, index=True)
|
||||||
|
|
||||||
# To prevent claiming and updating races
|
# To prevent claiming and updating races
|
||||||
race_preventer = Column(Integer, nullable=False, default=0)
|
race_preventer = Column(Integer, nullable=False, default=0)
|
||||||
@ -905,10 +916,8 @@ class AttachmentSpecs(BASE, CinderBase):
|
|||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
key = Column(String(255))
|
key = Column(String(255))
|
||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
attachment_id = (
|
attachment_id = Column(String(36), ForeignKey('volume_attachment.id'),
|
||||||
Column(String(36),
|
nullable=False, index=True)
|
||||||
ForeignKey('volume_attachment.id'),
|
|
||||||
nullable=False))
|
|
||||||
volume_attachment = relationship(
|
volume_attachment = relationship(
|
||||||
VolumeAttachment,
|
VolumeAttachment,
|
||||||
backref="attachment_specs",
|
backref="attachment_specs",
|
||||||
|
Loading…
Reference in New Issue
Block a user