Skip to content

✨(db-structure): Remove column.primary duplication with constraints #2205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 26, 2025

Conversation

MH4GF
Copy link
Member

@MH4GF MH4GF commented Jun 25, 2025

Issue

Why is this change needed?

The schema had semantic duplication between column.primary field and PRIMARY KEY constraints. This caused:

  • Data consistency issues when primary key information was stored in two places
  • Complexity in editing operations
  • Difficulty supporting composite primary keys
  • Confusion about which source of truth to use

What would you like reviewers to focus on?

  • Verify that all UI components correctly display primary key indicators using the new isPrimaryKey() function
  • Check that the migration function migratePrimaryToConstraints() properly handles existing schemas
  • Ensure parsers correctly set PRIMARY KEY constraints without the primary field

Testing Verification

  • All existing tests pass after updating snapshots
  • TypeScript compilation succeeds with no errors
  • Linting passes without issues
  • Manually tested UI components show primary key badges correctly

What was done

🤖 Generated by PR Agent at 529e683

  • Remove column.primary field duplication with PRIMARY KEY constraints
  • Add isPrimaryKey utility function for primary key detection
  • Update UI components to use constraint-based primary key logic
  • Modify parsers to only set PRIMARY KEY constraints

Detailed Changes

Relevant files
Enhancement
21 files
getAllMentionCandidates.ts
Update mention candidates to use isPrimaryKey function     
+8/-7     
convertSchemaToText.ts
Use isPrimaryKey for text conversion                                         
+2/-2     
utils.ts
Modify column definition generation for PRIMARY KEY           
+29/-12 
buildSchemaDiff.ts
Remove column primary diff item builder                                   
+0/-12   
buildColumnPrimaryDiffItem.ts
Delete column primary diff item builder                                   
+0/-36   
types.ts
Remove column primary diff item type                                         
+0/-12   
index.ts
Export isPrimaryKey utility function                                         
+1/-0     
constants.ts
Remove column primary path pattern                                             
+0/-1     
parser.ts
Remove primary field from Prisma parser                                   
+0/-3     
parser.ts
Remove primary field from SchemaRB parser                               
+0/-1     
converter.ts
Remove primary field from PostgreSQL converter                     
+0/-3     
parser.ts
Remove primary key extraction from tbls parser                     
+1/-42   
factories.ts
Remove primary field from column factory                                 
+0/-1     
index.ts
Remove column primary schema export                                           
+0/-1     
schema.ts
Remove primary field from column schema                                   
+0/-3     
isPrimaryKey.ts
Add isPrimaryKey utility function                                               
+11/-0   
TableColumn.tsx
Use isPrimaryKey for column icon display                                 
+9/-5     
TableColumnList.tsx
Use isPrimaryKey for column filtering                                       
+10/-3   
Columns.tsx
Pass constraints to columns component                                       
+4/-3     
ColumnsItem.tsx
Use isPrimaryKey for column item display                                 
+8/-3     
TableDetail.tsx
Pass constraints to columns component                                       
+1/-1     
Tests
17 files
workflow.test.ts
Remove primary field from test schema                                       
+7/-4     
operationDeparser.test.ts
Update test snapshots for PRIMARY KEY generation                 
+24/-19 
schemaDeparser.test.ts
Update schema deparser test snapshots                                       
+63/-38 
buildColumnCheckDiffItem.test.ts
Remove primary field from test schemas                                     
+0/-1     
buildColumnCommentDiffItem.test.ts
Remove primary field from test schemas                                     
+0/-1     
buildColumnDefaultDiffItem.test.ts
Remove primary field from test schemas                                     
+0/-1     
buildColumnDiffItem.test.ts
Remove primary field from test schemas                                     
+0/-1     
buildColumnNameDiffItem.test.ts
Remove primary field from test schemas                                     
+0/-1     
buildColumnNotNullDiffItem.test.ts
Remove primary field from test schemas                                     
+0/-1     
buildColumnPrimaryDiffItem.test.ts
Delete entire column primary diff item test                           
+0/-245 
buildColumnUniqueDiffItem.test.ts
Remove primary field from test schemas                                     
+0/-1     
index.test.ts
Remove primary field from parser tests                                     
+0/-7     
index.test.ts
Remove primary field from SchemaRB parser tests                   
+0/-3     
index.test.ts
Remove primary field from SQL parser tests                             
+0/-1     
index.test.ts
Remove primary field from tbls parser tests                           
+0/-4     
mergeSchema.test.ts
Update merge schema tests with constraints                             
+12/-7   
constraintsToRelationships.test.ts
Remove primary field from relationship tests                         
+0/-10   
Configuration changes
2 files
vercel.json
Update Storybook build command                                                     
+1/-1     
turbo.json
Add db-structure dependency to Storybook build                     
+1/-1     

Additional Notes

