Skip to content

chore(types): regen database.ts after postgame/signals prod reconcile#805

Merged
njrini99-code merged 1 commit into
mainfrom
chore/db-types-regen-0711
Jul 11, 2026
Merged

chore(types): regen database.ts after postgame/signals prod reconcile#805
njrini99-code merged 1 commit into
mainfrom
chore/db-types-regen-0711

Conversation

@njrini99-code

Copy link
Copy Markdown
Owner

Summary

Prod schema moved under the two reconcile migrations merged in #804 and applied to production today, so the committed database.ts no longer matched the live database. This regenerates it verbatim from prod (Supabase type generator, no hand edits).

Diff is confined to baseball_postgame_reviews / baseball_postgame_review_items (the reconciled columns, body now nullable) plus new FK Relationships entries for coach_id and timeline_event_id. The generator also dropped the empty graphql_public schema block from its output — nothing in src/ references it.

Partner-readable summary

Internal type definitions updated to match the production database after today's schema fixes. No user-facing change.

Type of change

  • Bug fix
  • Feature / new behavior
  • Security / RLS / auth
  • Database migration
  • CI / tooling / chore
  • Docs only

Area

baseball · ci

Risk level

  • Low — generated types only, verified against typecheck + docs:check

Git Activity Timeline note

Keeps generated database types in sync with production after the postgame/signals schema fixes.

Checklist

  • npm run typecheck passes (exit 0)
  • npm run docs:check passes (no glossary drift)
  • No migrations, no RLS changes, no secrets
  • Generator output written verbatim — no hand edits

🤖 Generated with Claude Code

https://claude.ai/code/session_019WJ1Gzjj9MT3UsxhMoMzSV


Generated by Claude Code

Prod schema moved under the two reconcile migrations merged in #804
(applied 2026-07-11); regenerate so the committed types match the live
database again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019WJ1Gzjj9MT3UsxhMoMzSV
@greptile-apps

greptile-apps Bot commented Jul 11, 2026

Copy link
Copy Markdown

No reviewable files after applying ignore patterns.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • src/lib/types/database.ts is excluded by !src/lib/types/database.ts

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5ed6098d-396d-44e9-a51b-b13106caaf8a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/db-types-regen-0711
  • 🛠️ helm safety pass
  • 🛠️ dashboard ux pass
  • 🛠️ rls test pass

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

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
helmv3 Ignored Ignored Jul 11, 2026 6:38pm

Request Review

@supabase

supabase Bot commented Jul 11, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project qmnssrrolpinvwjjnufo because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@njrini99-code njrini99-code merged commit 784138e into main Jul 11, 2026
35 of 36 checks passed
@njrini99-code njrini99-code deleted the chore/db-types-regen-0711 branch July 11, 2026 18:38
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Regenerate Supabase database types after postgame schema reconcile

⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Regenerate database.ts from production Supabase schema to remove drift after reconcile
 migrations.
• Update postgame review table types (new columns; body now nullable) and add FK relationship
 metadata.
• Drop the empty graphql_public schema block from generated output (unused).
Diagram

graph TD
  A[("Prod Supabase DB")] --> E["Postgame tables"] --> B["Supabase typegen"] --> C["src/lib/types/database.ts"] --> D["App TS typecheck"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add CI drift check (typegen + diff)
  • ➕ Prevents future production/schema drift from landing unnoticed
  • ➕ Keeps regenerated output consistently formatted and up to date
  • ➖ Adds CI time/complexity and requires secure DB access or a schema snapshot artifact
2. Stop committing generated DB types; generate at build/dev time
  • ➕ Eliminates PR churn from large generated diffs
  • ➕ Always matches the schema source used for generation
  • ➖ Requires reliable access to schema source during dev/CI
  • ➖ Harder to pin types to a specific deployed schema version

Recommendation: The current approach (regenerate and commit database.ts verbatim from prod) is appropriate for quickly restoring correctness with minimal risk. Consider a follow-up CI drift check if schema/type mismatches have been recurring.

Files changed (1) +105 / -31

Other (1) +105 / -31
database.tsRegenerate Database types from prod; update postgame review schemas +105/-31

Regenerate Database types from prod; update postgame review schemas

• Removes the empty generated 'graphql_public' schema block. Updates 'baseball_postgame_review_items' and 'baseball_postgame_reviews' table typings to match production (including 'body' becoming nullable, multiple new/required columns, and additional relationship metadata such as 'coach_id' and 'timeline_event_id' foreign keys).

src/lib/types/database.ts

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 98 rules

Grey Divider


Remediation recommended

1. Null title breaks conversion 🐞 Bug ☼ Reliability
Description
Database now types baseball_postgame_review_items.title as nullable, but
convertPostgameItemToTimeline forwards item.title into appendTimelineEvent which hard-rejects
missing/blank titles; any DB row with a null/blank title will make conversion fail and the caller
only returns a generic error. The postgame read-model also returns row.title as a required string,
so nullable titles can leak into UI data without any fallback.
Code

src/lib/types/database.ts[R5529-5541]

+          item_kind: string | null
          item_type: string
+          owner_role: string | null
          player_id: string | null
+          player_visible: boolean
+          priority: string
          review_id: string
+          signal_source: string | null
          source_refs: Json
          team_id: string
+          timeline_event_id: string | null
+          title: string | null
+          updated_at: string | null
Relevance

⭐⭐⭐ High

Team fixes schema drift/null crashes in baseball (PRs #618, #580); likely to add guard/fallback for
nullable title.

PR-#618
PR-#580
PR-#569

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The regenerated database types explicitly allow null title/item_kind for postgame items, while
both the conversion action and read model treat these fields as always present; additionally, the
timeline writer enforces a non-empty title, making null/blank titles a hard failure for conversion.

src/lib/types/database.ts[5517-5542]
src/app/baseball/actions/postgame.ts[275-312]
src/lib/baseball/timeline-writer.ts[155-166]
src/lib/baseball/read-models/postgame.ts[42-189]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`src/lib/types/database.ts` now reflects production nullability for postgame review item titles (`title: string | null`). Downstream code assumes a non-null title and can fail at runtime when attempting to convert an item to a timeline event because `appendTimelineEvent` requires a non-empty title.

### Issue Context
- Conversion path: `convertPostgameItemToTimeline` loads a postgame item and passes `item.title` directly into `appendTimelineEvent`.
- `appendTimelineEvent` returns `{ ok:false, error:'A timeline event title is required.' }` when title is null/blank.
- The conversion action currently discards this specific error and returns a generic message.
- The postgame read-model also treats `row.title` as a required string.

### Fix Focus Areas
- src/app/baseball/actions/postgame.ts[275-312]
- src/lib/baseball/timeline-writer.ts[155-166]
- src/lib/baseball/read-models/postgame.ts[42-189]

### Suggested fix
1. In `convertPostgameItemToTimeline`, validate `item.title` before calling `appendTimelineEvent`:
  - If missing/blank, return a specific error (e.g. `Item is missing a title; cannot convert.`).
  - Optionally, propagate `appended.error` instead of always returning `'Could not log the timeline event.'`.
2. In the postgame read-model `mapItem`, ensure `title` is never returned as `null` (either validate and drop/flag invalid rows, or provide a safe fallback string).
3. If titles are intended to be mandatory, consider enforcing `NOT NULL` at the DB level so the schema matches the application invariant.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread src/lib/types/database.ts
Comment on lines +5529 to +5541
item_kind: string | null
item_type: string
owner_role: string | null
player_id: string | null
player_visible: boolean
priority: string
review_id: string
signal_source: string | null
source_refs: Json
team_id: string
timeline_event_id: string | null
title: string | null
updated_at: string | null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Null title breaks conversion 🐞 Bug ☼ Reliability

Database now types baseball_postgame_review_items.title as nullable, but
convertPostgameItemToTimeline forwards item.title into appendTimelineEvent which hard-rejects
missing/blank titles; any DB row with a null/blank title will make conversion fail and the caller
only returns a generic error. The postgame read-model also returns row.title as a required string,
so nullable titles can leak into UI data without any fallback.
Agent Prompt
### Issue description
`src/lib/types/database.ts` now reflects production nullability for postgame review item titles (`title: string | null`). Downstream code assumes a non-null title and can fail at runtime when attempting to convert an item to a timeline event because `appendTimelineEvent` requires a non-empty title.

### Issue Context
- Conversion path: `convertPostgameItemToTimeline` loads a postgame item and passes `item.title` directly into `appendTimelineEvent`.
- `appendTimelineEvent` returns `{ ok:false, error:'A timeline event title is required.' }` when title is null/blank.
- The conversion action currently discards this specific error and returns a generic message.
- The postgame read-model also treats `row.title` as a required string.

### Fix Focus Areas
- src/app/baseball/actions/postgame.ts[275-312]
- src/lib/baseball/timeline-writer.ts[155-166]
- src/lib/baseball/read-models/postgame.ts[42-189]

### Suggested fix
1. In `convertPostgameItemToTimeline`, validate `item.title` before calling `appendTimelineEvent`:
   - If missing/blank, return a specific error (e.g. `Item is missing a title; cannot convert.`).
   - Optionally, propagate `appended.error` instead of always returning `'Could not log the timeline event.'`.
2. In the postgame read-model `mapItem`, ensure `title` is never returned as `null` (either validate and drop/flag invalid rows, or provide a safe fallback string).
3. If titles are intended to be mandatory, consider enforcing `NOT NULL` at the DB level so the schema matches the application invariant.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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