From 5a5ad0e6542b5b8605efbe6fe2f48c20a4df5732 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 3 Jan 2023 14:09:19 +0100 Subject: [PATCH] removed 'scope_ref' from code checks because we only support one 'ALLOTMENT_REF', so we need no checks --- app/main.py | 6 +++--- app/orm.py | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/main.py b/app/main.py index 9259843..303f81d 100644 --- a/app/main.py +++ b/app/main.py @@ -363,8 +363,8 @@ async def leasing_v1_lessor(request: Request): lease_result_list = [] for scope_ref in scope_ref_list: - if scope_ref not in [ALLOTMENT_REF]: - raise HTTPException(status_code=500, detail=f'no service instances found for scopes: ["{scope_ref}"]') + # if scope_ref not in [ALLOTMENT_REF]: + # raise HTTPException(status_code=500, detail=f'no service instances found for scopes: ["{scope_ref}"]') lease_ref = str(uuid4()) expires = cur_time + LEASE_EXPIRE_DELTA @@ -381,7 +381,7 @@ async def leasing_v1_lessor(request: Request): } }) - data = Lease(origin_ref=origin_ref, scope_ref=scope_ref, lease_ref=lease_ref, lease_created=cur_time, lease_expires=expires) + data = Lease(origin_ref=origin_ref, lease_ref=lease_ref, lease_created=cur_time, lease_expires=expires) Lease.create_or_update(db, data) response = { diff --git a/app/orm.py b/app/orm.py index 8128804..1dc5de8 100644 --- a/app/orm.py +++ b/app/orm.py @@ -72,7 +72,7 @@ class Lease(Base): lease_ref = Column(CHAR(length=36), primary_key=True, nullable=False, index=True) # uuid4 origin_ref = Column(CHAR(length=36), ForeignKey(Origin.origin_ref, ondelete='CASCADE'), nullable=False, index=True) # uuid4 - scope_ref = Column(CHAR(length=36), nullable=False, index=True) # uuid4 + # scope_ref = Column(CHAR(length=36), nullable=False, index=True) # uuid4 # not necessary, we only support one scope_ref lease_created = Column(DATETIME(), nullable=False) lease_expires = Column(DATETIME(), nullable=False) lease_updated = Column(DATETIME(), nullable=False) @@ -84,7 +84,7 @@ class Lease(Base): return { 'lease_ref': self.lease_ref, 'origin_ref': self.origin_ref, - 'scope_ref': self.scope_ref, + # 'scope_ref': self.scope_ref, 'lease_created': self.lease_created.isoformat(), 'lease_expires': self.lease_expires.isoformat(), 'lease_updated': self.lease_updated.isoformat(), @@ -180,14 +180,14 @@ def migrate(engine: Engine): Lease.__table__.drop(bind=engine) init(engine) - def upgrade_1_2_to_1_3(): - x = db.dialect.get_columns(engine.connect(), Lease.__tablename__) - x = next((_ for _ in x if _['name'] == 'scope_ref'), None) - if x is None: - Lease.scope_ref.compile() - column_name = Lease.scope_ref.name - column_type = Lease.scope_ref.type.compile(engine.dialect) - engine.execute(f'ALTER TABLE "{Lease.__tablename__}" ADD COLUMN "{column_name}" {column_type}') + # def upgrade_1_2_to_1_3(): + # x = db.dialect.get_columns(engine.connect(), Lease.__tablename__) + # x = next((_ for _ in x if _['name'] == 'scope_ref'), None) + # if x is None: + # Lease.scope_ref.compile() + # column_name = Lease.scope_ref.name + # column_type = Lease.scope_ref.type.compile(engine.dialect) + # engine.execute(f'ALTER TABLE "{Lease.__tablename__}" ADD COLUMN "{column_name}" {column_type}') upgrade_1_0_to_1_1() - upgrade_1_2_to_1_3() + # upgrade_1_2_to_1_3()