Skip to content

chore: deprecate activityTasks and activities tables in postgres (CM-1007)#4086

Merged
themarolt merged 5 commits intomainfrom
chore/drop-activities-table-CM-1007
May 7, 2026
Merged

chore: deprecate activityTasks and activities tables in postgres (CM-1007)#4086
themarolt merged 5 commits intomainfrom
chore/drop-activities-table-CM-1007

Conversation

@themarolt
Copy link
Copy Markdown
Contributor

@themarolt themarolt commented May 7, 2026

Note

High Risk
High risk because it drops the Postgres activities tables and removes multiple code paths/scripts that referenced them; any remaining runtime dependency on these tables or the removed GET /activity/{id} endpoint will break after deployment/migration.

Overview
Deprecates Postgres-backed activities storage. Adds a migration that drops activityTasks and activities, and removes the GET /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 updated activities.organizationId, and deletes several legacy maintenance scripts and old data-access helpers/queries that read/write from activities (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.

Signed-off-by: Uroš Marolt <uros@marolt.me>
Copilot AI review requested due to automatic review settings May 7, 2026 10:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 activities and activityTasks tables 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 activities table.

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.

Comment thread backend/src/database/repositories/memberRepository.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread backend/src/database/repositories/memberRepository.ts
Copilot AI review requested due to automatic review settings May 7, 2026 11:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with type: 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 omit type if 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>
@themarolt themarolt requested review from epipav and joanagmaia May 7, 2026 12:34
@themarolt themarolt merged commit 1bd18ad into main May 7, 2026
15 checks passed
@themarolt themarolt deleted the chore/drop-activities-table-CM-1007 branch May 7, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants