Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: delete deprecated tables #5833

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Generated by Django 4.2.16 on 2024-10-15 11:31

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("db", "0080_fileasset_draft_issue_alter_fileasset_entity_type"),
]

operations = [
migrations.RemoveField(
model_name="globalview",
name="created_by",
),
migrations.RemoveField(
model_name="globalview",
name="updated_by",
),
migrations.RemoveField(
model_name="globalview",
name="workspace",
),
Comment on lines +12 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Redundant field removals before model deletion

The fields from GlobalView are being removed individually before the model is deleted later in the migration. This is unnecessary as deleting the model will automatically remove all its fields.

Consider simplifying the migration by removing the individual RemoveField operations for GlobalView and directly deleting the model. This reduces the migration steps and avoids potential issues during rollback.

Apply this diff to remove the redundant operations:

-        migrations.RemoveField(
-            model_name="globalview",
-            name="created_by",
-        ),
-        migrations.RemoveField(
-            model_name="globalview",
-            name="updated_by",
-        ),
-        migrations.RemoveField(
-            model_name="globalview",
-            name="workspace",
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.RemoveField(
model_name="globalview",
name="created_by",
),
migrations.RemoveField(
model_name="globalview",
name="updated_by",
),
migrations.RemoveField(
model_name="globalview",
name="workspace",
),

migrations.AlterUniqueTogether(
name="issueviewfavorite",
unique_together=None,
),
Comment on lines +24 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Unnecessary AlterUniqueTogether before model deletion

The unique constraint for IssueViewFavorite is being altered before the model is deleted. Since the model is being deleted, modifying its constraints is redundant.

Consider removing the AlterUniqueTogether operation for IssueViewFavorite. This streamlines the migration and prevents unnecessary steps.

Apply this diff to remove the operation:

-        migrations.AlterUniqueTogether(
-            name="issueviewfavorite",
-            unique_together=None,
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.AlterUniqueTogether(
name="issueviewfavorite",
unique_together=None,
),

migrations.RemoveField(
model_name="issueviewfavorite",
name="created_by",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="project",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="updated_by",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="user",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="view",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="workspace",
),
Comment on lines +28 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Redundant field removals from IssueViewFavorite

Similar to GlobalView, fields are being removed from IssueViewFavorite before deleting the model. This is unnecessary.

Remove the individual RemoveField operations for IssueViewFavorite and proceed directly to deleting the model.

Apply this diff:

-        migrations.RemoveField(
-            model_name="issueviewfavorite",
-            name="created_by",
-        ),
-        migrations.RemoveField(
-            model_name="issueviewfavorite",
-            name="project",
-        ),
-        migrations.RemoveField(
-            model_name="issueviewfavorite",
-            name="updated_by",
-        ),
-        migrations.RemoveField(
-            model_name="issueviewfavorite",
-            name="user",
-        ),
-        migrations.RemoveField(
-            model_name="issueviewfavorite",
-            name="view",
-        ),
-        migrations.RemoveField(
-            model_name="issueviewfavorite",
-            name="workspace",
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.RemoveField(
model_name="issueviewfavorite",
name="created_by",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="project",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="updated_by",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="user",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="view",
),
migrations.RemoveField(
model_name="issueviewfavorite",
name="workspace",
),

migrations.AlterUniqueTogether(
name="modulefavorite",
unique_together=None,
),
Comment on lines +52 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Unnecessary AlterUniqueTogether before model deletion

The same issue applies to ModuleFavorite. Altering unique constraints before deleting the model is redundant.

Remove the AlterUniqueTogether operation for ModuleFavorite.

Apply this diff:

-        migrations.AlterUniqueTogether(
-            name="modulefavorite",
-            unique_together=None,
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.AlterUniqueTogether(
name="modulefavorite",
unique_together=None,
),

migrations.RemoveField(
model_name="modulefavorite",
name="created_by",
),
migrations.RemoveField(
model_name="modulefavorite",
name="module",
),
migrations.RemoveField(
model_name="modulefavorite",
name="project",
),
migrations.RemoveField(
model_name="modulefavorite",
name="updated_by",
),
migrations.RemoveField(
model_name="modulefavorite",
name="user",
),
migrations.RemoveField(
model_name="modulefavorite",
name="workspace",
),
Comment on lines +56 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Redundant field removals from ModuleFavorite

Fields are being removed before deleting ModuleFavorite.

Omit the RemoveField operations for ModuleFavorite.

Apply this diff:

-        migrations.RemoveField(
-            model_name="modulefavorite",
-            name="created_by",
-        ),
-        migrations.RemoveField(
-            model_name="modulefavorite",
-            name="module",
-        ),
-        migrations.RemoveField(
-            model_name="modulefavorite",
-            name="project",
-        ),
-        migrations.RemoveField(
-            model_name="modulefavorite",
-            name="updated_by",
-        ),
-        migrations.RemoveField(
-            model_name="modulefavorite",
-            name="user",
-        ),
-        migrations.RemoveField(
-            model_name="modulefavorite",
-            name="workspace",
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.RemoveField(
model_name="modulefavorite",
name="created_by",
),
migrations.RemoveField(
model_name="modulefavorite",
name="module",
),
migrations.RemoveField(
model_name="modulefavorite",
name="project",
),
migrations.RemoveField(
model_name="modulefavorite",
name="updated_by",
),
migrations.RemoveField(
model_name="modulefavorite",
name="user",
),
migrations.RemoveField(
model_name="modulefavorite",
name="workspace",
),

migrations.RemoveField(
model_name="pageblock",
name="created_by",
),
migrations.RemoveField(
model_name="pageblock",
name="issue",
),
migrations.RemoveField(
model_name="pageblock",
name="page",
),
migrations.RemoveField(
model_name="pageblock",
name="project",
),
migrations.RemoveField(
model_name="pageblock",
name="updated_by",
),
migrations.RemoveField(
model_name="pageblock",
name="workspace",
),
Comment on lines +80 to +103
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Redundant field removals from PageBlock

Fields are being individually removed from PageBlock prior to deletion.

Remove the RemoveField operations for PageBlock.

Apply this diff:

-        migrations.RemoveField(
-            model_name="pageblock",
-            name="created_by",
-        ),
-        migrations.RemoveField(
-            model_name="pageblock",
-            name="issue",
-        ),
-        migrations.RemoveField(
-            model_name="pageblock",
-            name="page",
-        ),
-        migrations.RemoveField(
-            model_name="pageblock",
-            name="project",
-        ),
-        migrations.RemoveField(
-            model_name="pageblock",
-            name="updated_by",
-        ),
-        migrations.RemoveField(
-            model_name="pageblock",
-            name="workspace",
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.RemoveField(
model_name="pageblock",
name="created_by",
),
migrations.RemoveField(
model_name="pageblock",
name="issue",
),
migrations.RemoveField(
model_name="pageblock",
name="page",
),
migrations.RemoveField(
model_name="pageblock",
name="project",
),
migrations.RemoveField(
model_name="pageblock",
name="updated_by",
),
migrations.RemoveField(
model_name="pageblock",
name="workspace",
),

migrations.AlterUniqueTogether(
name="pagefavorite",
unique_together=None,
),
Comment on lines +104 to +107
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Unnecessary AlterUniqueTogether before model deletion

For PageFavorite, altering unique constraints before deleting the model is not needed.

Remove the AlterUniqueTogether operation for PageFavorite.

Apply this diff:

-        migrations.AlterUniqueTogether(
-            name="pagefavorite",
-            unique_together=None,
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.AlterUniqueTogether(
name="pagefavorite",
unique_together=None,
),

migrations.RemoveField(
model_name="pagefavorite",
name="created_by",
),
migrations.RemoveField(
model_name="pagefavorite",
name="page",
),
migrations.RemoveField(
model_name="pagefavorite",
name="project",
),
migrations.RemoveField(
model_name="pagefavorite",
name="updated_by",
),
migrations.RemoveField(
model_name="pagefavorite",
name="user",
),
migrations.RemoveField(
model_name="pagefavorite",
name="workspace",
),
Comment on lines +108 to +131
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Redundant field removals from PageFavorite

Fields are being removed before deleting PageFavorite.

Exclude the RemoveField operations for PageFavorite.

Apply this diff:

-        migrations.RemoveField(
-            model_name="pagefavorite",
-            name="created_by",
-        ),
-        migrations.RemoveField(
-            model_name="pagefavorite",
-            name="page",
-        ),
-        migrations.RemoveField(
-            model_name="pagefavorite",
-            name="project",
-        ),
-        migrations.RemoveField(
-            model_name="pagefavorite",
-            name="updated_by",
-        ),
-        migrations.RemoveField(
-            model_name="pagefavorite",
-            name="user",
-        ),
-        migrations.RemoveField(
-            model_name="pagefavorite",
-            name="workspace",
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.RemoveField(
model_name="pagefavorite",
name="created_by",
),
migrations.RemoveField(
model_name="pagefavorite",
name="page",
),
migrations.RemoveField(
model_name="pagefavorite",
name="project",
),
migrations.RemoveField(
model_name="pagefavorite",
name="updated_by",
),
migrations.RemoveField(
model_name="pagefavorite",
name="user",
),
migrations.RemoveField(
model_name="pagefavorite",
name="workspace",
),

migrations.AlterUniqueTogether(
name="projectfavorite",
unique_together=None,
),
Comment on lines +132 to +135
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Unnecessary AlterUniqueTogether before model deletion

The AlterUniqueTogether operation for ProjectFavorite is unnecessary before model deletion.

Remove this operation to simplify the migration.

Apply this diff:

-        migrations.AlterUniqueTogether(
-            name="projectfavorite",
-            unique_together=None,
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.AlterUniqueTogether(
name="projectfavorite",
unique_together=None,
),

migrations.RemoveField(
model_name="projectfavorite",
name="created_by",
),
migrations.RemoveField(
model_name="projectfavorite",
name="project",
),
migrations.RemoveField(
model_name="projectfavorite",
name="updated_by",
),
migrations.RemoveField(
model_name="projectfavorite",
name="user",
),
migrations.RemoveField(
model_name="projectfavorite",
name="workspace",
),
Comment on lines +136 to +155
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Redundant field removals from ProjectFavorite

Fields are being removed from ProjectFavorite before its deletion.

Remove the RemoveField operations for ProjectFavorite.

Apply this diff:

-        migrations.RemoveField(
-            model_name="projectfavorite",
-            name="created_by",
-        ),
-        migrations.RemoveField(
-            model_name="projectfavorite",
-            name="project",
-        ),
-        migrations.RemoveField(
-            model_name="projectfavorite",
-            name="updated_by",
-        ),
-        migrations.RemoveField(
-            model_name="projectfavorite",
-            name="user",
-        ),
-        migrations.RemoveField(
-            model_name="projectfavorite",
-            name="workspace",
-        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrations.RemoveField(
model_name="projectfavorite",
name="created_by",
),
migrations.RemoveField(
model_name="projectfavorite",
name="project",
),
migrations.RemoveField(
model_name="projectfavorite",
name="updated_by",
),
migrations.RemoveField(
model_name="projectfavorite",
name="user",
),
migrations.RemoveField(
model_name="projectfavorite",
name="workspace",
),

migrations.AddField(
model_name="issuetype",
name="external_id",
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name="issuetype",
name="external_source",
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.DeleteModel(
name="CycleFavorite",
),
migrations.DeleteModel(
name="GlobalView",
),
migrations.DeleteModel(
name="IssueViewFavorite",
),
migrations.DeleteModel(
name="ModuleFavorite",
),
migrations.DeleteModel(
name="PageBlock",
),
migrations.DeleteModel(
name="PageFavorite",
),
migrations.DeleteModel(
name="ProjectFavorite",
),
]
9 changes: 3 additions & 6 deletions apiserver/plane/db/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .api import APIActivityLog, APIToken
from .asset import FileAsset
from .base import BaseModel
from .cycle import Cycle, CycleFavorite, CycleIssue, CycleUserProperties
from .cycle import Cycle, CycleIssue, CycleUserProperties
from .dashboard import Dashboard, DashboardWidget, Widget
from .deploy_board import DeployBoard
from .draft import DraftIssue, DraftIssueAssignee, DraftIssueLabel, DraftIssueModule, DraftIssueCycle
Expand Down Expand Up @@ -39,7 +39,6 @@
)
from .module import (
Module,
ModuleFavorite,
ModuleIssue,
ModuleLink,
ModuleMember,
Expand All @@ -52,7 +51,6 @@
)
from .page import (
Page,
PageFavorite,
PageLabel,
PageLog,
ProjectPage,
Expand All @@ -61,7 +59,6 @@
from .project import (
Project,
ProjectBaseModel,
ProjectFavorite,
ProjectIdentifier,
ProjectMember,
ProjectMemberInvite,
Expand All @@ -72,7 +69,7 @@
from .social_connection import SocialLoginConnection
from .state import State
from .user import Account, Profile, User
from .view import IssueView, IssueViewFavorite
from .view import IssueView

Check notice on line 72 in apiserver/plane/db/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

apiserver/plane/db/models/__init__.py#L72

'.view.IssueView' imported but unused (F401)
from .webhook import Webhook, WebhookLog
from .workspace import (
Team,
Expand All @@ -87,7 +84,7 @@

from .importer import Importer

from .page import Page, PageLog, PageFavorite, PageLabel
from .page import Page, PageLog, PageLabel

Check notice on line 87 in apiserver/plane/db/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

apiserver/plane/db/models/__init__.py#L87

'.page.Page' imported but unused (F401)

Check warning on line 87 in apiserver/plane/db/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

apiserver/plane/db/models/__init__.py#L87

Reimport 'Page' (imported line 52)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove redundant page module imports

The imports of Page, PageLog, and PageLabel on this line are redundant as they are already imported earlier in the file (around lines 53-55).

To clean up the imports and avoid potential confusion, please remove this line entirely. Here's the suggested change:

- from .page import Page, PageLog, PageLabel

This will help maintain a cleaner and more organized import structure.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from .page import Page, PageLog, PageLabel
🧰 Tools
🪛 Ruff

87-87: Redefinition of unused Page from line 53

Remove definition: Page

(F811)


87-87: .page.Page imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


87-87: Redefinition of unused PageLog from line 55

Remove definition: PageLog

(F811)


87-87: .page.PageLog imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


87-87: Redefinition of unused PageLabel from line 54

Remove definition: PageLabel

(F811)


87-87: .page.PageLabel imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


from .estimate import Estimate, EstimatePoint

Expand Down
27 changes: 0 additions & 27 deletions apiserver/plane/db/models/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,33 +127,6 @@ def __str__(self):
return f"{self.cycle}"


# DEPRECATED TODO: - Remove in next release
class CycleFavorite(ProjectBaseModel):
"""_summary_
CycleFavorite (model): To store all the cycle favorite of the user
"""

user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="cycle_favorites",
)
cycle = models.ForeignKey(
"db.Cycle", on_delete=models.CASCADE, related_name="cycle_favorites"
)

class Meta:
unique_together = ["cycle", "user"]
verbose_name = "Cycle Favorite"
verbose_name_plural = "Cycle Favorites"
db_table = "cycle_favorites"
ordering = ("-created_at",)

def __str__(self):
"""Return user and the cycle"""
return f"{self.user.email} <{self.cycle.name}>"


class CycleUserProperties(ProjectBaseModel):
cycle = models.ForeignKey(
"db.Cycle",
Expand Down
2 changes: 2 additions & 0 deletions apiserver/plane/db/models/issue_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class IssueType(BaseModel):
is_default = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
level = models.PositiveIntegerField(default=0)
external_source = models.CharField(max_length=255, null=True, blank=True)
external_id = models.CharField(max_length=255, blank=True, null=True)

class Meta:
verbose_name = "Issue Type"
Expand Down
31 changes: 2 additions & 29 deletions apiserver/plane/db/models/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ class Meta:
unique_together = ["name", "project", "deleted_at"]
constraints = [
models.UniqueConstraint(
fields=['name', 'project'],
fields=["name", "project"],
condition=Q(deleted_at__isnull=True),
name='module_unique_name_project_when_deleted_at_null'
name="module_unique_name_project_when_deleted_at_null",
)
]
verbose_name = "Module"
Expand Down Expand Up @@ -191,33 +191,6 @@ def __str__(self):
return f"{self.module.name} {self.url}"


# DEPRECATED TODO: - Remove in next release
class ModuleFavorite(ProjectBaseModel):
"""_summary_
ModuleFavorite (model): To store all the module favorite of the user
"""

user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="module_favorites",
)
module = models.ForeignKey(
"db.Module", on_delete=models.CASCADE, related_name="module_favorites"
)

class Meta:
unique_together = ["module", "user"]
verbose_name = "Module Favorite"
verbose_name_plural = "Module Favorites"
db_table = "module_favorites"
ordering = ("-created_at",)

def __str__(self):
"""Return user and the module"""
return f"{self.user.email} <{self.module.name}>"


class ModuleUserProperties(ProjectBaseModel):
module = models.ForeignKey(
"db.Module",
Expand Down
Loading
Loading