Merge pull request #6494 from ryanpetrello/quiter-pg-migration

detect event migration tables in a less noisy way

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2020-03-31 14:30:15 +00:00
committed by GitHub

View File

@@ -3,7 +3,7 @@
# Django # Django
from django.conf import settings # noqa from django.conf import settings # noqa
from django.db import connection, ProgrammingError from django.db import connection
from django.db.models.signals import pre_delete # noqa from django.db.models.signals import pre_delete # noqa
# AWX # AWX
@@ -91,14 +91,13 @@ def enforce_bigint_pk_migration():
'main_systemjobevent' 'main_systemjobevent'
): ):
with connection.cursor() as cursor: with connection.cursor() as cursor:
try: cursor.execute(
cursor.execute(f'SELECT MAX(id) FROM _old_{tblname}') 'SELECT 1 FROM information_schema.tables WHERE table_name=%s',
if cursor.fetchone(): (f'_old_{tblname}',)
from awx.main.tasks import migrate_legacy_event_data )
migrate_legacy_event_data.apply_async([tblname]) if bool(cursor.rowcount):
except ProgrammingError: from awx.main.tasks import migrate_legacy_event_data
# the table is gone (migration is unnecessary) migrate_legacy_event_data.apply_async([tblname])
pass
def cleanup_created_modified_by(sender, **kwargs): def cleanup_created_modified_by(sender, **kwargs):