diff --git a/apiserver/plane/db/migrations/0067_issue_estimate.py b/apiserver/plane/db/migrations/0067_issue_estimate.py deleted file mode 100644 index e729acade..000000000 --- a/apiserver/plane/db/migrations/0067_issue_estimate.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 4.2.7 on 2024-05-24 09:47 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('db', '0066_account_id_token_cycle_logo_props_module_logo_props'), - ] - - operations = [ - migrations.AddField( - model_name='issue', - name='estimate', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='issue_estimate', to='db.estimate'), - ), - ] diff --git a/apiserver/plane/db/migrations/0068_estimate_last_used.py b/apiserver/plane/db/migrations/0068_estimate_last_used.py deleted file mode 100644 index ede0114fc..000000000 --- a/apiserver/plane/db/migrations/0068_estimate_last_used.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.7 on 2024-05-27 07:11 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('db', '0067_issue_estimate'), - ] - - operations = [ - migrations.AddField( - model_name='estimate', - name='last_used', - field=models.BooleanField(default=False), - ), - ] diff --git a/apiserver/plane/db/migrations/0069_auto_20240531_0934.py b/apiserver/plane/db/migrations/0069_auto_20240531_0934.py deleted file mode 100644 index 6c994d1c2..000000000 --- a/apiserver/plane/db/migrations/0069_auto_20240531_0934.py +++ /dev/null @@ -1,74 +0,0 @@ -import django.db.models.deletion -from django.db import migrations, models - - -def issue_estimate_point(apps, schema_editor): - Project = apps.get_model("db", "Project") - EstimatePoint = apps.get_model("db", "EstimatePoint") - Issue = apps.get_model("db", "Issue") - updated_estimate_point = [] - - # loop through all the projects - for project in Project.objects.filter(estimate__isnull=False): - estimate_points = EstimatePoint.objects.filter( - estimate=project.estimate, project=project - ) - for issue in Issue.objects.filter( - point__isnull=False, project=project - ): - # get the estimate id for the corresponding estimate point in the issue - estimate = estimate_points.filter(key=issue.point).first() - issue.estimate_point = estimate - updated_estimate_point.append(issue) - - Issue.objects.bulk_update( - updated_estimate_point, ["estimate_point"], batch_size=1000 - ) - - -def last_used_estimate(apps, schema_editor): - Project = apps.get_model("db", "Project") - Estimate = apps.get_model("db", "Estimate") - - # Get all estimate ids used in projects - estimate_ids = Project.objects.filter(estimate__isnull=False).values_list( - "estimate", flat=True - ) - - # Update all matching estimates - Estimate.objects.filter(id__in=estimate_ids).update(last_used=True) - - -class Migration(migrations.Migration): - - dependencies = [ - ("db", "0068_estimate_last_used"), - ] - - operations = [ - # Rename the existing field - migrations.RenameField( - model_name="issue", - old_name="estimate_point", - new_name="point", - ), - # Add a new field with the original name as a foreign key - migrations.AddField( - model_name="issue", - name="estimate_point", - field=models.ForeignKey( - on_delete=django.db.models.deletion.SET_NULL, - related_name="issue_estimate", - to="db.EstimatePoint", - blank=True, - null=True, - ), - ), - migrations.AlterField( - model_name="estimate", - name="type", - field=models.CharField(default="categories", max_length=255), - ), - migrations.RunPython(issue_estimate_point), - migrations.RunPython(last_used_estimate), - ] diff --git a/apiserver/plane/db/models/issue.py b/apiserver/plane/db/models/issue.py index 404a20abc..8eefdc8b3 100644 --- a/apiserver/plane/db/models/issue.py +++ b/apiserver/plane/db/models/issue.py @@ -131,13 +131,6 @@ class Issue(ProjectBaseModel): null=True, blank=True, ) - estimate = models.ForeignKey( - "db.Estimate", - on_delete=models.SET_NULL, - related_name="issue_estimate", - null=True, - blank=True, - ) name = models.CharField(max_length=255, verbose_name="Issue Name") description = models.JSONField(blank=True, default=dict) description_html = models.TextField(blank=True, default="
")