Skip to content

Schema normalization fix 851096e#695

Open
ngoiyaeric wants to merge 3 commits into
mainfrom
schema-normalization-fix-851096e
Open

Schema normalization fix 851096e#695
ngoiyaeric wants to merge 3 commits into
mainfrom
schema-normalization-fix-851096e

Conversation

@ngoiyaeric

Copy link
Copy Markdown
Collaborator

No description provided.

google-labs-jules Bot and others added 3 commits June 26, 2026 13:27
- Consolidated users.system_prompt into the system_prompts table.
- Removed redundant locations.geojson and visualizations.data spatial overlap, using PostGIS geometry as canonical.
- Dropped derived chats.path and chats.share_path columns, computing routes dynamically.
- Removed synthetic role:'data' messages for calendar notes and drawing context.
- Introduced dedicated chat_contexts and junction tables for calendar-note tags.
- Reconciled migration history and added missing RLS policies.

Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
- Consolidated users.system_prompt into the system_prompts table.
- Removed redundant locations.geojson and visualizations.data spatial overlap, using PostGIS geometry as canonical.
- Dropped derived chats.path and chats.share_path columns, computing routes dynamically in UI components.
- Decomposed the overloaded messages table: removed synthetic role:'data' rows for calendar notes and drawing context while maintaining feature parity by passing context to agents and keeping a temporary synthetic message for the UI stream.
- Introduced dedicated chat_contexts and junction tables for calendar-note tags (calendar_note_locations, calendar_note_user_tags).
- Reconciled migration history by removing duplicate migrations and merging RLS policies.
- Verified that the project builds successfully with `bun run build`.

Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
- Consolidated `system_prompt` into `system_prompts` table.
- Removed redundant spatial columns and derived chat paths.
- Decomposed `messages` table by moving calendar notes and drawing context to dedicated tables (`calendar_notes`, `chat_contexts`).
- Updated `saveNote` to maintain real-time UI updates via synthetic messages while persisting data to normalized junction tables.
- Fixed various build errors related to component imports and missing types in `app/actions.tsx`.
- Verified successful build with `bun run build`.

Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qcx Ready Ready Preview, Comment Jun 26, 2026 6:10pm

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@ngoiyaeric, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 14 minutes and 58 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9d542472-9788-48ce-9c98-67d5c6b484f3

📥 Commits

Reviewing files that changed from the base of the PR and between fb67dc0 and 851096e.

📒 Files selected for processing (19)
  • app/actions.tsx
  • app/actions.tsx.patch
  • app/actions.tsx.tmp
  • components/history-list.tsx
  • components/history-sidebar.tsx
  • components/sidebar/chat-history-client.tsx
  • drizzle/migrations/0001_add_calendar_notes.sql
  • drizzle/migrations/0001_sync_schema_full.sql
  • drizzle/migrations/0003_consolidate_system_prompt.sql
  • drizzle/migrations/0004_remove_redundant_spatial.sql
  • drizzle/migrations/0005_drop_chat_paths.sql
  • drizzle/migrations/0006_remove_synthetic_calendar_notes.sql
  • drizzle/migrations/0007_add_chat_contexts.sql
  • drizzle/migrations/0008_normalize_calendar_tags.sql
  • drizzle/migrations/meta/_journal.json
  • lib/actions/calendar.ts
  • lib/actions/chat.ts
  • lib/db/schema.ts
  • lib/types/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch schema-normalization-fix-851096e

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@charliecreates charliecreates Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Blocking feedback

  1. Backfill into chat_contexts can fail when a chat has multiple historical context rows — drizzle/migrations/0007_add_chat_contexts.sql#L23
  2. saveNote can write a non-UUID value into calendar_note_locations.location_id and fail note saves when a location tag is attached — lib/actions/calendar.ts#L120

If you want Charlie to patch these directly, reply with the item numbers (for example: please fix 1-2).

END $$;

-- Migrate existing drawing-context role:'data' rows from messages into the new table
INSERT INTO "chat_contexts" ("chat_id", "data", "created_at", "updated_at")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This INSERT ... ON CONFLICT (chat_id) DO UPDATE can fail as soon as messages contains multiple drawing-context rows for the same chat_id (ON CONFLICT DO UPDATE command cannot affect row a second time). updateDrawingContext previously wrote one role='data' row per update, so duplicates per chat are expected in real data.

Suggested fix: dedupe the source to one row per chat_id before upsert (for example SELECT DISTINCT ON (chat_id) ... ORDER BY chat_id, created_at DESC) so the migration deterministically keeps the latest context and remains runnable.

Comment thread lib/actions/calendar.ts
} else if (locationTags && typeof locationTags === 'object') {
await tx.insert(calendarNoteLocations).values({
noteId,
locationId: locationTags.id || locationTags // handle ID or object

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

calendar_note_locations.location_id is a UUID FK, but this branch falls back to inserting the entire locationTags object when locationTags.id is missing. Current caller code (components/calendar-notepad.tsx) builds locationTags as { type: 'Point', coordinates: [...] }, so this path sends a non-UUID and the transaction fails when a user tags a location.

Suggested fix: require/validate a UUID before inserting here, and either resolve/create a locations row first or keep geometry tags in a non-FK structure until a location ID exists.

@ngoiyaeric

Copy link
Copy Markdown
Collaborator Author

Synchronize the main repository

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.

2 participants