Skip to content

feat(db): add naming_instructions to user_settings - #9387

Open
aaronrosenthal wants to merge 1 commit into
ParadevAI:mainfrom
aaronrosenthal:user-settings-naming-instructions-migration
Open

aaronrosenthal wants to merge 1 commit into
ParadevAI:mainfrom
aaronrosenthal:user-settings-naming-instructions-migration

Conversation

@aaronrosenthal

@aaronrosenthal aaronrosenthal commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What & why

First of three PRs for #9197 (account-wide naming instructions). This one only adds a nullable naming_instructions text column to user_settings. It ships alone because of the rule that a schema migration goes in its own PR (packages/trpc/AGENTS.md rule 10).

  • Next: the API field in userSettings.get/update (PR 2), then host-service and desktop (PR 3).
  • loadUserSettings selects columns explicitly, so the API output stays the same in this PR.

How I tested it

  • drizzle-kit generate wrote 0190_user_settings_naming_instructions.sql, which is one statement: ALTER TABLE "user_settings" ADD COLUMN "naming_instructions" text;
  • Applied all migrations to this workspace's own local Postgres 18 DB. The column exists afterwards.

Migration safety checklist:

  • Nullable column with no default, so Postgres changes only metadata: no table rewrite, and the ACCESS EXCLUSIVE lock is held for a moment only.
  • user_settings is small (one row per person who has changed a setting) and is not one of the hot tables in rule 4.
  • No foreign keys change, so lock order doesn't matter.
  • No tRPC input or output change in this PR.
  • Not rehearsed under load, and I didn't check production table sizes, since I have no production access. A metadata-only ADD COLUMN on a small table should not need it, but a maintainer may want to confirm the user_settings size.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR)

Summary by cubic

Adds a nullable naming_instructions text column to user_settings as the first step toward account-wide naming instructions (#9197). This PR ships only the schema migration; the API field and host-service changes come in follow-up PRs.

  • The migration is a single ALTER TABLE adding a nullable column, so it's metadata-only with no table rewrite.
  • loadUserSettings selects columns explicitly, so the API output is unchanged in this PR.

Written for commit 745d286. Summary will update on new commits.

View guided diff

Summary by CodeRabbit

  • New Features
    • User settings can now include optional naming instructions, which can be saved as text. Existing settings remain compatible when no instructions are provided.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The user settings schema now includes a nullable text field for naming instructions. A database migration adds the matching column, and the migration journal records the migration.

Changes: User settings naming instructions

Layer / File(s) Summary
Add naming instructions field
packages/db/src/schema/user-settings.ts, packages/db/drizzle/0190_user_settings_naming_instructions.sql, packages/db/drizzle/meta/_journal.json
The schema maps a nullable text field to naming_instructions. The migration adds the column, and the journal records the migration.

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Feature

Possibly related issues

  • Issue 9197 requests a user-scoped naming instructions field. This change adds the database column, while the issue’s API, host-service, and desktop requirements remain outside this change.

Suggested reviewers: harshithmullapudi

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title uses conventional commit format and clearly identifies the main change: adding naming_instructions to user_settings.
Description check Passed The description includes the required What & why, How I tested it, and Checklist sections. It explains the schema change, migration safety, testing, scope, and follow-up work. The unsigned CLA checkbo…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the required What & why, How I tested it, and Checklist sections. It explains the schema change, migration safety, testing, scope, and follow-up work. The unsigned CLA checkbox is a non-critical incomplete item.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Review coverage is incomplete: 1 file could not be fully reviewed. Findings from completed review steps are included; see review info for details.

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bf60b212-19f4-4eac-a8b2-034384a003b3
Commits

Reviewing files that changed from the base of the PR and between bcc2455 and 745d286.

Files selected for processing: 4

  • packages/db/drizzle/0190_user_settings_naming_instructions.sql
  • packages/db/drizzle/meta/0190_snapshot.json
  • packages/db/drizzle/meta/_journal.json
  • packages/db/src/schema/user-settings.ts
Files not fully reviewed because their changes were unavailable: 1

  • packages/db/drizzle/meta/0190_snapshot.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

Architecture diagram
sequenceDiagram
    participant Dev as Developer (Local)
    participant CLI as drizzle-kit
    participant DB as PostgreSQL
    participant App as Application
    participant Schema as Drizzle Schema
    participant ORM as Drizzle ORM
    participant API as tRPC API
    participant Settings as loadUserSettings

    Note over Dev,DB: Migration Generation & Application
    
    Dev->>CLI: generate migration
    CLI->>Schema: Read user-settings.ts
    Schema-->>CLI: Column defs (now includes naming_instructions)
    CLI->>DB: Write 0190_user_settings_naming_instructions.sql
    CLI-->>Dev: SQL file generated
    
    Dev->>DB: Apply migration (psql/runner)
    DB->>DB: ALTER TABLE - ADD COLUMN naming_instructions text
    
    Note over DB: Metadata-only op (nullable, no default)
    Note over DB: No table rewrite, brief ACCESS EXCLUSIVE lock
    
    DB-->>Dev: Migration applied
    
    Note over App,Settings: Runtime Data Flow (post-migration)
    
    App->>ORM: Query user_settings
    ORM->>Schema: Map table columns
    Schema-->>ORM: Column mapping includes naming_instructions
    
    ORM->>DB: SELECT specific columns via loadUserSettings
    DB-->>ORM: Row data (incl. naming_instructions if present)
    
    ORM->>Settings: Build settings object
    Settings->>Settings: Explicit column selection
    
    alt naming_instructions is NULL (no value set)
        Settings-->>API: Same output as before (field absent)
    else naming_instructions has value
        Settings-->>API: Output includes naming_instructions
    end
    
    API-->>App: Return user settings
    
    Note over DB: Future states (not in this PR)
    Note over DB: Naming instructions stored per user
    Note over DB: Field present only after user sets it
Loading

View guided diff | Re-trigger cubic

This branch has not been deployed

No deployments
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.

1 participant