Skip to content

RSS DB: schema changes #896

@aldbr

Description

@aldbr

User Story

As a diracx developer, I want the RSS database to be streamlined once DIRAC-diracX transition is complete.

Feature Description

The RSS tables currently use the magic string "all" as a server default for
the VO and StatusType columns. This convention was inherited from DIRAC's schema
and must be preserved during the transition because DIRAC reads/writes the same
tables.

After the transition, we should:

  1. Add an Alembic migration replacing "all" with NULL in existing rows
  2. Change the column server_default from "all" to None
  3. Update query logic to treat NULL as "applies to all"
  4. Review whether the ElementStatusBase / ElementStatusBaseWithID dual-class hierarchy is still needed (schema.py L24–71). DIRAC uses both composite-PK tables and autoincrement-ID tables; after the transition we may be able to consolidate into a single base class.

Context from PR #857:

See whether we still need:

class ElementStatusBase:
name: Mapped[str64] = mapped_column("Name", primary_key=True)
status_type: Mapped[str128] = mapped_column(
"StatusType", server_default="all", primary_key=True
)
vo: Mapped[str64] = mapped_column("VO", primary_key=True, server_default="all")
status: Mapped[str] = mapped_column("Status", String(8), server_default="")
reason: Mapped[str512] = mapped_column("Reason", server_default="Unspecified")
date_effective: Mapped[datetime] = mapped_column("DateEffective", SmarterDateTime())
token_expiration: Mapped[datetime] = mapped_column(
"TokenExpiration", SmarterDateTime(), server_default="9999-12-31 23:59:59"
)
element_type: Mapped[str32] = mapped_column("ElementType", server_default="")
last_check_time: Mapped[datetime] = mapped_column(
"LastCheckTime", SmarterDateTime(), server_default="1000-01-01 00:00:00"
)
token_owner: Mapped[str] = mapped_column(
"TokenOwner", String(16), server_default="rs_svc"
)
class ElementStatusBaseWithID(ElementStatusBase):
"""Almost the same as ElementStatusBase.
Differences:
- there's an autoincrement ID column which is also the primary key
- the name and statusType components are not part of the primary key
"""
id: Mapped[int] = mapped_column(
"ID", BigInteger, autoincrement=True, primary_key=True
)
name: Mapped[str64] = mapped_column("Name")
status_type: Mapped[str128] = mapped_column("StatusType", server_default="all")
vo: Mapped[str64] = mapped_column("VO", server_default="all")
status: Mapped[str] = mapped_column("Status", String(8), server_default="")
reason: Mapped[str512] = mapped_column("Reason", server_default="Unspecified")
date_effective: Mapped[datetime] = mapped_column("DateEffective", SmarterDateTime())
token_expiration: Mapped[datetime] = mapped_column(
"TokenExpiration", SmarterDateTime(), server_default="9999-12-31 23:59:59"
)
element_type: Mapped[str32] = mapped_column("ElementType", server_default="")
last_check_time: Mapped[datetime] = mapped_column(
"LastCheckTime", SmarterDateTime(), server_default="1000-01-01 00:00:00"
)
token_owner: Mapped[str] = mapped_column(
"TokenOwner", String(16), server_default="rs_svc"
)

Definition of Done

  • Alembic migration converts existing "all" values to NULL
  • Column defaults updated in SQLAlchemy schema
  • Query logic handles NULL semantics
  • ElementStatusBase / ElementStatusBaseWithID hierarchy reviewed and simplified if possible
  • Tests are written and passing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions