mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
3.2.0 should not have any replacements defined unless 0005a or 0005b migrations have been run previously
This commit is contained in:
@@ -6,7 +6,12 @@ from __future__ import unicode_literals
|
|||||||
from psycopg2.extensions import AsIs
|
from psycopg2.extensions import AsIs
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.db import migrations, models
|
from django.db import (
|
||||||
|
connection,
|
||||||
|
migrations,
|
||||||
|
models,
|
||||||
|
OperationalError
|
||||||
|
)
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import taggit.managers
|
import taggit.managers
|
||||||
|
|
||||||
@@ -15,15 +20,23 @@ import awx.main.fields
|
|||||||
from awx.main.models import Host
|
from awx.main.models import Host
|
||||||
|
|
||||||
|
|
||||||
|
def replaces():
|
||||||
|
squashed = ['0005a_squashed_v310_v313_updates', '0005b_squashed_v310_v313_updates']
|
||||||
|
try:
|
||||||
|
recorder = migrations.recorder.MigrationRecorder(connection)
|
||||||
|
result = recorder.migration_qs.filter(app='main').filter(name__in=squashed).all()
|
||||||
|
return [('main', m.name) for m in result]
|
||||||
|
except OperationalError:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('main', '0005_squashed_v310_v313_updates'),
|
('main', '0005_squashed_v310_v313_updates'),
|
||||||
]
|
]
|
||||||
|
|
||||||
replaces = [
|
replaces = replaces()
|
||||||
('main', '0005a_squashed_v310_v313_updates'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
# Release UJT unique_together constraint
|
# Release UJT unique_together constraint
|
||||||
|
|||||||
@@ -22,11 +22,14 @@ def squash_data(squashed):
|
|||||||
return squashed_keys, key_index
|
return squashed_keys, key_index
|
||||||
|
|
||||||
|
|
||||||
def current_migration():
|
def current_migration(exclude_squashed=True):
|
||||||
'''Get the latest migration non-squashed migration'''
|
'''Get the latest migration non-squashed migration'''
|
||||||
try:
|
try:
|
||||||
recorder = migrations.recorder.MigrationRecorder(connection)
|
recorder = migrations.recorder.MigrationRecorder(connection)
|
||||||
return recorder.migration_qs.filter(app='main').exclude(name__contains='squashed').latest('id')
|
migration_qs = recorder.migration_qs.filter(app='main')
|
||||||
|
if exclude_squashed:
|
||||||
|
migration_qs = migration_qs.exclude(name__contains='squashed')
|
||||||
|
return migration_qs.latest('id')
|
||||||
except (recorder.Migration.DoesNotExist, OperationalError):
|
except (recorder.Migration.DoesNotExist, OperationalError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user