Files
geo/server/migrations/20260526110000_add_publish_task_dedup_index.up.sql
T
root e5d94f961e feat(publish-dedup): add indexes for publish task dedup and lookup
Add a unique index on desktop_tasks.dedup_key for active publish kinds
(queued/in_progress/succeeded/unknown) so duplicate publish submissions can
be rejected at the DB layer, plus supporting indexes on publish_records and
the desktop_tasks publish_record_id payload expression used by the new
dedup lookup query.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:43:15 +08:00

9 lines
481 B
SQL

-- Keep succeeded publish tasks in the active dedup set intentionally: the
-- product rule is "one article can be published to an account once"; repeat
-- publishing should use a copied/new article or an explicit admin status reset.
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS uq_desktop_tasks_publish_dedup_active
ON desktop_tasks (dedup_key)
WHERE kind = 'publish'
AND dedup_key IS NOT NULL
AND status IN ('queued', 'in_progress', 'succeeded', 'unknown');