Skip to content

New backend with Django and PostgreSQL

schmidbe requested to merge django into staging

This PR reimplements the whole backend using Django with PostgreSQL.

This has several advantages:

  • We can get rid of MongoDB. VIS does not want any new projects with MongoDB and wants to migrate existing ones. Furthermore, most of the bugs we had with the old backend were due to there being no schema for the database.
  • By using Django we can much easier split the code into manageable modules. While the old backend was mostly one single file with around 3000 LOC, the new backend is split into several modules and several files per module. This makes the code a lot easier to understand for new (and existing) contributors. This also simplifies adding new features.
  • Django already provides a lot of features we had to reimplement in the old backend (e.g. CSRF protection).
  • Django provides an easy way to write tests. So far, we had no tests for the backend...

The current PR reimplements all features of the old backend. Some API endpoints now have a different path and some return the data in a slightly different format. The necessary changes in the frontend were already made.

In backend/mongodb_migration/management/commands/migrate_mongodb.py there is a script to migrate all data from the current MongoDB into the new PostgreSQL database. It can be called with ./manage.py migrate_mongodb (and some flags, depending on the usecase). It will iterate through all objects in the old database and create corresponding objects in the new database. Furthermore, we check that all attributes of the old object were read so we don't forget anything.

Especially the migration script should be checked carefully as we might otherwise lose data when we migrate.

Edited by schmidbe

Merge request reports

Loading