Skip to content

WIP : feed migrations to support multi-domain #22601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sonika-shah
Copy link
Contributor

@sonika-shah sonika-shah commented Jul 27, 2025

Describe your changes:

Fixes

  • domain related feeds not generated after multi-domain changes
  • domain still null in thread_entity table after adding column
  • filter threads by domain
  • Tests

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

Copy link
Contributor

@Copilot 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 addresses database migrations and configuration updates to support multi-domain functionality. The changes migrate from single domain support to multi-domain arrays in the thread_entity table and update activity feed configurations accordingly.

  • Migrate thread_entity table from single domain to multi-domain domains array
  • Update activity feed event configurations to track domains instead of domain
  • Add generated columns for efficient domain querying

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
ActivityFeedEvents.json Updates event subscription conditions to track domains field instead of domain
postgres/schemaChanges.sql Migrates thread_entity table data and schema for PostgreSQL multi-domain support
mysql/schemaChanges.sql Migrates thread_entity table data and schema for MySQL multi-domain support

Comment on lines 194 to 196
to_jsonb(ARRAY[json->'domain'])
)
WHERE json ? 'domain' AND json->'domain' IS NOT NULL;
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

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

The migration will create an array containing a null value when json->'domain' is null, despite the WHERE condition checking for NOT NULL. This could result in domains arrays like [null]. Consider using CASE to handle null values or adjust the WHERE condition to be more restrictive.

Suggested change
to_jsonb(ARRAY[json->'domain'])
)
WHERE json ? 'domain' AND json->'domain' IS NOT NULL;
CASE
WHEN json->'domain' IS NOT NULL AND json->>'domain' IS DISTINCT FROM 'null'
THEN to_jsonb(ARRAY[json->'domain'])
ELSE to_jsonb(ARRAY[]::text[])
END
)
WHERE json ? 'domain' AND json->>'domain' IS DISTINCT FROM 'null';

Copilot uses AI. Check for mistakes.

SET json = jsonb_set(
json #- '{feedInfo,entitySpecificInfo,entity,domain}',
'{feedInfo,entitySpecificInfo,entity,domains}',
to_jsonb(ARRAY[json#>'{feedInfo,entitySpecificInfo,entity,domain}'])
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

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

Similar to the previous migration, this could create an array with null values when the nested domain is null. The WHERE condition checks for NOT NULL but the array creation doesn't handle the null case properly.

Suggested change
to_jsonb(ARRAY[json#>'{feedInfo,entitySpecificInfo,entity,domain}'])
to_jsonb(CASE
WHEN json#>'{feedInfo,entitySpecificInfo,entity,domain}' IS NULL THEN ARRAY[]::jsonb[]
ELSE ARRAY[json#>'{feedInfo,entitySpecificInfo,entity,domain}']
END)

Copilot uses AI. Check for mistakes.

SET json = JSON_SET(
JSON_REMOVE(json, '$.domain'),
'$.domains',
JSON_ARRAY(JSON_EXTRACT(json, '$.domain'))
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

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

The migration could create arrays containing null values when JSON_EXTRACT returns null, despite the WHERE condition. MySQL's JSON_ARRAY will include null values in the array. Consider using CASE to handle null extractions properly.

Suggested change
JSON_ARRAY(JSON_EXTRACT(json, '$.domain'))
JSON_ARRAY(
CASE
WHEN JSON_EXTRACT(json, '$.domain') IS NOT NULL
THEN JSON_EXTRACT(json, '$.domain')
ELSE NULL
END
)

Copilot uses AI. Check for mistakes.

Comment on lines +169 to +170
JSON_ARRAY(JSON_EXTRACT(json, '$.feedInfo.entitySpecificInfo.entity.domain'))
)
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

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

Similar null handling issue as above - JSON_ARRAY will include null values even when the WHERE condition attempts to filter them out. This could result in domains arrays containing null elements.

Suggested change
JSON_ARRAY(JSON_EXTRACT(json, '$.feedInfo.entitySpecificInfo.entity.domain'))
)
JSON_ARRAY(
IF(
JSON_EXTRACT(json, '$.feedInfo.entitySpecificInfo.entity.domain') IS NOT NULL,
JSON_EXTRACT(json, '$.feedInfo.entitySpecificInfo.entity.domain'),
NULL
)
)

Copilot uses AI. Check for mistakes.

Copy link
Contributor

TypeScript types have been updated based on the JSON schema changes in the PR

@github-actions github-actions bot requested a review from a team as a code owner July 29, 2025 03:04
Copy link
Contributor

github-actions bot commented Jul 29, 2025

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
63.76% (48523/76101) 39.85% (20353/51070) 43.64% (5846/13396)

Copy link

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend safe to test Add this label to run secure Github workflows on PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant