Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

TML-1756: Extract core migration base types for CLI - #55

Merged
wmadden merged 11 commits into
mainfrom
tml-1756-extract-core-migration-base-types-for-cli
Dec 30, 2025
Merged

wmadden merged 11 commits into
mainfrom
tml-1756-extract-core-migration-base-types-for-cli

Conversation

@wmadden

@wmadden wmadden commented Dec 30, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Public migration planning & execution surface added, with SQL-specific migration types.
    • Targets (including Postgres) expose a migrations capability (new namespace; old direct methods kept as deprecated).
  • Improvements

    • CLI updated to use the standardized migration types.
    • Stronger typing and clearer success/failure reporting across migration flows.
  • Tests

    • New databaseOperation timeout introduced and applied to relevant integration tests.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add MigrationPlan, MigrationPlanner, MigrationRunner interfaces
- Add MigrationPlannerResult, MigrationRunnerResult types
- Add TargetMigrationsCapability for optional migration support
- Add migrations? property to ControlTargetDescriptor
- Export all new types from core-control-plane/types

These family-agnostic types allow CLI to work with migration
planners/runners without importing SQL-specific types.
- Rename MigrationPlan -> SqlMigrationPlan (extends core MigrationPlan)
- Rename MigrationPlanner -> SqlMigrationPlanner
- Rename MigrationRunner -> SqlMigrationRunner
- Rename PlannerConflict -> SqlPlannerConflict
- Rename all related types with Sql prefix
- Re-export core migration types for convenience
- Update plan-helpers to use Sql-prefixed types
- Update control.ts exports with new type names

SQL-specific types now extend canonical core types, enabling
CLI to work with family-agnostic interfaces.
- Update planner/runner to use Sql-prefixed types
- Add migrations property to postgresTargetDescriptor
- migrations.createPlanner/createRunner for CLI compatibility
- Keep direct createPlanner/createRunner methods (deprecated)
- Update test file to use Sql-prefixed type names
- Remove local migration interfaces (MigrationPlan, PlannerResult, etc.)
- Import core migration types from @prisma-next/core-control-plane/types
- Use config.target.migrations capability instead of hasMigrationSupport()
- Add explicit type annotations for plannerResult, migrationPlan, runnerResult
- Simplifies db-init by ~90 lines of duck-typed interfaces
- Fix SqlSqlMigrationPlanContractInfo -> SqlMigrationPlanContractInfo
- Fix SqlSqlMigrationPlanOperationStep -> SqlMigrationPlanOperationStep
- Fix SqlSqlMigrationPlanOperation -> SqlMigrationPlanOperation
- Fix SqlSqlMigrationRunnerExecuteOptions -> SqlMigrationRunnerExecuteOptions
- Add migrations.types.test-d.ts with type-level tests
- Verify SqlMigration* types extend core MigrationPlan types
- Test SqlMigrationPlanOperation, SqlMigrationPlan, SqlPlannerConflict
- Test SqlMigrationRunnerSuccessValue, SqlMigrationRunnerFailure
- Re-export MigrationPlanner from core types in SQL family
… family instance

- TargetMigrationsCapability now accepts TFamilyInstance type parameter
- ControlTargetDescriptor passes TFamilyInstance to migrations capability
- SqlControlTargetDescriptor passes SqlControlFamilyInstance to base type
- Fixes type error when migrations capability uses SQL-specific family instance
… hooks

- Add timeouts.databaseOperation (5s) for DB setup/teardown hooks
- Add explicit databaseOperation timeout to beforeEach/afterEach in:
  - budgets.test.ts
  - codecs.test.ts
  - comparison-operators.test.ts
- Default timeout remains 100ms for non-DB tests
@coderabbitai

coderabbitai Bot commented Dec 30, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a family-agnostic migration API (planners, runners, plans, result types), SQL-specific migration types and implementations, exposes a migrations capability on targets, updates Postgres and CLI to use the new capability, and adjusts tests/timeouts for database operations.

Changes

Cohort / File(s) Summary
Core Migration Types
packages/1-framework/1-core/migration/control-plane/src/migrations.ts, packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
New family-agnostic migration types and interfaces: MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationRunner, planner/runner result and conflict types, MigrationOperationPolicy, MigrationOperationClass, and TargetMigrationsCapability.
Target Descriptor Enhancement
packages/1-framework/1-core/migration/control-plane/src/types.ts
ControlTargetDescriptor gains generic TFamilyInstance and optional migrations?: TargetMigrationsCapability<TFamilyInstance> property; core migration types re-exported.
CLI Migration
packages/1-framework/3-tooling/cli/src/commands/db-init.ts
Replaced local duck-typed migration interfaces with imports from core control-plane; uses config.target.migrations.createPlanner/createRunner and explicit planner/runner result typing.
SQL Family Core Types
packages/2-sql/3-tooling/family/src/core/migrations/types.ts, packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
Introduces SQL-specific types (SqlMigrationPlan*, SqlPlanner*, SqlMigrationRunner*) and updates helpers to produce/consume SQL-prefixed types (create plan options, operations, steps, errors, results).
SQL Family Exports
packages/2-sql/3-tooling/family/src/exports/control.ts
Public exports replaced generic migration types with SQL-prefixed variants (adds CreateSqlMigrationPlanOptions and suite of Sql* types; retains TargetMigrationsCapability re-exports from core).
Postgres Target Implementation
packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts, packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts, packages/3-targets/3-targets/postgres/src/exports/control.ts
Postgres planner/runner switched to implement SqlMigrationPlanner/SqlMigrationRunner; signatures and internals updated to Sql* types; postgres target descriptor adds migrations capability (deprecated direct methods kept).
Type Tests
packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts, packages/2-sql/3-tooling/family/test/migrations.types.test.ts
Added type-level tests asserting Sql* types extend core migration contracts; updated existing tests to use Sql* names.
Test Timeouts / Hooks
test/utils/src/timeouts.ts, test/integration/test/budgets.test.ts, test/integration/test/codecs.test.ts, test/integration/test/comparison-operators.test.ts
Added databaseOperation timeout (5000 ms) and applied it to before/after hooks in integration tests to extend allowed DB operation durations.
Policies Typing Import
packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
Switched MigrationOperationPolicy import source to @prisma-next/core-control-plane/types (no runtime change to INIT_ADDITIVE_POLICY).

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant Target
    participant Planner as MigrationPlanner
    participant PlanResult
    participant Runner as MigrationRunner
    participant Driver as ControlDriver
    participant RunResult

    CLI->>Target: read config.target.migrations
    Target->>CLI: TargetMigrationsCapability

    rect rgb(220, 235, 255)
      CLI->>Target: migrations.createPlanner(family)
      Target->>Planner: instantiate planner
      CLI->>Planner: plan({ contract, schema, policy })
      Planner->>PlanResult: produce success(plan) or failure(conflicts)
      PlanResult-->>CLI: MigrationPlannerResult
    end

    rect rgb(235, 255, 220)
      alt plan succeeded
        CLI->>Target: migrations.createRunner(family)
        Target->>Runner: instantiate runner
        CLI->>Runner: execute({ plan, driver, policy, callbacks? })
        Runner->>Driver: apply operations (precheck -> execute -> postcheck)
        Driver-->>Runner: per-operation results
        Runner->>RunResult: aggregate success or failure
        RunResult-->>CLI: MigrationRunnerResult
      else plan failed
        CLI->>CLI: report conflicts, abort execution
      end
    end
Loading

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between cc1f2a7 and eeca9e7.

📒 Files selected for processing (4)
  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
🧰 Additional context used
📓 Path-based instructions (21)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)

