From eb49f3eb04b798a531f3a0a773cee7c30289a62b Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Sat, 8 Jun 2013 12:45:16 +0400 Subject: Fix db.models.Certificate description 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 missing 'nullable' parameters to all Columns Add empty __table_args__ parameter to Table Add 2 missing indexes in Certificate model definition. blueprint db-sync-models-with-migrations Change-Id: Ida607c2b8899e145116d46cffdc49b7176b05550 --- nova/db/sqlalchemy/models.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index 647c548c1..f5cda04cc 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -129,11 +129,15 @@ class ComputeNodeStat(BASE, NovaBase): class Certificate(BASE, NovaBase): """Represents a x509 certificate.""" __tablename__ = 'certificates' + __table_args__ = ( + Index('certificates_project_id_deleted_idx', 'project_id', 'deleted'), + Index('certificates_user_id_deleted_idx', 'user_id', 'deleted') + ) id = Column(Integer, primary_key=True) - user_id = Column(String(255)) - project_id = Column(String(255)) - file_name = Column(String(255)) + user_id = Column(String(255), nullable=True) + project_id = Column(String(255), nullable=True) + file_name = Column(String(255), nullable=True) class Instance(BASE, NovaBase): -- cgit