Skip to content

feat(backend): Generate db migrations from exposed table definitions - #7141

Draft
tombch wants to merge 3 commits into
mainfrom
exposed-auto-migrate
Draft

tombch wants to merge 3 commits into
mainfrom
exposed-auto-migrate

Conversation

@tombch

@tombch tombch commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

related to #7138 and #7139

Just an idea - this is something I've seen with Django for instance, you (in most cases) only modify the Python models and then run makemigrations and migrate and it generates the corresponding SQL tables or schema changes. This PR adds the same kind of thing but generating the SQL migration from the Exposed table definitions.

This would add a command that can be run as follows:

./gradlew generateMigration -PscriptName=V1.35__name_of_migration

which computes the difference between the existing DB schema and the exposed table definitions, and creates a migration for it.

This is not something that could be merged yet as the Exposed definitions miss a lot of the DB schema, and the generated migration would remove constraints and columns from the database. Exposed needs to be in line with the DB schema (i.e. with PR #7138), but this might be useful after, if we want to remove having to write SQL and Exposed definitions. Although I guess with Claude you can now just ask it to write the corresponding SQL for you anyway 🙃

Screenshot

PR Checklist

  • All necessary documentation has been adapted.
  • The implemented feature is covered by appropriate, automated tests.
  • Any manual testing that has been done is documented (i.e. what exactly was tested?)

🚀 Preview: Add preview label to enable

@claude claude Bot added the backend related to the loculus backend component label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend related to the loculus backend component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant