From ebeedadb2d3604941309122542d260a4bbd9268e Mon Sep 17 00:00:00 2001 From: tdruez Date: Tue, 6 Aug 2024 16:15:37 +0400 Subject: [PATCH] Consolidate migrations files into one single file #138 Signed-off-by: tdruez --- .../commands/fetchvulnerabilities.py | 2 +- .../migrations/0006_vulnerability.py | 140 +++--------------- ...nerability_affected_components_and_more.py | 23 --- ...emove_vulnerability_created_by_and_more.py | 21 --- 4 files changed, 19 insertions(+), 167 deletions(-) delete mode 100644 component_catalog/migrations/0007_vulnerability_affected_components_and_more.py delete mode 100644 component_catalog/migrations/0008_remove_vulnerability_created_by_and_more.py diff --git a/component_catalog/management/commands/fetchvulnerabilities.py b/component_catalog/management/commands/fetchvulnerabilities.py index 8bf539d6..2a89d7ea 100644 --- a/component_catalog/management/commands/fetchvulnerabilities.py +++ b/component_catalog/management/commands/fetchvulnerabilities.py @@ -72,7 +72,7 @@ def add_arguments(self, parser): parser.add_argument( "--batch-size", type=int, - default=10, + default=50, help="Specifies the number of objects per requests to the VulnerableCode service", ) parser.add_argument( diff --git a/component_catalog/migrations/0006_vulnerability.py b/component_catalog/migrations/0006_vulnerability.py index f891b8bb..a62c03d6 100644 --- a/component_catalog/migrations/0006_vulnerability.py +++ b/component_catalog/migrations/0006_vulnerability.py @@ -1,142 +1,38 @@ -# Generated by Django 5.0.6 on 2024-07-15 10:33 +# Generated by Django 5.0.6 on 2024-08-06 12:14 import django.db.models.deletion import dje.fields import uuid -from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ("component_catalog", "0005_remove_component_concluded_license_and_more"), - ("dje", "0003_alter_dejacodeuser_homepage_layout"), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('component_catalog', '0005_remove_component_concluded_license_and_more'), + ('dje', '0003_alter_dejacodeuser_homepage_layout'), ] operations = [ migrations.CreateModel( - name="Vulnerability", + name='Vulnerability', fields=[ - ( - "id", - models.AutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ( - "uuid", - models.UUIDField( - default=uuid.uuid4, editable=False, verbose_name="UUID" - ), - ), - ( - "created_date", - models.DateTimeField( - auto_now_add=True, - db_index=True, - help_text="The date and time the object was created.", - ), - ), - ( - "last_modified_date", - models.DateTimeField( - auto_now=True, - db_index=True, - help_text="The date and time the object was last modified.", - ), - ), - ( - "vulnerability_id", - models.CharField( - help_text="A unique identifier for the vulnerability, prefixed with 'VCID-'. For example, 'VCID-2024-0001'.", - max_length=20, - unique=True, - ), - ), - ( - "summary", - models.TextField( - blank=True, - help_text="A brief summary of the vulnerability, outlining its nature and impact.", - ), - ), - ( - "aliases", - dje.fields.JSONListField( - blank=True, - default=list, - help_text="A list of aliases for this vulnerability, such as CVE identifiers (e.g., 'CVE-2017-1000136').", - ), - ), - ( - "references", - dje.fields.JSONListField( - blank=True, - default=list, - help_text="A list of references for this vulnerability. Each reference includes a URL, an optional reference ID, scores, and the URL for further details. ", - ), - ), - ( - "fixed_packages", - dje.fields.JSONListField( - blank=True, - default=list, - help_text="A list of packages that are not affected by this vulnerability.", - ), - ), - ( - "affected_packages", - models.ManyToManyField( - help_text="Packages that are affected by this vulnerability.", - related_name="affected_by_vulnerabilities", - to="component_catalog.package", - ), - ), - ( - "created_by", - models.ForeignKey( - editable=False, - help_text="The application user who created the object.", - null=True, - on_delete=django.db.models.deletion.PROTECT, - related_name="created_%(class)ss", - serialize=False, - to=settings.AUTH_USER_MODEL, - ), - ), - ( - "dataspace", - models.ForeignKey( - editable=False, - help_text="A Dataspace is an independent, exclusive set of DejaCode data, which can be either nexB master reference data or installation-specific data.", - on_delete=django.db.models.deletion.PROTECT, - to="dje.dataspace", - ), - ), - ( - "last_modified_by", - dje.fields.LastModifiedByField( - editable=False, - help_text="The application user who last modified the object.", - null=True, - on_delete=django.db.models.deletion.PROTECT, - related_name="modified_%(class)ss", - serialize=False, - to=settings.AUTH_USER_MODEL, - ), - ), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')), + ('created_date', models.DateTimeField(auto_now_add=True, db_index=True, help_text='The date and time the object was created.')), + ('last_modified_date', models.DateTimeField(auto_now=True, db_index=True, help_text='The date and time the object was last modified.')), + ('vulnerability_id', models.CharField(help_text="A unique identifier for the vulnerability, prefixed with 'VCID-'. For example, 'VCID-2024-0001'.", max_length=20, unique=True)), + ('summary', models.TextField(blank=True, help_text='A brief summary of the vulnerability, outlining its nature and impact.')), + ('aliases', dje.fields.JSONListField(blank=True, default=list, help_text="A list of aliases for this vulnerability, such as CVE identifiers (e.g., 'CVE-2017-1000136').")), + ('references', dje.fields.JSONListField(blank=True, default=list, help_text='A list of references for this vulnerability. Each reference includes a URL, an optional reference ID, scores, and the URL for further details. ')), + ('fixed_packages', dje.fields.JSONListField(blank=True, default=list, help_text='A list of packages that are not affected by this vulnerability.')), + ('affected_components', models.ManyToManyField(help_text='Components affected by this vulnerability.', related_name='affected_by_vulnerabilities', to='component_catalog.component')), + ('affected_packages', models.ManyToManyField(help_text='Packages affected by this vulnerability.', related_name='affected_by_vulnerabilities', to='component_catalog.package')), + ('dataspace', models.ForeignKey(editable=False, help_text='A Dataspace is an independent, exclusive set of DejaCode data, which can be either nexB master reference data or installation-specific data.', on_delete=django.db.models.deletion.PROTECT, to='dje.dataspace')), ], options={ - "verbose_name_plural": "Vulnerabilities", - "unique_together": { - ("dataspace", "uuid"), - ("dataspace", "vulnerability_id"), - }, + 'verbose_name_plural': 'Vulnerabilities', + 'unique_together': {('dataspace', 'uuid'), ('dataspace', 'vulnerability_id')}, }, ), ] diff --git a/component_catalog/migrations/0007_vulnerability_affected_components_and_more.py b/component_catalog/migrations/0007_vulnerability_affected_components_and_more.py deleted file mode 100644 index a4432b9f..00000000 --- a/component_catalog/migrations/0007_vulnerability_affected_components_and_more.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 5.0.6 on 2024-08-05 07:34 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('component_catalog', '0006_vulnerability'), - ] - - operations = [ - migrations.AddField( - model_name='vulnerability', - name='affected_components', - field=models.ManyToManyField(help_text='Components affected by this vulnerability.', related_name='affected_by_vulnerabilities', to='component_catalog.component'), - ), - migrations.AlterField( - model_name='vulnerability', - name='affected_packages', - field=models.ManyToManyField(help_text='Packages affected by this vulnerability.', related_name='affected_by_vulnerabilities', to='component_catalog.package'), - ), - ] diff --git a/component_catalog/migrations/0008_remove_vulnerability_created_by_and_more.py b/component_catalog/migrations/0008_remove_vulnerability_created_by_and_more.py deleted file mode 100644 index 872f9e5a..00000000 --- a/component_catalog/migrations/0008_remove_vulnerability_created_by_and_more.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 5.0.6 on 2024-08-05 13:56 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('component_catalog', '0007_vulnerability_affected_components_and_more'), - ] - - operations = [ - migrations.RemoveField( - model_name='vulnerability', - name='created_by', - ), - migrations.RemoveField( - model_name='vulnerability', - name='last_modified_by', - ), - ]