Repository navigation
feat(db): add naming_instructions to user_settings - #9387
aaronrosenthal wants to merge 1 commit into
Conversation
Walkthrough
Pre-merge checks:
|
There was a problem hiding this comment.
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
What & why
First of three PRs for #9197 (account-wide naming instructions). This one only adds a nullable
naming_instructions textcolumn touser_settings. It ships alone because of the rule that a schema migration goes in its own PR (packages/trpc/AGENTS.mdrule 10).userSettings.get/update(PR 2), then host-service and desktop (PR 3).loadUserSettingsselects columns explicitly, so the API output stays the same in this PR.How I tested it
drizzle-kit generatewrote0190_user_settings_naming_instructions.sql, which is one statement:ALTER TABLE "user_settings" ADD COLUMN "naming_instructions" text;Migration safety checklist:
user_settingsis small (one row per person who has changed a setting) and is not one of the hot tables in rule 4.ADD COLUMNon a small table should not need it, but a maintainer may want to confirm theuser_settingssize.Checklist
type(scope): subject)bun run lintandbun run typecheckpass (CI fails on lint warnings too)Summary by cubic
Adds a nullable
naming_instructionstext column touser_settingsas 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.ALTER TABLEadding a nullable column, so it's metadata-only with no table rewrite.loadUserSettingsselects columns explicitly, so the API output is unchanged in this PR.Written for commit 745d286. Summary will update on new commits.
Summary by CodeRabbit