@prisma-next/target-postgres 0.3.0-dev.34 → 0.3.0-dev.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/control.d.mts +16 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +2494 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-DxB8oZzB.mjs +13 -0
- package/dist/descriptor-meta-DxB8oZzB.mjs.map +1 -0
- package/dist/pack.d.mts +7 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +9 -0
- package/dist/pack.mjs.map +1 -0
- package/dist/runtime.d.mts +9 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +21 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +28 -28
- package/src/core/migrations/planner.ts +237 -22
- package/src/core/migrations/runner.ts +27 -20
- package/src/core/migrations/statement-builders.ts +6 -6
- package/src/core/types.ts +5 -0
- package/src/exports/control.ts +1 -3
- package/src/exports/runtime.ts +7 -12
- package/dist/chunk-RKEXRSSI.js +0 -14
- package/dist/chunk-RKEXRSSI.js.map +0 -1
- package/dist/core/descriptor-meta.d.ts +0 -9
- package/dist/core/descriptor-meta.d.ts.map +0 -1
- package/dist/core/migrations/planner.d.ts +0 -14
- package/dist/core/migrations/planner.d.ts.map +0 -1
- package/dist/core/migrations/runner.d.ts +0 -8
- package/dist/core/migrations/runner.d.ts.map +0 -1
- package/dist/core/migrations/statement-builders.d.ts +0 -30
- package/dist/core/migrations/statement-builders.d.ts.map +0 -1
- package/dist/exports/control.d.ts +0 -8
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -1260
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/pack.d.ts +0 -4
- package/dist/exports/pack.d.ts.map +0 -1
- package/dist/exports/pack.js +0 -11
- package/dist/exports/pack.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -12
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -19
- package/dist/exports/runtime.js.map +0 -1
package/README.md
CHANGED
|
@@ -19,7 +19,11 @@ Provides the Postgres target descriptor (`SqlControlTargetDescriptor`) for CLI c
|
|
|
19
19
|
- **Multi-Plane Support**: Provides both migration-plane (control) and runtime-plane entry points for the Postgres target
|
|
20
20
|
- **Planner Factory**: Implements `migrations.createPlanner()` to create Postgres-specific migration planners
|
|
21
21
|
- **Runner Factory**: Implements `migrations.createRunner()` to create Postgres-specific migration runners
|
|
22
|
+
- **Schema Verification Normalization**: Normalizes Postgres default expressions (for example, `nextval(...)`, `now()`) when verifying the post-apply schema
|
|
23
|
+
- **Postgres-Only Contract Extensions**: Defines Postgres-specific column defaults (e.g., sequences) used by the migration planner
|
|
24
|
+
- **Generated Defaults Policy**: Treats client-generated defaults as non-DB defaults when emitting DDL
|
|
22
25
|
- **Database Dependency Consumption**: The planner extracts database dependencies from the configured framework components (passed as `frameworkComponents`), verifies each dependency against the live schema, and only emits install operations when required. The runner reuses the same metadata for post-apply verification, so there are no hardcoded extension mappings—database dependencies stay component-owned.
|
|
26
|
+
- **Storage Type Planning**: The planner dispatches storage type hooks for `storage.types` and emits type operations before table creation when supported by the policy
|
|
23
27
|
|
|
24
28
|
This package spans multiple planes:
|
|
25
29
|
- **Migration plane** (`src/exports/control.ts`): Control plane entry point that exports `SqlControlTargetDescriptor` for config files
|
|
@@ -30,7 +34,7 @@ This package spans multiple planes:
|
|
|
30
34
|
|
|
31
35
|
This package provides the Postgres implementation of the SQL migration planner/runner used by `prisma-next db init`:
|
|
32
36
|
|
|
33
|
-
- **Planner** (`src/core/migrations/planner.ts`): produces an additive-only `MigrationPlan` to bring the database schema in line with a destination contract. Extra unrelated schema is tolerated; non-additive mismatches (type/nullability/constraint incompatibilities) surface as structured conflicts.
|
|
37
|
+
- **Planner** (`src/core/migrations/planner.ts`): produces an additive-only `MigrationPlan` to bring the database schema in line with a destination contract. Extra unrelated schema is tolerated; non-additive mismatches (type/nullability/constraint incompatibilities) surface as structured conflicts. Storage type operations (from codec-owned hooks) are emitted before table operations when `storage.types` are present. The planner respects the contract's `foreignKeys` configuration: when `foreignKeys.constraints` is `false`, FK constraint operations are skipped; when `foreignKeys.indexes` is `false`, FK-backing indexes are omitted. See [ADR 161](../../../docs/architecture%20docs/adrs/ADR%20161%20-%20Explicit%20foreign%20key%20constraint%20and%20index%20configuration.md).
|
|
34
38
|
- **Runner** (`src/core/migrations/runner.ts`): executes a plan under an advisory lock, verifies the post-state schema, then writes the contract marker and appends a ledger entry in the `prisma_contract` schema.
|
|
35
39
|
|
|
36
40
|
For the CLI orchestration, see `packages/1-framework/3-tooling/cli/src/commands/db-init.ts`.
|
|
@@ -149,6 +153,7 @@ This package ships a mix of fast planner unit tests and slower runner integratio
|
|
|
149
153
|
- **Default (`pnpm --filter @prisma-next/target-postgres test`)**: runs all tests including integration tests
|
|
150
154
|
- **Test files**:
|
|
151
155
|
- `test/migrations/planner.behavior.test.ts`: Planner unit tests (classification, conflicts, dependency ops)
|
|
156
|
+
- `test/migrations/planner.fk-config.test.ts`: Planner unit tests for FK constraint/index configuration combinations
|
|
152
157
|
- `test/migrations/planner.integration.test.ts`: Planner integration tests
|
|
153
158
|
- `test/migrations/runner.*.integration.test.ts`: Runner integration tests (basic, errors, idempotency, policy)
|
|
154
159
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SqlControlTargetDescriptor } from "@prisma-next/family-sql/control";
|
|
2
|
+
|
|
3
|
+
//#region src/core/migrations/planner.d.ts
|
|
4
|
+
type OperationClass = 'extension' | 'type' | 'table' | 'unique' | 'index' | 'foreignKey';
|
|
5
|
+
interface PostgresPlanTargetDetails {
|
|
6
|
+
readonly schema: string;
|
|
7
|
+
readonly objectType: OperationClass;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly table?: string;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/exports/control.d.ts
|
|
13
|
+
declare const postgresTargetDescriptor: SqlControlTargetDescriptor<'postgres', PostgresPlanTargetDetails>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { postgresTargetDescriptor as default };
|
|
16
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/migrations/planner.ts","../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;KAuCK,cAAA;UAuBY,yBAAA;EAvBZ,SAAA,MAAA,EAAc,MAAA;EAuBF,SAAA,UAAA,EAEM,cAFmB;;;;;;cChDpC,0BAA0B,uCAAuC"}
|