**/*.{ts,tsx}: Use the 'key?' syntax with the ? suffix for optional keys in Arktype schemas instead of using 'string | undefined' type unions
Reference schemas directly as object property values in Arktype schemas - this works seamlessly without special syntax
Use type({ '[string]': Schema }) syntax to create Record<string, Schema> types in Arktype instead of using Record<string, Schema> string notation
Use the .array() method on Arktype schemas to create array types instead of wrapping schemas in type([Schema]) or using manual validation
Extract TypeScript types from Arktype schemas using the .infer property instead of manually duplicating type definitions
Use type.declare<>() to ensure Arktype schemas match pre-existing TypeScript types for compile-time type safety, especially when working with readonly properties
Use .array().readonly() method chaining to create readonly array types in Arktype instead of using string notation like 'string[]'
Don't manually re-validate what Arktype has already checked - once validation passes, trust the structure matches the schema
Use instanceof type.errors to check for Arktype validation errors instead of other error checking patterns, for proper type narrowing
Return the original input value from validation functions instead of returning the Arktype validation result to preserve literal types

Prefer explicit, direct imports over barrel imports: import from specific module paths like @prisma/sql/builder instead of barrel re-exports like @prisma/sql

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties on objects

**/*.{ts,tsx}: Import core contract types (ContractBase, Source) and document family types (DocumentContract) from @prisma-next/contract/types
Import target-neutral operations (OperationRegistry, ArgSpec, ReturnSpec, createOperationRegistry) from @prisma-next/operations

**/*.{ts,tsx}: Extract CodecTypes from contract using the he...

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/import-validation.mdc)

packages/**/*.{ts,tsx}: Same-layer imports are allowed: packages in the same layer can import from each other (e.g., orm-lane can import from sql-relational-core if both are in the lanes layer)
Cross-layer imports must flow inward (toward core): packages can only import from inner layers (closer to core). Outer layers cannot import from inner layers (e.g., core layer cannot import from lanes layer)

Import SQL emitter hook (sqlTargetFamilyHook) from @prisma-next/sql-contract-emitter

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/modular-refactoring-patterns.mdc)

**/*.ts: Start refactoring by extracting pure, side-effect-free utility functions as thin wrappers around AST factories and error constructors
Extract state management into separate modules defining immutable state shapes and interfaces
Replace any types with proper generic type parameters during function extraction, using existing type definitions like ModelColumnAccessor
Use the compact helper function to remove undefined values from objects when TypeScript's exactOptionalPropertyTypes is enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value imports

**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid in TypeScript. Use non-null assertions (!) after validation checks instead of optional chaining or defensive conditionals.
Use assertions to access validated properties directly (e.g., columnMeta.codecId, columnMeta.nullable) instead of optional chaining (columnMeta?.codecId) after validation has already occurred.

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/src/core/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)

**/src/core/**/*.{ts,tsx,js,jsx}: Keep shared implementation in src/core/** directory with no migration/runtime plane imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/core/** directory

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/src/{core,exports}/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)

Multi-plane packages must use a structured directory layout with src/core/ for shared plane code and src/exports/ for entry points

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/src/core/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)

**/src/core/**/*.ts: Core implementation (src/core/**) must contain shared plane code with no CLI-specific or runtime-specific dependencies
Core code (src/core/**) can only import from shared plane packages

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
packages/**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should only contain side-effect-free code (types, validators, factories) with no migration-specific logic or IO operations

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Import from shared plane packages using the package name and export identifier (e.g., @prisma-next/sql-contract/types), not /exports/ paths

**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in the exports/ folders

**/*.{ts,tsx,js,jsx}: Import loadContractFromTs and createContractEmitCommand from the main package export @prisma-next/cli, not from subpaths
Import config utilities (defineConfig and config types) from the @prisma-next/cli/config-types subpath, not from the main package
Import loadExtensionPacks and loadExtensionPackManifest from the @prisma-next/cli/pack-loading subpath, not from the main package
Import command factory functions (e.g., createDbIntrospectCommand, createDbVerifyCommand) from their specific command subpaths (e.g., @prisma-next/cli/commands/db-introspect), not from the main package
Import the loadConfig function from the @prisma-next/cli/config-loader subpath, not from the main package

Update relative paths in source files (manifest paths, import paths, etc.) when moving packages by recalculating the path based on the new location's directory depth

If you need to disable a Biome rule for more than a couple of lines in a file, use a file-level disable comment at the top instead of many inline comments

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/*.{test,spec,ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Use factory functions for creating AST nodes instead of manual object creation as per .cursor/rules/use-ast-factories.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{ts,tsx,js}: Use LATERAL/json_agg patterns for PostgreSQL queries as per .cursor/rules/postgres-lateral-patterns.mdc
Use Object.hasOwn() instead of hasOwnProperty() as per .cursor/rules/object-hasown.mdc
Prefer assertions over defensive checks; avoid schema validation redundancy as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc

**/*.{ts,tsx,js}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing (see scripts/check-imports.mjs and .cursor/rules/import-validation.mdc)
Numbered prefixes in package directory structure indicate dependency direction: lower numbers can be imported by higher numbers, never the reverse

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
{src,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Prohibit inline type imports in source files as per .cursor/rules/no-inline-imports.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}: Blind type casts (as unknown as X) are forbidden in production code; use type predicates instead
Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/+(src|lib)/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/+(src|lib)/**/*.{ts,tsx}: When extracting types from ColumnBuilder instances, use infer for all type parameters without constraints to allow correct type inference
Use RuntimeContext to decouple codec and operations registries from Runtime, allowing them to be passed to schema and query builders

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx,json,js}

📄 CodeRabbit inference engine (AGENTS.md)

SQL family internals live under packages/2-sql/; top-level packages/3-targets/ is reserved for target extension packs (dialect, adapter, driver)

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
packages/**/test/**/*.{ts,test.ts}

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should include unit tests for validators and factories, type tests for exported types, and no integration tests requiring migration or runtime plane packages

Files:

  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
**/*.test-d.ts

📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)

Use expectTypeOf from Vitest for type-level testing in type test files

Files:

  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
**/src/exports/control.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)

Migration plane entrypoint must be named control.ts (not cli.ts) and located at src/exports/control.ts; import control plane/tooling only from this file

**/src/exports/control.ts: Migration plane entry point (src/exports/control.ts) must export control plane descriptors and use naming convention control.ts (not cli.ts)
Migration plane entry point (src/exports/control.ts) can import from migration plane packages and core (../core/...)

Files:

  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/src/exports/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)

Exports directory (src/exports/) should include re-export files (adapter.ts, codec-types.ts, types.ts) in addition to plane-specific entry points (control.ts, runtime.ts)

Files:

  • packages/2-sql/3-tooling/family/src/exports/control.ts
packages/**/src/exports/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages must export types, validators, and factories through separate export files in the src/exports/ directory

Files:

  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/control.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)

Control plane entry points must export default descriptors with the appropriate types: @prisma-next/family-*/control exports ControlFamilyDescriptor, @prisma-next/target-*/control exports ControlTargetDescriptor, @prisma-next/adapter-*/control exports ControlAdapterDescriptor, @prisma-next/driver-*/control exports ControlDriverDescriptor, and @prisma-next/extensions-*/control exports ControlExtensionDescriptor.

Files:

  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/exports/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

When a class with private properties is part of an exported type, the class must be explicitly exported from the exports file, not just from the source file

Files:

  • packages/2-sql/3-tooling/family/src/exports/control.ts
🧠 Learnings (1)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.

Applied to files:

  • packages/2-sql/3-tooling/family/src/core/migrations/policies.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
🧬 Code graph analysis (1)
packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts (1)
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (5)
  • SqlMigrationPlanOperation (53-62)
  • SqlMigrationPlan (76-89)
  • SqlPlannerConflict (123-127)
  • SqlMigrationRunnerSuccessValue (230-230)
  • SqlMigrationRunnerFailure (221-224)
🔇 Additional comments (8)
packages/2-sql/3-tooling/family/src/core/migrations/policies.ts (1)

1-8: LGTM!

The import path change to @prisma-next/core-control-plane/types correctly aligns with the PR objective of extracting core migration types to a shared package. The Object.freeze pattern with as const ensures proper immutability.

packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts (1)

1-51: LGTM!

Well-structured type-level tests that verify SQL migration types properly extend their core counterparts. The use of expectTypeOf follows the coding guidelines for type test files, and the test coverage is comprehensive across plan, operation, planner, and runner types.

