|
1 | | -# Vulnerability ID entity tables: the normalized VulnerabilityId registry and the ordered |
2 | | -# Finding -> VulnerabilityId reference table. Both tables are CREATED EMPTY here, so every index |
| 1 | +# Vulnerability ID entity tables: the normalized Vulnerability registry and the ordered |
| 2 | +# Finding -> Vulnerability reference table. Both tables are CREATED EMPTY here, so every index |
3 | 3 | # (including the two GIN indexes) is built on zero rows — the DDL is effectively instant and needs |
4 | 4 | # no AddIndexConcurrently. The data backfill runs separately in 0286 (atomic=False, resumable). |
5 | 5 | # |
6 | 6 | # >50M-row fallback (documented, NOT the default path): on installs where the subsequent 0286 |
7 | 7 | # backfill would insert tens of millions of reference rows, GIN maintenance during the backfill |
8 | | -# dominates. Such installs can strip the two GinIndex entries from the VulnerabilityId Meta here, |
| 8 | +# dominates. Such installs can strip the two GinIndex entries from the Vulnerability Meta here, |
9 | 9 | # let 0286 populate the tables, then add both GIN indexes with CREATE INDEX CONCURRENTLY in a |
10 | 10 | # follow-up migration. Not needed for typical installs. |
11 | 11 |
|
|
20 | 20 | class Migration(migrations.Migration): |
21 | 21 |
|
22 | 22 | dependencies = [ |
23 | | - ('dojo', '0284_backfill_finding_cwe'), |
| 23 | + ("dojo", "0284_backfill_finding_cwe"), |
24 | 24 | ] |
25 | 25 |
|
26 | 26 | operations = [ |
27 | 27 | migrations.CreateModel( |
28 | | - name='VulnerabilityId', |
| 28 | + name="Vulnerability", |
29 | 29 | fields=[ |
30 | | - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
31 | | - ('vulnerability_id', models.TextField(unique=True, verbose_name='Vulnerability Id')), |
32 | | - ('vulnerability_id_type', models.CharField(blank=True, db_index=True, editable=False, max_length=20, null=True)), |
33 | | - ('epss_score', models.FloatField(blank=True, default=None, null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])), |
34 | | - ('epss_percentile', models.FloatField(blank=True, default=None, null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])), |
35 | | - ('known_exploited', models.BooleanField(blank=True, default=None, null=True)), |
36 | | - ('ransomware_used', models.BooleanField(blank=True, default=None, null=True)), |
37 | | - ('kev_date', models.DateField(blank=True, default=None, null=True)), |
38 | | - ('created', models.DateTimeField(auto_now_add=True)), |
39 | | - ('updated', models.DateTimeField(auto_now=True)), |
| 30 | + ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), |
| 31 | + ("vulnerability_id", models.TextField(unique=True, verbose_name="Vulnerability Id")), |
| 32 | + ("vulnerability_id_type", models.CharField(blank=True, db_index=True, editable=False, max_length=20, null=True)), |
| 33 | + ("epss_score", models.FloatField(blank=True, default=None, null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])), |
| 34 | + ("epss_percentile", models.FloatField(blank=True, default=None, null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])), |
| 35 | + ("known_exploited", models.BooleanField(blank=True, default=None, null=True)), |
| 36 | + ("ransomware_used", models.BooleanField(blank=True, default=None, null=True)), |
| 37 | + ("kev_date", models.DateField(blank=True, default=None, null=True)), |
| 38 | + ("created", models.DateTimeField(auto_now_add=True)), |
| 39 | + ("updated", models.DateTimeField(auto_now=True)), |
40 | 40 | ], |
41 | 41 | options={ |
42 | | - 'indexes': [django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.search.SearchVector('vulnerability_id', config='english', weight='A'), name='dojo_vulnid_entity_fts_gin'), django.contrib.postgres.indexes.GinIndex(fields=['vulnerability_id'], name='dojo_vulnid_entity_trgm', opclasses=['gin_trgm_ops']), models.Index(django.db.models.functions.text.Upper('vulnerability_id'), name='dojo_vulnid_entity_upper')], |
| 42 | + "indexes": [django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.search.SearchVector("vulnerability_id", config="english", weight="A"), name="dojo_vulnid_entity_fts_gin"), django.contrib.postgres.indexes.GinIndex(fields=["vulnerability_id"], name="dojo_vulnid_entity_trgm", opclasses=["gin_trgm_ops"]), models.Index(django.db.models.functions.text.Upper("vulnerability_id"), name="dojo_vulnid_entity_upper")], |
43 | 43 | }, |
44 | 44 | ), |
45 | 45 | migrations.CreateModel( |
46 | | - name='FindingVulnerabilityReference', |
| 46 | + name="FindingVulnerabilityReference", |
47 | 47 | fields=[ |
48 | | - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
49 | | - ('order', models.PositiveSmallIntegerField(default=0, help_text="Position in the finding's id list; 0 is the primary identifier.")), |
50 | | - ('created', models.DateTimeField(auto_now_add=True)), |
51 | | - ('finding', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='vulnerability_references', to='dojo.finding')), |
52 | | - ('vulnerability', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='finding_references', to='dojo.vulnerabilityid')), |
| 48 | + ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), |
| 49 | + ("order", models.PositiveSmallIntegerField(default=0, help_text="Position in the finding's id list; 0 is the primary identifier.")), |
| 50 | + ("created", models.DateTimeField(auto_now_add=True)), |
| 51 | + ("finding", models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="vulnerability_references", to="dojo.finding")), |
| 52 | + ("vulnerability", models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="finding_references", to="dojo.vulnerability")), |
53 | 53 | ], |
54 | 54 | options={ |
55 | | - 'ordering': ['order'], |
56 | | - 'indexes': [models.Index(fields=['finding', 'order'], name='dojo_findin_finding_d1a7a8_idx'), models.Index(fields=['vulnerability'], name='dojo_findin_vulnera_13169c_idx')], |
57 | | - 'constraints': [models.UniqueConstraint(fields=('finding', 'vulnerability'), name='unique_finding_vulnerability')], |
| 55 | + "ordering": ["order"], |
| 56 | + "indexes": [models.Index(fields=["finding", "order"], name="dojo_findin_finding_d1a7a8_idx"), models.Index(fields=["vulnerability"], name="dojo_findin_vulnera_13169c_idx")], |
| 57 | + "constraints": [models.UniqueConstraint(fields=("finding", "vulnerability"), name="unique_finding_vulnerability"), models.UniqueConstraint(fields=("finding", "order"), name="unique_finding_order")], |
58 | 58 | }, |
59 | 59 | ), |
60 | 60 | ] |
0 commit comments