chore: deprecate activityTasks and activities tables in postgres (CM-1007)#4086
chore: deprecate activityTasks and activities tables in postgres (CM-1007)#4086
Conversation
Signed-off-by: Uroš Marolt <uros@marolt.me>
There was a problem hiding this comment.
Pull request overview
This PR removes remaining Postgres dependencies on the legacy activities/activityTasks tables and introduces a migration to drop those tables from the backend database schema.
Changes:
- Drop
activitiesandactivityTaskstables via a new migration, and remove related legacy repositories/helpers. - Remove multiple Postgres-based helper queries/mutations around activities in the data-access layer and backend repositories.
- Adjust member-erasure and affiliation logic to no longer touch the removed
activitiestable.
Reviewed changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| services/libs/data-access-layer/src/old/apps/data_sink_worker/repo/activity.repo.ts | Deletes the legacy Postgres activities repository implementation. |
| services/libs/data-access-layer/src/old/apps/data_sink_worker/repo/activity.data.ts | Removes legacy ColumnSet builders tied to Postgres activities inserts/updates. |
| services/libs/data-access-layer/src/activities/sql.ts | Removes Postgres-only helper functions (by-id fetch, member flags update, conversation link, sentiment/type aggregations). |
| services/apps/data_sink_worker/src/bin/erase-member.ts | Stops attempting to delete from the activities table during member erasure. |
| backend/src/database/repositories/memberSegmentAffiliationRepository.ts | Removes write/update paths that were updating activities.organizationId. |
| backend/src/database/repositories/memberRepository.ts | Replaces a segment lookup from activities with a lookup from memberSegments during identity conflict handling. |
| backend/src/database/migrations/V1778146717__drop-activities-and-activity-tasks.sql | Adds migration to drop activityTasks and activities. |
| backend/src/database/migrations/U1778146717__drop-activities-and-activity-tasks.sql | Adds an undo migration file (currently empty). |
| backend/src/bin/scripts/fix-auto-merged-orgs.ts | Removes a backend script that directly updated Postgres activities. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 408007f. Configure here.
Signed-off-by: Uroš Marolt <uros@marolt.me>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
backend/src/database/repositories/memberSegmentAffiliationRepository.ts:88
- In destroyAll(), the raw
DELETE FROM "memberSegmentAffiliations" ...query is executed withtype: QueryTypes.SELECT. This is inconsistent with other repositories (which use QueryTypes.DELETE) and can lead to incorrect result handling. Change the query type to QueryTypes.DELETE (or omittypeif you rely on metadata).
override async destroyAll(ids: string[]): Promise<void> {
const transaction = this.transaction
const records = await this.findInIds(ids)
Signed-off-by: Uroš Marolt <uros@marolt.me>

Note
High Risk
High risk because it drops the Postgres
activitiestables and removes multiple code paths/scripts that referenced them; any remaining runtime dependency on these tables or the removedGET /activity/{id}endpoint will break after deployment/migration.Overview
Deprecates Postgres-backed activities storage. Adds a migration that drops
activityTasksandactivities, and removes theGET /activity/{id}API plus related repository/service methods for reading/creating activities directly in Postgres.Updates remaining code to stop depending on the dropped tables (e.g., member identity conflict checks now use
memberSegments), removes affiliation logic that updatedactivities.organizationId, and deletes several legacy maintenance scripts and old data-access helpers/queries that read/write fromactivities(including email-worker “top activity types” and data-sink-worker activity repo/columns).Reviewed by Cursor Bugbot for commit 39689a7. Bugbot is set up for automated code reviews on this repo. Configure here.