How to add a field to models.yml - OpenSlides/OpenSlides GitHub Wiki

Introduction

The central point of administering the logical data models of the openslides database is the file models.yml in the openslides-backend repository, directory global/meta/.

Steps to do

  1. Add the field to the models.yml in repository openslides-backend, directory globals/meta, see here.
  2. Complement it in the Documentation, especially in related action descriptions.
  3. Write migration code in the backend. This is needed, if you want to fill some initial data into existing databases. It is necessary, if the new field is required or has a default value. Here you will find a simple migration file. A link to more complex migration code you'll find here.
  4. For complex migration code you should write tests, for example see here.
  5. Edit initial-data.json and add the field to the initial-data, if needed. Set the _migration_index to the target_migration_index of your migration-file.
  6. Edit example-data.json and add the field if needed.
  7. To create the necessary models.py, you need the environment. With some python experience you could build a virtualenv using the dev/requirements-development.txt. The easiest way is the docker-way: make run-dev build a working docker setup. There you'll have a terminal for further commands:
    • Call make generate-models to generate the models.py
    • Call make check-all checks, if models.yml, models.py, initial-data.json and example-data.json are valid and up-to-date
    • Call make test calls all the backend-tests.
  8. Send a pull request to the backend repo. Github uses the same tests as above and all of them are required to pass.
  9. The pull request will sent notifications to some registered users, because the autoupdate-service needs some actions, too, see here
⚠️ **GitHub.com Fallback** ⚠️