From dfef67852088e683608a23857bd295663c5e7620 Mon Sep 17 00:00:00 2001 From: Arash Date: Wed, 18 Dec 2024 19:09:48 +0100 Subject: [PATCH] refactor user credentials model and introduce variable and secret model --- lib/galaxy/model/__init__.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 899392dbc5d3..1c5c2d4afcd0 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -11616,7 +11616,7 @@ class UserCredentials(Base): reference: Mapped[str] = mapped_column(nullable=False) source_type: Mapped[str] = mapped_column(nullable=False) source_id: Mapped[str] = mapped_column(nullable=False) - current_group_id: Mapped[int] = mapped_column(ForeignKey("user_credentials_group.id"), index=True) + current_group_id: Mapped[int] = mapped_column(ForeignKey("user_credentials_group.id"), index=True, nullable=True) create_time: Mapped[Optional[datetime]] = mapped_column(default=now) update_time: Mapped[Optional[datetime]] = mapped_column(default=now, onupdate=now) @@ -11630,29 +11630,45 @@ class CredentialsGroup(Base): id: Mapped[int] = mapped_column(primary_key=True) name: Mapped[str] = mapped_column(nullable=False) - user_credentials_id: Mapped[int] = mapped_column(ForeignKey("user_credentials.id"), index=True, nullable=True) + user_credentials_id: Mapped[int] = mapped_column(ForeignKey("user_credentials.id"), index=True) create_time: Mapped[Optional[datetime]] = mapped_column(default=now) update_time: Mapped[Optional[datetime]] = mapped_column(default=now, onupdate=now) -class Credential(Base): +class Variable(Base): """ - Represents a credential associated with a user for a specific service. + Represents a variable associated with a user for a specific service. """ - __tablename__ = "credential" + __tablename__ = "variable" id: Mapped[int] = mapped_column(primary_key=True) user_credential_group_id: Mapped[int] = mapped_column( ForeignKey("user_credentials_group.id"), index=True, nullable=False ) name: Mapped[str] = mapped_column(nullable=False) - type: Mapped[str] = mapped_column(nullable=False) value: Mapped[str] = mapped_column(nullable=False) create_time: Mapped[Optional[datetime]] = mapped_column(default=now) update_time: Mapped[Optional[datetime]] = mapped_column(default=now, onupdate=now) +class Secret(Base): + """ + Represents a secret associated with a user for a specific service. + """ + + __tablename__ = "secret" + + id: Mapped[int] = mapped_column(primary_key=True) + user_credential_group_id: Mapped[int] = mapped_column( + ForeignKey("user_credentials_group.id"), index=True, nullable=False + ) + name: Mapped[str] = mapped_column(nullable=False) + already_set: Mapped[bool] = mapped_column(nullable=False, default=False) + create_time: Mapped[Optional[datetime]] = mapped_column(default=now) + update_time: Mapped[Optional[datetime]] = mapped_column(default=now, onupdate=now) + + # The following models (HDA, LDDA) are mapped imperatively (for details see discussion in PR #12064) # TLDR: there are issues ('metadata' property, Galaxy object wrapping) that need to be addressed separately # before these models can be mapped declaratively. Keeping them in the mapping module breaks the auth package