Skip to content

Backend code (exposed db table definitions) can get out of sync with the actual db state #7168

Description

@anna-parker

As seen in #7136 we have no tests or checks to ensure that the backend code that defines the database table structures is the same as the actual database tables in the database.

It also has been seen in other issues such as #5497, #1517

This could lead to some pretty bad situations if the backend tries to write using the wrong type or to non existing columns. Ideally we would at least have tests that ensure the backend table definitions are correct.

I tried to do this is in #7138 but it is not trivial because exposed does not have functions that convert existing tables into exposed table structures. Although it has code that can apply a migration exposed cannot properly reconcile postgres types (see https://www.jetbrains.com/help/exposed/migrations.html) and only catches the case where types in Exposed are narrower than DB (where actually the reverse would be more dangerous).

The paid jetbrains exposed plugin actually offers codegen (turning sql table definitions into exposed code) but this isnt sadly available.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendrelated to the loculus backend componentbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions