You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by gj...@apache.org on 2021/09/08 00:17:09 UTC

[bloodhound-core] branch main updated: Update models to match legacy db column names

This is an automated email from the ASF dual-hosted git repository.

gjm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/bloodhound-core.git


The following commit(s) were added to refs/heads/main by this push:
     new 22b632f  Update models to match legacy db column names
22b632f is described below

commit 22b632fc8cc692e11afd93614a4705267bf0a263
Author: Gary Martin <gj...@apache.org>
AuthorDate: Wed Sep 8 01:13:56 2021 +0100

    Update models to match legacy db column names
---
 trackers/api/views.py |  4 +---
 trackers/models.py    | 45 +++++++++++++++++++++++++++++++++++----------
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/trackers/api/views.py b/trackers/api/views.py
index 7995b5f..9bacff7 100644
--- a/trackers/api/views.py
+++ b/trackers/api/views.py
@@ -16,11 +16,9 @@
 #  under the License.
 
 from django.contrib.auth.models import User, Group
-from django.shortcuts import get_object_or_404
 from drf_yasg.views import get_schema_view
 from drf_yasg import openapi
-from rest_framework import permissions, status, viewsets
-from rest_framework.response import Response
+from rest_framework import permissions, viewsets
 from . import serializers
 from .. import models
 
diff --git a/trackers/models.py b/trackers/models.py
index 989e359..5c6592d 100644
--- a/trackers/models.py
+++ b/trackers/models.py
@@ -18,7 +18,6 @@
 import logging
 
 from django.db import models
-from django.urls import reverse
 
 logger = logging.getLogger(__name__)
 
@@ -61,7 +60,11 @@ class Component(models.Model):
     name = models.TextField(primary_key=True)
     owner = models.TextField(blank=True, null=True)
     description = models.TextField(blank=True, null=True)
-    product = models.ForeignKey(Product, on_delete=models.PROTECT)
+    product = models.ForeignKey(
+        Product,
+        db_column="product",
+        on_delete=models.PROTECT,
+    )
 
     class Meta:
         db_table = 'component'
@@ -84,7 +87,11 @@ class Milestone(models.Model):
     due = models.BigIntegerField(blank=True, null=True)
     completed = models.BigIntegerField(blank=True, null=True)
     description = models.TextField(blank=True, null=True)
-    product = models.ForeignKey(Product, on_delete=models.PROTECT)
+    product = models.ForeignKey(
+        Product,
+        db_column="product",
+        on_delete=models.PROTECT,
+    )
 
     class Meta:
         db_table = 'milestone'
@@ -95,7 +102,11 @@ class Version(models.Model):
     name = models.TextField(primary_key=True)
     time = models.BigIntegerField(blank=True, null=True)
     description = models.TextField(blank=True, null=True)
-    product = models.ForeignKey(Product, on_delete=models.PROTECT)
+    product = models.ForeignKey(
+        Product,
+        db_column="product",
+        on_delete=models.PROTECT,
+    )
 
     class Meta:
         db_table = 'version'
@@ -106,15 +117,20 @@ class Ticket(models.Model):
     uid = models.AutoField(primary_key=True)
     type = models.ForeignKey(
         Enum,
-        blank=True,
-        null=True,
         on_delete=models.PROTECT,
+        db_column="type",
         related_name='%(app_label)s_%(class)s_type_related',
+        blank=True,
+        null=True,
     )
     time = models.BigIntegerField(blank=True, null=True)
     changetime = models.BigIntegerField(blank=True, null=True)
     component = models.ForeignKey(
-        Component, on_delete=models.PROTECT, blank=True, null=True
+        Component,
+        on_delete=models.PROTECT,
+        db_column="component",
+        blank=True,
+        null=True,
     )
     severity = models.TextField(blank=True, null=True)
     priority = models.TextField(blank=True, null=True)
@@ -122,15 +138,24 @@ class Ticket(models.Model):
     reporter = models.TextField(blank=True, null=True)
     cc = models.TextField(blank=True, null=True)
     version = models.ForeignKey(
-        Version, on_delete=models.PROTECT, blank=True, null=True
+        Version,
+        on_delete=models.PROTECT,
+        db_column="version",
+        blank=True,
+        null=True,
     )
     milestone = models.ForeignKey(
-        Milestone, on_delete=models.PROTECT, blank=True, null=True
+        Milestone,
+        on_delete=models.PROTECT,
+        db_column="milestone",
+        blank=True,
+        null=True,
     )
     status = models.TextField(blank=True, null=True)
     resolution = models.ForeignKey(
         Enum,
         on_delete=models.PROTECT,
+        db_column="resolution",
         related_name='%(app_label)s_%(class)s_resolution_related',
         blank=True,
         null=True,
@@ -138,7 +163,7 @@ class Ticket(models.Model):
     summary = models.TextField()
     description = models.TextField(blank=True, null=True)
     keywords = models.TextField(blank=True, null=True)
-    product = models.ForeignKey(Product, on_delete=models.PROTECT)
+    product = models.ForeignKey(Product, on_delete=models.PROTECT, db_column="product")
     product_ticket_id = models.IntegerField(db_column='id', editable=False)
 
     class Meta: