[WEB - 1500] chore: add extra fields on instance and create changelog table to store release change logs (#4673)

* chore: add extra fields on instance and create changelog table to store release change logs

* dev: rename new_version to latest_version
This commit is contained in:
Nikhil 2024-05-31 23:39:13 +05:30 committed by GitHub
parent de7dad59f0
commit f96e76dbbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 131 additions and 2 deletions

View File

@ -0,0 +1,101 @@
# Generated by Django 4.2.11 on 2024-05-31 10:46
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("license", "0001_initial"),
]
operations = [
migrations.RenameField(
model_name="instance",
old_name="version",
new_name="current_version",
),
migrations.RemoveField(
model_name="instance",
name="api_key",
),
migrations.AddField(
model_name="instance",
name="domain",
field=models.TextField(blank=True),
),
migrations.AddField(
model_name="instance",
name="latest_version",
field=models.CharField(blank=True, max_length=10, null=True),
),
migrations.AddField(
model_name="instance",
name="product",
field=models.CharField(default="plane-ce", max_length=50),
),
migrations.CreateModel(
name="ChangeLog",
fields=[
(
"created_at",
models.DateTimeField(
auto_now_add=True, verbose_name="Created At"
),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("title", models.CharField(max_length=100)),
("description", models.TextField(blank=True)),
("version", models.CharField(max_length=100)),
("tags", models.JSONField(default=list)),
("release_date", models.DateTimeField(null=True)),
("is_release_candidate", models.BooleanField(default=False)),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
],
options={
"verbose_name": "Change Log",
"verbose_name_plural": "Change Logs",
"db_table": "changelogs",
"ordering": ("-created_at",),
},
),
]

View File

@ -1,3 +1,6 @@
# Python imports
from enum import Enum
# Django imports # Django imports
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings
@ -8,14 +11,22 @@ from plane.db.models import BaseModel
ROLE_CHOICES = ((20, "Admin"),) ROLE_CHOICES = ((20, "Admin"),)
class ProductTypes(Enum):
PLANE_CE = "plane-ce"
class Instance(BaseModel): class Instance(BaseModel):
# General informations # General informations
instance_name = models.CharField(max_length=255) instance_name = models.CharField(max_length=255)
whitelist_emails = models.TextField(blank=True, null=True) whitelist_emails = models.TextField(blank=True, null=True)
instance_id = models.CharField(max_length=25, unique=True) instance_id = models.CharField(max_length=25, unique=True)
license_key = models.CharField(max_length=256, null=True, blank=True) license_key = models.CharField(max_length=256, null=True, blank=True)
api_key = models.CharField(max_length=16) current_version = models.CharField(max_length=10)
version = models.CharField(max_length=10) latest_version = models.CharField(max_length=10, null=True, blank=True)
product = models.CharField(
max_length=50, default=ProductTypes.PLANE_CE.value
)
domain = models.TextField(blank=True)
# Instnace specifics # Instnace specifics
last_checked_at = models.DateTimeField() last_checked_at = models.DateTimeField()
namespace = models.CharField(max_length=50, blank=True, null=True) namespace = models.CharField(max_length=50, blank=True, null=True)
@ -70,3 +81,20 @@ class InstanceConfiguration(BaseModel):
verbose_name_plural = "Instance Configurations" verbose_name_plural = "Instance Configurations"
db_table = "instance_configurations" db_table = "instance_configurations"
ordering = ("-created_at",) ordering = ("-created_at",)
class ChangeLog(BaseModel):
"""Change Log model to store the release changelogs made in the application."""
title = models.CharField(max_length=100)
description = models.TextField(blank=True)
version = models.CharField(max_length=100)
tags = models.JSONField(default=list)
release_date = models.DateTimeField(null=True)
is_release_candidate = models.BooleanField(default=False)
class Meta:
verbose_name = "Change Log"
verbose_name_plural = "Change Logs"
db_table = "changelogs"
ordering = ("-created_at",)