Repository navigation
TML-1756: Extract core migration base types for CLI - #55
Conversation
- 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
WalkthroughAdds 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
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
📜 Recent review detailsConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Lite 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (21)**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
Files:
packages/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/import-validation.mdc)
Files:
**/*.ts📄 CodeRabbit inference engine (.cursor/rules/modular-refactoring-patterns.mdc)
Files:
**/src/core/**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Files:
**/src/{core,exports}/**/*.ts📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Files:
**/src/core/**/*.ts📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Files:
packages/**/src/**/*.ts📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Files:
**/*.{test,spec,ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/README.md)
Files:
**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/README.md)
Files:
{src,packages}/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/README.md)
Files:
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)
Files:
**/+(src|lib)/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)
Files:
packages/{2-sql,3-targets}/**/*.{ts,tsx,json,js}📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/**/test/**/*.{ts,test.ts}📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Files:
**/*.test-d.ts📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)
Files:
**/src/exports/control.ts📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Files:
**/src/exports/**/*.ts📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Files:
packages/**/src/exports/*.ts📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Files:
**/control.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
Files:
**/exports/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)
Files:
🧠 Learnings (1)📚 Learning: 2025-12-26T23:02:40.679ZApplied to files:
🧬 Code graph analysis (1)packages/2-sql/3-tooling/family/test/migrations.types.test-d.ts (1)
🔇 Additional comments (8)
Comment |
There was a problem hiding this comment.
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 usingtimeouts.databaseOperationfor consistency.The
beforeEachhook performs database operations (dropping and creating tables) but usestimeouts.spinUpPpgDev. For consistency with other test files in this PR (budgets.test.tsandcomparison-operators.test.ts), consider usingtimeouts.databaseOperationinstead. ThespinUpPpgDevtimeout should typically be reserved forbeforeAllhooks 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
📒 Files selected for processing (16)
packages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/test/migrations.types.test-d.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/3-targets/3-targets/postgres/src/core/migrations/runner.tspackages/3-targets/3-targets/postgres/src/exports/control.tstest/integration/test/budgets.test.tstest/integration/test/codecs.test.tstest/integration/test/comparison-operators.test.tstest/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
Usetype({ '[string]': Schema })syntax to createRecord<string, Schema>types in Arktype instead of usingRecord<string, Schema>string notation
Use the.array()method on Arktype schemas to create array types instead of wrapping schemas intype([Schema])or using manual validation
Extract TypeScript types from Arktype schemas using the.inferproperty instead of manually duplicating type definitions
Usetype.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
Useinstanceof type.errorsto 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 typesPrefer explicit, direct imports over barrel imports: import from specific module paths like
@prisma/sql/builderinstead of barrel re-exports like@prisma/sqlAlways use
Object.hasOwn()instead ofhasOwnProperty()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}: ExtractCodecTypesfrom contract using the he...
Files:
test/integration/test/budgets.test.tstest/utils/src/timeouts.tstest/integration/test/comparison-operators.test.tspackages/2-sql/3-tooling/family/test/migrations.types.test-d.tstest/integration/test/codecs.test.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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 usingwithDevDatabase()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 ofwithDevDatabase()viawithClient()andprocess.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')notit('should return correct value'))
Prefer object comparison withtoEqualortoMatchObjectinstead 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.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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
Replaceanytypes with proper generic type parameters during function extraction, using existing type definitions likeModelColumnAccessor
Use thecompacthelper function to removeundefinedvalues from objects when TypeScript'sexactOptionalPropertyTypesis 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.tstest/utils/src/timeouts.tstest/integration/test/comparison-operators.test.tspackages/2-sql/3-tooling/family/test/migrations.types.test-d.tstest/integration/test/codecs.test.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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 individualexpect().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 usingtoEqualortoMatchObjectinstead of piece-by-piece property checks withtoHavePropertyor individual type assertions
Useexpect.any()for type-only checks andexpect.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 correctUse factory functions (such as
createColumnRef,createParamRef,createLiteralExpr,createTableRef,createBinaryExpr) for creating AST nodes in tests instead of manual object creationUse factory functions (e.g.,
createContractIR()) instead of manual object creation when creatingContractIRobjects 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 deprecatedtoMatchTypeOf()matcher in Vitest'sexpectTypeOfAPI; usetoExtend()instead for verifying ...
Files:
test/integration/test/budgets.test.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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 theexports/folders
**/*.{ts,tsx,js,jsx}: ImportloadContractFromTsandcreateContractEmitCommandfrom the main package export@prisma-next/cli, not from subpaths
Import config utilities (defineConfigand config types) from the@prisma-next/cli/config-typessubpath, not from the main package
ImportloadExtensionPacksandloadExtensionPackManifestfrom the@prisma-next/cli/pack-loadingsubpath, 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 theloadConfigfunction from the@prisma-next/cli/config-loadersubpath, not from the main packageUpdate 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.tstest/utils/src/timeouts.tstest/integration/test/comparison-operators.test.tspackages/2-sql/3-tooling/family/test/migrations.types.test-d.tstest/integration/test/codecs.test.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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 testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
test/integration/test/budgets.test.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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.mdcKeep tests concise; omit 'should' from test descriptions
Files:
test/integration/test/budgets.test.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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 Vitestexpect().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.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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.tstest/utils/src/timeouts.tstest/integration/test/comparison-operators.test.tspackages/2-sql/3-tooling/family/test/migrations.types.test-d.tstest/integration/test/codecs.test.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.tstest/utils/src/timeouts.tstest/integration/test/comparison-operators.test.tspackages/2-sql/3-tooling/family/test/migrations.types.test-d.tstest/integration/test/codecs.test.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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 usingvalidateContractfunction; 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.tstest/integration/test/comparison-operators.test.tstest/integration/test/codecs.test.tspackages/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.tstest/utils/src/timeouts.tstest/integration/test/comparison-operators.test.tspackages/2-sql/3-tooling/family/test/migrations.types.test-d.tstest/integration/test/codecs.test.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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, useinferfor 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.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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-lanecan import fromsql-relational-coreif both are in thelaneslayer)
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.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.tspackages/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.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/3-targets/3-targets/postgres/src/core/migrations/runner.ts
**/*.test-d.ts
📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)
Use
expectTypeOffrom 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.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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 andsrc/exports/for entry points
Files:
packages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/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.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/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.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/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.tsto 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 usesControlDriverInstanceinternally.
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(notcli.ts) and located atsrc/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 conventioncontrol.ts(notcli.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.tspackages/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-*/controlexportsControlFamilyDescriptor,@prisma-next/target-*/controlexportsControlTargetDescriptor,@prisma-next/adapter-*/controlexportsControlAdapterDescriptor,@prisma-next/driver-*/controlexportsControlDriverDescriptor, and@prisma-next/extensions-*/controlexportsControlExtensionDescriptor.
Files:
packages/3-targets/3-targets/postgres/src/exports/control.tspackages/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.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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 insrc/core/**directory with no migration/runtime plane imports; depend only on shared-plane packages
Do not add plane-crossing imports insidesrc/core/**directory
Files:
packages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.tstest/utils/src/timeouts.tstest/integration/test/comparison-operators.test.tspackages/2-sql/3-tooling/family/test/migrations.types.test-d.tstest/integration/test/codecs.test.tspackages/1-framework/1-core/migration/control-plane/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/types.tspackages/2-sql/3-tooling/family/test/migrations.types.test.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/1-framework/1-core/migration/control-plane/src/migrations.tspackages/2-sql/3-tooling/family/src/exports/control.tspackages/2-sql/3-tooling/family/src/core/migrations/types.tspackages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/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.databaseOperationfor 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.tsand ensures consistent timeout handling across integration tests.Also applies to: 61-61
test/utils/src/timeouts.ts (1)
4-4: LGTM!The new
databaseOperationtimeout 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 SqlPlannerConflictconstraintThese 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 deprecatedtoMatchTypeOf()) 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
migrationsproperty correctly implementsTargetMigrationsCapability, exposingcreatePlannerandcreateRunnerfor 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
createPlannerandcreateRunnermethods are correctly marked as deprecated with clear guidance to usemigrations.createPlanner()andmigrations.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
TFamilyInstancegeneric parameter with its constraint and default value maintains backward compatibility while enabling typed migrations capability. The optionalmigrationsproperty 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
migrationsproperty 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
migrationscapability 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, andrunnerResult: MigrationRunnerResultmake 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
createPostgresMigrationPlannerreturn type andPostgresMigrationPlannerclass implementation correctly useSqlMigrationPlanner<PostgresPlanTargetDetails>andSqlMigrationPlannerPlanOptions, 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. Thereadonlymodifier 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
./typesmodule. The organization follows the coding guidelines with type imports grouped together.
27-42: LGTM!Type signatures correctly updated to use
SqlMigrationPlanOperationStep,SqlMigrationPlanOperationTarget, andSqlMigrationPlanOperationtypes. 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
CreateSqlMigrationPlanOptionsand returnSqlMigrationPlan. 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, andSqlMigrationRunnerFailure. The Result wrapper pattern withok/notOkis 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
AnyRecordtype alias is appropriately defined as a readonly record.
46-107: LGTM!SQL plan types are well-designed:
SqlMigrationPlanOperationStepadds SQL-specificsqlfieldSqlMigrationPlanOperationTargetprovides target identification with generic detailsSqlMigrationPlanOperationproperly extendsMigrationPlanOperationwith precheck/execute/postcheck stepsSqlMigrationPlanextendsMigrationPlanwith 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:
SqlPlannerConflictKinddefines SQL-specific conflict categoriesSqlPlannerConflictLocationadds location context (table, column, index, etc.)SqlPlannerConflictproperly extendsMigrationPlannerConflictwith SQL-specific fields- Result types use
Omitto override plan/conflicts with SQL-specific variantsSqlMigrationPlannerinterface with typedplanmethod
189-265: LGTM!SQL runner types are well-structured:
- Callbacks and options interfaces properly typed with generics
SqlMigrationRunnerErrorCodeprovides SQL-specific error codesSqlMigrationRunnerFailureextends core with specific code typeSqlMigrationRunnerinterface matches the expected contract
267-309: LGTM!
SqlControlTargetDescriptorproperly extends the coreControlTargetDescriptorand adds SQL-specificcreatePlannerandcreateRunnermethods that return SQL-typed interfaces.CreateSqlMigrationPlanOptionsprovides 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
executemethod is well-structured with proper error handling and transaction management. The type signature correctly usesSqlMigrationRunnerExecuteOptionsandSqlMigrationRunnerResult. The flow is:
- Static checks (destination, policy)
- Transaction with advisory lock
- Marker validation
- Plan application or skip if already at destination
- Schema verification
- Marker and ledger updates
- Commit with proper rollback on failure
169-219: LGTM!The
applyPlanmethod 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
runExpectationStepsandrunExecuteStepsmethods correctly use SQL-specific types and handle errors appropriately with specific error codes (PRECHECK_FAILED,POSTCHECK_FAILED,EXECUTION_FAILED).
324-356: LGTM!The
createPostcheckPreSatisfiedSkipRecordmethod correctly creates a skip record with frozen metadata. The type signature usesSqlMigrationPlanOperation<PostgresPlanTargetDetails>for both input and output.
374-458: LGTM!Policy and marker compatibility checks are thorough with proper error handling:
enforcePolicyCompatibilityvalidates operation classes against policyensureMarkerCompatibilityhandles all cases: no origin expected, origin expected but missing, hash mismatches- Error messages are descriptive with relevant metadata
460-493: LGTM!The
ensurePlanMatchesDestinationContractmethod correctly validates that the plan's destination hashes match the provided contract. BothcoreHashandprofileHashare 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) andexecuteStatementare properly implemented.
47-64: These are distinct functions with different purposes—not duplicates.The
cloneRecordfunction inplan-helpers.tsperforms a shallow clone with freeze (Object.freeze({ ...value })), whilecloneAndFreezeRecordinrunner.tsperforms 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!
MigrationOperationClassandMigrationOperationPolicyprovide 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:
MigrationPlanOperationcontains only display fields (id, label, operationClass)MigrationPlanprovides 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 withkind: stringto allow family-specific conflict kinds.
103-131: LGTM!Runner result types are clean:
MigrationRunnerSuccessValuetracks planned vs executed operationsMigrationRunnerFailureprovides error code, summary, and optional explanation- Result type uses the
Resultutility from@prisma-next/utils/result
132-163: Usingunknownfor contract/schema types is intentional but consider documentation.The
MigrationPlanner.plan()andMigrationRunner.execute()interfaces useunknownfor 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:
- Family-specific types (e.g.,
SqlMigrationPlanner) override with concrete types- 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!
TargetMigrationsCapabilityprovides 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
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
packages/2-sql/3-tooling/family/src/core/migrations/types.tstest/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
Usetype({ '[string]': Schema })syntax to createRecord<string, Schema>types in Arktype instead of usingRecord<string, Schema>string notation
Use the.array()method on Arktype schemas to create array types instead of wrapping schemas intype([Schema])or using manual validation
Extract TypeScript types from Arktype schemas using the.inferproperty instead of manually duplicating type definitions
Usetype.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
Useinstanceof type.errorsto 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 typesPrefer explicit, direct imports over barrel imports: import from specific module paths like
@prisma/sql/builderinstead of barrel re-exports like@prisma/sqlAlways use
Object.hasOwn()instead ofhasOwnProperty()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}: ExtractCodecTypesfrom contract using the he...
Files:
test/integration/test/codecs.test.tspackages/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 usingwithDevDatabase()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 ofwithDevDatabase()viawithClient()andprocess.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')notit('should return correct value'))
Prefer object comparison withtoEqualortoMatchObjectinstead 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
Replaceanytypes with proper generic type parameters during function extraction, using existing type definitions likeModelColumnAccessor
Use thecompacthelper function to removeundefinedvalues from objects when TypeScript'sexactOptionalPropertyTypesis 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.tspackages/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 individualexpect().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 usingtoEqualortoMatchObjectinstead of piece-by-piece property checks withtoHavePropertyor individual type assertions
Useexpect.any()for type-only checks andexpect.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 correctUse factory functions (such as
createColumnRef,createParamRef,createLiteralExpr,createTableRef,createBinaryExpr) for creating AST nodes in tests instead of manual object creationUse factory functions (e.g.,
createContractIR()) instead of manual object creation when creatingContractIRobjects 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 deprecatedtoMatchTypeOf()matcher in Vitest'sexpectTypeOfAPI; usetoExtend()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 theexports/folders
**/*.{ts,tsx,js,jsx}: ImportloadContractFromTsandcreateContractEmitCommandfrom the main package export@prisma-next/cli, not from subpaths
Import config utilities (defineConfigand config types) from the@prisma-next/cli/config-typessubpath, not from the main package
ImportloadExtensionPacksandloadExtensionPackManifestfrom the@prisma-next/cli/pack-loadingsubpath, 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 theloadConfigfunction from the@prisma-next/cli/config-loadersubpath, not from the main packageUpdate 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.tspackages/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 testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor 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.mdcKeep 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 Vitestexpect().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.tspackages/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.tspackages/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 usingvalidateContractfunction; 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.tspackages/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-lanecan import fromsql-relational-coreif both are in thelaneslayer)
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 insrc/core/**directory with no migration/runtime plane imports; depend only on shared-plane packages
Do not add plane-crossing imports insidesrc/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 andsrc/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, useinferfor 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.tspackages/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.databaseOperationto thebeforeEachandafterEachhooks 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
SqlControlTargetDescriptorcorrectly extends the coreControlTargetDescriptorwhile adding strongly-typedcreatePlannerandcreateRunnermethods for SQL-specific usage. The JSDoc comments clearly document the purpose of these direct access methods alongside the inheritedmigrationscapability.
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 (usingextendsandOmit) 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
|
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. |
Summary by CodeRabbit
New Features
Improvements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.