From cdc342a6eec75a53ba5cb0f35053b570dcef47e6 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 11 Mar 2016 12:59:21 -0500 Subject: [PATCH] Fix fact database migration For new installs the database may not be online and thus the migration can't happen. This will allow it to continue but we may want more messaging to the user running potential upgrades --- .../{0004_v300_fact_changes.py => 0004_v300_changes.py} | 0 .../{0005_v300_fact_migrations.py => 0005_v300_changes.py} | 2 +- awx/main/migrations/0006_v300_changes.py | 2 +- awx/main/migrations/_system_tracking.py | 7 ++++++- 4 files changed, 8 insertions(+), 3 deletions(-) rename awx/main/migrations/{0004_v300_fact_changes.py => 0004_v300_changes.py} (100%) rename awx/main/migrations/{0005_v300_fact_migrations.py => 0005_v300_changes.py} (87%) diff --git a/awx/main/migrations/0004_v300_fact_changes.py b/awx/main/migrations/0004_v300_changes.py similarity index 100% rename from awx/main/migrations/0004_v300_fact_changes.py rename to awx/main/migrations/0004_v300_changes.py diff --git a/awx/main/migrations/0005_v300_fact_migrations.py b/awx/main/migrations/0005_v300_changes.py similarity index 87% rename from awx/main/migrations/0005_v300_fact_migrations.py rename to awx/main/migrations/0005_v300_changes.py index 8362227c2f..70dea77778 100644 --- a/awx/main/migrations/0005_v300_fact_migrations.py +++ b/awx/main/migrations/0005_v300_changes.py @@ -7,7 +7,7 @@ from django.db import migrations class Migration(migrations.Migration): dependencies = [ - ('main', '0004_v300_fact_changes'), + ('main', '0004_v300_changes'), ] operations = [ diff --git a/awx/main/migrations/0006_v300_changes.py b/awx/main/migrations/0006_v300_changes.py index fb2e4a1b7c..4d60f2c795 100644 --- a/awx/main/migrations/0006_v300_changes.py +++ b/awx/main/migrations/0006_v300_changes.py @@ -107,7 +107,7 @@ def create_system_job_templates(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('main', '0005_v300_fact_migrations'), + ('main', '0005_v300_changes'), ] operations = [ diff --git a/awx/main/migrations/_system_tracking.py b/awx/main/migrations/_system_tracking.py index 95fdb62c2e..e5be20f4ef 100644 --- a/awx/main/migrations/_system_tracking.py +++ b/awx/main/migrations/_system_tracking.py @@ -16,7 +16,12 @@ def migrate_facts(apps, schema_editor): Fact = apps.get_model('main', "Fact") Host = apps.get_model('main', "Host") - # TODO: Check to see if mongo connection works and mongo is on. + try: + n = FactVersion.objects.all().count() + except ConnectionError: + # TODO: Let the user know about the error. Likely this is + # a new install and we just don't need to do this + return (0, 0) migrated_count = 0 not_migrated_count = 0