diff --git a/nautobot_device_lifecycle_mgmt/migrations/0004_squash__0004_0014_0015_0016.py b/nautobot_device_lifecycle_mgmt/migrations/0004_squash__0004_0014_0015_0016.py new file mode 100644 index 00000000..ce31f691 --- /dev/null +++ b/nautobot_device_lifecycle_mgmt/migrations/0004_squash__0004_0014_0015_0016.py @@ -0,0 +1,72 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("dcim", "0005_device_local_context_schema"), + ("extras", "0013_default_fallback_value_computedfield"), + ("nautobot_device_lifecycle_mgmt", "0003_service_contracts"), + ] + + replaces = [ + ("nautobot_device_lifecycle_mgmt", "0004_validated_software_m2m"), + ("nautobot_device_lifecycle_mgmt", "0014_pre_nautobot_v2_migrations"), + ("nautobot_device_lifecycle_mgmt", "0015_role_migration"), + ("nautobot_device_lifecycle_mgmt", "0016_role_migration_cleanup"), + ] + + operations = [ + # 0004_validated_software_m2m + migrations.AlterModelOptions( + name="softwarelcm", + options={ + "ordering": ("device_platform", "version", "end_of_support", "release_date"), + "verbose_name": "Software", + }, + ), + migrations.AddField( + model_name="validatedsoftwarelcm", + name="device_roles", + field=models.ManyToManyField( + blank=True, related_name="_validatedsoftwarelcm_device_roles_+", to="extras.Role" + ), + ), + migrations.AddField( + model_name="validatedsoftwarelcm", + name="device_types", + field=models.ManyToManyField( + blank=True, related_name="_validatedsoftwarelcm_device_types_+", to="dcim.DeviceType" + ), + ), + migrations.AddField( + model_name="validatedsoftwarelcm", + name="devices", + field=models.ManyToManyField(blank=True, related_name="_validatedsoftwarelcm_devices_+", to="dcim.Device"), + ), + migrations.AddField( + model_name="validatedsoftwarelcm", + name="inventory_items", + field=models.ManyToManyField( + blank=True, related_name="_validatedsoftwarelcm_inventory_items_+", to="dcim.InventoryItem" + ), + ), + migrations.AddField( + model_name="validatedsoftwarelcm", + name="object_tags", + field=models.ManyToManyField( + blank=True, related_name="_validatedsoftwarelcm_object_tags_+", to="extras.Tag" + ), + ), + migrations.AlterUniqueTogether( + name="validatedsoftwarelcm", + unique_together=set(), + ), + migrations.RemoveField( + model_name="validatedsoftwarelcm", + name="assigned_to_content_type", + ), + migrations.RemoveField( + model_name="validatedsoftwarelcm", + name="assigned_to_object_id", + ), + ] diff --git a/nautobot_device_lifecycle_mgmt/migrations/0014_pre_nautobot_v2_migrations.py b/nautobot_device_lifecycle_mgmt/migrations/0014_pre_nautobot_v2_migrations.py index 2e12d761..348cddea 100644 --- a/nautobot_device_lifecycle_mgmt/migrations/0014_pre_nautobot_v2_migrations.py +++ b/nautobot_device_lifecycle_mgmt/migrations/0014_pre_nautobot_v2_migrations.py @@ -1,11 +1,10 @@ from django.db import migrations, models -import nautobot.core.models.fields class Migration(migrations.Migration): dependencies = [ ("extras", "0062_collect_roles_from_related_apps_roles"), - ("nautobot_device_lifecycle_mgmt", "0013_alter_softwareimagelcm_device_types"), + ("nautobot_device_lifecycle_mgmt", "0004_validated_software_m2m"), ] operations = [ @@ -21,109 +20,4 @@ class Migration(migrations.Migration): old_name="device_roles", new_name="legacy_roles", ), - migrations.AlterField( - model_name="contactlcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="contactlcm", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="contractlcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="contractlcm", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="cvelcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="cvelcm", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="devicesoftwarevalidationresult", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="devicesoftwarevalidationresult", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="hardwarelcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="hardwarelcm", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="inventoryitemsoftwarevalidationresult", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="inventoryitemsoftwarevalidationresult", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="providerlcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="softwareimagelcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="softwareimagelcm", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="softwarelcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="softwarelcm", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="validatedsoftwarelcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="validatedsoftwarelcm", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), - migrations.AlterField( - model_name="vulnerabilitylcm", - name="created", - field=models.DateTimeField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name="vulnerabilitylcm", - name="tags", - field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), - ), ] diff --git a/nautobot_device_lifecycle_mgmt/migrations/0016_role_migration_cleanup.py b/nautobot_device_lifecycle_mgmt/migrations/0016_role_migration_cleanup.py index d25e05f8..41528152 100644 --- a/nautobot_device_lifecycle_mgmt/migrations/0016_role_migration_cleanup.py +++ b/nautobot_device_lifecycle_mgmt/migrations/0016_role_migration_cleanup.py @@ -1,4 +1,4 @@ -from django.db import migrations +from django.db import connection, migrations class Migration(migrations.Migration): @@ -6,7 +6,7 @@ class Migration(migrations.Migration): ("nautobot_device_lifecycle_mgmt", "0015_role_migration"), ] - run_before = [("dcim", "0031_remove_device_role_and_rack_role")] + nautobot_run_before = [("dcim", "0031_remove_device_role_and_rack_role")] operations = [ migrations.RemoveField( @@ -19,3 +19,18 @@ class Migration(migrations.Migration): new_name="device_roles", ), ] + + def __init__(self, name, app_label): + """ + Override the default __init__ method to conditionally set the run_before attribute based on whether + the first squashed migration has already been applied. This is necessary to ensure that the depdendency + graph generated by Django does not fail due to a circular dependency. + """ + super().__init__(name, app_label) + if self.nautobot_run_before: + recorder = migrations.recorder.MigrationRecorder(connection) + applied_migrations = recorder.applied_migrations() + if ("nautobot_device_onboarding", "0004_validated_software_m2m") in applied_migrations: + for migration in self.nautobot_run_before: + if migration not in applied_migrations: + self.run_before.append(migration) diff --git a/nautobot_device_lifecycle_mgmt/migrations/0017_set_default_on_text_fields.py b/nautobot_device_lifecycle_mgmt/migrations/0017_set_default_on_text_fields.py index deb852df..2dc046fd 100644 --- a/nautobot_device_lifecycle_mgmt/migrations/0017_set_default_on_text_fields.py +++ b/nautobot_device_lifecycle_mgmt/migrations/0017_set_default_on_text_fields.py @@ -83,7 +83,10 @@ def set_default_on_software_text_fields(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ("nautobot_device_lifecycle_mgmt", "0016_role_migration_cleanup"), + ("nautobot_device_lifecycle_mgmt", "0001_hardwarelcm"), + ("nautobot_device_lifecycle_mgmt", "0002_softwarelcm"), + ("nautobot_device_lifecycle_mgmt", "0003_service_contracts"), + ("nautobot_device_lifecycle_mgmt", "0006_cvelcm_vulnerabilitylcm"), ] operations = [ diff --git a/nautobot_device_lifecycle_mgmt/migrations/0020_alter_created_tags.py b/nautobot_device_lifecycle_mgmt/migrations/0020_alter_created_tags.py new file mode 100644 index 00000000..939e92d0 --- /dev/null +++ b/nautobot_device_lifecycle_mgmt/migrations/0020_alter_created_tags.py @@ -0,0 +1,127 @@ +from django.db import migrations, models + +import nautobot.core.models.fields + + +class Migration(migrations.Migration): + dependencies = [ + ("nautobot_device_lifecycle_mgmt", "0001_hardwarelcm"), + ("nautobot_device_lifecycle_mgmt", "0002_softwarelcm"), + ("nautobot_device_lifecycle_mgmt", "0003_service_contracts"), + ("nautobot_device_lifecycle_mgmt", "0005_software_reporting"), + ("nautobot_device_lifecycle_mgmt", "0006_cvelcm_vulnerabilitylcm"), + ("nautobot_device_lifecycle_mgmt", "0007_softwareimagelcm"), + # This migration does not actually depend on the below migrations but they are added here to + # prevent Django from failing to migrate due to multiple leaf nodes in the migration graph + ("nautobot_device_lifecycle_mgmt", "0013_alter_softwareimagelcm_device_types"), + ("nautobot_device_lifecycle_mgmt", "0016_role_migration_cleanup"), + ("nautobot_device_lifecycle_mgmt", "0019_cve_and_contract_m2m_migration"), + ] + + operations = [ + migrations.AlterField( + model_name="contactlcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="contactlcm", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="contractlcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="contractlcm", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="cvelcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="cvelcm", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="devicesoftwarevalidationresult", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="devicesoftwarevalidationresult", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="hardwarelcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="hardwarelcm", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="inventoryitemsoftwarevalidationresult", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="inventoryitemsoftwarevalidationresult", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="providerlcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="softwareimagelcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="softwareimagelcm", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="softwarelcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="softwarelcm", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="validatedsoftwarelcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="validatedsoftwarelcm", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + migrations.AlterField( + model_name="vulnerabilitylcm", + name="created", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AlterField( + model_name="vulnerabilitylcm", + name="tags", + field=nautobot.core.models.fields.TagsField(through="extras.TaggedItem", to="extras.Tag"), + ), + ]