mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 01:47:31 -02:30
* wfjt migration to catch renaming * Added rename_wfjt function to template constraint migration * Add test to add duplicate names and verify that the duplicates are renamed * move object creation * add missing rename_wfjt operation * fix linter issues * fix tox issues * test manually and move operation * added back credential type validation code
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
# Generated by Django 4.2.20 on 2025-04-22 15:54
|
|
|
|
import logging
|
|
|
|
from django.db import migrations, models
|
|
|
|
from awx.main.migrations._db_constraints import _rename_duplicates
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def rename_jts(apps, schema_editor):
|
|
cls = apps.get_model('main', 'JobTemplate')
|
|
_rename_duplicates(cls)
|
|
|
|
|
|
def rename_projects(apps, schema_editor):
|
|
cls = apps.get_model('main', 'Project')
|
|
_rename_duplicates(cls)
|
|
|
|
|
|
def change_inventory_source_org_unique(apps, schema_editor):
|
|
cls = apps.get_model('main', 'InventorySource')
|
|
r = cls.objects.update(org_unique=False)
|
|
logger.info(f'Set database constraint rule for {r} inventory source objects')
|
|
|
|
|
|
def rename_wfjt(apps, schema_editor):
|
|
cls = apps.get_model('main', 'WorkflowJobTemplate')
|
|
_rename_duplicates(cls)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('main', '0199_inventorygroupvariableswithhistory_and_more'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(rename_jts, migrations.RunPython.noop),
|
|
migrations.RunPython(rename_projects, migrations.RunPython.noop),
|
|
migrations.AddField(
|
|
model_name='unifiedjobtemplate',
|
|
name='org_unique',
|
|
field=models.BooleanField(blank=True, default=True, editable=False, help_text='Used internally to selectively enforce database constraint on name'),
|
|
),
|
|
migrations.RunPython(rename_wfjt, migrations.RunPython.noop),
|
|
migrations.RunPython(change_inventory_source_org_unique, migrations.RunPython.noop),
|
|
migrations.AddConstraint(
|
|
model_name='unifiedjobtemplate',
|
|
constraint=models.UniqueConstraint(
|
|
condition=models.Q(('org_unique', True)), fields=('polymorphic_ctype', 'name', 'organization'), name='ujt_hard_name_constraint'
|
|
),
|
|
),
|
|
]
|