import { t as MigrationMetadata$1 } from "../metadata-DtStFLKa.mjs"; import { ControlStack, MigrationPlan, MigrationPlanOperation } from "@prisma-next/framework-components/control"; //#region src/migration-base.d.ts interface MigrationMeta { readonly from: string | null; readonly to: string; } /** * Base class for migrations. * * A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the * runner can consume it directly via `targetId`, `operations`, `origin`, and * `destination`. The metadata-shaped inputs come from `describe()`, which * every migration must implement — `migration.json` is required for a * migration to be valid. */ declare abstract class Migration<_TOperation extends MigrationPlanOperation = MigrationPlanOperation, TFamilyId extends string = string, TTargetId extends string = string> implements MigrationPlan { abstract readonly targetId: string; /** * Assembled `ControlStack` injected by the orchestrator (`runMigration`). * * Subclasses (e.g. `PostgresMigration`) read the stack to materialize their * adapter once per instance. Optional at the abstract level so unit tests can * construct `Migration` instances purely for `operations` / `describe` * assertions without needing a real stack; concrete subclasses that need the * stack at runtime should narrow the parameter to required. */ protected readonly stack: ControlStack | undefined; constructor(stack?: ControlStack); /** * Ordered list of operations this migration performs. * * Implemented as a getter so that subclasses can either precompute the list * in their constructor or build it lazily per access. Entries may be Promises * when the target requires async codec resolution (e.g. DDL literal defaults). */ abstract get operations(): readonly (MigrationPlanOperation | Promise)[]; /** * Metadata inputs used to build `migration.json` and to derive the plan's * origin/destination identities. Every migration must provide this — * omitting it would produce an invalid on-disk migration package. */ abstract describe(): MigrationMeta; get origin(): { readonly storageHash: string; } | null; get destination(): { readonly storageHash: string; }; } /** * Returns true when `import.meta.url` resolves to the same file that was * invoked as the node entrypoint (`process.argv[1]`). Used by * `MigrationCLI.run` (in `@prisma-next/cli/migration-cli`) to no-op when * the migration module is being imported (e.g. by another script) rather * than executed directly. */ declare function isDirectEntrypoint(importMetaUrl: string): boolean; /** * In-memory artifacts produced from a `Migration` instance: the * serialized `ops.json` body, the `migration.json` metadata object, and * its serialized form. Returned by `buildMigrationArtifacts` so callers * (today: `MigrationCLI.run` in `@prisma-next/cli/migration-cli`) can * decide how to persist them — write to disk, print in dry-run, ship * over the wire — without coupling artifact construction to file I/O. * * `metadataJson` is `JSON.stringify(metadata, null, 2)` — the canonical * on-disk shape that the arktype loader-schema in `./io` validates. */ interface MigrationArtifacts { readonly opsJson: string; readonly metadata: MigrationMetadata$1; readonly metadataJson: string; } /** * Pure conversion from a `Migration` instance (plus the previously * scaffolded metadata, when one exists on disk) to the in-memory * artifacts that downstream tooling persists. Owns metadata validation, * metadata synthesis/preservation, and the content-addressed * `migrationHash` computation, but performs no file I/O — callers handle * reads (to source `existing`) and writes (to persist `opsJson` / * `metadataJson`). */ declare function buildMigrationArtifacts(instance: Migration, existing: Partial | null): Promise; //#endregion export { Migration, type MigrationArtifacts, type MigrationMeta, buildMigrationArtifacts, isDirectEntrypoint }; //# sourceMappingURL=migration.d.mts.map