mirror of
https://github.com/ansible/awx.git
synced 2026-08-01 02:19:55 -02:30
add model fact recent
* Copy of the most recent system tracking fact for each module type. Utimately, this allows us to GIN index the jsonb object to support fact searching.
This commit is contained in:
43
awx/main/migrations/0037_v320_fact_recent.py
Normal file
43
awx/main/migrations/0037_v320_fact_recent.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Python
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# Django
|
||||
from django.db import migrations, models
|
||||
|
||||
from psycopg2.extensions import AsIs
|
||||
|
||||
# AWX
|
||||
import awx.main.fields
|
||||
from awx.main.models import FactRecent
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0036_v311_insights'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='FactRecent',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('timestamp', models.DateTimeField(default=None, help_text='Date and time of the corresponding fact scan gathering time.', editable=False)),
|
||||
('module', models.CharField(max_length=128)),
|
||||
('facts', awx.main.fields.JSONBField(default={}, help_text='Arbitrary JSON structure of module facts captured at timestamp for a single host.', blank=True)),
|
||||
('host', models.ForeignKey(related_name='facts_recent', to='main.Host', help_text='Host for the facts that the fact scan captured.')),
|
||||
],
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='fact',
|
||||
name='facts',
|
||||
field=awx.main.fields.JSONBField(default={}, help_text='Arbitrary JSON structure of module facts captured at timestamp for a single host.', blank=True),
|
||||
),
|
||||
migrations.AlterIndexTogether(
|
||||
name='factrecent',
|
||||
index_together=set([('timestamp', 'module', 'host')]),
|
||||
),
|
||||
migrations.RunSQL([("CREATE INDEX fact_recent_facts_default_gin ON %s USING gin"
|
||||
"(facts jsonb_path_ops);", [AsIs(FactRecent._meta.db_table)])]),
|
||||
]
|
||||
Reference in New Issue
Block a user