feat: add brand asset cleanup worker and related functionality
- 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:
@@ -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;
|
||||
Reference in New Issue
Block a user