From 87c1daf011108325cb731055edda62e2456d95a2 Mon Sep 17 00:00:00 2001 From: Svetlana Shturm Date: Wed, 24 Jul 2013 15:04:34 +0400 Subject: [PATCH] Sync models for AgentBuild, Aggregates, AggregateHost tables. DB models definition should be up-to-date with DB schema obtained after applying of migrations. Currently, there are no tests enforcing this and it's really hard to analyze what indexes should be added, and what indexes we have at the moment. So the first step is it to fix all models, and add missing descriptions about Indexes and UniqueConstraints in __table_args__ and use explicit 'nullable' parameter in columns description. Add empty __table_args__ parameter to Table blueprint db-sync-models-with-migrations Change-Id: I76e064cf11d8b0df473c6085271b48a81fe31702 --- nova/db/sqlalchemy/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index c29edf7ac4..13c0b8c2cd 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -1015,7 +1015,7 @@ class AggregateHost(BASE, NovaBase): ), ) id = Column(Integer, primary_key=True, autoincrement=True) - host = Column(String(255), unique=False) + host = Column(String(255)) aggregate_id = Column(Integer, ForeignKey('aggregates.id'), nullable=False) @@ -1034,6 +1034,7 @@ class AggregateMetadata(BASE, NovaBase): class Aggregate(BASE, NovaBase): """Represents a cluster of hosts that exists in this zone.""" __tablename__ = 'aggregates' + __table_args__ = () id = Column(Integer, primary_key=True, autoincrement=True) name = Column(String(255)) _hosts = relationship(AggregateHost, @@ -1070,6 +1071,8 @@ class AgentBuild(BASE, NovaBase): """Represents an agent build.""" __tablename__ = 'agent_builds' __table_args__ = ( + Index('agent_builds_hypervisor_os_arch_idx', 'hypervisor', 'os', + 'architecture'), schema.UniqueConstraint("hypervisor", "os", "architecture", "deleted", name="uniq_agent_builds0hypervisor0os0architecture0deleted"), )