packages/2-sql/3-tooling/family/src/exports/control.ts (1)

3-47: LGTM!

Clean organization of exports following the guidelines:

  • Core types re-exported from canonical source (lines 4-13)
  • SQL-specific types properly separated (lines 24-47)
  • Re-exports in exports/ folder are explicitly allowed per coding guidelines
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (5)

1-26: LGTM!

Well-structured imports following the organization guideline (external type imports first). The AnyRecord type alias is appropriately defined for reuse across the file.


28-89: LGTM!

The SQL-specific plan types properly extend core types with clear documentation. The nullable origin field (line 82) correctly handles the "empty database" case as documented.


91-169: LGTM!

The planner types correctly use Omit to override specific fields from core types (like plan and conflicts) while preserving the rest of the structure. The SqlPlannerConflictKind union provides clear, domain-specific conflict categorization.


226-230: Good improvement addressing prior feedback.

The added comment (lines 226-229) explaining the purpose of the empty SqlMigrationRunnerSuccessValue extension clarifies the intent for type branding and future extensions, as suggested in the previous review.


250-292: LGTM!

The SqlControlTargetDescriptor properly extends the core ControlTargetDescriptor and exposes SQL-specific createPlanner and createRunner methods. The CreateSqlMigrationPlanOptions helper type correctly uses SQL-specific types for migration plan construction.


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

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/integration/test/codecs.test.ts (1)

90-90: Consider using timeouts.databaseOperation for consistency.

The beforeEach hook performs database operations (dropping and creating tables) but uses timeouts.spinUpPpgDev. For consistency with other test files in this PR (budgets.test.ts and comparison-operators.test.ts), consider using timeouts.databaseOperation instead. The spinUpPpgDev timeout should typically be reserved for beforeAll hooks that actually spin up the database server.

🔎 Suggested change for consistency
-  }, timeouts.spinUpPpgDev);
+  }, timeouts.databaseOperation);
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between d0add78 and 1cad924.

📒 Files selected for processing (16)
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • test/integration/test/budgets.test.ts
  • test/integration/test/codecs.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/utils/src/timeouts.ts
🧰 Additional context used
📓 Path-based instructions (35)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)

**/*.{ts,tsx}: Use the 'key?' syntax with the ? suffix for optional keys in Arktype schemas instead of using 'string | undefined' type unions
Reference schemas directly as object property values in Arktype schemas - this works seamlessly without special syntax
Use type({ '[string]': Schema }) syntax to create Record<string, Schema> types in Arktype instead of using Record<string, Schema> string notation
Use the .array() method on Arktype schemas to create array types instead of wrapping schemas in type([Schema]) or using manual validation
Extract TypeScript types from Arktype schemas using the .infer property instead of manually duplicating type definitions
Use type.declare<>() to ensure Arktype schemas match pre-existing TypeScript types for compile-time type safety, especially when working with readonly properties
Use .array().readonly() method chaining to create readonly array types in Arktype instead of using string notation like 'string[]'
Don't manually re-validate what Arktype has already checked - once validation passes, trust the structure matches the schema
Use instanceof type.errors to check for Arktype validation errors instead of other error checking patterns, for proper type narrowing
Return the original input value from validation functions instead of returning the Arktype validation result to preserve literal types

Prefer explicit, direct imports over barrel imports: import from specific module paths like @prisma/sql/builder instead of barrel re-exports like @prisma/sql

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties on objects

**/*.{ts,tsx}: Import core contract types (ContractBase, Source) and document family types (DocumentContract) from @prisma-next/contract/types
Import target-neutral operations (OperationRegistry, ArgSpec, ReturnSpec, createOperationRegistry) from @prisma-next/operations

**/*.{ts,tsx}: Extract CodecTypes from contract using the he...

Files:

  • test/integration/test/budgets.test.ts
  • test/utils/src/timeouts.ts
  • test/integration/test/comparison-operators.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • test/integration/test/codecs.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/*.test.ts

📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)

**/*.test.ts: Contract builder tests must verify that normalization happens correctly with all required fields receiving their default values
Validator tests must verify that validation fails when required fields are missing, and must NOT test normalization behavior
Parser and emitter hook tests must test functionality with normalized contracts and must NOT test normalization behavior

**/*.test.ts: In tests using withDevDatabase() from @prisma-next/test-utils, avoid selecting or using extension-dependent columns (like pgvector, pg_trgm) when testing features unrelated to extension functionality, as pglite does not support PostgreSQL extensions
When tests must verify extension functionality end-to-end (e.g., pgvector queries), use a real PostgreSQL database instead of withDevDatabase() via withClient() and process.env['DATABASE_URL']
When writing ORM tests with includes, relation filters, or other non-extension features, explicitly exclude extension-dependent columns from select statements to ensure compatibility with pglite-based test databases

**/*.test.ts: Avoid using type assertions in tests to bypass type checking or test impossible states. Remove tests that use type assertions (e.g., 'as SqlContract') to test scenarios that contradict validated schemas.
Remove tests that use type assertions to test impossible states or test code coverage without testing real scenarios. After refactoring to use assertions, clean up unrealistic test cases.

**/*.test.ts: Write test descriptions that omit 'should' - use direct, action-oriented language (e.g., it('returns correct value') not it('should return correct value'))
Prefer object comparison with toEqual or toMatchObject instead of piece-by-piece property checks with type casts
Keep test files under 500 lines maximum and split large files by functionality, feature area, or test type using descriptive file names
Extract helper functions when the same pattern appears 3+ times, ensuring...

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/modular-refactoring-patterns.mdc)

**/*.ts: Start refactoring by extracting pure, side-effect-free utility functions as thin wrappers around AST factories and error constructors
Extract state management into separate modules defining immutable state shapes and interfaces
Replace any types with proper generic type parameters during function extraction, using existing type definitions like ModelColumnAccessor
Use the compact helper function to remove undefined values from objects when TypeScript's exactOptionalPropertyTypes is enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value imports

**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid in TypeScript. Use non-null assertions (!) after validation checks instead of optional chaining or defensive conditionals.
Use assertions to access validated properties directly (e.g., columnMeta.codecId, columnMeta.nullable) instead of optional chaining (columnMeta?.codecId) after validation has already occurred.

Files:

  • test/integration/test/budgets.test.ts
  • test/utils/src/timeouts.ts
  • test/integration/test/comparison-operators.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • test/integration/test/codecs.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/*.{test,spec}.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)

Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)

Prefer object matchers with .toMatchObject() over multiple individual expect().toBe() calls when checking 2+ related values in tests

**/*.{test,spec}.ts: Test files must not exceed 500 lines; split files that exceed this limit into multiple files organized by logical functionality
Split test files by logical groupings: by functionality (basic, errors, structure), by feature area (joins, projections, includes), or by test type (unit, integration, edge-cases)
Use descriptive test file names following the pattern {base}.{category}.test.ts, where base name indicates the subject being tested and category indicates the test type (e.g., .basic.test.ts, .errors.test.ts, .joins.test.ts)
Ensure each split test file contains all necessary imports, setup/teardown code, and is independently runnable without dependencies on other test files
Prefer object comparison assertions using toEqual or toMatchObject instead of piece-by-piece property checks with toHaveProperty or individual type assertions
Use expect.any() for type-only checks and expect.not.objectContaining() for absence checks when performing partial object comparisons
Compare entire plan structures using object comparison assertions instead of checking individual AST fields piecemeal to ensure all fields are present and correct

Use factory functions (such as createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) for creating AST nodes in tests instead of manual object creation

Use factory functions (e.g., createContractIR()) instead of manual object creation when creating ContractIR objects in tests. Ensure all required fields (schemaVersion, targetFamily, target, models, relations, storage, extensions, capabilities, meta, sources) are present through the factory function rather than manual construction.

