From cfd682c8b7fb7ffcf435891d0d1da1cccaa70aa3 Mon Sep 17 00:00:00 2001 From: Simon Hellmayr Date: Mon, 1 Jul 2024 10:11:31 +0200 Subject: [PATCH] add commit hash to github url and add information about model dependency graphs --- src/docs/database-migrations.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/docs/database-migrations.mdx b/src/docs/database-migrations.mdx index f9aada908a..02b39f0dec 100644 --- a/src/docs/database-migrations.mdx +++ b/src/docs/database-migrations.mdx @@ -91,12 +91,13 @@ To run the test locally, run `pytest` with `--migrations` flag. For example, `py ### Backup Testing When you add or change a model, an error message in CI may appear explaining that one or multiple tests "produced an `export.json` backup file that was missing the above models". In order to resolve this, there are two steps: -1. Add the new or modified model to the exhaustive organization in [testutils/helpers/backups.py](https://github.com/getsentry/sentry/blob/master/src/sentry/testutils/helpers/backups.py#L366) by creating an instance of your model, for example by invoking MyModel.objects.create(). This ensures the presence of the new model when creating the snapshot and during testing. +1. Add the new or modified model to the exhaustive organization in [testutils/helpers/backups.py](https://github.com/getsentry/sentry/blob/f9e6aa610340fd41cc13490aeda71b06bbc933c2/src/sentry/testutils/helpers/backups.py#L366) by creating an instance of your model, for example by invoking MyModel.objects.create(). This ensures the presence of the new model when creating the snapshot and during testing. 2. The snapshot files can be regenerated using the following command: ``` SENTRY_SNAPSHOTS_WRITEBACK=1 pytest tests/sentry/backup/test_sanitize.py ``` +There are also tests for model dependencies that make use of automatically generated fixtures in tests/sentry/backup/test_dependencies.py. These tests will fail if they are not updated when a new model with dependencies on other models is added, or dependencies are modified. In order to re-generate the model dependency graphs, you can run bin/generate-model-dependency-fixtures. #### Notes