mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 22:37:41 -02:30
Register new column created by SQL
* .. using FakeAddField model type
* .. without doing this, Django won't know
about the field we created using raw SQL
This commit is contained in:
@@ -63,6 +63,16 @@ def migrate_event_data(apps, schema_editor):
|
|||||||
cursor.execute(
|
cursor.execute(
|
||||||
f'DROP TABLE {tblname}_old'
|
f'DROP TABLE {tblname}_old'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class FakeAddField(migrations.AddField):
|
||||||
|
|
||||||
|
def database_forwards(self, *args):
|
||||||
|
# this is intentionally left blank, because we're
|
||||||
|
# going to accomplish the migration with some custom raw SQL
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
@@ -71,4 +81,9 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(migrate_event_data),
|
migrations.RunPython(migrate_event_data),
|
||||||
|
FakeAddField(
|
||||||
|
model_name='jobevent',
|
||||||
|
name='job_created',
|
||||||
|
field=models.DateTimeField(editable=False),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -482,6 +482,9 @@ class JobEvent(BasePlaybookEvent):
|
|||||||
default='',
|
default='',
|
||||||
editable=False,
|
editable=False,
|
||||||
)
|
)
|
||||||
|
job_created = models.DateTimeField(
|
||||||
|
editable=False
|
||||||
|
)
|
||||||
|
|
||||||
def get_absolute_url(self, request=None):
|
def get_absolute_url(self, request=None):
|
||||||
return reverse('api:job_event_detail', kwargs={'pk': self.pk}, request=request)
|
return reverse('api:job_event_detail', kwargs={'pk': self.pk}, request=request)
|
||||||
|
|||||||
Reference in New Issue
Block a user