[_]: feat/add migration to clean up duplicate folders#916
Merged
Conversation
sg-gs
requested changes
Feb 5, 2026
adcaf58 to
0d26e88
Compare
sg-gs
previously approved these changes
Feb 5, 2026
Member
sg-gs
left a comment
There was a problem hiding this comment.
FYI: Analysed the count and there are 185 cases where this is happening. Running migration @jzunigax2
Contributor
Author
|
@sg-gs added a temporary support index which resulted on the following explain result locally it gets rid of the sequential scan and instead leverages the supporting index |
sg-gs
previously approved these changes
Feb 5, 2026
Member
sg-gs
left a comment
There was a problem hiding this comment.
Great, let's see how it performs. Executing migration @jzunigax2
|
This PR is stale because it has been open for more than 15 days with no activity. |
21b7c8c to
85f8682
Compare
|
sg-gs
approved these changes
Feb 25, 2026
Member
sg-gs
left a comment
There was a problem hiding this comment.
Migration run @jzunigax2
Sequelize CLI [Node: 22.16.0, CLI: 6.6.3, ORM: 6.37.7]
Loaded configuration file "src/config/sequelize.js".
Using environment "production".
== 20260225012358-cleanup-duplicate-folders: migrating =======
Starting cleanup of duplicate folders...
Creating supporting index...
Found 185 duplicate (parent_uuid, plain_name) pairs.
=== Cleanup Complete: renamed 530 folders ===
Dropping supporting index...
== 20260225012358-cleanup-duplicate-folders: migrated (306.883s)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



What
Adds a batched migration to rename duplicate folders that share the same
(parent_uuid, plain_name)pair wheredeleted = falseWhy
The unique index on
folders(parent_uuid, plain_name) WHERE deleted = false(blocked PR: #882) cannot be applied because existing duplicate entries violate the constraint:This migration resolves those conflicts by renaming duplicates, making the data safe for the unique index.
How
GROUP BY parent_uuid, plain_name HAVING COUNT(*) > 1to find only duplicate groupsMIN(id)(oldest) unchangedplain_name || '_' || id::textEXPLAIN ANALYZE