**/*.{test,spec}.ts: Do not use the deprecated toMatchTypeOf() matcher in Vitest's expectTypeOf API; use toExtend() instead for verifying ...

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Import from shared plane packages using the package name and export identifier (e.g., @prisma-next/sql-contract/types), not /exports/ paths

**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in the exports/ folders

**/*.{ts,tsx,js,jsx}: Import loadContractFromTs and createContractEmitCommand from the main package export @prisma-next/cli, not from subpaths
Import config utilities (defineConfig and config types) from the @prisma-next/cli/config-types subpath, not from the main package
Import loadExtensionPacks and loadExtensionPackManifest from the @prisma-next/cli/pack-loading subpath, not from the main package
Import command factory functions (e.g., createDbIntrospectCommand, createDbVerifyCommand) from their specific command subpaths (e.g., @prisma-next/cli/commands/db-introspect), not from the main package
Import the loadConfig function from the @prisma-next/cli/config-loader subpath, not from the main package

Update relative paths in source files (manifest paths, import paths, etc.) when moving packages by recalculating the path based on the new location's directory depth

If you need to disable a Biome rule for more than a couple of lines in a file, use a file-level disable comment at the top instead of many inline comments

Files:

  • test/integration/test/budgets.test.ts
  • test/utils/src/timeouts.ts
  • test/integration/test/comparison-operators.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • test/integration/test/codecs.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)

Use local pnpm test scripts for testing; use pnpm test:coverage for all packages or pnpm coverage:packages for packages only

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.{test,spec,util,utils}.ts

📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)

For same-package tests needing private functions, create test utilities within the same package that use relative imports and can be exported if needed, rather than exporting the private functions directly

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.{test,spec}.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Omit 'should' from test descriptions as per .cursor/rules/omit-should-in-tests.mdc

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx,js}: Use correct test import patterns: import from source files with relative paths, don't export for tests as per .cursor/rules/test-import-patterns.mdc
Organize test files with max 500 lines, split by functionality as per .cursor/rules/test-file-organization.mdc
Prefer object matchers over multiple individual expect().toBe() calls as per .cursor/rules/prefer-object-matcher.mdc

Keep tests concise; omit 'should' from test descriptions

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx}: Use Vitest expect().toEqual(expect.any(Type)) pattern for type testing as per .cursor/rules/vitest-expect-typeof.mdc
Use factory functions for ContractIR objects in tests as per .cursor/rules/use-contract-ir-factories.mdc

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.{test,spec,ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Use factory functions for creating AST nodes instead of manual object creation as per .cursor/rules/use-ast-factories.mdc

Files:

  • test/integration/test/budgets.test.ts
  • test/utils/src/timeouts.ts
  • test/integration/test/comparison-operators.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • test/integration/test/codecs.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{ts,tsx,js}: Use LATERAL/json_agg patterns for PostgreSQL queries as per .cursor/rules/postgres-lateral-patterns.mdc
Use Object.hasOwn() instead of hasOwnProperty() as per .cursor/rules/object-hasown.mdc
Prefer assertions over defensive checks; avoid schema validation redundancy as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc

**/*.{ts,tsx,js}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing (see scripts/check-imports.mjs and .cursor/rules/import-validation.mdc)
Numbered prefixes in package directory structure indicate dependency direction: lower numbers can be imported by higher numbers, never the reverse

Files:

  • test/integration/test/budgets.test.ts
  • test/utils/src/timeouts.ts
  • test/integration/test/comparison-operators.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • test/integration/test/codecs.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/*.test.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

When moving test files to new locations, update paths to other packages, fixtures, and manifests (e.g., extension pack manifests) by recalculating directory depth based on the new location

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/*.test.{ts,tsx}: Always validate contracts in tests using validateContract function; contracts must have fully qualified type IDs, not bare scalars
Blind type casts (as unknown as X) are acceptable only in test files for mocking and error cases
Use @ts-expect-error comments with explanations in test files only when working with dynamic proxy objects or complex type scenarios
When mocking class instances in tests, use Object.create() and Object.assign() to preserve the prototype instead of the spread operator
Common patterns in test files should be extracted into helper functions from appropriate shared utility packages or created as package-specific helpers

Files:

  • test/integration/test/budgets.test.ts
  • test/integration/test/comparison-operators.test.ts
  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}: Blind type casts (as unknown as X) are forbidden in production code; use type predicates instead
Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead

Files:

  • test/integration/test/budgets.test.ts
  • test/utils/src/timeouts.ts
  • test/integration/test/comparison-operators.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • test/integration/test/codecs.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/+(src|lib)/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/+(src|lib)/**/*.{ts,tsx}: When extracting types from ColumnBuilder instances, use infer for all type parameters without constraints to allow correct type inference
Use RuntimeContext to decouple codec and operations registries from Runtime, allowing them to be passed to schema and query builders

Files:

  • test/utils/src/timeouts.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/import-validation.mdc)

packages/**/*.{ts,tsx}: Same-layer imports are allowed: packages in the same layer can import from each other (e.g., orm-lane can import from sql-relational-core if both are in the lanes layer)
Cross-layer imports must flow inward (toward core): packages can only import from inner layers (closer to core). Outer layers cannot import from inner layers (e.g., core layer cannot import from lanes layer)

Import SQL emitter hook (sqlTargetFamilyHook) from @prisma-next/sql-contract-emitter

Files:

  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
packages/**/test/**/*.{ts,test.ts}

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should include unit tests for validators and factories, type tests for exported types, and no integration tests requiring migration or runtime plane packages

Files:

  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
{src,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Prohibit inline type imports in source files as per .cursor/rules/no-inline-imports.mdc

Files:

  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/*.test-d.ts

📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)

Use expectTypeOf from Vitest for type-level testing in type test files

Files:

  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx,json,js}

📄 CodeRabbit inference engine (AGENTS.md)

SQL family internals live under packages/2-sql/; top-level packages/3-targets/ is reserved for target extension packs (dialect, adapter, driver)

Files:

  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/src/{core,exports}/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)

Multi-plane packages must use a structured directory layout with src/core/ for shared plane code and src/exports/ for entry points

Files:

  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/src/exports/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)

Exports directory (src/exports/) should include re-export files (adapter.ts, codec-types.ts, types.ts) in addition to plane-specific entry points (control.ts, runtime.ts)

Files:

  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
packages/**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should only contain side-effect-free code (types, validators, factories) with no migration-specific logic or IO operations

Files:

  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
packages/**/src/exports/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages must export types, validators, and factories through separate export files in the src/exports/ directory

Files:

  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/exports/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

When a class with private properties is part of an exported type, the class must be explicitly exported from the exports file, not just from the source file

Files:

  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/*cli**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/cli-error-handling.mdc)

Use factory functions from utils/cli-errors.ts to create structured errors with consistent structure and metadata

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
{src,packages}/**/cli/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

{src,packages}/**/cli/**/*.{ts,tsx,js}: Follow CLI command description patterns as per .cursor/rules/cli-command-descriptions.mdc
CLI command error handling: throw errors, don't call process.exit as per .cursor/rules/cli-error-handling.mdc
Follow CLI package export structure and import patterns as per .cursor/rules/cli-package-exports.mdc

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
**/commands/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)

FamilyInstance is retained for CLI command handlers that need the full method set (validateContractIR, verify, schemaVerify, introspect, emitContract, toSchemaView). It uses ControlDriverInstance internally.

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
**/src/exports/control.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)

Migration plane entrypoint must be named control.ts (not cli.ts) and located at src/exports/control.ts; import control plane/tooling only from this file

**/src/exports/control.ts: Migration plane entry point (src/exports/control.ts) must export control plane descriptors and use naming convention control.ts (not cli.ts)
Migration plane entry point (src/exports/control.ts) can import from migration plane packages and core (../core/...)

Files:

  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
**/control.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)

Control plane entry points must export default descriptors with the appropriate types: @prisma-next/family-*/control exports ControlFamilyDescriptor, @prisma-next/target-*/control exports ControlTargetDescriptor, @prisma-next/adapter-*/control exports ControlAdapterDescriptor, @prisma-next/driver-*/control exports ControlDriverDescriptor, and @prisma-next/extensions-*/control exports ControlExtensionDescriptor.

