feat: add brand asset cleanup worker and related functionality
Frontend CI / Frontend (push) Successful in 3m23s
Backend CI / Backend (push) Failing after 6m46s

- Implemented a new BrandAssetCleanupWorker to handle the cleanup of brand-related assets after a brand is deleted.
- Added SQL queries for cleaning up articles, keywords, questions, competitors, and monitoring data associated with a brand.
- Introduced a new API endpoint to delete publish records.
- Updated the router to include the new delete publish record endpoint.
- Added tests for the BrandAssetCleanupWorker to ensure proper functionality.
- Created migration scripts to support soft deletion of publish records and to add the brand asset cleanup scheduler job.
This commit is contained in:
2026-06-19 11:45:13 +08:00
parent 97ae601cfd
commit 6e0519a232
29 changed files with 1621 additions and 54 deletions
@@ -0,0 +1,9 @@
DROP INDEX CONCURRENTLY IF EXISTS idx_publish_records_visible_status;
DROP INDEX CONCURRENTLY IF EXISTS idx_publish_records_article_account_active;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_publish_records_article_account_active
ON publish_records (tenant_id, article_id, platform_account_id, updated_at DESC, id DESC)
WHERE status IN ('queued', 'publishing', 'success');
ALTER TABLE publish_records
DROP COLUMN IF EXISTS deleted_at;
@@ -0,0 +1,12 @@
ALTER TABLE publish_records
ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_publish_records_visible_status
ON publish_records (tenant_id, status, created_at DESC, id DESC)
WHERE deleted_at IS NULL;
DROP INDEX CONCURRENTLY IF EXISTS idx_publish_records_article_account_active;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_publish_records_article_account_active
ON publish_records (tenant_id, article_id, platform_account_id, updated_at DESC, id DESC)
WHERE status IN ('queued', 'publishing', 'success')
AND deleted_at IS NULL;