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
This commit is contained in:
Matthew Jones 2016-03-11 12:59:21 -05:00
parent c2ea9c3c00
commit cdc342a6ee
4 changed files with 8 additions and 3 deletions

View File

@ -7,7 +7,7 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0004_v300_fact_changes'),
('main', '0004_v300_changes'),
]
operations = [

View File

@ -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 = [

View File

@ -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