From 819fde08b7a3693a67d542eb4c433ac848750cf2 Mon Sep 17 00:00:00 2001 From: Akashdeep Dhar Date: Fri, 12 Jul 2024 14:21:15 +0530 Subject: [PATCH] Move the `token` column from the APIKEY table to the SERVICE table Remove the APIKEY table from the entire database schema Signed-off-by: Akashdeep Dhar --- webhook_to_fedora_messaging/models/apikey.py | 21 ------------------- webhook_to_fedora_messaging/models/service.py | 3 +++ 2 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 webhook_to_fedora_messaging/models/apikey.py diff --git a/webhook_to_fedora_messaging/models/apikey.py b/webhook_to_fedora_messaging/models/apikey.py deleted file mode 100644 index 6a86524..0000000 --- a/webhook_to_fedora_messaging/models/apikey.py +++ /dev/null @@ -1,21 +0,0 @@ -# SPDX-FileCopyrightText: Contributors to the Fedora Project -# -# SPDX-License-Identifier: GPL-3.0-or-later - -from sqlalchemy import Column, Integer, UnicodeText, Boolean, ForeignKey, DateTime -from webhook_to_fedora_messaging.models.util import UUIDCreatableMixin, CreatableMixin - -from webhook_to_fedora_messaging.database import Base - -from uuid import uuid4 - - -class APIKey(Base, UUIDCreatableMixin, CreatableMixin): - __tablename__ = "apikeys" - - id = Column(Integer, primary_key=True, nullable=False) - user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), unique=False, nullable=False) - name = Column(UnicodeText, nullable=False) - token = Column(UnicodeText, unique=True, nullable=False, default=uuid4().hex) - expiry_date = Column(DateTime, nullable=True) - disabled = Column(Boolean, nullable=False, default=False) diff --git a/webhook_to_fedora_messaging/models/service.py b/webhook_to_fedora_messaging/models/service.py index 6297e5b..fa85365 100644 --- a/webhook_to_fedora_messaging/models/service.py +++ b/webhook_to_fedora_messaging/models/service.py @@ -7,12 +7,15 @@ from webhook_to_fedora_messaging.database import Base +from uuid import uuid4 + class Service(Base, UUIDCreatableMixin, CreatableMixin): __tablename__ = "services" id = Column(Integer, primary_key=True, nullable=False) user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), unique=False, nullable=False) + token = Column(UnicodeText, unique=False, nullable=False, default=uuid4().hex) name = Column(UnicodeText, nullable=False) type = Column(UnicodeText, nullable=False) desc = Column(UnicodeText, nullable=False)