Skip to content

[WIKI-619] chore: added sort order migration for page model#7673

Merged
sriramveeraghanta merged 1 commit intopreviewfrom
chore-page-sort-order-migration
Aug 29, 2025
Merged

[WIKI-619] chore: added sort order migration for page model#7673
sriramveeraghanta merged 1 commit intopreviewfrom
chore-page-sort-order-migration

Conversation

@NarayanBavisetti
Copy link
Copy Markdown
Collaborator

@NarayanBavisetti NarayanBavisetti commented Aug 29, 2025

Description

this pull request adds a new field in the page model called sort_order and one more new field called entity_type in the page log model.

Type of Change

  • Feature (non-breaking change which adds functionality)

Summary by CodeRabbit

  • New Features
    • Pages can now be custom-ordered, enabling flexible arrangement in lists and navigation.
  • Chores
    • Backend updates to activity logs to capture additional context and accept more identifier formats, improving traceability and future compatibility.

Copilot AI review requested due to automatic review settings August 29, 2025 11:33
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 29, 2025

Walkthrough

Adds Page.sort_order (FloatField, default 65535). Introduces Pagelog.entity_type (CharField, nullable/blank, max_length=30). Updates Pagelog.entity_identifier to UUIDField allowing null and blank. Corresponding Django model and migration changes are included.

Changes

Cohort / File(s) Summary
Database migration
apps/api/plane/db/migrations/0102_page_sort_order_pagelog_entity_type_and_more.py
Adds Page.sort_order, adds Pagelog.entity_type, alters Pagelog.entity_identifier to UUIDField with null/blank.
Models
apps/api/plane/db/models/page.py
Declares Page.sort_order; updates PageLog.entity_identifier to allow blank; adds PageLog.entity_type with verbose name.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws—new fields appear,
A sort to steer our pages clear;
Logs now know an entity’s type,
UUIDs relax their stripe.
In burrows of schema, tidy and bright,
I nibble carrots, all fields set right. 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore-page-sort-order-migration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds database model changes to support page sorting and enhanced page logging functionality by introducing two new fields across the Page and PageLog models.

  • Added sort_order field to Page model for ordering functionality
  • Added entity_type field to PageLog model for better categorization of log entries
  • Modified entity_identifier field in PageLog model to allow blank values

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/api/plane/db/models/page.py Adds sort_order field to Page model and entity_type field to PageLog model, plus modifies entity_identifier to allow blank values
apps/api/plane/db/migrations/0102_page_sort_order_pagelog_entity_type_and_more.py Django migration file implementing the database schema changes for the new fields

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@NarayanBavisetti NarayanBavisetti changed the title chore: added sort order migration for page model [WIKI-619] chore: added sort order migration for page model Aug 29, 2025
@makeplane
Copy link
Copy Markdown

makeplane bot commented Aug 29, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
apps/api/plane/db/models/page.py (1)

104-104: Constrain entity_type (choices) and index for filtering

Define canonical choices (TextChoices) to prevent drift and add an index if used in analytics/filters.

Apply:

-    entity_type = models.CharField(max_length=30, verbose_name="Entity Type", null=True, blank=True)
+    class EntityType(models.TextChoices):
+        ISSUE = "issue", "Issue"
+        IMAGE = "image", "Image"
+        VIDEO = "video", "Video"
+        FILE = "file", "File"
+        LINK = "link", "Link"
+        CYCLE = "cycle", "Cycle"
+        MODULE = "module", "Module"
+        PAGE_MENTION = "page_mention", "Page Mention"
+        USER_MENTION = "user_mention", "User Mention"
+
+    entity_type = models.CharField(
+        max_length=30,
+        choices=EntityType.choices,
+        verbose_name="Entity Type",
+        null=True,
+        blank=True,
+        db_index=True,
+    )

If choices must remain open-ended, at least keep db_index=True.

apps/api/plane/db/migrations/0102_page_sort_order_pagelog_entity_type_and_more.py (1)

18-24: Index entity_type (frequent filter) or keep it nullable-only if purely descriptive

Add db_index for common filtering.

-        migrations.AddField(
-            model_name="pagelog",
-            name="entity_type",
-            field=models.CharField(
-                blank=True, max_length=30, null=True, verbose_name="Entity Type"
-            ),
-        ),
+        migrations.AddField(
+            model_name="pagelog",
+            name="entity_type",
+            field=models.CharField(
+                blank=True, max_length=30, null=True, verbose_name="Entity Type", db_index=True
+            ),
+        ),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4042af9 and 02fea73.

📒 Files selected for processing (2)
  • apps/api/plane/db/migrations/0102_page_sort_order_pagelog_entity_type_and_more.py (1 hunks)
  • apps/api/plane/db/models/page.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/api/plane/db/models/page.py (1)

102-102: Add index to entity_identifier on Page model

--- a/apps/api/plane/db/models/page.py
+++ b/apps/api/plane/db/models/page.py
@@ line 102
-    entity_identifier = models.UUIDField(null=True, blank=True)
+    entity_identifier = models.UUIDField(null=True, blank=True, db_index=True)
  • Ensure migrations include this field’s creation (no matching migration found for entity_identifier); confirm the existing column is already UUID typed before deploying (add cast/cleanup migration if needed).
apps/api/plane/db/migrations/0102_page_sort_order_pagelog_entity_type_and_more.py (1)

25-29: Safe-cast suggestion is unnecessary: page_logs.entity_identifier has been a UUID column since migration 0048, so there’s no type conversion or data cleanup required.

Likely an incorrect or invalid review comment.

@NarayanBavisetti NarayanBavisetti marked this pull request as draft August 29, 2025 11:53
@NarayanBavisetti NarayanBavisetti marked this pull request as ready for review August 29, 2025 12:03
@NarayanBavisetti NarayanBavisetti added 🔄migrations Contains Migration changes ready to merge labels Aug 29, 2025
@sriramveeraghanta sriramveeraghanta merged commit ebd517b into preview Aug 29, 2025
8 of 12 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore-page-sort-order-migration branch August 29, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔄migrations Contains Migration changes ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants