From b40e8d15c02847dc403d7d07e4d59994722ebf6d Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Thu, 15 Apr 2021 21:25:59 -0400 Subject: [PATCH] Fix migration bug Bump migration number Skip data migration for fresh migrations where ContentType for custom inventory scripts has not yet been created no scripts will exist in this case, so no-op --- ...data.py => 0137_custom_inventory_scripts_removal_data.py} | 2 +- ...s_removal.py => 0138_custom_inventory_scripts_removal.py} | 2 +- awx/main/migrations/_rbac.py | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) rename awx/main/migrations/{0136_custom_inventory_scripts_removal_data.py => 0137_custom_inventory_scripts_removal_data.py} (89%) rename awx/main/migrations/{0137_custom_inventory_scripts_removal.py => 0138_custom_inventory_scripts_removal.py} (97%) diff --git a/awx/main/migrations/0136_custom_inventory_scripts_removal_data.py b/awx/main/migrations/0137_custom_inventory_scripts_removal_data.py similarity index 89% rename from awx/main/migrations/0136_custom_inventory_scripts_removal_data.py rename to awx/main/migrations/0137_custom_inventory_scripts_removal_data.py index 7ade393641..bb965de3ab 100644 --- a/awx/main/migrations/0136_custom_inventory_scripts_removal_data.py +++ b/awx/main/migrations/0137_custom_inventory_scripts_removal_data.py @@ -10,7 +10,7 @@ from awx.main.migrations._inventory_source import delete_custom_inv_source class Migration(migrations.Migration): dependencies = [ - ('main', '0135_schedule_sort_fallback_to_id'), + ('main', '0136_scm_track_submodules'), ] operations = [ diff --git a/awx/main/migrations/0137_custom_inventory_scripts_removal.py b/awx/main/migrations/0138_custom_inventory_scripts_removal.py similarity index 97% rename from awx/main/migrations/0137_custom_inventory_scripts_removal.py rename to awx/main/migrations/0138_custom_inventory_scripts_removal.py index 10bfdc9484..fb781c8648 100644 --- a/awx/main/migrations/0137_custom_inventory_scripts_removal.py +++ b/awx/main/migrations/0138_custom_inventory_scripts_removal.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('main', '0136_custom_inventory_scripts_removal_data'), + ('main', '0137_custom_inventory_scripts_removal_data'), ] operations = [ diff --git a/awx/main/migrations/_rbac.py b/awx/main/migrations/_rbac.py index 480fdd8929..7f120645ef 100644 --- a/awx/main/migrations/_rbac.py +++ b/awx/main/migrations/_rbac.py @@ -50,7 +50,10 @@ def delete_all_user_roles(apps, schema_editor): def delete_all_custom_script_roles(apps, schema_editor): ContentType = apps.get_model('contenttypes', "ContentType") Role = apps.get_model('main', "Role") - cis_type = ContentType.objects.get(model='custominventoryscript') + try: + cis_type = ContentType.objects.get(model='custominventoryscript') + except ContentType.DoesNotExist: + return role_ct = 0 for role in Role.objects.filter(content_type=cis_type).iterator(): role.delete()