Skip to content

Commit

Permalink
Testing: Add type annotations and improved docstrings; #6677
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingstaff authored and bari12 committed Apr 23, 2024
1 parent a10f13e commit 695c4bc
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/rucio/db/sqla/models.py
Expand Up @@ -1690,15 +1690,25 @@ class FollowEvents(BASE, ModelBase):
Index('DIDS_FOLLOWED_EVENTS_ACC_IDX', 'account'))


def register_models(engine):
def register_models(engine: Engine) -> None:
"""
Creates database tables for all models with the given engine
Creates database tables for all models in the `BASE.metadata` schema with the given engine.
Functionally this creates all models, as they all inherit from BASE and exist in the same `BASE.metadata` schema.
:param engine: engine to register the models with
:type engine: sqlalchemy.engine.Engine
:returns: None
"""
BASE.metadata.create_all(engine)


def unregister_models(engine):
def unregister_models(engine: Engine) -> None:
"""
Drops database tables for all models with the given engine
Drops database tables for all models in the `BASE.metadata` schema with the given engine.
Functionally this drops all models, as they all inherit from BASE and exist in the same `BASE.metadata` schema.
:param engine: The engine to unregister the models with
:type engine: sqlalchemy.engine.Engine
:returns: None
"""
BASE.metadata.drop_all(engine)

0 comments on commit 695c4bc

Please sign in to comment.