How to add a field to models.yml - OpenSlides/OpenSlides GitHub Wiki
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/
.
- Add the field to the models.yml in repository
openslides-backend
, directoryglobals/meta
, see here. - Complement it in the Documentation, especially in related action descriptions.
- 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.
- For complex migration code you should write tests, for example see here.
- Edit initial-data.json and add the field to the initial-data, if needed. Set the
_migration_index
to thetarget_migration_index
of your migration-file. - Edit example-data.json and add the field if needed.
- 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.
- Call
- Send a pull request to the backend repo. Github uses the same tests as above and all of them are required to pass.
- The pull request will sent notifications to some registered users, because the autoupdate-service needs some actions, too, see here