diff options
Diffstat (limited to 'backend/db/migrations')
| -rw-r--r-- | backend/db/migrations/005_add_guid_index.sql | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/backend/db/migrations/005_add_guid_index.sql b/backend/db/migrations/005_add_guid_index.sql index a653d79..e3625ee 100644 --- a/backend/db/migrations/005_add_guid_index.sql +++ b/backend/db/migrations/005_add_guid_index.sql @@ -1,2 +1,10 @@ --- Add index on guid for deduplication queries +-- Add index on guid for deduplication CREATE INDEX IF NOT EXISTS idx_articles_guid ON articles(guid); + +-- Remove duplicate articles by guid, keeping only the one with the smallest id +DELETE FROM articles +WHERE id NOT IN ( + SELECT MIN(id) + FROM articles + GROUP BY guid +); |
