-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[WIKI-659] chore: added issue relation and page sort order #7784
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
Merged
sriramveeraghanta
merged 7 commits into
preview
from
chore-page-sort-order-data-migration
Sep 15, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c4f40bc
chore: added issue relation and page sort order
NarayanBavisetti 733cbf2
feat: add ProjectWebhook model to manage webhooks associated with pro…
pablohashescobar cec249b
chore: updated the migration file
NarayanBavisetti 79a0df5
Merge branch 'chore-page-sort-order-data-migration' of github.com:mak…
NarayanBavisetti 3bdd4b9
chore: added migration
NarayanBavisetti 758f72e
chore: reverted the page base code
NarayanBavisetti 6733828
chore: added a variable for sort order in pages
NarayanBavisetti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
apps/api/plane/db/migrations/0106_auto_20250912_0845.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| # Generated by Django 4.2.22 on 2025-09-12 08:45 | ||
| import uuid | ||
| import django | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| def set_page_sort_order(apps, schema_editor): | ||
| Page = apps.get_model("db", "Page") | ||
|
|
||
| batch_size = 3000 | ||
| sort_order = 100 | ||
|
|
||
| # Get page IDs ordered by name using the historical model | ||
| # This should include all pages regardless of soft-delete status | ||
| page_ids = list(Page.objects.all().order_by("name").values_list("id", flat=True)) | ||
|
|
||
| updated_pages = [] | ||
| for page_id in page_ids: | ||
| # Create page instance with minimal data | ||
| updated_pages.append(Page(id=page_id, sort_order=sort_order)) | ||
| sort_order += 100 | ||
|
|
||
| # Bulk update when batch is full | ||
| if len(updated_pages) >= batch_size: | ||
| Page.objects.bulk_update( | ||
| updated_pages, ["sort_order"], batch_size=batch_size | ||
| ) | ||
| updated_pages = [] | ||
|
|
||
| # Update remaining pages | ||
| if updated_pages: | ||
| Page.objects.bulk_update(updated_pages, ["sort_order"], batch_size=batch_size) | ||
|
|
||
|
|
||
| def reverse_set_page_sort_order(apps, schema_editor): | ||
| Page = apps.get_model("db", "Page") | ||
| Page.objects.update(sort_order=Page.DEFAULT_SORT_ORDER) | ||
|
|
||
NarayanBavisetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("db", "0105_alter_project_cycle_view_and_more"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="ProjectWebhook", | ||
| 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" | ||
| ), | ||
| ), | ||
| ( | ||
| "deleted_at", | ||
| models.DateTimeField( | ||
| blank=True, null=True, verbose_name="Deleted At" | ||
| ), | ||
| ), | ||
| ( | ||
| "id", | ||
| models.UUIDField( | ||
| db_index=True, | ||
| default=uuid.uuid4, | ||
| editable=False, | ||
| primary_key=True, | ||
| serialize=False, | ||
| unique=True, | ||
| ), | ||
| ), | ||
| ( | ||
| "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", | ||
| ), | ||
| ), | ||
| ( | ||
| "project", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="project_%(class)s", | ||
| to="db.project", | ||
| ), | ||
| ), | ||
| ( | ||
| "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", | ||
| ), | ||
| ), | ||
| ( | ||
| "webhook", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="project_webhooks", | ||
| to="db.webhook", | ||
| ), | ||
| ), | ||
| ( | ||
| "workspace", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="workspace_%(class)s", | ||
| to="db.workspace", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name": "Project Webhook", | ||
| "verbose_name_plural": "Project Webhooks", | ||
| "db_table": "project_webhooks", | ||
| "ordering": ("-created_at",), | ||
| }, | ||
| ), | ||
| migrations.AddConstraint( | ||
| model_name="projectwebhook", | ||
| constraint=models.UniqueConstraint( | ||
| condition=models.Q(("deleted_at__isnull", True)), | ||
| fields=("project", "webhook"), | ||
| name="project_webhook_unique_project_webhook_when_deleted_at_null", | ||
| ), | ||
| ), | ||
| migrations.AlterUniqueTogether( | ||
| name="projectwebhook", | ||
| unique_together={("project", "webhook", "deleted_at")}, | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="issuerelation", | ||
| name="relation_type", | ||
| field=models.CharField( | ||
| default="blocked_by", max_length=20, verbose_name="Issue Relation Type" | ||
| ), | ||
| ), | ||
sriramveeraghanta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| migrations.RunPython( | ||
| set_page_sort_order, reverse_code=reverse_set_page_sort_order | ||
| ), | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.