Files:

  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
packages/3-targets/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (AGENTS.md)

Don't branch on target; use adapters instead

Files:

  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/src/core/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)

**/src/core/**/*.{ts,tsx,js,jsx}: Keep shared implementation in src/core/** directory with no migration/runtime plane imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/core/** directory

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/src/core/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)

**/src/core/**/*.ts: Core implementation (src/core/**) must contain shared plane code with no CLI-specific or runtime-specific dependencies
Core code (src/core/**) can only import from shared plane packages

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
🧠 Learnings (1)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.

Applied to files:

  • test/integration/test/budgets.test.ts
  • test/utils/src/timeouts.ts
  • test/integration/test/comparison-operators.test.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts
  • test/integration/test/codecs.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/2-sql/3-tooling/family/test/migrations.types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/exports/control.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
🧬 Code graph analysis (9)
test/integration/test/comparison-operators.test.ts (2)
test/utils/src/timeouts.ts (1)
  • timeouts (46-76)
test/utils/src/exports/index.ts (1)
  • teardownTestDatabase (99-106)
test/integration/test/codecs.test.ts (1)
test/utils/src/timeouts.ts (1)
  • timeouts (46-76)
packages/1-framework/1-core/migration/control-plane/src/types.ts (2)
packages/1-framework/1-core/migration/control-plane/src/exports/types.ts (2)
  • ControlFamilyInstance (10-10)
  • TargetMigrationsCapability (34-34)
packages/1-framework/1-core/migration/control-plane/src/migrations.ts (1)
  • TargetMigrationsCapability (175-180)
packages/2-sql/3-tooling/family/test/migrations.types.test.ts (2)
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (3)
  • SqlMigrationPlanOperation (71-80)
  • SqlMigrationPlan (94-107)
  • SqlPlannerConflict (141-145)
packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts (1)
  • createMigrationPlan (94-106)
packages/1-framework/3-tooling/cli/src/commands/db-init.ts (3)
packages/1-framework/1-core/migration/control-plane/src/errors.ts (1)
  • errorTargetMigrationNotSupported (248-257)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/3-targets/3-targets/postgres/src/exports/control.ts (3)
packages/2-sql/3-tooling/family/src/core/instance.ts (1)
  • SqlControlFamilyInstance (246-318)
packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts (1)
  • createPostgresMigrationPlanner (47-54)
packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts (1)
  • createPostgresMigrationRunner (66-71)
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (3)
packages/2-sql/3-tooling/family/src/exports/control.ts (15)
  • SqlMigrationPlanOperationStep (28-28)
  • SqlMigrationPlanOperationTarget (29-29)
  • SqlMigrationPlanOperation (27-27)
  • MigrationPlanOperation (21-21)
  • SqlMigrationPlanContractInfo (24-24)
  • SqlMigrationPlan (23-23)
  • MigrationPlan (18-18)
  • SqlPlannerConflictKind (38-38)
  • SqlPlannerConflictLocation (39-39)
  • SqlPlannerConflict (37-37)
  • MigrationPlannerConflict (19-19)
  • SqlPlannerSuccessResult (42-42)
  • SqlPlannerFailureResult (40-40)
  • MigrationOperationPolicy (17-17)
  • SqlControlFamilyInstance (3-3)
packages/1-framework/1-core/migration/control-plane/src/types.ts (6)
  • MigrationPlanOperation (17-17)
  • MigrationPlan (11-11)
  • MigrationPlannerConflict (13-13)
  • MigrationPlannerSuccessResult (16-16)
  • MigrationPlannerFailureResult (14-14)
  • MigrationOperationPolicy (10-10)
packages/2-sql/3-tooling/family/src/core/instance.ts (1)
  • SqlControlFamilyInstance (246-318)
packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts (1)
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (12)
  • SqlMigrationPlanOperationStep (53-57)
  • SqlMigrationPlanOperationTarget (62-65)
  • SqlMigrationPlanOperation (71-80)
  • CreateSqlMigrationPlanOptions (303-309)
  • SqlMigrationPlan (94-107)
  • SqlPlannerSuccessResult (150-154)
  • SqlPlannerConflict (141-145)
  • SqlPlannerFailureResult (159-162)
  • SqlMigrationRunnerSuccessValue (247-247)
  • SqlMigrationRunnerErrorCode (226-233)
  • AnyRecord (44-44)
  • SqlMigrationRunnerFailure (239-242)
packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts (2)
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (3)
  • SqlMigrationPlanner (185-187)
  • SqlMigrationPlannerPlanOptions (174-179)
  • SqlMigrationPlanOperation (71-80)
packages/2-sql/3-tooling/family/src/exports/control.ts (3)
  • SqlMigrationPlanner (25-25)
  • SqlMigrationPlannerPlanOptions (26-26)
  • SqlMigrationPlanOperation (27-27)
🔇 Additional comments (48)
test/integration/test/budgets.test.ts (1)

79-79: LGTM!

The timeout additions are appropriate for database setup and teardown operations. Using timeouts.databaseOperation for these hooks ensures consistent timeout handling across database operations.

Also applies to: 83-83

test/integration/test/codecs.test.ts (1)

94-94: LGTM!

The timeout addition for the afterEach teardown is appropriate.

test/integration/test/comparison-operators.test.ts (1)

57-57: LGTM!

The timeout additions are appropriate for database setup and teardown operations. This follows the same pattern as budgets.test.ts and ensures consistent timeout handling across integration tests.

Also applies to: 61-61

test/utils/src/timeouts.ts (1)

4-4: LGTM!

The new databaseOperation timeout category follows the established pattern and fills a semantic gap. The 5000ms base value is appropriate for database operations like table creation, data insertion, and cleanup. The implementation correctly applies the multiplier and includes clear documentation.

Also applies to: 62-68

packages/2-sql/3-tooling/family/test/migrations.types.test.ts (2)

7-11: LGTM!

The import changes correctly align with the PR's goal of using SQL-prefixed types (SqlMigrationPlan, SqlMigrationPlanOperation, SqlPlannerConflict) instead of generic migration types. This maintains consistency with the type surface exposed in ../src/core/migrations/types.


35-35: Type annotations correctly updated to SQL-specific variants.

The type casts and annotations are appropriately updated:

  • Line 35: Cast to SqlMigrationPlanOperation<TestTargetDetails>[]
  • Line 146: Variable typed as SqlMigrationPlan<TestTargetDetails>
  • Line 160: satisfies SqlPlannerConflict constraint

These align with the test file's purpose of validating SQL-specific migration plan helpers.

Also applies to: 146-146, 160-160

packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts (1)

1-54: Well-structured type-level compatibility tests.

This new test file correctly validates that SQL-specific migration types extend the core framework types:

  • Uses toExtend() (not the deprecated toMatchTypeOf()) as per coding guidelines
  • Imports follow correct patterns: cross-package via @prisma-next/core-control-plane/types, within-package via relative paths
  • Comprehensive coverage of key type relationships: operation classes, plan operations, plans, conflicts, and runner results

This ensures the CLI can safely use core types while SQL-specific code uses the extended types.

packages/1-framework/1-core/migration/control-plane/src/exports/types.ts (1)

16-34: LGTM!

Clean extension of the public API surface with canonical, family-agnostic migration types. The re-exports are well-organized with a descriptive comment and maintain alphabetical ordering. This enables the CLI to import all migration types from a single location (@prisma-next/core-control-plane/types).

packages/3-targets/3-targets/postgres/src/exports/control.ts (2)

66-76: LGTM!

The migrations property correctly implements TargetMigrationsCapability, exposing createPlanner and createRunner for CLI access via core types. This enables the CLI to use the core migration interfaces while the underlying implementation uses SQL-specific types.


83-96: Deprecation annotations appropriately guide migration to new API.

The direct createPlanner and createRunner methods are correctly marked as deprecated with clear guidance to use migrations.createPlanner() and migrations.createRunner() respectively. Consider removing these deprecated methods in a follow-up once consumers have migrated.

packages/1-framework/1-core/migration/control-plane/src/types.ts (2)

4-23: LGTM!

Clean import and re-export of migration types from ./migrations. The re-export block with its descriptive comment provides a convenient single-import location for consumers of migration types.


169-189: Well-designed extension to ControlTargetDescriptor.

The new TFamilyInstance generic parameter with its constraint and default value maintains backward compatibility while enabling typed migrations capability. The optional migrations property is properly documented with JSDoc explaining its purpose.

packages/1-framework/3-tooling/cli/src/commands/db-init.ts (4)

4-10: LGTM!

Clean migration from local duck-typed interfaces to public types from @prisma-next/core-control-plane/types. This aligns the CLI with the canonical core migration types introduced in this PR.


153-159: Improved migrations capability check.

The check now uses the migrations property on the target descriptor instead of method-based duck typing. The error message clearly identifies which target lacks migration support.


180-182: Correct usage of migrations capability API.

Planner and runner are now created through the migrations capability object, enabling the CLI to work with the core migration interfaces while targets provide family-specific implementations.


194-194: Explicit type annotations improve clarity.

The added type annotations for plannerResult: MigrationPlannerResult, migrationPlan: MigrationPlan, and runnerResult: MigrationRunnerResult make the code more self-documenting and ensure type safety at key boundaries.

Also applies to: 211-211, 245-245

packages/2-sql/3-tooling/family/src/exports/control.ts (1)

12-44: LGTM!

The export surface is well-organized with clear separation between SQL-specific types (Sql-prefixed) and core re-exports. The inline comments help consumers understand which types belong to which category. The comprehensive export of SQL migration types enables downstream packages to use the full SQL-specific API surface.

packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts (3)

1-6: LGTM!

Imports correctly updated to use SQL-specific types from @prisma-next/family-sql/control. This aligns the Postgres planner with the SQL family's type surface.


47-59: Correct type alignment for factory and class.

The createPostgresMigrationPlanner return type and PostgresMigrationPlanner class implementation correctly use SqlMigrationPlanner<PostgresPlanTargetDetails> and SqlMigrationPlannerPlanOptions, maintaining type consistency with the SQL family's migration interface.


83-83: Consistent SQL-specific operation types throughout builder methods.

All operation arrays and builder method return types correctly use SqlMigrationPlanOperation<PostgresPlanTargetDetails>, ensuring type consistency across the planner implementation. The readonly modifier on return types appropriately signals immutability.

Also applies to: 148-151, 206-210, 245-249, 288-292, 332-336

packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts (5)

1-16: LGTM!

Import statements correctly updated to use SQL-specific types from the local ./types module. The organization follows the coding guidelines with type imports grouped together.


27-42: LGTM!

Type signatures correctly updated to use SqlMigrationPlanOperationStep, SqlMigrationPlanOperationTarget, and SqlMigrationPlanOperation types. The freezing logic remains unchanged and properly handles immutability.

Also applies to: 60-67, 69-83, 85-92


94-106: LGTM!

Factory function correctly updated to use CreateSqlMigrationPlanOptions and return SqlMigrationPlan. The implementation properly freezes the plan structure including origin, destination, and operations.


108-132: LGTM!

Planner result helper functions correctly updated to use SQL-specific types (SqlMigrationPlan, SqlPlannerSuccessResult, SqlPlannerConflict, SqlPlannerFailureResult). The freezing semantics are preserved.


137-163: LGTM!

Runner result helpers correctly updated to use SqlMigrationRunnerSuccessValue, SqlMigrationRunnerErrorCode, and SqlMigrationRunnerFailure. The Result wrapper pattern with ok/notOk is properly maintained.

packages/2-sql/3-tooling/family/src/core/migrations/types.ts (6)

1-24: LGTM!

Well-structured file header with clear documentation explaining the purpose of SQL-specific migration types. Imports are correctly organized with type imports from core control-plane and SQL-specific packages.


26-44: LGTM!

Re-exporting core types for convenience is a clean pattern that allows consumers to import both core and SQL-specific types from a single location. The AnyRecord type alias is appropriately defined as a readonly record.


46-107: LGTM!

SQL plan types are well-designed:

  • SqlMigrationPlanOperationStep adds SQL-specific sql field
  • SqlMigrationPlanOperationTarget provides target identification with generic details
  • SqlMigrationPlanOperation properly extends MigrationPlanOperation with precheck/execute/postcheck steps
  • SqlMigrationPlan extends MigrationPlan with origin/destination contract info
  • Default type parameter uses Record<string, never> per coding guidelines

109-187: LGTM!

SQL planner types provide a comprehensive type system:

  • SqlPlannerConflictKind defines SQL-specific conflict categories
  • SqlPlannerConflictLocation adds location context (table, column, index, etc.)
  • SqlPlannerConflict properly extends MigrationPlannerConflict with SQL-specific fields
  • Result types use Omit to override plan/conflicts with SQL-specific variants
  • SqlMigrationPlanner interface with typed plan method

189-265: LGTM!

SQL runner types are well-structured:

  • Callbacks and options interfaces properly typed with generics
  • SqlMigrationRunnerErrorCode provides SQL-specific error codes
  • SqlMigrationRunnerFailure extends core with specific code type
  • SqlMigrationRunner interface matches the expected contract

267-309: LGTM!

SqlControlTargetDescriptor properly extends the core ControlTargetDescriptor and adds SQL-specific createPlanner and createRunner methods that return SQL-typed interfaces. CreateSqlMigrationPlanOptions provides a clean factory options type.

packages/3-targets/3-targets/postgres/src/core/migrations/runner.ts (10)

1-26: LGTM!

Import statements correctly updated to use SQL-specific types from @prisma-next/family-sql/control. The imports follow the coding guidelines with type imports separated from value imports.


66-77: LGTM!

Factory function and class correctly updated to implement SqlMigrationRunner<PostgresPlanTargetDetails>. The return type and class signature are consistent.


79-167: LGTM!

The execute method is well-structured with proper error handling and transaction management. The type signature correctly uses SqlMigrationRunnerExecuteOptions and SqlMigrationRunnerResult. The flow is:

  1. Static checks (destination, policy)
  2. Transaction with advisory lock
  3. Marker validation
  4. Plan application or skip if already at destination
  5. Schema verification
  6. Marker and ledger updates
  7. Commit with proper rollback on failure

169-219: LGTM!

The applyPlan method correctly:

  • Uses SqlMigrationPlanOperation<PostgresPlanTargetDetails> for executed operations tracking
  • Implements postcheck pre-satisfaction check to skip already-satisfied operations
  • Runs precheck → execute → postcheck sequence with proper error handling
  • Invokes callbacks for operation lifecycle events

229-279: LGTM!

Both runExpectationSteps and runExecuteSteps methods correctly use SQL-specific types and handle errors appropriately with specific error codes (PRECHECK_FAILED, POSTCHECK_FAILED, EXECUTION_FAILED).


324-356: LGTM!

The createPostcheckPreSatisfiedSkipRecord method correctly creates a skip record with frozen metadata. The type signature uses SqlMigrationPlanOperation<PostgresPlanTargetDetails> for both input and output.


374-458: LGTM!

Policy and marker compatibility checks are thorough with proper error handling:

  • enforcePolicyCompatibility validates operation classes against policy
  • ensureMarkerCompatibility handles all cases: no origin expected, origin expected but missing, hash mismatches
  • Error messages are descriptive with relevant metadata

460-493: LGTM!

The ensurePlanMatchesDestinationContract method correctly validates that the plan's destination hashes match the provided contract. Both coreHash and profileHash are checked.


495-569: LGTM!

The remaining helper methods are correctly typed with SqlMigrationRunnerExecuteOptions<PostgresPlanTargetDetails>['driver'] for the driver parameter. Transaction handling methods (beginTransaction, commitTransaction, rollbackTransaction) and executeStatement are properly implemented.


47-64: These are distinct functions with different purposes—not duplicates.

The cloneRecord function in plan-helpers.ts performs a shallow clone with freeze (Object.freeze({ ...value })), while cloneAndFreezeRecord in runner.ts performs deep recursive cloning with freezing, handling nested objects and arrays. They serve different use cases and should not be merged. Additionally, Lodash is not a project dependency, making the suggested approach infeasible. No refactoring is needed.

Likely an incorrect or invalid review comment.

packages/1-framework/1-core/migration/control-plane/src/migrations.ts (7)

1-12: LGTM!

Excellent documentation explaining the purpose of this module. The separation of family-agnostic types for CLI commands while allowing family-specific extensions is a clean architectural pattern.


14-31: LGTM!

MigrationOperationClass and MigrationOperationPolicy provide a clear safety model for migration operations. The three-tier classification (additive, widening, destructive) with policy-based filtering is well-designed.


33-64: LGTM!

Display-oriented plan types are appropriately minimal:

  • MigrationPlanOperation contains only display fields (id, label, operationClass)
  • MigrationPlan provides summary information for CLI output
  • Comments clearly indicate these are for display purposes

66-101: LGTM!

Planner result types follow the discriminated union pattern with kind: 'success' | 'failure'. The conflict type is generic with kind: string to allow family-specific conflict kinds.


103-131: LGTM!

Runner result types are clean:

  • MigrationRunnerSuccessValue tracks planned vs executed operations
  • MigrationRunnerFailure provides error code, summary, and optional explanation
  • Result type uses the Result utility from @prisma-next/utils/result

132-163: Using unknown for contract/schema types is intentional but consider documentation.

The MigrationPlanner.plan() and MigrationRunner.execute() interfaces use unknown for contract/schema types. While this is intentional for family-agnostic design, it relies on implementations to perform their own type assertions.

This is acceptable since:

  1. Family-specific types (e.g., SqlMigrationPlanner) override with concrete types
  2. CLI only needs the return types, not the input specifics

A brief inline comment noting this design decision could help future maintainers.


165-180: LGTM!

TargetMigrationsCapability provides a clean capability pattern for targets that support migrations. The generic constraint with default allows both generic and family-specific usage.

Type exists for type branding and potential SQL-specific extensions,
maintaining consistency with other Sql* prefixed types.
spinUpPpgDev should be reserved for beforeAll hooks that start the DB server

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (1)

244-248: Empty interface now has explanatory comment.

The JSDoc comment adequately explains the purpose of type branding and allowing future SQL-specific extensions.

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 1cad924 and cc1f2a7.

📒 Files selected for processing (2)
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • test/integration/test/codecs.test.ts
🧰 Additional context used
📓 Path-based instructions (24)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)

**/*.{ts,tsx}: Use the 'key?' syntax with the ? suffix for optional keys in Arktype schemas instead of using 'string | undefined' type unions
Reference schemas directly as object property values in Arktype schemas - this works seamlessly without special syntax
Use type({ '[string]': Schema }) syntax to create Record<string, Schema> types in Arktype instead of using Record<string, Schema> string notation
Use the .array() method on Arktype schemas to create array types instead of wrapping schemas in type([Schema]) or using manual validation
Extract TypeScript types from Arktype schemas using the .infer property instead of manually duplicating type definitions
Use type.declare<>() to ensure Arktype schemas match pre-existing TypeScript types for compile-time type safety, especially when working with readonly properties
Use .array().readonly() method chaining to create readonly array types in Arktype instead of using string notation like 'string[]'
Don't manually re-validate what Arktype has already checked - once validation passes, trust the structure matches the schema
Use instanceof type.errors to check for Arktype validation errors instead of other error checking patterns, for proper type narrowing
Return the original input value from validation functions instead of returning the Arktype validation result to preserve literal types

Prefer explicit, direct imports over barrel imports: import from specific module paths like @prisma/sql/builder instead of barrel re-exports like @prisma/sql

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties on objects

**/*.{ts,tsx}: Import core contract types (ContractBase, Source) and document family types (DocumentContract) from @prisma-next/contract/types
Import target-neutral operations (OperationRegistry, ArgSpec, ReturnSpec, createOperationRegistry) from @prisma-next/operations

**/*.{ts,tsx}: Extract CodecTypes from contract using the he...

Files:

  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/*.test.ts

📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)

**/*.test.ts: Contract builder tests must verify that normalization happens correctly with all required fields receiving their default values
Validator tests must verify that validation fails when required fields are missing, and must NOT test normalization behavior
Parser and emitter hook tests must test functionality with normalized contracts and must NOT test normalization behavior

**/*.test.ts: In tests using withDevDatabase() from @prisma-next/test-utils, avoid selecting or using extension-dependent columns (like pgvector, pg_trgm) when testing features unrelated to extension functionality, as pglite does not support PostgreSQL extensions
When tests must verify extension functionality end-to-end (e.g., pgvector queries), use a real PostgreSQL database instead of withDevDatabase() via withClient() and process.env['DATABASE_URL']
When writing ORM tests with includes, relation filters, or other non-extension features, explicitly exclude extension-dependent columns from select statements to ensure compatibility with pglite-based test databases

**/*.test.ts: Avoid using type assertions in tests to bypass type checking or test impossible states. Remove tests that use type assertions (e.g., 'as SqlContract') to test scenarios that contradict validated schemas.
Remove tests that use type assertions to test impossible states or test code coverage without testing real scenarios. After refactoring to use assertions, clean up unrealistic test cases.

**/*.test.ts: Write test descriptions that omit 'should' - use direct, action-oriented language (e.g., it('returns correct value') not it('should return correct value'))
Prefer object comparison with toEqual or toMatchObject instead of piece-by-piece property checks with type casts
Keep test files under 500 lines maximum and split large files by functionality, feature area, or test type using descriptive file names
Extract helper functions when the same pattern appears 3+ times, ensuring...

Files:

  • test/integration/test/codecs.test.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/modular-refactoring-patterns.mdc)

**/*.ts: Start refactoring by extracting pure, side-effect-free utility functions as thin wrappers around AST factories and error constructors
Extract state management into separate modules defining immutable state shapes and interfaces
Replace any types with proper generic type parameters during function extraction, using existing type definitions like ModelColumnAccessor
Use the compact helper function to remove undefined values from objects when TypeScript's exactOptionalPropertyTypes is enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value imports

**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid in TypeScript. Use non-null assertions (!) after validation checks instead of optional chaining or defensive conditionals.
Use assertions to access validated properties directly (e.g., columnMeta.codecId, columnMeta.nullable) instead of optional chaining (columnMeta?.codecId) after validation has already occurred.

Files:

  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/*.{test,spec}.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)

Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')

Files:

  • test/integration/test/codecs.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)

Prefer object matchers with .toMatchObject() over multiple individual expect().toBe() calls when checking 2+ related values in tests

**/*.{test,spec}.ts: Test files must not exceed 500 lines; split files that exceed this limit into multiple files organized by logical functionality
Split test files by logical groupings: by functionality (basic, errors, structure), by feature area (joins, projections, includes), or by test type (unit, integration, edge-cases)
Use descriptive test file names following the pattern {base}.{category}.test.ts, where base name indicates the subject being tested and category indicates the test type (e.g., .basic.test.ts, .errors.test.ts, .joins.test.ts)
Ensure each split test file contains all necessary imports, setup/teardown code, and is independently runnable without dependencies on other test files
Prefer object comparison assertions using toEqual or toMatchObject instead of piece-by-piece property checks with toHaveProperty or individual type assertions
Use expect.any() for type-only checks and expect.not.objectContaining() for absence checks when performing partial object comparisons
Compare entire plan structures using object comparison assertions instead of checking individual AST fields piecemeal to ensure all fields are present and correct

Use factory functions (such as createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) for creating AST nodes in tests instead of manual object creation

Use factory functions (e.g., createContractIR()) instead of manual object creation when creating ContractIR objects in tests. Ensure all required fields (schemaVersion, targetFamily, target, models, relations, storage, extensions, capabilities, meta, sources) are present through the factory function rather than manual construction.

**/*.{test,spec}.ts: Do not use the deprecated toMatchTypeOf() matcher in Vitest's expectTypeOf API; use toExtend() instead for verifying ...

Files:

  • test/integration/test/codecs.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Import from shared plane packages using the package name and export identifier (e.g., @prisma-next/sql-contract/types), not /exports/ paths

**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in the exports/ folders

**/*.{ts,tsx,js,jsx}: Import loadContractFromTs and createContractEmitCommand from the main package export @prisma-next/cli, not from subpaths
Import config utilities (defineConfig and config types) from the @prisma-next/cli/config-types subpath, not from the main package
Import loadExtensionPacks and loadExtensionPackManifest from the @prisma-next/cli/pack-loading subpath, not from the main package
Import command factory functions (e.g., createDbIntrospectCommand, createDbVerifyCommand) from their specific command subpaths (e.g., @prisma-next/cli/commands/db-introspect), not from the main package
Import the loadConfig function from the @prisma-next/cli/config-loader subpath, not from the main package

Update relative paths in source files (manifest paths, import paths, etc.) when moving packages by recalculating the path based on the new location's directory depth

If you need to disable a Biome rule for more than a couple of lines in a file, use a file-level disable comment at the top instead of many inline comments

Files:

  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)

