From 0126c026ff60f43bdb10abd6cc055e0d6f917b04 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 10:39:00 +0000 Subject: [PATCH 1/2] [skip ci] Updated CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16551b6..c467986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [Unreleased](https://github.com/Onemind-Services-LLC/netbox-secrets/tree/HEAD) + +[Full Changelog](https://github.com/Onemind-Services-LLC/netbox-secrets/compare/v1.8.3...HEAD) + +**Closed issues:** + +- \[Bug\]: Migration Failure due to previous bug [\#73](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/73) + +**Merged pull requests:** + +- Prepare for release [\#74](https://github.com/Onemind-Services-LLC/netbox-secrets/pull/74) ([kprince28](https://github.com/kprince28)) +- Fix copy of data in migration [\#72](https://github.com/Onemind-Services-LLC/netbox-secrets/pull/72) ([kprince28](https://github.com/kprince28)) + ## [v1.8.3](https://github.com/Onemind-Services-LLC/netbox-secrets/tree/v1.8.3) (2023-06-02) [Full Changelog](https://github.com/Onemind-Services-LLC/netbox-secrets/compare/v1.8.2...v1.8.3) From 3a45362a476ab86a564fff0016ab8ae21bdaa888 Mon Sep 17 00:00:00 2001 From: kprince28 Date: Wed, 14 Jun 2023 10:33:45 +0530 Subject: [PATCH 2/2] fix migration to skip deleted devices and virtual_machines --- ...t__object_repr_secret_comments_and_more.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/netbox_secrets/migrations/0007_secret__object_repr_secret_comments_and_more.py b/netbox_secrets/migrations/0007_secret__object_repr_secret_comments_and_more.py index 8565bd2..0e2d22c 100644 --- a/netbox_secrets/migrations/0007_secret__object_repr_secret_comments_and_more.py +++ b/netbox_secrets/migrations/0007_secret__object_repr_secret_comments_and_more.py @@ -6,15 +6,16 @@ def copy_assigned_object(apps, schema_editor): Secret = apps.get_model('netbox_secrets', 'Secret') - try: - for secret in Secret.objects.all(): - content_type = ContentType.objects.get(id=secret.assigned_object_type_id) - Model = apps.get_model(content_type.app_label, str(content_type.model).capitalize()) - object = Model.objects.filter(id=secret.assigned_object_id).first() - secret._object_repr = object.name - secret.save() - except: - pass + for secret in Secret.objects.all(): + content_type = ContentType.objects.get(id=secret.assigned_object_type_id) + Model = apps.get_model(content_type.app_label, str(content_type.model).capitalize()) + object = Model.objects.filter(id=secret.assigned_object_id).first() + if not object: + continue + secret._object_repr = object.name + secret.save() + + class Migration(migrations.Migration):