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 3 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,145 @@
# Generated by Django 4.2.16 on 2024-10-15 11:01

from django.db import migrations, models


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

operations = [
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",
),
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",
),
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",
),
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",
),
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="IssueViewFavorite",
),
migrations.DeleteModel(
name="ModuleFavorite",
),
migrations.DeleteModel(
name="PageFavorite",
),
migrations.DeleteModel(
name="ProjectFavorite",
),
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

Potential data loss from deleting models

Deleting models CycleFavorite, IssueViewFavorite, ModuleFavorite, PageFavorite, and ProjectFavorite will permanently remove all associated data. If this data is still needed or valuable for analytics, user experience, or compliance purposes, consider performing a data migration to archive or transfer the data before deletion.

Would you like assistance in creating a data migration to preserve the existing data before dropping these models?

]
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
23 changes: 0 additions & 23 deletions apiserver/plane/db/models/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,29 +176,6 @@ def __str__(self):
return f"{self.page.name} <{self.name}>"


# DEPRECATED TODO: - Remove in next release
class PageFavorite(ProjectBaseModel):
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="page_favorites",
)
page = models.ForeignKey(
"db.Page", on_delete=models.CASCADE, related_name="page_favorites"
)

class Meta:
unique_together = ["page", "user"]
verbose_name = "Page Favorite"
verbose_name_plural = "Page Favorites"
db_table = "page_favorites"
ordering = ("-created_at",)

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


class PageLabel(BaseModel):
label = models.ForeignKey(
"db.Label", on_delete=models.CASCADE, related_name="page_labels"
Expand Down
24 changes: 3 additions & 21 deletions apiserver/plane/db/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ class ProjectBaseModel(BaseModel):
Project, on_delete=models.CASCADE, related_name="project_%(class)s"
)
workspace = models.ForeignKey(
"db.Workspace", on_delete=models.CASCADE, related_name="workspace_%(class)s"
"db.Workspace",
on_delete=models.CASCADE,
related_name="workspace_%(class)s",
)

class Meta:
Expand Down Expand Up @@ -285,26 +287,6 @@ class Meta:
ordering = ("-created_at",)


# DEPRECATED TODO: - Remove in next release
class ProjectFavorite(ProjectBaseModel):
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="project_favorites",
)

class Meta:
unique_together = ["project", "user"]
verbose_name = "Project Favorite"
verbose_name_plural = "Project Favorites"
db_table = "project_favorites"
ordering = ("-created_at",)

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


def get_anchor():
return uuid4().hex

Expand Down
25 changes: 1 addition & 24 deletions apiserver/plane/db/models/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def get_default_display_properties():
"updated_on": True,
}


# DEPRECATED TODO: - Remove in next release
class GlobalView(BaseModel):
workspace = models.ForeignKey(
Expand Down Expand Up @@ -109,7 +110,6 @@ class IssueView(WorkspaceBaseModel):
)
is_locked = models.BooleanField(default=False)


class Meta:
verbose_name = "Issue View"
verbose_name_plural = "Issue Views"
Expand Down Expand Up @@ -139,26 +139,3 @@ def save(self, *args, **kwargs):
def __str__(self):
"""Return name of the View"""
return f"{self.name} <{self.project.name}>"


# DEPRECATED TODO: - Remove in next release
class IssueViewFavorite(ProjectBaseModel):
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="user_view_favorites",
)
view = models.ForeignKey(
"db.IssueView", on_delete=models.CASCADE, related_name="view_favorites"
)

class Meta:
unique_together = ["view", "user"]
verbose_name = "View Favorite"
verbose_name_plural = "View Favorites"
db_table = "view_favorites"
ordering = ("-created_at",)

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