Use local pnpm test scripts for testing; use pnpm test:coverage for all packages or pnpm coverage:packages for packages only

Files:

  • test/integration/test/codecs.test.ts
**/*.{test,spec,util,utils}.ts

📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)

For same-package tests needing private functions, create test utilities within the same package that use relative imports and can be exported if needed, rather than exporting the private functions directly

Files:

  • test/integration/test/codecs.test.ts
**/*.{test,spec}.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Omit 'should' from test descriptions as per .cursor/rules/omit-should-in-tests.mdc

Files:

  • test/integration/test/codecs.test.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx,js}: Use correct test import patterns: import from source files with relative paths, don't export for tests as per .cursor/rules/test-import-patterns.mdc
Organize test files with max 500 lines, split by functionality as per .cursor/rules/test-file-organization.mdc
Prefer object matchers over multiple individual expect().toBe() calls as per .cursor/rules/prefer-object-matcher.mdc

Keep tests concise; omit 'should' from test descriptions

Files:

  • test/integration/test/codecs.test.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx}: Use Vitest expect().toEqual(expect.any(Type)) pattern for type testing as per .cursor/rules/vitest-expect-typeof.mdc
Use factory functions for ContractIR objects in tests as per .cursor/rules/use-contract-ir-factories.mdc

Files:

  • test/integration/test/codecs.test.ts
