diff --git a/dongtai_common/migrations/0005_iastprojectmetadata.py b/dongtai_common/migrations/0005_iastprojectmetadata.py new file mode 100644 index 000000000..f6e83ee36 --- /dev/null +++ b/dongtai_common/migrations/0005_iastprojectmetadata.py @@ -0,0 +1,30 @@ +# Generated by Django 3.2.20 on 2023-08-01 11:33 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('dongtai_common', '0004_auto_20230731_1556'), + ] + + operations = [ + migrations.CreateModel( + name='IastProjectMetaData', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('api_count', models.IntegerField(default=0, help_text='API数量统计')), + ('vul_api_count', models.IntegerField(default=0, help_text='漏洞API数量统计')), + ('create_at', models.DateTimeField(auto_now_add=True, null=True)), + ('update_at', models.DateTimeField(auto_now=True, null=True)), + ('project', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to='dongtai_common.iastproject')), + ('project_version', models.ForeignKey(blank=True, db_constraint=False, default=-1, on_delete=django.db.models.deletion.DO_NOTHING, to='dongtai_common.iastprojectversion')), + ], + options={ + 'db_table': 'iast_project_meta_data', + 'managed': True, + }, + ), + ] diff --git a/dongtai_common/models/__init__.py b/dongtai_common/models/__init__.py index 54a4daa44..c02214369 100644 --- a/dongtai_common/models/__init__.py +++ b/dongtai_common/models/__init__.py @@ -4,6 +4,7 @@ from .user import User # noqa: I001, F401 from . import api_route # noqa: F401 from .project_group import IastProjectGroup # noqa: F401 +from .project_metadata import IastProjectMetaData # noqa: F401 LANGUAGE_DICT = {"JAVA": 1, "PYTHON": 2, "PHP": 3, "GO": 4} # aggregation diff --git a/dongtai_common/models/project_metadata.py b/dongtai_common/models/project_metadata.py index 9051584d0..af84e55a5 100644 --- a/dongtai_common/models/project_metadata.py +++ b/dongtai_common/models/project_metadata.py @@ -9,8 +9,10 @@ class IastProjectMetaData(models.Model): - project = models.ForeignKey(IastProject, models.CASCADE) - project_version = models.ForeignKey(IastProjectVersion, on_delete=models.DO_NOTHING, blank=True, default=-1) + project = models.ForeignKey(IastProject, models.CASCADE, db_constraint=False) + project_version = models.ForeignKey( + IastProjectVersion, on_delete=models.DO_NOTHING, blank=True, default=-1, db_constraint=False + ) api_count = models.IntegerField(help_text="API数量统计", default=0) vul_api_count = models.IntegerField(help_text="漏洞API数量统计", default=0) create_at = models.DateTimeField(auto_now_add=True, blank=True, null=True)