diff --git a/docs/development/design.rst b/docs/development/design.rst index e27ce0666ba5a96b88eaf12c5a7f631df4b510a5..ed8cfaf490cd505470ecfa5ce71eea41ae57f5d4 100644 --- a/docs/development/design.rst +++ b/docs/development/design.rst @@ -162,6 +162,31 @@ has the proper access (based on the network):: if not current_user.has_access_to_network(interface.network): abort(403) +Database versioning +------------------- + +SQLAlchemy-Continuum_ is used to track changes and keep an history. + +To enable versioning on a models, the ``__versioned__`` attribute shall be added to the model class. +The following classes are versioned: + +- :class:`~app.models.Item` +- :class:`~app.models.Host` +- :class:`~app.models.AnsibleGroup` + +The *History* on the view host or view group page displays the list of changes performed. +As there is a relationship between Host and AnsibleGroup, it can lead to unexpected behavior. + +1. Edit a group to add a host -> new host added to the group history +2. Edit another host to add it to that group -> new group added to the host history + +At this point the group page will show 2 hosts but only one was added in the history. +If the group is edited, to add a variable, the recorded change will display all current hosts in the history. +This is correct as those hosts were present when the group was edited. +But the information showing the hosts were added previously is missing. +This is a limitation of the current implementation. + + .. _Flask: https://flask.palletsprojects.com .. _The Flask Mega-Tutorial: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world @@ -171,3 +196,4 @@ has the proper access (based on the network):: .. _Elasticsearch: https://www.elastic.co/elasticsearch/ .. _RQ: https://python-rq.org .. _alembic: https://alembic.sqlalchemy.org +.. _SQLAlchemy-Continuum: https://sqlalchemy-continuum.readthedocs.io/en/latest/