**/*.{test,spec,ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Use factory functions for creating AST nodes instead of manual object creation as per .cursor/rules/use-ast-factories.mdc

Files:

  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{ts,tsx,js}: Use LATERAL/json_agg patterns for PostgreSQL queries as per .cursor/rules/postgres-lateral-patterns.mdc
Use Object.hasOwn() instead of hasOwnProperty() as per .cursor/rules/object-hasown.mdc
Prefer assertions over defensive checks; avoid schema validation redundancy as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc

**/*.{ts,tsx,js}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing (see scripts/check-imports.mjs and .cursor/rules/import-validation.mdc)
Numbered prefixes in package directory structure indicate dependency direction: lower numbers can be imported by higher numbers, never the reverse

Files:

  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/*.test.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

When moving test files to new locations, update paths to other packages, fixtures, and manifests (e.g., extension pack manifests) by recalculating directory depth based on the new location

Files:

  • test/integration/test/codecs.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/*.test.{ts,tsx}: Always validate contracts in tests using validateContract function; contracts must have fully qualified type IDs, not bare scalars
Blind type casts (as unknown as X) are acceptable only in test files for mocking and error cases
Use @ts-expect-error comments with explanations in test files only when working with dynamic proxy objects or complex type scenarios
When mocking class instances in tests, use Object.create() and Object.assign() to preserve the prototype instead of the spread operator
Common patterns in test files should be extracted into helper functions from appropriate shared utility packages or created as package-specific helpers

Files:

  • test/integration/test/codecs.test.ts
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}: Blind type casts (as unknown as X) are forbidden in production code; use type predicates instead
Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead

Files:

  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/import-validation.mdc)

packages/**/*.{ts,tsx}: Same-layer imports are allowed: packages in the same layer can import from each other (e.g., orm-lane can import from sql-relational-core if both are in the lanes layer)
Cross-layer imports must flow inward (toward core): packages can only import from inner layers (closer to core). Outer layers cannot import from inner layers (e.g., core layer cannot import from lanes layer)