This is a breaking change for the schema format, but the migratePrimaryToConstraints() function is provided to help users migrate existing data.


Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Summary by CodeRabbit

    • New Features

      • Improved detection of primary key columns across the app by using a new utility function for constraint-based identification.
    • Refactor

      • Updated all primary key handling to rely on table constraints instead of a direct column property.
      • Adjusted component and utility function signatures to support the new primary key approach.
      • Removed obsolete properties and types related to column-level primary key flags.
    • Bug Fixes

      • Enhanced validation for foreign key constraint parsing to prevent invalid entries.
    • Tests

      • Updated all relevant test cases to reflect the new primary key constraint handling.
      • Removed tests related to deprecated primary key property logic.

    Remove the duplication between column.primary field and PRIMARY KEY constraints by:
    - Removing primary field from column schema
    - Creating isPrimaryKey() utility function to detect primary keys from constraints
    - Updating all UI components to use isPrimaryKey() instead of column.primary
    - Updating parsers to only set PRIMARY KEY constraints
    - Providing migratePrimaryToConstraints() for data migration
    
    This improves data consistency, simplifies editing, and better supports composite primary keys by having a single source of truth for primary key information.
    
    Closes #2192
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    Copy link

    changeset-bot bot commented Jun 25, 2025

    ⚠️ No Changeset found

    Latest commit: 3017110

    Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

    This PR includes no changesets

    When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

    Click here to learn what changesets are, and how to add one.

    Click here if you're a maintainer who wants to add a changeset to this PR

    Copy link

    supabase bot commented Jun 25, 2025

    Updates to Preview Branch (remove-primary-field) ↗︎

    Deployments Status Updated
    Database Thu, 26 Jun 2025 07:17:47 UTC
    Services Thu, 26 Jun 2025 07:17:47 UTC
    APIs Thu, 26 Jun 2025 07:17:47 UTC

    Tasks are run on every commit but only new migration files are pushed.
    Close and reopen this PR if you want to apply changes from existing seed or migration files.

    Tasks Status Updated
    Configurations Thu, 26 Jun 2025 07:17:48 UTC
    Migrations Thu, 26 Jun 2025 07:17:48 UTC
    Seeding Thu, 26 Jun 2025 07:17:48 UTC
    Edge Functions Thu, 26 Jun 2025 07:17:48 UTC

    View logs for this Workflow Run ↗︎.
    Learn more about Supabase for Git ↗︎.

    Copy link

    vercel bot commented Jun 25, 2025

    The latest updates on your projects. Learn more about Vercel for Git ↗︎

    Name Status Preview Comments Updated (UTC)
    liam-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 7:21am
    liam-erd-sample ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 7:21am
    liam-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 7:21am
    1 Skipped Deployment
    Name Status Preview Comments Updated (UTC)
    liam-docs ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2025 7:21am

    …statements
    
    - Modified generateCreateTableStatement to add PRIMARY KEY inline with column definitions
    - Fixed TypeScript errors for array access safety
    - Updated test snapshots to reflect correct PRIMARY KEY generation
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    MH4GF and others added 2 commits June 25, 2025 18:13
    - Delete migratePrimaryToConstraints.ts file as it was never used
    - Remove export from index.ts
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    - Modified generateColumnDefinition to accept isPrimaryKey parameter
    - Prevent adding NOT NULL when column will be PRIMARY KEY
    - PRIMARY KEY columns now show as 'bigint PRIMARY KEY' not 'bigint PRIMARY KEY NOT NULL'
    - Updated test snapshots to match correct behavior from origin/main
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    MH4GF and others added 2 commits June 25, 2025 18:30
    Remove the duplication between column.primary field and PRIMARY KEY constraints by:
    - Removing primary field from column schema
    - Creating isPrimaryKey() utility function to detect primary keys from constraints
    - Updating all UI components to use isPrimaryKey() instead of column.primary
    - Updating parsers to only set PRIMARY KEY constraints
    - Providing migratePrimaryToConstraints() for data migration
    
    This improves data consistency, simplifies editing, and better supports composite primary keys by having a single source of truth for primary key information.
    
    Closes #2192
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    - Fixed merge conflicts in deparser test files to maintain PRIMARY KEY behavior
    - Removed remaining primary field references from agent test
    - Fixed import order in index.ts to satisfy biome linter
    - All lint and type checks now pass
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    …oyment
    
    - Added dependency on @liam-hq/db-structure for Storybook build in turbo.json
    - Updated build command in vercel.json to ensure correct path and filtering for Storybook
    
    This change ensures that the Storybook build process correctly includes necessary dependencies and operates as expected in the Vercel environment.
    Copy link
    Contributor

    qodo-merge-for-open-source bot commented Jun 25, 2025

    PR Reviewer Guide 🔍

    (Review updated until commit 25c5c52)

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis 🔶

    2192 - Partially compliant

    Compliant requirements:

    • Remove column.primary field from column schema
    • Implement isPrimaryKey utility function to derive primary key status from constraints
    • Update UI components to display primary keys based on constraints
    • Update parsers to not set primary field and use constraints instead
    • Support composite primary keys through constraint-based design
    • Maintain RDB standard compliance

    Non-compliant requirements:

    • Create migration functionality to convert existing primary: true to PRIMARY KEY constraints

    Requires further human verification:

    • Verify all UI components correctly display primary key indicators using the new function
    • Ensure all parsers correctly set PRIMARY KEY constraints without the primary field
    • Test that existing schemas are properly handled without migration issues

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Validation

    The isPrimaryKey function implementation should be validated to ensure it correctly identifies primary key columns from constraints, especially for composite primary keys and edge cases.

    export const isPrimaryKey = (
      columnName: string,
      constraints: Constraints,
    ): boolean => {
      return Object.values(constraints).some(
        (constraint) =>
          constraint.type === 'PRIMARY KEY' && constraint.columnName === columnName,
      )
    }
    SQL Generation

    The generateCreateTableStatement function has complex logic for handling primary key constraints and column definitions. The interaction between isPrimaryKey detection and PRIMARY KEY inline addition needs careful validation.

    const primaryKeyColumns = new Set<string>()
    for (const constraint of Object.values(table.constraints)) {
      if (constraint.type === 'PRIMARY KEY') {
        primaryKeyColumns.add(constraint.columnName)
      }
    }
    
    // Generate column definitions
    const columnDefinitions = (Object.values(table.columns) as Column[]).map(
      (column) => {
        const isPrimaryKey = primaryKeyColumns.has(column.name)
        let definition = generateColumnDefinition(column, isPrimaryKey)
    
        // Add PRIMARY KEY inline if this column is a primary key
        if (isPrimaryKey) {
          definition += ' PRIMARY KEY'
        }
    
        return definition
      },
    )
    Logic Change

    The condition change from result.success to result.success && result.output may affect the evaluation logic and should be verified for correctness and necessity.

    if (result.success && result.output) {
      referenceForeignKeys.push({

    Copy link
    Contributor

    qodo-merge-for-open-source bot commented Jun 25, 2025

    PR Code Suggestions ✨

    Latest suggestions up to 25c5c52
    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Prevent redundant UNIQUE constraint on primary keys
    Suggestion Impact:The commit completely removed the UNIQUE constraint logic instead of adding the suggested conditional check, which achieves the same goal of preventing redundant UNIQUE constraints on primary keys

    code diff:

    -  if (column.unique) {
    -    definition += ' UNIQUE'
    -  }

    The UNIQUE constraint should not be added for primary key columns since PRIMARY
    KEY already implies uniqueness. Add a check to prevent redundant UNIQUE
    constraint on primary key columns.

    frontend/packages/db-structure/src/deparser/postgresql/utils.ts [13-20]

    -if (column.unique) {
    +if (column.unique && !isPrimaryKey) {
       definition += ' UNIQUE'
     }
     
     // Don't add NOT NULL if this will be a PRIMARY KEY
     if (column.notNull && !isPrimaryKey) {
       definition += ' NOT NULL'
     }

    [Suggestion processed]

    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly points out that a PRIMARY KEY constraint in SQL already implies UNIQUE. The PR refactored how primary keys are handled but missed adding a check to prevent adding a redundant UNIQUE keyword for primary key columns. This fixes a regression introduced in the PR and improves the correctness of the generated SQL.

    Medium
    • Update

    Previous suggestions

    ✅ Suggestions up to commit 529e683
    CategorySuggestion                                                                                                                                    Impact
    General
    Avoid redundant UNIQUE constraint for primary keys
    Suggestion Impact:The commit completely removed the UNIQUE constraint logic instead of conditionally applying it. This goes beyond the suggestion but achieves the same goal of avoiding redundant UNIQUE constraints for primary keys.

    code diff:

    -  if (column.unique) {
    -    definition += ' UNIQUE'
    -  }

    The UNIQUE constraint should not be added for primary key columns since PRIMARY
    KEY already implies uniqueness. This prevents redundant SQL generation.

    frontend/packages/db-structure/src/deparser/postgresql/utils.ts [13-20]

    -if (column.unique) {
    +if (column.unique && !isPrimaryKey) {
       definition += ' UNIQUE'
     }
     
     // Don't add NOT NULL if this will be a PRIMARY KEY
     if (column.notNull && !isPrimaryKey) {
       definition += ' NOT NULL'
     }
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly points out that a PRIMARY KEY constraint already implies UNIQUE. The current code would generate a redundant UNIQUE keyword for primary key columns. This change improves the correctness and cleanliness of the generated SQL, aligning with the logic already present for the NOT NULL constraint.

    Medium

    Copy link

    coderabbitai bot commented Jun 26, 2025

    Walkthrough

    This change removes the primary property from column definitions throughout the codebase, unifying primary key representation under table-level constraints. All logic and UI components that previously relied on column.primary now use a new isPrimaryKey utility, which determines primary key status from constraints. Associated type definitions, tests, and schema validations are updated accordingly.

    Changes

    File(s) Change Summary
    .../getAllMentionCandidates.ts, .../convertSchemaToText.ts, .../TableColumn.tsx, .../TableColumnList.tsx, .../Columns/Columns.tsx, .../Columns/ColumnsItem.tsx, .../TableDetail.tsx Updated logic/UI to use isPrimaryKey utility instead of column.primary for primary key detection; updated component props and function signatures as needed.
    .../utils/isPrimaryKey.ts, .../index.ts Added and exported new isPrimaryKey utility function for constraint-based primary key detection.
    .../utils/constraintsToRelationships.test.ts, .../operationDeparser.test.ts, .../schemaDeparser.test.ts, .../mergeSchema.test.ts, .../parser/prisma/index.test.ts, .../parser/schemarb/index.test.ts, .../parser/sql/postgresql/index.test.ts, .../parser/tbls/index.test.ts Removed primary property from test fixtures and updated test schemas to use constraints for primary key representation.
    .../parser/prisma/parser.ts, .../parser/schemarb/parser.ts, .../parser/sql/postgresql/converter.ts, .../parser/tbls/parser.ts Removed logic assigning or using primary property in column objects; updated or removed related functions accordingly.
    .../deparser/postgresql/utils.ts Refactored column definition generation to use constraint-based primary key detection; removed handling of primary property.
    .../diff/buildSchemaDiff.ts Removed logic for diffing column primary key status.
    .../diff/columns/buildColumnPrimaryDiffItem.ts, .../diff/columns/tests/buildColumnPrimaryDiffItem.test.ts Deleted obsolete diff logic and tests for column primary key changes.
    .../diff/types.ts Removed types and schemas related to column primary key diff items.
    .../operation/constants.ts Removed path pattern for column primary key operations.
    .../schema/factories.ts Removed default primary property from column factory.
    .../schema/index.ts, .../schema/schema.ts Removed export and schema definition for columnPrimarySchema; updated columnSchema to exclude primary.
    .../evaluate/evaluate.ts Minor: Improved validation of parsed foreign key constraints (unrelated to primary key logic).

    Sequence Diagram(s)

    sequenceDiagram
        participant UI_Component
        participant isPrimaryKey
        participant Table_Constraints
    
        UI_Component->>isPrimaryKey: isPrimaryKey(column.name, table.constraints)
        isPrimaryKey->>Table_Constraints: Check for PRIMARY KEY constraint on column
        isPrimaryKey-->>UI_Component: true/false (primary key status)
    
    Loading

    Assessment against linked issues

    Objective (Issue #) Addressed Explanation
    Remove primary field from columnSchema (#2192)
    Implement isPrimaryKey function for primary key detection (#2192)
    Update UI components to display primary keys based on constraints (#2192)
    Remove logic for diffing column primary key status (#2192)

    Assessment against linked issues: Out-of-scope changes

    Code Change Explanation
    Improved validation of parsed foreign key constraints (frontend/internal-packages/schema-bench/src/evaluate/evaluate.ts) This logic change is unrelated to the removal of column.primary or primary key constraint unification. It improves validation for foreign key parsing, which is out of scope for the stated objectives.

    Suggested reviewers

    • hoshinotsuyoshi
    • junkisai
    • NoritakaIkeda
    • FunamaYukina

    Poem

    A bunny hopped through schema fields,
    And swept away what "primary" yields—
    Now keys are found in constraints' nest,
    With isPrimaryKey, we know the rest!
    No more flags to keep in sync,
    Just one true source—don’t you think?
    🐇✨


    📜 Recent review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 5149697 and 3017110.

    📒 Files selected for processing (1)
    • frontend/packages/db-structure/src/parser/tbls/parser.ts (1 hunks)
    ✅ Files skipped from review due to trivial changes (1)
    • frontend/packages/db-structure/src/parser/tbls/parser.ts
    ⏰ Context from checks skipped due to timeout of 90000ms (6)
    • GitHub Check: Supabase Preview
    • GitHub Check: frontend-ci
    • GitHub Check: frontend-lint
    • GitHub Check: codeql / languages (javascript) / Perform CodeQL for javascript
    • GitHub Check: trigger_dev
    • GitHub Check: Supabase Preview
    ✨ Finishing Touches
    • 📝 Generate Docstrings

    🪧 Tips

    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.
      • Explain this complex logic.
      • 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. Examples:
      • @coderabbitai explain this code block.
      • @coderabbitai modularize this function.
    • 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 src/utils.ts and explain its main purpose.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
      • @coderabbitai help me debug CodeRabbit configuration file.

    Support

    Need help? Create a ticket on our support page for assistance with any issues or questions.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (Invoked using PR 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 generate docstrings to generate docstrings for this PR.
    • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
    • @coderabbitai help to get help.

    Other keywords and placeholders

    • Add @coderabbitai 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.
    • 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

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.

    Copy link

    @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: 0

    🧹 Nitpick comments (1)
    frontend/packages/db-structure/src/utils/isPrimaryKey.ts (1)

    3-11: Well-implemented utility function with proper TypeScript usage.

    The function correctly implements primary key detection based on constraints. The use of Object.values() with some() provides efficient early termination, and the type annotations follow the coding guidelines.

    Consider future enhancement for composite primary keys if the constraint model supports them (e.g., if columnName could be an array or if there are separate constraint types for composite keys).

    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between ba70300 and dee6349.

    ⛔ Files ignored due to path filters (1)
    • frontend/packages/db-structure/src/parser/__snapshots__/index.test.ts.snap is excluded by !**/*.snap
    📒 Files selected for processing (38)
    • frontend/apps/app/components/ChatInput/components/MentionSuggestor/utils/getAllMentionCandidates.ts (2 hunks)
    • frontend/internal-packages/agent/src/chat/workflow/workflow.test.ts (1 hunks)
    • frontend/internal-packages/agent/src/utils/convertSchemaToText.ts (2 hunks)
    • frontend/packages/db-structure/src/deparser/postgresql/operationDeparser.test.ts (2 hunks)
    • frontend/packages/db-structure/src/deparser/postgresql/schemaDeparser.test.ts (11 hunks)
    • frontend/packages/db-structure/src/deparser/postgresql/utils.ts (2 hunks)
    • frontend/packages/db-structure/src/diff/buildSchemaDiff.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnCheckDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnCommentDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnDefaultDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnNameDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnNotNullDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnPrimaryDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnUniqueDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/buildColumnPrimaryDiffItem.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/types.ts (0 hunks)
    • frontend/packages/db-structure/src/index.ts (1 hunks)
    • frontend/packages/db-structure/src/operation/constants.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/prisma/index.test.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/prisma/parser.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/schemarb/index.test.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/schemarb/parser.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/sql/postgresql/converter.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/sql/postgresql/index.test.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/tbls/index.test.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/tbls/parser.ts (1 hunks)
    • frontend/packages/db-structure/src/schema/factories.ts (0 hunks)
    • frontend/packages/db-structure/src/schema/index.ts (0 hunks)
    • frontend/packages/db-structure/src/schema/mergeSchema.test.ts (5 hunks)
    • frontend/packages/db-structure/src/schema/schema.ts (0 hunks)
    • frontend/packages/db-structure/src/utils/constraintsToRelationships.test.ts (0 hunks)
    • frontend/packages/db-structure/src/utils/isPrimaryKey.ts (1 hunks)
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableColumnList/TableColumn/TableColumn.tsx (3 hunks)
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableColumnList/TableColumnList.tsx (3 hunks)
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/Columns/Columns.tsx (3 hunks)
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/Columns/ColumnsItem/ColumnsItem.tsx (3 hunks)
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/TableDetail.tsx (1 hunks)
    💤 Files with no reviewable changes (23)
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnDefaultDiffItem.test.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnDiffItem.test.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnNotNullDiffItem.test.ts
    • frontend/packages/db-structure/src/schema/index.ts
    • frontend/packages/db-structure/src/schema/factories.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnCheckDiffItem.test.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnCommentDiffItem.test.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnNameDiffItem.test.ts
    • frontend/packages/db-structure/src/parser/sql/postgresql/index.test.ts
    • frontend/packages/db-structure/src/parser/schemarb/index.test.ts
    • frontend/packages/db-structure/src/operation/constants.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnUniqueDiffItem.test.ts
    • frontend/packages/db-structure/src/diff/buildSchemaDiff.ts
    • frontend/packages/db-structure/src/parser/prisma/parser.ts
    • frontend/packages/db-structure/src/parser/schemarb/parser.ts
    • frontend/packages/db-structure/src/utils/constraintsToRelationships.test.ts
    • frontend/packages/db-structure/src/parser/tbls/index.test.ts
    • frontend/packages/db-structure/src/schema/schema.ts
    • frontend/packages/db-structure/src/parser/sql/postgresql/converter.ts
    • frontend/packages/db-structure/src/parser/prisma/index.test.ts
    • frontend/packages/db-structure/src/diff/columns/buildColumnPrimaryDiffItem.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnPrimaryDiffItem.test.ts
    • frontend/packages/db-structure/src/diff/types.ts
    🧰 Additional context used
    📓 Path-based instructions (4)
    `**/*.ts`: Use TypeScript for all components and functions. Avoid using type ass...

    **/*.ts: Use TypeScript for all components and functions.
    Avoid using type assertions (as keyword) in TypeScript code.
    Use runtime type validation with valibot instead of type assertions for API responses and external data.
    Use type predicates or instanceof checks for DOM element type narrowing.
    Use descriptive variable and function/const names. Event functions should be named with a 'handle' prefix, like 'handleClick' for onClick and 'handleKeyDown' for onKeyDown.
    Use consts instead of functions, for example, 'const toggle = () =>'. Also, define a type if possible.

    📄 Source: CodeRabbit Inference Engine (.cursorrules)

    List of files the instruction was applied to:

    • frontend/packages/db-structure/src/index.ts
    • frontend/packages/db-structure/src/schema/mergeSchema.test.ts
    • frontend/packages/db-structure/src/utils/isPrimaryKey.ts
    • frontend/apps/app/components/ChatInput/components/MentionSuggestor/utils/getAllMentionCandidates.ts
    • frontend/internal-packages/agent/src/utils/convertSchemaToText.ts
    • frontend/internal-packages/agent/src/chat/workflow/workflow.test.ts
    • frontend/packages/db-structure/src/deparser/postgresql/schemaDeparser.test.ts
    • frontend/packages/db-structure/src/deparser/postgresql/operationDeparser.test.ts
    • frontend/packages/db-structure/src/parser/tbls/parser.ts
    • frontend/packages/db-structure/src/deparser/postgresql/utils.ts
    `**/*.tsx`: Do not code within the `page.tsx` file in Next.js App Router. Instead, create a separate `XXXPage` component and write all code there.

    **/*.tsx: Do not code within the page.tsx file in Next.js App Router. Instead, create a separate XXXPage component and write all code there.

    📄 Source: CodeRabbit Inference Engine (.cursorrules)

    List of files the instruction was applied to:

    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/Columns/Columns.tsx
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/TableDetail.tsx
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/Columns/ColumnsItem/ColumnsItem.tsx
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableColumnList/TableColumn/TableColumn.tsx
    • frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableColumnList/TableColumnList.tsx
    `frontend/apps/app/**/*`: Run development commands such as pnpm dev, pnpm dev:cs...

    frontend/apps/app/**/*: Run development commands such as pnpm dev, pnpm dev:css, and pnpm lint:tsc specifically within the frontend/apps/app directory for app-specific development.

    📄 Source: CodeRabbit Inference Engine (CLAUDE.md)

    List of files the instruction was applied to:

    • frontend/apps/app/components/ChatInput/components/MentionSuggestor/utils/getAllMentionCandidates.ts
    `frontend/apps/app/**/*.ts{,x}`: Use database types from '@liam-hq/db/supabase/database.types' for database entities to ensure type safety and consistency with the database schema.

    frontend/apps/app/**/*.ts{,x}: Use database types from '@liam-hq/db/supabase/database.types' for database entities to ensure type safety and consistency with the database schema.

    📄 Source: CodeRabbit Inference Engine (.clinerules/general.md)

    List of files the instruction was applied to:

    • frontend/apps/app/components/ChatInput/components/MentionSuggestor/utils/getAllMentionCandidates.ts
    🧬 Code Graph Analysis (6)
    frontend/packages/db-structure/src/utils/isPrimaryKey.ts (3)
    frontend/packages/db-structure/src/index.ts (2)
    • isPrimaryKey (49-49)
    • Constraints (29-29)
    frontend/packages/db-structure/src/schema/index.ts (1)
    • Constraints (17-17)
    frontend/packages/db-structure/src/schema/schema.ts (1)
    • Constraints (113-113)
    frontend/apps/app/components/ChatInput/components/MentionSuggestor/utils/getAllMentionCandidates.ts (2)
    frontend/packages/db-structure/src/index.ts (1)
    • isPrimaryKey (49-49)
    frontend/packages/db-structure/src/utils/isPrimaryKey.ts (1)
    • isPrimaryKey (3-11)
    frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/Columns/ColumnsItem/ColumnsItem.tsx (2)
    frontend/packages/db-structure/src/schema/schema.ts (1)
    • Constraints (113-113)
    frontend/packages/db-structure/src/utils/isPrimaryKey.ts (1)
    • isPrimaryKey (3-11)
    frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableColumnList/TableColumn/TableColumn.tsx (2)
    frontend/packages/db-structure/src/schema/schema.ts (2)
    • Table (122-122)
    • Column (34-34)
    frontend/packages/db-structure/src/utils/isPrimaryKey.ts (1)
    • isPrimaryKey (3-11)
    frontend/internal-packages/agent/src/utils/convertSchemaToText.ts (2)
    frontend/packages/db-structure/src/index.ts (1)
    • isPrimaryKey (49-49)
    frontend/packages/db-structure/src/utils/isPrimaryKey.ts (1)
    • isPrimaryKey (3-11)
    frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableColumnList/TableColumnList.tsx (5)
    frontend/packages/db-structure/src/index.ts (2)
    • Table (39-39)
    • isPrimaryKey (49-49)
    frontend/packages/db-structure/src/schema/index.ts (1)
    • Table (24-24)
    frontend/packages/db-structure/src/schema/schema.ts (1)
    • Table (122-122)
    frontend/packages/erd-core/src/features/erd/types.ts (1)
    • TableNodeData (5-15)
    frontend/packages/db-structure/src/utils/isPrimaryKey.ts (1)
    • isPrimaryKey (3-11)
    ⏰ Context from checks skipped due to timeout of 90000ms (6)
    • GitHub Check: Supabase Preview
    • GitHub Check: frontend-ci
    • GitHub Check: frontend-lint
    • GitHub Check: codeql / languages (javascript) / Perform CodeQL for javascript
    • GitHub Check: trigger_dev
    • GitHub Check: Supabase Preview
    🔇 Additional comments (27)
    frontend/packages/db-structure/src/index.ts (1)

    49-49: LGTM! Clean export statement.

    The export follows the established pattern and makes the isPrimaryKey utility available for use across the codebase, which aligns well with the PR's goal of centralizing primary key detection logic.

    frontend/packages/db-structure/src/schema/mergeSchema.test.ts (2)

    20-30: LGTM! Correctly migrated to constraint-based primary keys.

    The test data has been properly updated to use constraints instead of the primary property. The constraint structure with type: 'PRIMARY KEY', name: 'users_pkey', and columnName: 'id' follows the expected format and aligns with the PR's goal of eliminating primary key duplication.


    65-78: Consistent constraint usage across test scenarios.

    The migration to constraint-based primary keys is consistently applied across all test scenarios, ensuring comprehensive test coverage for the new approach.

    frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/Columns/Columns.tsx (3)

    1-1: Clean TypeScript import with proper type usage.

    The import statement correctly includes the Constraints type, following the coding guidelines for TypeScript usage.


    8-13: Well-structured props interface and component signature.

    The component correctly accepts the constraints prop and follows TypeScript best practices with proper type annotations and destructuring.


    26-26: Proper prop propagation to child components.

    The constraints prop is correctly passed down to each ColumnsItem, enabling primary key detection at the child component level.

    frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/TableDetail.tsx (1)

    111-111: Correct prop passing for constraint-based primary key detection.

    The addition of the constraints prop enables the Columns component to access table constraints for primary key detection, properly supporting the migration from column-level primary key flags to constraint-based detection.

    frontend/internal-packages/agent/src/chat/workflow/workflow.test.ts (1)

    82-88: LGTM! Test schema correctly migrated to constraint-based primary keys.

    The test schema has been properly updated to use table-level constraints instead of column-level primary flags. The constraint definition includes all required fields (type, name, columnName) and follows the expected structure for the refactor.

    frontend/internal-packages/agent/src/utils/convertSchemaToText.ts (2)

    1-1: LGTM! Proper import of isPrimaryKey utility.

    The import statement correctly includes the isPrimaryKey function needed for constraint-based primary key detection.


    25-25: LGTM! Correct implementation of constraint-based primary key detection.

    The logic properly replaces the column-level primary check with the isPrimaryKey function call. The defensive programming with || {} fallback handles cases where constraints might be undefined.

    frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableDetail/Columns/ColumnsItem/ColumnsItem.tsx (3)

    1-5: LGTM! Proper imports for constraint-based primary key detection.

    The import statement correctly includes both the Constraints type and isPrimaryKey function needed for the refactor.


    21-21: LGTM! Component props properly extended for constraints.

    The constraints prop has been correctly added to the Props type and function signature to support constraint-based primary key detection.

    Also applies to: 24-24


    40-40: LGTM! Correct implementation of constraint-based primary key check.

    The conditional logic properly replaces the direct column.primary check with the isPrimaryKey(column.name, constraints) function call, maintaining the same UI behavior while using the new schema structure.

    frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableColumnList/TableColumn/TableColumn.tsx (4)

    1-6: LGTM! Proper import of isPrimaryKey utility.

    The import statement correctly includes the isPrimaryKey function needed for constraint-based primary key detection.


    28-28: LGTM! Component props properly extended for table constraints.

    The ColumnIconProps type and ColumnIcon function signature have been correctly updated to accept the table prop, enabling access to constraints for primary key detection.

    Also applies to: 35-35


    40-40: LGTM! Correct implementation of constraint-based primary key check.

    The primary key detection logic properly replaces the direct column.primary check with isPrimaryKey(column.name, table.constraints), maintaining consistent behavior while using the new constraint-based approach.


    139-139: LGTM! Table prop properly passed to ColumnIcon.

    The table prop is correctly passed to the ColumnIcon component to enable constraint-based primary key detection.

    frontend/apps/app/components/ChatInput/components/MentionSuggestor/utils/getAllMentionCandidates.ts (2)

    1-8: LGTM! Proper import of isPrimaryKey utility.

    The import statement correctly includes the isPrimaryKey function needed for constraint-based primary key detection in column type classification.


    51-51: LGTM! Correct implementation of constraint-based primary key detection.

    The column type determination logic properly replaces the direct column.primary check with isPrimaryKey(column.name, table.constraints || {}). The defensive programming with || {} fallback ensures proper handling when constraints might be undefined.

    frontend/packages/db-structure/src/deparser/postgresql/schemaDeparser.test.ts (1)

    34-40: LGTM! Consistent constraint-based primary key definition.

    The test cases have been correctly updated to remove the primary property from columns and define primary keys via explicit constraints. The generated SQL snapshots show that the deparser correctly translates these constraints into inline PRIMARY KEY declarations, maintaining the same SQL output format.

    Also applies to: 76-82, 147-153, 191-197, 237-243, 269-275

    frontend/packages/db-structure/src/deparser/postgresql/operationDeparser.test.ts (1)

    36-42: LGTM! Operation deparser tests updated consistently.

    The test operations have been correctly updated to use constraint-based primary key definitions instead of column-level primary properties. The generated SQL maintains the same format with inline PRIMARY KEY declarations, demonstrating that the operation deparser correctly handles the new constraint-based schema format.

    Also applies to: 100-106

    frontend/packages/erd-core/src/features/erd/components/ERDContent/components/TableNode/TableColumnList/TableColumnList.tsx (3)

    1-1: LGTM! Proper import of constraint-based primary key utility.

    The import correctly adds the isPrimaryKey utility function and Table type needed for the constraint-based primary key detection refactor.


    12-25: LGTM! Correctly updated to use constraint-based primary key detection.

    The shouldDisplayColumn function has been properly updated to:

    • Accept a table parameter to access constraints
    • Use isPrimaryKey(column.name, table.constraints) instead of checking the removed column.primary property
    • Maintain the same filtering logic for the 'KEY_ONLY' mode

    This change aligns perfectly with the broader refactor to move primary key identification from column properties to table constraints.


    32-37: LGTM! Function call updated to pass required table parameter.

    The call to shouldDisplayColumn has been correctly updated to pass the data.table parameter, which is needed for the constraint-based primary key detection.

    frontend/packages/db-structure/src/parser/tbls/parser.ts (1)

    353-353: LGTM! Simplified column processing to use constraint-only primary keys.

    The removal of primary key column names from the processColumns function call correctly implements the refactor goal of eliminating the primary property from columns. Primary key information is now managed exclusively through the table's constraints, which is processed separately in the processConstraints function.

    This change simplifies the parsing logic and eliminates the duplication of primary key information that was previously stored in both column properties and constraints.

    frontend/packages/db-structure/src/deparser/postgresql/utils.ts (2)

    6-27: LGTM! Improved column definition with constraint-aware logic.

    The generateColumnDefinition function has been correctly updated to:

    • Accept an optional isPrimaryKey parameter for constraint-aware generation
    • Avoid redundant NOT NULL constraints for primary key columns (since PRIMARY KEY implies NOT NULL in PostgreSQL)
    • Maintain the same column definition format while being aware of primary key status

    This change follows PostgreSQL best practices and aligns with the constraint-based primary key refactor.


    87-108: LGTM! Correctly implemented constraint-based primary key identification.

    The generateCreateTableStatement function has been properly updated to:

    • Identify primary key columns by iterating through table constraints instead of checking column properties
    • Collect primary key column names into a Set for efficient lookup
    • Pass the isPrimaryKey flag to generateColumnDefinition for each column
    • Add inline PRIMARY KEY declarations for primary key columns

    This implementation correctly translates the constraint-based schema format to the expected SQL output while maintaining the same generated SQL format as before the refactor.

    - Fix import order in getAllMentionCandidates.ts
    - Add proper type checking for valibot safeParse result.output in evaluate.ts
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    Copy link
    Member

    @hoshinotsuyoshi hoshinotsuyoshi left a comment

    Choose a reason for hiding this comment

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

    took a quick look and didn’t notice anything concerning — LGTM!

    Resolved conflicts by removing both primary and unique fields from column schema
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    Copy link

    @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

    🔭 Outside diff range comments (2)
    frontend/packages/db-structure/src/parser/tbls/parser.ts (2)

    62-92: Clarify the purpose of extracting unique column names.

    The function was renamed from extractPrimaryKeyColumnNames to extractUniqueColumnNames and now extracts single-column UNIQUE constraints. However, the extracted unique column names are not used in processColumns (parameter is prefixed with underscore). This suggests the extraction logic might be incomplete or serving a different purpose that's not yet implemented.

    Additionally, the function only extracts UNIQUE constraints with exactly one column, which may not capture all unique constraints in the schema.

    Consider one of the following approaches:

    1. If unique column names are not needed: Remove the extraction logic entirely.
    -/**
    - * Extract unique column names from constraints
    - */
    -function extractUniqueColumnNames(
    -  constraints:
    -    | Array<{
    -        type: string
    -        name: string
    -        columns?: string[]
    -        def: string
    -        referenced_table?: string
    -        referenced_columns?: string[]
    -      }>
    -    | undefined,
    -): Set<string> {
    -  const uniqueColumns: string[] = []
    -
    -  if (constraints) {
    -    const uniqueConstraints = constraints.filter(
    -      (constraint) =>
    -        constraint.type === 'UNIQUE' && constraint.columns?.length === 1,
    -    )
    -
    -    for (const constraint of uniqueConstraints) {
    -      if (constraint.columns?.[0]) {
    -        uniqueColumns.push(constraint.columns[0])
    -      }
    -    }
    -  }
    -
    -  return new Set(uniqueColumns)
    -}
    1. If unique column names will be used: Implement the usage in processColumns and remove the underscore prefix.

    420-420: Replace type assertion with runtime validation.

    The code uses a type assertion (as CompatibleTable) which violates the coding guidelines. Use runtime type validation instead.

    Replace the type assertion with proper runtime validation:

    -    const [tableName, table] = processTable(tblsTable as CompatibleTable)
    +    // Validate table structure at runtime
    +    if (!isValidTable(tblsTable)) {
    +      errors.push(new Error(`Invalid table structure: ${tblsTable.name}`))
    +      continue
    +    }
    +    const [tableName, table] = processTable(tblsTable)

    You'll need to implement the isValidTable function or use a validation library like valibot as mentioned in the coding guidelines.

    🧹 Nitpick comments (1)
    frontend/packages/db-structure/src/parser/tbls/parser.ts (1)

    349-352: Ensure consistency between function call and parameter usage.

    The function call and parameter passing appear consistent, but since the unique column names are unused, this entire chain of operations may be unnecessary.

    If unique column extraction is not needed, simplify the code:

    -  const uniqueColumnNames = extractUniqueColumnNames(tblsTable.constraints)
    -  const columns = processColumns(tblsTable.columns, uniqueColumnNames)
    +  const columns = processColumns(tblsTable.columns)
    📜 Review details

    Configuration used: CodeRabbit UI
    Review profile: CHILL
    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 25c5c52 and 5149697.

    ⛔ Files ignored due to path filters (1)
    • frontend/packages/db-structure/src/parser/__snapshots__/index.test.ts.snap is excluded by !**/*.snap
    📒 Files selected for processing (27)
    • frontend/internal-packages/agent/src/chat/workflow/workflow.test.ts (1 hunks)
    • frontend/internal-packages/schema-bench/src/evaluate/evaluate.ts (2 hunks)
    • frontend/packages/db-structure/src/deparser/postgresql/operationDeparser.test.ts (2 hunks)
    • frontend/packages/db-structure/src/deparser/postgresql/schemaDeparser.test.ts (10 hunks)
    • frontend/packages/db-structure/src/deparser/postgresql/utils.ts (2 hunks)
    • frontend/packages/db-structure/src/diff/buildSchemaDiff.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnCheckDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnCommentDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnDefaultDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnNameDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/columns/__tests__/buildColumnNotNullDiffItem.test.ts (0 hunks)
    • frontend/packages/db-structure/src/diff/types.ts (0 hunks)
    • frontend/packages/db-structure/src/operation/constants.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/prisma/index.test.ts (1 hunks)
    • frontend/packages/db-structure/src/parser/prisma/parser.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/schemarb/index.test.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/schemarb/parser.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/sql/postgresql/converter.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/sql/postgresql/index.test.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/tbls/index.test.ts (0 hunks)
    • frontend/packages/db-structure/src/parser/tbls/parser.ts (4 hunks)
    • frontend/packages/db-structure/src/schema/factories.ts (0 hunks)
    • frontend/packages/db-structure/src/schema/index.ts (0 hunks)
    • frontend/packages/db-structure/src/schema/mergeSchema.test.ts (5 hunks)
    • frontend/packages/db-structure/src/schema/schema.ts (0 hunks)
    • frontend/packages/db-structure/src/utils/constraintsToRelationships.test.ts (0 hunks)
    💤 Files with no reviewable changes (19)
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnNameDiffItem.test.ts
    • frontend/packages/db-structure/src/utils/constraintsToRelationships.test.ts
    • frontend/packages/db-structure/src/schema/factories.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnNotNullDiffItem.test.ts
    • frontend/packages/db-structure/src/schema/index.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnCheckDiffItem.test.ts
    • frontend/packages/db-structure/src/parser/sql/postgresql/index.test.ts
    • frontend/packages/db-structure/src/diff/buildSchemaDiff.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnCommentDiffItem.test.ts
    • frontend/packages/db-structure/src/schema/schema.ts
    • frontend/packages/db-structure/src/parser/schemarb/parser.ts
    • frontend/packages/db-structure/src/parser/schemarb/index.test.ts
    • frontend/packages/db-structure/src/operation/constants.ts
    • frontend/packages/db-structure/src/parser/sql/postgresql/converter.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnDefaultDiffItem.test.ts
    • frontend/packages/db-structure/src/diff/columns/tests/buildColumnDiffItem.test.ts
    • frontend/packages/db-structure/src/diff/types.ts
    • frontend/packages/db-structure/src/parser/tbls/index.test.ts
    • frontend/packages/db-structure/src/parser/prisma/parser.ts
    🚧 Files skipped from review as they are similar to previous changes (7)
    • frontend/internal-packages/agent/src/chat/workflow/workflow.test.ts
    • frontend/internal-packages/schema-bench/src/evaluate/evaluate.ts
    • frontend/packages/db-structure/src/schema/mergeSchema.test.ts
    • frontend/packages/db-structure/src/deparser/postgresql/schemaDeparser.test.ts
    • frontend/packages/db-structure/src/deparser/postgresql/operationDeparser.test.ts
    • frontend/packages/db-structure/src/parser/prisma/index.test.ts
    • frontend/packages/db-structure/src/deparser/postgresql/utils.ts
    🧰 Additional context used
    📓 Path-based instructions (1)
    `**/*.ts`: Use TypeScript for all components and functions. Avoid using type ass...

    **/*.ts: Use TypeScript for all components and functions.
    Avoid using type assertions (as keyword) in TypeScript code.
    Use runtime type validation with valibot instead of type assertions for API responses and external data.
    Use type predicates or instanceof checks for DOM element type narrowing.
    Use descriptive variable and function/const names. Event functions should be named with a 'handle' prefix, like 'handleClick' for onClick and 'handleKeyDown' for onKeyDown.
    Use consts instead of functions, for example, 'const toggle = () =>'. Also, define a type if possible.

    📄 Source: CodeRabbit Inference Engine (.cursorrules)

    List of files the instruction was applied to:

    • frontend/packages/db-structure/src/parser/tbls/parser.ts
    ⏰ Context from checks skipped due to timeout of 90000ms (5)
    • GitHub Check: Supabase Preview
    • GitHub Check: frontend-lint
    • GitHub Check: frontend-ci
    • GitHub Check: codeql / languages (javascript) / Perform CodeQL for javascript
    • GitHub Check: Supabase Preview

    - Removed primary field from column processing
    - Removed unused extractPrimaryKeyColumnNames function
    - Fixed formatting issues
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <[email protected]>
    @MH4GF MH4GF added this pull request to the merge queue Jun 26, 2025
    Merged via the queue into main with commit b7c3183 Jun 26, 2025
    28 checks passed
    @MH4GF MH4GF deleted the remove-primary-field branch June 26, 2025 07:32
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Remove column.primary duplication with constraints
    2 participants