Skip to content

Commit

Permalink
Merge pull request #75 from Onemind-Services-LLC/fix/migration
Browse files Browse the repository at this point in the history
Fix migration to skip deleted devices and virtual machines
  • Loading branch information
abhi1693 authored Jun 19, 2023
2 parents 1b545de + c793f3a commit 0b41317
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0b41317

Please sign in to comment.