Skip to content

Commit 409a6b9

Browse files
committed
test(integration,examples): migrate to M2.5 aggregate executeDbInit (M4)
executePerSpaceDbApply was retired in M2.5 in favour of the aggregate-pipeline CLI surface (executeDbInit / executeDbUpdate / executeDbVerify). Two e2e integration suites still imported the old symbol after the cascade rebase: extension-pgvector-scenario-a (test/integration) and multi-space.e2e (examples/multi-extension-monorepo). Migrate both to executeDbInit: * drop the per-space {extensionContractSpaces:[{id}], policy, action} options; * pass the actual extension descriptors via extensionPacks; the loader resolves their declared spaces from the descriptor surface, so the test no longer enumerates space ids manually; * add the required targetId option (M2.5 aggregate pipeline pins the target rather than inferring from the migrations registry); * drop the now-unused INIT_ADDITIVE_POLICY import in pgvector (db init's policy is fixed by executeDbInit internally); * refresh docblocks that named the old symbol. Mirrors the same migration applied to packages/3-extensions/cipherstash/test/scenario-a.e2e.integration.test.ts on M3.
1 parent 8e08414 commit 409a6b9

2 files changed

Lines changed: 22 additions & 28 deletions

File tree

examples/multi-extension-monorepo/test/multi-space.e2e.integration.test.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Multi-extension monorepo end-to-end against PGlite — project:
33
* extension-contract-spaces, M4 / T4.4 / TC-8 / spec AC4.
44
*
5-
* Drives the CLI per-space `db init` flow (`executePerSpaceDbApply`)
5+
* Drives the CLI aggregate `db init` flow (`executeDbInit`)
66
* against a real Postgres (PGlite via `createDevDatabase`) with **two**
77
* internal extension packages (`audit`, `feature-flags`) plus the
88
* application's own contract. Mirrors the cipherstash + pgvector
@@ -22,7 +22,7 @@
2222
* on-disk shape level.
2323
*
2424
* 2. **Multi-space planning across three spaces.** Calling
25-
* `executePerSpaceDbApply` with `mode: 'plan'` produces a plan
25+
* `executeDbInit` with `mode: 'plan'` produces a plan
2626
* whose ops are ordered alphabetically by space id (extensions
2727
* first, app last) per `concatenateSpaceApplyInputs`. The audit
2828
* `CREATE TABLE audit_event` op precedes the feature-flags
@@ -54,9 +54,9 @@ import { mkdir, mkdtemp, readFile, rm } from 'node:fs/promises';
5454
import { tmpdir } from 'node:os';
5555
import { join } from 'node:path';
5656
import postgresAdapterDescriptor from '@prisma-next/adapter-postgres/control';
57-
import { executePerSpaceDbApply } from '@prisma-next/cli/control-api';
57+
import { executeDbInit } from '@prisma-next/cli/control-api';
5858
import postgresDriverDescriptor from '@prisma-next/driver-postgres/control';
59-
import sqlFamilyDescriptor, { INIT_ADDITIVE_POLICY } from '@prisma-next/family-sql/control';
59+
import sqlFamilyDescriptor from '@prisma-next/family-sql/control';
6060
import { createControlStack } from '@prisma-next/framework-components/control';
6161
import { materialiseMigrationPackage } from '@prisma-next/migration-tools/io';
6262
import { emitContractSpaceArtefacts } from '@prisma-next/migration-tools/spaces';
@@ -223,17 +223,16 @@ describe.sequential(
223223
it('mode=plan produces a multi-space plan ordered alphabetically (extensions first, app last)', async () => {
224224
project = await setupTestProject();
225225

226-
const result = await executePerSpaceDbApply({
226+
const result = await executeDbInit({
227227
driver: driver!,
228228
familyInstance: buildFamilyInstance('natural'),
229229
contract: appContract,
230230
mode: 'plan',
231231
migrations: postgresTargetDescriptor.migrations,
232232
frameworkComponents: [...frameworkComponents],
233233
migrationsDir: project.migrationsDir,
234-
extensionContractSpaces: [{ id: AUDIT_SPACE_ID }, { id: FEATURE_FLAGS_SPACE_ID }],
235-
policy: INIT_ADDITIVE_POLICY,
236-
action: 'dbInit',
234+
targetId: 'postgres',
235+
extensionPacks: [auditExtensionDescriptor, featureFlagsExtensionDescriptor],
237236
});
238237

239238
if (!result.ok) {
@@ -259,17 +258,16 @@ describe.sequential(
259258
it('mode=apply: three spaces apply atomically; markers + round-trips OK (TC-8 / AC5)', async () => {
260259
project = await setupTestProject();
261260

262-
const result = await executePerSpaceDbApply({
261+
const result = await executeDbInit({
263262
driver: driver!,
264263
familyInstance: buildFamilyInstance('natural'),
265264
contract: appContract,
266265
mode: 'apply',
267266
migrations: postgresTargetDescriptor.migrations,
268267
frameworkComponents: [...frameworkComponents],
269268
migrationsDir: project.migrationsDir,
270-
extensionContractSpaces: [{ id: AUDIT_SPACE_ID }, { id: FEATURE_FLAGS_SPACE_ID }],
271-
policy: INIT_ADDITIVE_POLICY,
272-
action: 'dbInit',
269+
targetId: 'postgres',
270+
extensionPacks: [auditExtensionDescriptor, featureFlagsExtensionDescriptor],
273271
});
274272

275273
if (!result.ok) {
@@ -349,17 +347,16 @@ describe.sequential(
349347
it('marker hashes are independent of `extensionPacks` declaration order (NFR6)', async () => {
350348
project = await setupTestProject();
351349

352-
const result = await executePerSpaceDbApply({
350+
const result = await executeDbInit({
353351
driver: driver!,
354352
familyInstance: buildFamilyInstance('reverse'),
355353
contract: appContract,
356354
mode: 'apply',
357355
migrations: postgresTargetDescriptor.migrations,
358356
frameworkComponents: [...frameworkComponents],
359357
migrationsDir: project.migrationsDir,
360-
extensionContractSpaces: [{ id: FEATURE_FLAGS_SPACE_ID }, { id: AUDIT_SPACE_ID }],
361-
policy: INIT_ADDITIVE_POLICY,
362-
action: 'dbInit',
358+
targetId: 'postgres',
359+
extensionPacks: [featureFlagsExtensionDescriptor, auditExtensionDescriptor],
363360
});
364361

365362
if (!result.ok) {

test/integration/test/extension-pgvector-scenario-a.e2e.integration.test.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* inlined here with comments tying them to their source-of-truth
2323
* locations.
2424
*
25-
* Drives the CLI per-space `db init` flow (`executePerSpaceDbApply`,
25+
* Drives the CLI aggregate `db init` flow (`executeDbInit`,
2626
* sub-spec § 6) against a real Postgres (PGlite via
2727
* `createDevDatabase`) with pgvector wired as an extension space and a
2828
* user `Doc` table that carries a `vector(N)` column. Three layers of
@@ -34,7 +34,7 @@
3434
* `installVectorExtension.execute[0].sql` and is serialised
3535
* byte-for-byte.
3636
*
37-
* 2. **Multi-space planning (real DDL).** `executePerSpaceDbApply`
37+
* 2. **Multi-space planning (real DDL).** `executeDbInit`
3838
* with `mode: 'plan'` against the real descriptor produces a plan
3939
* that includes the pgvector baseline op AND the app-space
4040
* `CREATE TABLE Doc` op, ordered first per
@@ -52,12 +52,11 @@ import { mkdir, mkdtemp, readFile, rm } from 'node:fs/promises';
5252
import { tmpdir } from 'node:os';
5353
import { join } from 'node:path';
5454
import postgresAdapterDescriptor from '@prisma-next/adapter-postgres/control';
55-
import { executePerSpaceDbApply } from '@prisma-next/cli/control-api';
55+
import { executeDbInit } from '@prisma-next/cli/control-api';
5656
import { type Contract, coreHash, profileHash } from '@prisma-next/contract/types';
5757
import postgresDriverDescriptor from '@prisma-next/driver-postgres/control';
5858
import pgvectorExtensionDescriptor from '@prisma-next/extension-pgvector/control';
5959
import sqlFamilyDescriptor, {
60-
INIT_ADDITIVE_POLICY,
6160
type SqlMigrationPlanOperation,
6261
} from '@prisma-next/family-sql/control';
6362
import {
@@ -322,17 +321,16 @@ describe.sequential(
322321
it('mode=plan against the real install op produces a multi-space plan', async () => {
323322
project = await setupTestProject({ migration: pgvectorBaselineMigration });
324323

325-
const result = await executePerSpaceDbApply({
324+
const result = await executeDbInit({
326325
driver: driver!,
327326
familyInstance,
328327
contract: buildAppContract({ withLength: true }),
329328
mode: 'plan',
330329
migrations: postgresTargetDescriptor.migrations,
331330
frameworkComponents: [...frameworkComponents],
332331
migrationsDir: project.migrationsDir,
333-
extensionContractSpaces: [{ id: PGVECTOR_SPACE_ID }],
334-
policy: INIT_ADDITIVE_POLICY,
335-
action: 'dbInit',
332+
targetId: 'postgres',
333+
extensionPacks: [pgvectorExtensionDescriptor],
336334
});
337335

338336
if (!result.ok) {
@@ -356,17 +354,16 @@ describe.sequential(
356354
it('synthetic vector stub: applies pgvector + app-space atomically; markers + round-trip OK', async () => {
357355
project = await setupTestProject({ migration: buildSyntheticBaselineMigration() });
358356

359-
const result = await executePerSpaceDbApply({
357+
const result = await executeDbInit({
360358
driver: driver!,
361359
familyInstance,
362360
contract: buildAppContract({ withLength: false }),
363361
mode: 'apply',
364362
migrations: postgresTargetDescriptor.migrations,
365363
frameworkComponents: [...frameworkComponents],
366364
migrationsDir: project.migrationsDir,
367-
extensionContractSpaces: [{ id: PGVECTOR_SPACE_ID }],
368-
policy: INIT_ADDITIVE_POLICY,
369-
action: 'dbInit',
365+
targetId: 'postgres',
366+
extensionPacks: [pgvectorExtensionDescriptor],
370367
});
371368

372369
if (!result.ok) {

0 commit comments

Comments
 (0)