From e9152d7e9f7d4e550f8a9181d043c1f65bab0a2f Mon Sep 17 00:00:00 2001 From: Coco <419546439@qq.com> Date: Tue, 19 Feb 2019 01:02:06 -0500 Subject: [PATCH] Modify "extended_accelerator_requests" table "project_id" field. Set "project_id" nullable=True, because we don't have project related constraints in Stein Release, but keep the "project_id" field for further expansion. Besides, change ExtendedAcceleratorRequests Object name to "ExtArq" for concise purpose and add annotations for that. Change-Id: Id814926e36d368bb18d06abfca1f28bdecd06065 --- .../alembic/versions/ede4e3f1a232_new_db_schema.py | 4 +++- cyborg/db/sqlalchemy/models.py | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cyborg/db/sqlalchemy/alembic/versions/ede4e3f1a232_new_db_schema.py b/cyborg/db/sqlalchemy/alembic/versions/ede4e3f1a232_new_db_schema.py index 34260072..2a7b1b6f 100644 --- a/cyborg/db/sqlalchemy/alembic/versions/ede4e3f1a232_new_db_schema.py +++ b/cyborg/db/sqlalchemy/alembic/versions/ede4e3f1a232_new_db_schema.py @@ -143,7 +143,9 @@ def upgrade(): sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('uuid', sa.String(length=36), nullable=False, unique=True), - sa.Column('project_id', sa.String(length=255), nullable=False), + # NOTICE: we don't have project related constraints in Stein Release, + # set nullable=True but keep this field for further expansion. + sa.Column('project_id', sa.String(length=255), nullable=True), sa.Column('state', state, nullable=False, default='Initial'), sa.Column('device_profile_id', sa.Integer(), sa.ForeignKey('device_profiles.id', ondelete="RESTRICT"), diff --git a/cyborg/db/sqlalchemy/models.py b/cyborg/db/sqlalchemy/models.py index 557551f1..db6a5ae9 100644 --- a/cyborg/db/sqlalchemy/models.py +++ b/cyborg/db/sqlalchemy/models.py @@ -171,8 +171,9 @@ class DeviceProfile(Base): profile_json = Column(Text, nullable=False) -class ExtendedAcceleratorRequest(Base): - """Represents extended nova requests for attach related operations.""" +class ExtArq(Base): + """ExtArq is the abbreviation of ExtendedAcceleratorRequest, it represents + extended nova requests for attach related operations.""" __tablename__ = 'extended_accelerator_requests' __table_args__ = ( @@ -187,7 +188,7 @@ class ExtendedAcceleratorRequest(Base): id = Column(Integer, primary_key=True) uuid = Column(String(36), nullable=False, unique=True) - project_id = Column(String(255), nullable=False) + project_id = Column(String(255), nullable=True) state = Column(Enum('Initial', 'Bound', 'BindFailed', name='state'), nullable=False) device_profile_id = Column(Integer, ForeignKey('device_profiles.id',