Import SQL emitter hook (sqlTargetFamilyHook) from @prisma-next/sql-contract-emitter

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/src/core/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)

**/src/core/**/*.{ts,tsx,js,jsx}: Keep shared implementation in src/core/** directory with no migration/runtime plane imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/core/** directory

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/src/{core,exports}/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)

Multi-plane packages must use a structured directory layout with src/core/ for shared plane code and src/exports/ for entry points

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/src/core/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)

**/src/core/**/*.ts: Core implementation (src/core/**) must contain shared plane code with no CLI-specific or runtime-specific dependencies
Core code (src/core/**) can only import from shared plane packages

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
packages/**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should only contain side-effect-free code (types, validators, factories) with no migration-specific logic or IO operations

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
{src,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Prohibit inline type imports in source files as per .cursor/rules/no-inline-imports.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
**/+(src|lib)/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/+(src|lib)/**/*.{ts,tsx}: When extracting types from ColumnBuilder instances, use infer for all type parameters without constraints to allow correct type inference
Use RuntimeContext to decouple codec and operations registries from Runtime, allowing them to be passed to schema and query builders

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx,json,js}

📄 CodeRabbit inference engine (AGENTS.md)

SQL family internals live under packages/2-sql/; top-level packages/3-targets/ is reserved for target extension packs (dialect, adapter, driver)

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
🧠 Learnings (1)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.

Applied to files:

  • test/integration/test/codecs.test.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
🧬 Code graph analysis (1)
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (1)
packages/1-framework/1-core/migration/control-plane/src/types.ts (9)
  • MigrationPlanOperation (17-17)
  • MigrationPlan (11-11)
  • MigrationPlannerConflict (13-13)
  • MigrationPlannerSuccessResult (16-16)
  • MigrationPlannerFailureResult (14-14)
  • MigrationRunnerFailure (19-19)
  • MigrationRunnerSuccessValue (21-21)
  • ControlTargetDescriptor (171-191)
  • ControlTargetInstance (45-51)
🔇 Additional comments (3)
test/integration/test/codecs.test.ts (1)

90-90: LGTM! Appropriate timeout configuration for database operations.

The addition of timeouts.databaseOperation to the beforeEach and afterEach hooks is correct and follows the coding guidelines. These hooks perform database setup and teardown operations that can benefit from extended timeouts, aligning with the broader standardization effort across the test suite.

Also applies to: 94-94

packages/2-sql/3-tooling/family/src/core/migrations/types.ts (2)

276-295: LGTM!

The SqlControlTargetDescriptor correctly extends the core ControlTargetDescriptor while adding strongly-typed createPlanner and createRunner methods for SQL-specific usage. The JSDoc comments clearly document the purpose of these direct access methods alongside the inherited migrations capability.


1-24: Well-structured SQL migration types module.

The file establishes a clean SQL-specific type surface that properly extends the core migration types. The organization with section headers, consistent use of readonly, appropriate generic defaults (Record<string, never>), and proper extension patterns (using extends and Omit) follows TypeScript best practices.

- Remove re-exports from migrations/types.ts
- Update policies.ts to import MigrationOperationPolicy from core
- Update control.ts to re-export core types from canonical source
- Update test file to remove redundant type compatibility test
@wmadden

wmadden commented Dec 30, 2025

Copy link
Copy Markdown
Contributor Author

Merging without review. All checks pass, CodeRabbit is satisfied. Changes continue to add to the new migration system and shouldn't affect ongoing work in the rest of the repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant