Skip to content

Consider moving tpp-database-utils tasks (and future EMIS tasks) into ehrQL #2803

@evansd

Description

@evansd

We currently have a separate image for performing some basic admin tasks and checks involving the TPP database.

It would be possible to move these into the ehrQL repo while avoiding mixing ehrQL core with provider-specific functionality.

The idea would be to add another hook method to the Backend class which provides a CLI entrypoint. You'd invoke this using something like:

ehrql backend-admin tpp [sub_command_name] [..args]

There are a number of advantages to this approach:

  • ehrQL already has to have the necessary libraries and machinery for connecting to the relevant databases so this avoids duplication.
  • It means fewer moving parts: repos to maintain, images to build etc.
  • It allows tighter integration between the checks and the code which uses the data being checked e.g. this HES_EXPECTED_ACTIVITY_MONTH no longer needs to be duplicated between two repos.
  • It reduces the number of special-cased images which are ever allowed database access by the agent.

There's no added risk of users being able to inappropriately run these commands. Or rather, they can run them all they want but they won't be able to do so in the context of having database credentials or network access so they won't do anything except error. User database access would remain restricted to the two special commands generate-dataset and generate-measures.

This proposal came out of discussion about implementing temporary table clean-up in EMIS:

One option would be to implement this new feature inside ehrQL and then later move the TPP-related features over.

There's a related question of folding SQL Runner into ehrQL as well, but that's a more involved task:

Slack discussion:
https://bennettoxford.slack.com/archives/C069YDR4NCA/p1778837409844219?thread_ts=1772532162.313909&cid=C069YDR4NCA

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