Skip to content

chore:add cassandra message schema documentation#22

Merged
yenta merged 6 commits intomainfrom
chore/add_cassandra_data_model
Mar 27, 2026
Merged

chore:add cassandra message schema documentation#22
yenta merged 6 commits intomainfrom
chore/add_cassandra_data_model

Conversation

@yenta
Copy link
Copy Markdown
Collaborator

@yenta yenta commented Mar 27, 2026

add cassandra data model

Summary by CodeRabbit

  • Documentation
    • Added a new reference describing the message storage model: room/thread/pinned collections, participant metadata (including bots), attachments and rich content (cards, files, actions), reactions mapping, visibility/unread and edit history, deletion/system-message handling, and considerations for federated message sources.

yenta added 2 commits March 27, 2026 11:30
This document outlines the Cassandra message data model, including user-defined types (UDTs) for participants, cards, card actions, and files, as well as the messages_by_room table schema.
Added definitions for thread_messages_by_room and pinned_messages_by_room tables.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 831f01e1-a059-478e-ba8d-d6435db26310

📥 Commits

Reviewing files that changed from the base of the PR and between 79359e5 and ccdf75a.

📒 Files selected for processing (1)
  • docs/cassandra_message_model.md
✅ Files skipped from review due to trivial changes (1)
  • docs/cassandra_message_model.md

📝 Walkthrough

Walkthrough

Adds a new documentation page that defines a Cassandra CQL message data model: four UDTs (Participant, Card, CardAction, File) and three tables (messages_by_room, thread_messages_by_room, pinned_messages_by_room) with keys, clustering, columns for content, reactions, visibility, deletion, federation, and timestamps.

Changes

Cohort / File(s) Summary
Documentation
docs/cassandra_message_model.md
New document defining four UDTs (Participant, Card, CardAction, File) and three tables (messages_by_room, thread_messages_by_room, pinned_messages_by_room) including partition/clustering keys and ordering; columns for sender/target, msg, mentions, attachments (LIST<BLOB>), optional file/card/card_action UDTs, visible_to/unread, reactions map, deletion/system message fields, federate_from, and created/updated timestamps.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 I hopped through schema, carrots found,
Four tidy UDTs beneath the ground.
Threads and pins in ordered rows,
Reactions bloom where data flows.
Hop, send, and stamp—the model grows.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding Cassandra message schema documentation to the docs folder.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/add_cassandra_data_model

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/cassandra_message_model.md`:
- Line 2: Update the description sentence in the document fragment "Description:
This schema is for message related operation in Cassandra, include query,
upsert..." to correct grammar and hyphenation by changing it to something like:
"Description: This schema is for message-related operations in Cassandra,
including queries and upserts." Locate the exact text in the
docs/cassandra_message_model.md content and replace the original phrase with the
revised sentence.
- Around line 44-124: The docs currently describe
messages_by_room/thread_messages_by_room/pinned_messages_by_room schemas which
do not match the runtime tables and columns used in code (e.g., messages with
room_id, created_at, id, user_id, content referenced in
history-service/store_real.go, message-worker/store_mongo.go,
history-service/integration_test.go, pkg/model/message.go); update docs to
include a clear "Compatibility and Migrations" section that: states whether the
documented tables are future-state or current production, lists the actual
current production schema (table name messages and its columns), provides
explicit migration steps (DDL changes, data backfill strategy, and any
dual-write or read-cutover plan), and documents read/write cutover expectations
and impacted services (reference the functions/files above and the table names
messages_by_room/thread_messages_by_room/pinned_messages_by_room) so
implementers are not misled.
- Line 53: The mentions field is incorrectly using SET<"Participants"> and must
reference the singular UDT "Participant" and wrap UDT elements in FROZEN; update
every mentions declaration to use SET<FROZEN<"Participant">> (matching the
pattern used by reactions, e.g., MAP<TEXT,FROZEN<SET<FROZEN<"Participant">>>>),
ensuring all three table definitions that currently reference "Participants" are
changed to SET<FROZEN<"Participant">>.
- Line 21: The CREATE TYPE UDT definitions for Card and File contain trailing
commas before the closing ");" which is invalid CQL; edit the Card and File UDT
declarations to remove the trailing comma after the last field so the field
lists end with the final field then the closing ");" (i.e., locate the CREATE
TYPE Card and CREATE TYPE File blocks and delete the comma that appears
immediately before the closing parenthesis/semicolon).
- Line 68: Replace the misspelled CQL keyword "CLUSTRING" with the correct
"CLUSTERING" in the schema CQL statements (the lines containing the WITH ...
ORDER BY (createAt DESC, messageId DESC) clauses); update all occurrences of the
token "CLUSTRING" (appearing alongside the ORDER BY on lines noted in the
review) to "CLUSTERING" so the CQL schema is valid and executable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc7024ec-daad-4a80-b92e-ecfe1920cbac

📥 Commits

Reviewing files that changed from the base of the PR and between aa675f6 and f333b2b.

📒 Files selected for processing (1)
  • docs/cassandra_message_model.md

Comment thread docs/cassandra_message_model.md Outdated
Comment thread docs/cassandra_message_model.md
Comment thread docs/cassandra_message_model.md Outdated
Comment thread docs/cassandra_message_model.md Outdated
Comment thread docs/cassandra_message_model.md Outdated
Comment thread docs/cassandra_message_model.md
Comment thread docs/cassandra_message_model.md Outdated
Comment thread docs/cassandra_message_model.md Outdated
Comment thread docs/cassandra_message_model.md Outdated
Updated field names in Cassandra message model for consistency and clarity.
@yenta
Copy link
Copy Markdown
Collaborator Author

yenta commented Mar 27, 2026

@coderabbitai help

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@yenta
Copy link
Copy Markdown
Collaborator Author

yenta commented Mar 27, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yenta
Copy link
Copy Markdown
Collaborator Author

yenta commented Mar 27, 2026

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

✅ Actions performed

Full review triggered.

@yenta yenta requested a review from ngangwar962 March 27, 2026 05:30
Comment thread docs/cassandra_message_model.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
docs/cassandra_message_model.md (2)

44-126: ⚠️ Potential issue | 🟠 Major

Clarify whether this is future-state schema and add migration/cutover notes.

This schema is much broader than the current runtime message model (pkg/model/message.go, Lines 5-11), so readers can easily assume it is already active. Please add a Compatibility and Migration section covering current production shape, future-state intent, and read/write cutover expectations.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cassandra_message_model.md` around lines 44 - 126, Add a "Compatibility
and Migration" section to this document that explicitly states these tables
(messages_by_room, thread_messages_by_room, pinned_messages_by_room) represent a
future-state schema, contrasts it with the current production message model
(referencing pkg/model/message.go), and provides concrete migration/cutover
guidance: list current production column set, mapping of new columns/types to
current fields, steps for dual-write or backfill strategy, read/write cutover
order, and any downtime/compatibility notes so readers understand rollout
expectations.

2-2: ⚠️ Potential issue | 🟡 Minor

Polish the opening description sentence for grammar and clarity.

Line 2 still reads awkwardly (“operation”, “include query, upsert...”). Please rewrite to a concise, grammatical sentence so this doc is unambiguous.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cassandra_message_model.md` at line 2, The opening description sentence
labeled "Description:" is awkward; replace it with a concise grammatical
sentence such as: "This schema defines message-related operations in Cassandra,
including queries and upserts." Update the "Description" line so it clearly
states the purpose (message-related operations) and lists examples using proper
plural nouns ("queries" and "upserts") to remove ambiguity.
🧹 Nitpick comments (1)
docs/cassandra_message_model.md (1)

67-67: Use a consistent timestamp field name across tables.

Line 67 uses update_at while the other tables use updated_at (Lines 96 and 122). Prefer one canonical name to avoid downstream mapping mistakes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cassandra_message_model.md` at line 67, The schema uses a mismatched
timestamp field name: change the column named update_at to updated_at so it
matches the other tables (references to update_at should be renamed to
updated_at); update any related schema definitions, CQL queries, data mappers,
serializers/deserializers, and tests that reference update_at to use updated_at
(look for the symbol update_at and replace with updated_at, and verify code that
expects updated_at like in other tables still works).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/cassandra_message_model.md`:
- Line 98: The CLUSTERING ORDER clause for table thread_messages_by_room uses
camelCase identifiers (threadRoomId, createAt, messageId) that don't match the
table's actual column names; update the clause to use the real column names
thread_room_id, created_at, and message_id so the CQL is valid (i.e., replace
threadRoomId→thread_room_id, createAt→created_at, messageId→message_id in the
CLUSTERING ORDER BY clause).

---

Duplicate comments:
In `@docs/cassandra_message_model.md`:
- Around line 44-126: Add a "Compatibility and Migration" section to this
document that explicitly states these tables (messages_by_room,
thread_messages_by_room, pinned_messages_by_room) represent a future-state
schema, contrasts it with the current production message model (referencing
pkg/model/message.go), and provides concrete migration/cutover guidance: list
current production column set, mapping of new columns/types to current fields,
steps for dual-write or backfill strategy, read/write cutover order, and any
downtime/compatibility notes so readers understand rollout expectations.
- Line 2: The opening description sentence labeled "Description:" is awkward;
replace it with a concise grammatical sentence such as: "This schema defines
message-related operations in Cassandra, including queries and upserts." Update
the "Description" line so it clearly states the purpose (message-related
operations) and lists examples using proper plural nouns ("queries" and
"upserts") to remove ambiguity.

---

Nitpick comments:
In `@docs/cassandra_message_model.md`:
- Line 67: The schema uses a mismatched timestamp field name: change the column
named update_at to updated_at so it matches the other tables (references to
update_at should be renamed to updated_at); update any related schema
definitions, CQL queries, data mappers, serializers/deserializers, and tests
that reference update_at to use updated_at (look for the symbol update_at and
replace with updated_at, and verify code that expects updated_at like in other
tables still works).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2ac94b37-2b45-4808-8f58-79c046d94504

📥 Commits

Reviewing files that changed from the base of the PR and between aa675f6 and d828833.

📒 Files selected for processing (1)
  • docs/cassandra_message_model.md

Comment thread docs/cassandra_message_model.md Outdated
@yenta yenta changed the title Chore/add cassandra data model chore:add cassandra message schema documentation Mar 27, 2026
@yenta yenta requested a review from ngangwar962 March 27, 2026 05:38
Copy link
Copy Markdown
Collaborator

@ngangwar962 ngangwar962 left a comment

Choose a reason for hiding this comment

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

I think, required changes have been made. Good to go for initial version for cassandra tables

Comment thread docs/cassandra_message_model.md Outdated
Updated 'Participant' type to change 'xxxx_name' to 'company_name'.
Copy link
Copy Markdown
Collaborator

@ngangwar962 ngangwar962 left a comment

Choose a reason for hiding this comment

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

Looks good to me

Removed duplicate 'tshow' field from message model.
Copy link
Copy Markdown
Collaborator

@mliu33 mliu33 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@yenta yenta merged commit 4c43a25 into main Mar 27, 2026
1 check passed
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.

3 participants