@prisma/migrate 6.6.0-dev.1 → 6.6.0-dev.100

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.
Files changed (169) hide show
  1. package/dist/CLI.js +3 -3
  2. package/dist/Migrate.js +9 -7
  3. package/dist/SchemaEngine.js +0 -28
  4. package/dist/{chunk-RM5LJIEV.js → SchemaEngineCLI.js} +10 -16
  5. package/dist/{utils/getSchemaPathAndPrint.js → SchemaEngineWasm.js} +8 -8
  6. package/dist/bin.js +52 -53
  7. package/dist/chunk-23DZXSTI.js +62 -0
  8. package/dist/{chunk-WWAWV7DQ.js → chunk-2ESYSVXG.js} +3 -27
  9. package/dist/{chunk-LKTTJWFT.js → chunk-2R6DII47.js} +5 -5
  10. package/dist/chunk-33LPBNDX.js +1399 -0
  11. package/dist/{chunk-MKK3GSDF.js → chunk-344G2PKM.js} +9 -9
  12. package/dist/{chunk-V3ZMNXZC.js → chunk-5LKIRKDL.js} +307 -382
  13. package/dist/{chunk-LOGAFLCN.js → chunk-5R44VVVX.js} +29 -29
  14. package/dist/{chunk-DJMFXNR4.js → chunk-74LUB4XX.js} +56 -57
  15. package/dist/{chunk-ZQ3OWSVS.js → chunk-A4FQW4A5.js} +54 -50
  16. package/dist/{chunk-RP2N6UXA.js → chunk-AI6DH66U.js} +6 -6
  17. package/dist/{chunk-A6PMXMMT.js → chunk-AUGZZ6RT.js} +105 -13
  18. package/dist/{chunk-G2XUUMKH.js → chunk-B4SUSDC2.js} +31 -39
  19. package/dist/{chunk-LZOZZRHB.js → chunk-CLSF7VUT.js} +42 -38
  20. package/dist/{chunk-Q7M5ANIE.js → chunk-CNCVJ2IN.js} +379 -534
  21. package/dist/{chunk-IR55GBON.js → chunk-CU5UT2ED.js} +19 -18
  22. package/dist/{chunk-TPJISPJ5.js → chunk-CYEVXXRH.js} +51 -47
  23. package/dist/{chunk-W2SZNLK4.js → chunk-EJG7GKM7.js} +37 -39
  24. package/dist/{chunk-5VDXAE53.js → chunk-EJUXYFV3.js} +26 -16
  25. package/dist/{chunk-X6KW7BYP.js → chunk-HIDSEBVV.js} +55 -54
  26. package/dist/{chunk-ZOEKRXDP.js → chunk-I3LT2PO3.js} +35 -57
  27. package/dist/{chunk-E7OXHCDR.js → chunk-IEEJZC3B.js} +56 -49
  28. package/dist/chunk-IINN7QUV.js +2565 -0
  29. package/dist/chunk-IK3BVD3Y.js +233 -0
  30. package/dist/{chunk-255BRND3.js → chunk-KRQEFTDT.js} +6 -6
  31. package/dist/{chunk-EX2UWGES.js → chunk-KW633S3Y.js} +56 -52
  32. package/dist/{chunk-VVKOFN3Y.js → chunk-LLO7YF56.js} +44 -46
  33. package/dist/{chunk-VZ23KD5C.js → chunk-NGQA5JTN.js} +8 -10
  34. package/dist/{chunk-MATFO4ZW.js → chunk-OEWQACEH.js} +38 -39
  35. package/dist/chunk-PQKZ53DW.js +76 -0
  36. package/dist/{chunk-EGPJABTW.js → chunk-QVMYNWAN.js} +257 -103
  37. package/dist/{chunk-X5N72JHI.js → chunk-SO3VXCZV.js} +93 -92
  38. package/dist/{chunk-V5TUSOJX.js → chunk-SQKGZVG3.js} +45 -45
  39. package/dist/chunk-URKH6SE2.js +479 -0
  40. package/dist/{chunk-DLLXDCI2.js → chunk-VAJ4VX67.js} +5 -6
  41. package/dist/{chunk-POKX77OK.js → chunk-W5SQWSLC.js} +380 -535
  42. package/dist/{chunk-A4BCLP6K.js → chunk-YBS5GSRF.js} +64 -69
  43. package/dist/{chunk-OCQGHQED.js → chunk-YBX7R3MT.js} +12 -12
  44. package/dist/chunk-YSWLN2IJ.js +890 -0
  45. package/dist/commands/DbCommand.js +3 -3
  46. package/dist/commands/DbDrop.js +4 -5
  47. package/dist/commands/DbExecute.js +10 -8
  48. package/dist/commands/DbPull.js +17 -16
  49. package/dist/commands/DbPush.js +12 -11
  50. package/dist/commands/DbSeed.js +4 -5
  51. package/dist/commands/MigrateCommand.js +3 -3
  52. package/dist/commands/MigrateDeploy.js +14 -13
  53. package/dist/commands/MigrateDev.js +17 -16
  54. package/dist/commands/MigrateDiff.js +13 -11
  55. package/dist/commands/MigrateReset.js +16 -15
  56. package/dist/commands/MigrateResolve.js +12 -11
  57. package/dist/commands/MigrateStatus.js +12 -11
  58. package/dist/index.js +58 -60
  59. package/dist/internals/src/Generator.d.ts +23 -5
  60. package/dist/internals/src/WasmSchemaEngineLoader.d.ts +5 -0
  61. package/dist/internals/src/cli/checkUnsupportedDataProxy.d.ts +12 -17
  62. package/dist/internals/src/cli/directoryConfig.d.ts +7 -0
  63. package/dist/internals/src/cli/getSchema.d.ts +3 -28
  64. package/dist/internals/src/cli/hashes.d.ts +1 -2
  65. package/dist/internals/src/cli/schemaContext.d.ts +59 -0
  66. package/dist/internals/src/client/getClientEngineType.d.ts +1 -1
  67. package/dist/internals/src/convertCredentials.d.ts +1 -1
  68. package/dist/internals/src/engine-commands/getConfig.d.ts +1 -5
  69. package/dist/internals/src/engine-commands/getDmmf.d.ts +3 -6
  70. package/dist/internals/src/engine-commands/lintSchema.d.ts +1 -1
  71. package/dist/internals/src/errorReporting.d.ts +0 -1
  72. package/dist/internals/src/get-generators/getGenerators.d.ts +22 -9
  73. package/dist/internals/src/get-generators/utils/binaryTypeToEngineType.d.ts +1 -1
  74. package/dist/internals/src/get-generators/utils/engineTypeToBinaryType.d.ts +1 -1
  75. package/dist/internals/src/get-generators/utils/fixBinaryTargets.d.ts +1 -1
  76. package/dist/internals/src/get-generators/utils/getBinaryPathsByVersion.d.ts +1 -1
  77. package/dist/internals/src/get-generators/utils/getEngineVersionForGenerator.d.ts +1 -1
  78. package/dist/internals/src/get-generators/utils/printGeneratorConfig.d.ts +1 -1
  79. package/dist/internals/src/index.d.ts +9 -8
  80. package/dist/internals/src/migrateTypes.d.ts +63 -0
  81. package/dist/internals/src/panic.d.ts +1 -4
  82. package/dist/internals/src/resolvePkg.d.ts +7 -0
  83. package/dist/internals/src/types.d.ts +1 -1
  84. package/dist/internals/src/utils/extractPreviewFeatures.d.ts +2 -2
  85. package/dist/internals/src/utils/getEnvPaths.d.ts +1 -1
  86. package/dist/internals/src/utils/parseEnvValue.d.ts +1 -1
  87. package/dist/internals/src/utils/schemaFileInput.d.ts +0 -4
  88. package/dist/internals/src/utils/toSchemasContainer.d.ts +2 -3
  89. package/dist/internals/src/wasm.d.ts +3 -1
  90. package/dist/migrate/src/Migrate.d.ts +18 -7
  91. package/dist/migrate/src/SchemaEngine.d.ts +20 -50
  92. package/dist/migrate/src/SchemaEngineCLI.d.ts +139 -0
  93. package/dist/migrate/src/SchemaEngineWasm.d.ts +134 -0
  94. package/dist/migrate/src/commands/DbExecute.d.ts +1 -1
  95. package/dist/migrate/src/commands/DbPull.d.ts +1 -1
  96. package/dist/migrate/src/commands/DbPush.d.ts +1 -1
  97. package/dist/migrate/src/commands/MigrateDeploy.d.ts +1 -1
  98. package/dist/migrate/src/commands/MigrateDev.d.ts +1 -1
  99. package/dist/migrate/src/commands/MigrateDiff.d.ts +1 -1
  100. package/dist/migrate/src/commands/MigrateReset.d.ts +1 -1
  101. package/dist/migrate/src/commands/MigrateResolve.d.ts +1 -1
  102. package/dist/migrate/src/commands/MigrateStatus.d.ts +1 -1
  103. package/dist/migrate/src/index.d.ts +2 -2
  104. package/dist/migrate/src/types.d.ts +19 -19
  105. package/dist/migrate/src/utils/createMigration.d.ts +21 -0
  106. package/dist/migrate/src/utils/ensureDatabaseExists.d.ts +4 -6
  107. package/dist/migrate/src/utils/introspectSql.d.ts +3 -2
  108. package/dist/migrate/src/utils/listMigrations.d.ts +9 -0
  109. package/dist/migrate/src/utils/printDatasources.d.ts +1 -1
  110. package/dist/migrate/src/utils/seed.d.ts +0 -2
  111. package/dist/migrate/src/views/handleViewsIO.d.ts +2 -2
  112. package/dist/{multipart-parser-54WEFGGN-NLZG56KM.js → multipart-parser-ASKQAOL4-WZ47HU6G.js} +92 -125
  113. package/dist/{multipart-parser-NDLECNMN.js → multipart-parser-QCI3Y5IB.js} +66 -68
  114. package/dist/types.js +1 -1
  115. package/dist/{typescript-WN4QH2CP.js → typescript-2LKASCMC.js} +33 -33
  116. package/dist/{typescript-AILDXN3I.js → typescript-H3AVJ6KX.js} +32 -32
  117. package/dist/utils/byline.js +1 -1
  118. package/dist/utils/captureStdout.js +3 -3
  119. package/dist/utils/countModelsAndTypes.js +1 -1
  120. package/dist/utils/createMigration.js +27 -0
  121. package/dist/utils/customColors.js +1 -1
  122. package/dist/utils/ensureDatabaseExists.js +7 -7
  123. package/dist/utils/errors.js +1 -1
  124. package/dist/utils/flagErrors.js +1 -1
  125. package/dist/utils/getDatabaseVersionSafe.js +10 -5
  126. package/dist/utils/handleEvaluateDataloss.js +1 -1
  127. package/dist/utils/introspectSql.js +10 -5
  128. package/dist/utils/isSchemaEmpty.js +1 -1
  129. package/dist/utils/listMigrations.js +25 -0
  130. package/dist/utils/now.js +1 -1
  131. package/dist/utils/printDatasource.js +1 -1
  132. package/dist/utils/printDatasources.js +5 -5
  133. package/dist/utils/printFiles.js +5 -5
  134. package/dist/utils/printIntrospectedSchema.js +1 -1
  135. package/dist/utils/printMigrationId.js +1 -1
  136. package/dist/utils/promptForMigrationName.js +3 -3
  137. package/dist/utils/removeSchemaFiles.js +1 -1
  138. package/dist/utils/replaceOrAddDatasource.js +1 -1
  139. package/dist/utils/replaceOrAddDatasource.test.js +1 -1
  140. package/dist/utils/saveSchemaFiles.js +1 -1
  141. package/dist/utils/seed.js +4 -7
  142. package/dist/utils/setupCockroach.js +3 -3
  143. package/dist/utils/setupMSSQL.js +1583 -710
  144. package/dist/utils/setupMongo.js +6563 -5984
  145. package/dist/utils/setupMysql.js +508 -563
  146. package/dist/utils/setupPostgres.js +3 -3
  147. package/dist/utils/spinner.js +4 -7
  148. package/dist/utils/test-handlePanic.js +1 -30
  149. package/dist/utils/unixSocket.js +1 -1
  150. package/dist/views/handleViewsIO.js +3 -3
  151. package/package.json +15 -14
  152. package/dist/chunk-6C7ESGWY.js +0 -1184
  153. package/dist/chunk-DIAO4W7O.js +0 -5774
  154. package/dist/chunk-GKDFIHM2.js +0 -45
  155. package/dist/chunk-J46BJQHT.js +0 -268
  156. package/dist/chunk-KXMACMQC.js +0 -660
  157. package/dist/chunk-YUCPBDWV.js +0 -131
  158. package/dist/chunk-YYPMC5FN.js +0 -1407
  159. package/dist/internals/src/get-generators/generatorResolvers/generatorResolvers.d.ts +0 -15
  160. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.d.ts +0 -6
  161. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.d.ts +0 -9
  162. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.d.ts +0 -8
  163. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.d.ts +0 -6
  164. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.d.ts +0 -1
  165. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.d.ts +0 -20
  166. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.d.ts +0 -7
  167. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.d.ts +0 -20
  168. package/dist/internals/src/get-generators/utils/check-feature-flags/checkFeatureFlags.d.ts +0 -8
  169. package/dist/migrate/src/utils/getSchemaPathAndPrint.d.ts +0 -10
@@ -1,49 +1,27 @@
1
1
  import { type MigrateTypes } from '@prisma/internals';
2
2
  import type { EngineArgs, EngineResults } from './types';
3
- export interface SchemaEngineOptions {
4
- schemaPath?: string;
5
- debug?: boolean;
6
- enabledPreviewFeatures?: string[];
7
- }
8
- export declare class EngineError extends Error {
9
- code: number;
10
- constructor(message: string, code: number);
11
- }
12
- export declare class SchemaEngine {
13
- private debug;
14
- private child?;
15
- private schemaPath?;
16
- private listeners;
17
- /** _All_ the logs from the engine process. */
18
- private messages;
19
- private lastRequest?;
20
- /** The fields of the last engine log event with an `ERROR` level. */
21
- private lastError;
22
- private initPromise?;
23
- private enabledPreviewFeatures?;
24
- private latestSchema?;
3
+ export interface SchemaEngine {
25
4
  isRunning: boolean;
26
- constructor({ debug, schemaPath, enabledPreviewFeatures }: SchemaEngineOptions);
27
5
  /**
28
6
  * Apply the migrations from the migrations directory to the database.
29
7
  * This is the command behind prisma migrate deploy.
30
8
  */
31
- applyMigrations(args: EngineArgs.ApplyMigrationsInput): Promise<EngineResults.ApplyMigrationsOutput>;
9
+ applyMigrations(input: EngineArgs.ApplyMigrationsInput): Promise<EngineResults.ApplyMigrationsOutput>;
32
10
  /**
33
11
  * Create the logical database from the Prisma schema.
34
12
  */
35
- createDatabase(args: EngineArgs.CreateDatabaseInput): Promise<EngineResults.CreateDatabaseOutput>;
13
+ createDatabase?(input: EngineArgs.CreateDatabaseInput): Promise<EngineResults.CreateDatabaseOutput>;
36
14
  /**
37
15
  * Create the next migration in the migrations history.
38
16
  * If draft is false and there are no unexecutable steps, it will also apply the newly created migration.
39
17
  * Note: This will use the shadow database on the connectors where we need one.
40
18
  */
41
- createMigration(args: EngineArgs.CreateMigrationInput): Promise<EngineResults.CreateMigrationOutput>;
19
+ createMigration(input: EngineArgs.CreateMigrationInput): Promise<EngineResults.CreateMigrationOutput>;
42
20
  /**
43
21
  * Execute a database script directly on the specified live database.
44
22
  * Note that this may not be defined on all connectors.
45
23
  */
46
- dbExecute(args: EngineArgs.DbExecuteInput): Promise<EngineResults.DbExecuteOutput>;
24
+ dbExecute(input: EngineArgs.DbExecuteInput): Promise<EngineResults.DbExecuteOutput>;
47
25
  /**
48
26
  * Make the Schema engine panic. Only useful to test client error handling.
49
27
  */
@@ -55,23 +33,22 @@ export declare class SchemaEngine {
55
33
  * Its role is to interpret the diagnostic output,
56
34
  * and translate it to a concrete action to be performed by the CLI.
57
35
  */
58
- devDiagnostic(args: EngineArgs.DevDiagnosticInput): Promise<EngineResults.DevDiagnosticOutput>;
36
+ devDiagnostic(input: EngineArgs.DevDiagnosticInput): Promise<EngineResults.DevDiagnosticOutput>;
59
37
  /**
60
38
  * Read the contents of the migrations directory and the migrations table, and returns their relative statuses.
61
39
  * At this stage, the Schema engine only reads,
62
40
  * it does not write to the database nor the migrations directory, nor does it use a shadow database.
63
41
  */
64
- diagnoseMigrationHistory(args: EngineArgs.DiagnoseMigrationHistoryInput): Promise<EngineResults.DiagnoseMigrationHistoryOutput>;
42
+ diagnoseMigrationHistory(input: EngineArgs.DiagnoseMigrationHistoryInput): Promise<EngineResults.DiagnoseMigrationHistoryOutput>;
65
43
  /**
66
44
  * Make sure the Schema engine can connect to the database from the Prisma schema.
67
45
  */
68
- ensureConnectionValidity(args: EngineArgs.EnsureConnectionValidityInput): Promise<void>;
46
+ ensureConnectionValidity(input: EngineArgs.EnsureConnectionValidityInput): Promise<void>;
69
47
  /**
70
48
  * Development command for migrations.
71
49
  * Evaluate the data loss induced by the next migration the engine would generate on the main database.
72
50
  */
73
- evaluateDataLoss(args: EngineArgs.EvaluateDataLossInput): Promise<EngineResults.EvaluateDataLossOutput>;
74
- getDatabaseDescription(schema: string): Promise<string>;
51
+ evaluateDataLoss(input: EngineArgs.EvaluateDataLossInput): Promise<EngineResults.EvaluateDataLossOutput>;
75
52
  /**
76
53
  * Get the database version for error reporting.
77
54
  * If no argument is given, the version of the database associated to the Prisma schema provided
@@ -82,8 +59,9 @@ export declare class SchemaEngine {
82
59
  * Given a Prisma schema, introspect the database definitions and update the schema with the results.
83
60
  * `compositeTypeDepth` is optional, and only required for MongoDB.
84
61
  */
85
- introspect({ schema, force, baseDirectoryPath, compositeTypeDepth, // cannot be undefined
86
- namespaces, }: EngineArgs.IntrospectParams): Promise<EngineArgs.IntrospectResult>;
62
+ introspect(input: EngineArgs.IntrospectParams & {
63
+ viewsDirectoryPath: string;
64
+ }): Promise<EngineArgs.IntrospectResult>;
87
65
  /**
88
66
  * Compares two databases schemas from two arbitrary sources,
89
67
  * and display the difference as either a human-readable summary,
@@ -93,11 +71,7 @@ export declare class SchemaEngine {
93
71
  * The resulting diff should be thought of as a migration from the schema in `args.from` to the schema in `args.to`.
94
72
  * By default, we output a human-readable diff. If you want an executable script, pass the "script": true param.
95
73
  */
96
- migrateDiff(args: EngineArgs.MigrateDiffInput): Promise<EngineResults.MigrateDiffOutput>;
97
- /**
98
- * List the names of the migrations in the migrations directory.
99
- */
100
- listMigrationDirectories(args: EngineArgs.ListMigrationDirectoriesInput): Promise<EngineResults.ListMigrationDirectoriesOutput>;
74
+ migrateDiff(input: EngineArgs.MigrateDiffInput): Promise<EngineResults.MigrateDiffOutput>;
101
75
  /**
102
76
  * Mark a migration as applied in the migrations table.
103
77
  * There are two possible outcomes:
@@ -105,11 +79,11 @@ export declare class SchemaEngine {
105
79
  * - The migration is not in the table. We will create a new entry in the migrations table. The started_at and finished_at will be the same.
106
80
  * If it is already applied, we return a user-facing error.
107
81
  */
108
- markMigrationApplied(args: EngineArgs.MarkMigrationAppliedInput): Promise<void>;
82
+ markMigrationApplied(input: EngineArgs.MarkMigrationAppliedInput): Promise<void>;
109
83
  /**
110
84
  * Mark an existing failed migration as rolled back in the migrations table. It will still be there, but ignored for all purposes except as audit trail.
111
85
  */
112
- markMigrationRolledBack(args: EngineArgs.MarkMigrationRolledBackInput): Promise<void>;
86
+ markMigrationRolledBack(input: EngineArgs.MarkMigrationRolledBackInput): Promise<void>;
113
87
  /**
114
88
  * Try to make the database empty: no data and no schema.
115
89
  * On most connectors, this is implemented by dropping and recreating the database.
@@ -121,19 +95,15 @@ export declare class SchemaEngine {
121
95
  /**
122
96
  * The command behind db push.
123
97
  */
124
- schemaPush(args: EngineArgs.SchemaPushInput): Promise<EngineResults.SchemaPush>;
98
+ schemaPush(input: EngineArgs.SchemaPushInput): Promise<EngineResults.SchemaPush>;
125
99
  /**
126
100
  * SQL introspection that powers TypedSQL feature
127
101
  * @param args
128
102
  * @returns
129
103
  */
130
- introspectSql(args: EngineArgs.IntrospectSqlParams): Promise<EngineResults.IntrospectSqlOutput>;
104
+ introspectSql(input: EngineArgs.IntrospectSqlParams): Promise<EngineResults.IntrospectSqlOutput>;
105
+ /**
106
+ * Stop the engine.
107
+ */
131
108
  stop(): void;
132
- private rejectAll;
133
- private registerCallback;
134
- private handleResponse;
135
- private init;
136
- private internalInit;
137
- private runCommand;
138
- private getRPCPayload;
139
109
  }
@@ -0,0 +1,139 @@
1
+ import { type MigrateTypes, SchemaContext } from '@prisma/internals';
2
+ import type { SchemaEngine } from './SchemaEngine';
3
+ import type { EngineArgs, EngineResults } from './types';
4
+ export declare class EngineError extends Error {
5
+ code: number;
6
+ constructor(message: string, code: number);
7
+ }
8
+ interface SchemaEngineCLISetupInput {
9
+ debug?: boolean;
10
+ enabledPreviewFeatures?: string[];
11
+ schemaContext?: SchemaContext;
12
+ }
13
+ export type SchemaEngineCLIOptions = SchemaEngineCLISetupInput;
14
+ export declare class SchemaEngineCLI implements SchemaEngine {
15
+ private debug;
16
+ private child?;
17
+ private schemaContext?;
18
+ private listeners;
19
+ /** _All_ the logs from the engine process. */
20
+ private messages;
21
+ private lastRequest?;
22
+ /** The fields of the last engine log event with an `ERROR` level. */
23
+ private lastError;
24
+ private initPromise?;
25
+ private enabledPreviewFeatures?;
26
+ private latestSchema?;
27
+ isRunning: boolean;
28
+ private constructor();
29
+ static setup(input: SchemaEngineCLISetupInput): Promise<SchemaEngineCLI>;
30
+ /**
31
+ * Apply the migrations from the migrations directory to the database.
32
+ * This is the command behind prisma migrate deploy.
33
+ */
34
+ applyMigrations(args: EngineArgs.ApplyMigrationsInput): Promise<EngineResults.ApplyMigrationsOutput>;
35
+ /**
36
+ * Create the logical database from the Prisma schema.
37
+ */
38
+ createDatabase(args: EngineArgs.CreateDatabaseInput): Promise<EngineResults.CreateDatabaseOutput>;
39
+ /**
40
+ * Create the next migration in the migrations history.
41
+ * If draft is false and there are no unexecutable steps, it will also apply the newly created migration.
42
+ * Note: This will use the shadow database on the connectors where we need one.
43
+ */
44
+ createMigration(args: EngineArgs.CreateMigrationInput): Promise<EngineResults.CreateMigrationOutput>;
45
+ /**
46
+ * Execute a database script directly on the specified live database.
47
+ * Note that this may not be defined on all connectors.
48
+ */
49
+ dbExecute(args: EngineArgs.DbExecuteInput): Promise<EngineResults.DbExecuteOutput>;
50
+ /**
51
+ * Make the Schema engine panic. Only useful to test client error handling.
52
+ */
53
+ debugPanic(): Promise<void>;
54
+ /**
55
+ * The method called at the beginning of migrate dev to decide the course of action,
56
+ * based on the current state of the workspace.
57
+ * It acts as a wrapper around diagnoseMigrationHistory.
58
+ * Its role is to interpret the diagnostic output,
59
+ * and translate it to a concrete action to be performed by the CLI.
60
+ */
61
+ devDiagnostic(args: EngineArgs.DevDiagnosticInput): Promise<EngineResults.DevDiagnosticOutput>;
62
+ /**
63
+ * Read the contents of the migrations directory and the migrations table, and returns their relative statuses.
64
+ * At this stage, the Schema engine only reads,
65
+ * it does not write to the database nor the migrations directory, nor does it use a shadow database.
66
+ */
67
+ diagnoseMigrationHistory(args: EngineArgs.DiagnoseMigrationHistoryInput): Promise<EngineResults.DiagnoseMigrationHistoryOutput>;
68
+ /**
69
+ * Make sure the Schema engine can connect to the database from the Prisma schema.
70
+ */
71
+ ensureConnectionValidity(args: EngineArgs.EnsureConnectionValidityInput): Promise<void>;
72
+ /**
73
+ * Development command for migrations.
74
+ * Evaluate the data loss induced by the next migration the engine would generate on the main database.
75
+ */
76
+ evaluateDataLoss(args: EngineArgs.EvaluateDataLossInput): Promise<EngineResults.EvaluateDataLossOutput>;
77
+ getDatabaseDescription(schema: string): Promise<string>;
78
+ /**
79
+ * Get the database version for error reporting.
80
+ * If no argument is given, the version of the database associated to the Prisma schema provided
81
+ * in the constructor will be returned.
82
+ */
83
+ getDatabaseVersion(args?: MigrateTypes.GetDatabaseVersionParams): Promise<string>;
84
+ /**
85
+ * Given a Prisma schema, introspect the database definitions and update the schema with the results.
86
+ * `compositeTypeDepth` is optional, and only required for MongoDB.
87
+ */
88
+ introspect({ schema, force, baseDirectoryPath, viewsDirectoryPath, compositeTypeDepth, // cannot be undefined
89
+ namespaces, }: EngineArgs.IntrospectParams): Promise<EngineArgs.IntrospectResult>;
90
+ /**
91
+ * Compares two databases schemas from two arbitrary sources,
92
+ * and display the difference as either a human-readable summary,
93
+ * or an executable script that can be passed to dbExecute.
94
+ * Connection to a shadow database is only necessary when either the from or the to params is a migrations directory.
95
+ * Diffs have a direction. Which source is from and which is to matters.
96
+ * The resulting diff should be thought of as a migration from the schema in `args.from` to the schema in `args.to`.
97
+ * By default, we output a human-readable diff. If you want an executable script, pass the "script": true param.
98
+ */
99
+ migrateDiff(args: EngineArgs.MigrateDiffInput): Promise<EngineResults.MigrateDiffOutput>;
100
+ /**
101
+ * Mark a migration as applied in the migrations table.
102
+ * There are two possible outcomes:
103
+ * - The migration is already in the table, but in a failed state. In this case, we will mark it as rolled back, then create a new entry.
104
+ * - The migration is not in the table. We will create a new entry in the migrations table. The started_at and finished_at will be the same.
105
+ * If it is already applied, we return a user-facing error.
106
+ */
107
+ markMigrationApplied(args: EngineArgs.MarkMigrationAppliedInput): Promise<void>;
108
+ /**
109
+ * Mark an existing failed migration as rolled back in the migrations table. It will still be there, but ignored for all purposes except as audit trail.
110
+ */
111
+ markMigrationRolledBack(args: EngineArgs.MarkMigrationRolledBackInput): Promise<void>;
112
+ /**
113
+ * Try to make the database empty: no data and no schema.
114
+ * On most connectors, this is implemented by dropping and recreating the database.
115
+ * If that fails (most likely because of insufficient permissions),
116
+ * the engine attempts a “best effort reset” by inspecting the contents of the database and dropping them individually.
117
+ * Drop and recreate the database. The migrations will not be applied, as it would overlap with applyMigrations.
118
+ */
119
+ reset(): Promise<void>;
120
+ /**
121
+ * The command behind db push.
122
+ */
123
+ schemaPush(args: EngineArgs.SchemaPushInput): Promise<EngineResults.SchemaPush>;
124
+ /**
125
+ * SQL introspection that powers TypedSQL feature
126
+ * @param args
127
+ * @returns
128
+ */
129
+ introspectSql(args: EngineArgs.IntrospectSqlParams): Promise<EngineResults.IntrospectSqlOutput>;
130
+ stop(): void;
131
+ private rejectAll;
132
+ private registerCallback;
133
+ private handleResponse;
134
+ private init;
135
+ private internalInit;
136
+ private runCommand;
137
+ private getRPCPayload;
138
+ }
139
+ export {};
@@ -0,0 +1,134 @@
1
+ import type { ErrorCapturingSqlDriverAdapterFactory } from '@prisma/driver-adapter-utils';
2
+ import { SchemaContext, wasm } from '@prisma/internals';
3
+ import { SchemaEngine } from './SchemaEngine';
4
+ import { EngineArgs } from './types';
5
+ type SchemaEngineMethods = Omit<wasm.SchemaEngineWasm, 'free'>;
6
+ export type SchemaEngineInput<M extends keyof SchemaEngineMethods> = Parameters<wasm.SchemaEngineWasm[M]>[0];
7
+ export type SchemaEngineOutput<M extends keyof SchemaEngineMethods> = ReturnType<wasm.SchemaEngineWasm[M]>;
8
+ interface SchemaEngineWasmSetupInput {
9
+ adapter: ErrorCapturingSqlDriverAdapterFactory;
10
+ enabledPreviewFeatures?: string[];
11
+ schemaContext?: SchemaContext;
12
+ }
13
+ export interface SchemaEngineWasmOptions extends Omit<SchemaEngineWasmSetupInput, 'adapter'> {
14
+ debug?: boolean;
15
+ engine: wasm.SchemaEngineWasm;
16
+ }
17
+ /**
18
+ * Wrapper around `@prisma/schema-engine-wasm`, which will eventually replace `SchemaEngineCLI`.
19
+ *
20
+ * TODOs:
21
+ * - Forward initial schema and preview features to the Wasm engine
22
+ * - Collect and forward logs to the CLI
23
+ * - Catch and throw "rich" connector errors
24
+ */
25
+ export declare class SchemaEngineWasm implements SchemaEngine {
26
+ private engine;
27
+ private schemaContext?;
28
+ private enabledPreviewFeatures?;
29
+ isRunning: boolean;
30
+ private constructor();
31
+ static setup({ adapter, ...rest }: SchemaEngineWasmSetupInput): Promise<SchemaEngineWasm>;
32
+ private runCommand;
33
+ /**
34
+ * Apply the migrations from the migrations directory to the database.
35
+ * This is the command behind prisma migrate deploy.
36
+ */
37
+ applyMigrations(input: SchemaEngineInput<'applyMigrations'>): SchemaEngineOutput<'applyMigrations'>;
38
+ /**
39
+ * Create the next migration in the migrations history.
40
+ * If draft is false and there are no unexecutable steps, it will also apply the newly created migration.
41
+ * Note: This will use the shadow database on the connectors where we need one.
42
+ */
43
+ createMigration(input: SchemaEngineInput<'createMigration'>): SchemaEngineOutput<'createMigration'>;
44
+ /**
45
+ * Execute a database script directly on the specified live database.
46
+ * Note that this may not be defined on all connectors.
47
+ */
48
+ dbExecute(input: SchemaEngineInput<'dbExecute'>): Promise<null>;
49
+ /**
50
+ * Make the Schema engine panic. Only useful to test client error handling.
51
+ */
52
+ debugPanic(): Promise<never>;
53
+ /**
54
+ * The method called at the beginning of migrate dev to decide the course of action,
55
+ * based on the current state of the workspace.
56
+ * It acts as a wrapper around diagnoseMigrationHistory.
57
+ * Its role is to interpret the diagnostic output,
58
+ * and translate it to a concrete action to be performed by the CLI.
59
+ */
60
+ devDiagnostic(input: SchemaEngineInput<'devDiagnostic'>): SchemaEngineOutput<'devDiagnostic'>;
61
+ /**
62
+ * Read the contents of the migrations directory and the migrations table, and returns their relative statuses.
63
+ * At this stage, the Schema engine only reads,
64
+ * it does not write to the database nor the migrations directory, nor does it use a shadow database.
65
+ */
66
+ diagnoseMigrationHistory(input: SchemaEngineInput<'diagnoseMigrationHistory'>): SchemaEngineOutput<'diagnoseMigrationHistory'>;
67
+ /**
68
+ * Make sure the Schema engine can connect to the database from the Prisma schema.
69
+ */
70
+ ensureConnectionValidity(input: SchemaEngineInput<'ensureConnectionValidity'>): Promise<void>;
71
+ /**
72
+ * Development command for migrations.
73
+ * Evaluate the data loss induced by the next migration the engine would generate on the main database.
74
+ */
75
+ evaluateDataLoss(input: SchemaEngineInput<'evaluateDataLoss'>): SchemaEngineOutput<'evaluateDataLoss'>;
76
+ /**
77
+ * Get the database version for error reporting.
78
+ * If no argument is given, the version of the database associated to the Prisma schema provided
79
+ * in the constructor will be returned.
80
+ */
81
+ getDatabaseVersion(input?: SchemaEngineInput<'version'>): SchemaEngineOutput<'version'>;
82
+ /**
83
+ * Given a Prisma schema, introspect the database definitions and update the schema with the results.
84
+ * `compositeTypeDepth` is optional, and only required for MongoDB.
85
+ */
86
+ introspect({ schema, force, baseDirectoryPath, viewsDirectoryPath, compositeTypeDepth, namespaces, }: EngineArgs.IntrospectParams): SchemaEngineOutput<'introspect'>;
87
+ /**
88
+ * Compares two databases schemas from two arbitrary sources,
89
+ * and display the difference as either a human-readable summary,
90
+ * or an executable script that can be passed to dbExecute.
91
+ * Connection to a shadow database is only necessary when either the from or the to params is a migrations directory.
92
+ * Diffs have a direction. Which source is from and which is to matters.
93
+ * The resulting diff should be thought of as a migration from the schema in `args.from` to the schema in `args.to`.
94
+ * By default, we output a human-readable diff. If you want an executable script, pass the "script": true param.
95
+ */
96
+ migrateDiff(input: SchemaEngineInput<'diff'>): Promise<{
97
+ exitCode: number;
98
+ }>;
99
+ /**
100
+ * Mark a migration as applied in the migrations table.
101
+ * There are two possible outcomes:
102
+ * - The migration is already in the table, but in a failed state. In this case, we will mark it as rolled back, then create a new entry.
103
+ * - The migration is not in the table. We will create a new entry in the migrations table. The started_at and finished_at will be the same.
104
+ * If it is already applied, we return a user-facing error.
105
+ */
106
+ markMigrationApplied(input: SchemaEngineInput<'markMigrationApplied'>): Promise<void>;
107
+ /**
108
+ * Mark an existing failed migration as rolled back in the migrations table. It will still be there, but ignored for all purposes except as audit trail.
109
+ */
110
+ markMigrationRolledBack(input: SchemaEngineInput<'markMigrationRolledBack'>): Promise<void>;
111
+ /**
112
+ * Try to make the database empty: no data and no schema.
113
+ * On most connectors, this is implemented by dropping and recreating the database.
114
+ * If that fails (most likely because of insufficient permissions),
115
+ * the engine attempts a “best effort reset” by inspecting the contents of the database and dropping them individually.
116
+ * Drop and recreate the database. The migrations will not be applied, as it would overlap with applyMigrations.
117
+ */
118
+ reset(): Promise<void>;
119
+ /**
120
+ * The command behind db push.
121
+ */
122
+ schemaPush(input: SchemaEngineInput<'schemaPush'>): SchemaEngineOutput<'schemaPush'>;
123
+ /**
124
+ * SQL introspection that powers TypedSQL feature
125
+ * @param args
126
+ * @returns
127
+ */
128
+ introspectSql(input: SchemaEngineInput<'introspectSql'>): SchemaEngineOutput<'introspectSql'>;
129
+ /**
130
+ * Stop the engine.
131
+ */
132
+ stop(): void;
133
+ }
134
+ export {};
@@ -3,6 +3,6 @@ import { Command, HelpError } from '@prisma/internals';
3
3
  export declare class DbExecute implements Command {
4
4
  static new(): DbExecute;
5
5
  private static help;
6
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
6
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
7
7
  help(error?: string): string | HelpError;
8
8
  }
@@ -4,7 +4,7 @@ export declare class DbPull implements Command {
4
4
  static new(): DbPull;
5
5
  private static help;
6
6
  private urlToDatasource;
7
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
7
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
8
8
  private getWarningMessage;
9
9
  help(error?: string): string | HelpError;
10
10
  }
@@ -3,6 +3,6 @@ import { Command, HelpError } from '@prisma/internals';
3
3
  export declare class DbPush implements Command {
4
4
  static new(): DbPush;
5
5
  private static help;
6
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
6
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
7
7
  help(error?: string): string | HelpError;
8
8
  }
@@ -3,6 +3,6 @@ import { Command, HelpError } from '@prisma/internals';
3
3
  export declare class MigrateDeploy implements Command {
4
4
  static new(): MigrateDeploy;
5
5
  private static help;
6
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
6
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
7
7
  help(error?: string): string | HelpError;
8
8
  }
@@ -3,7 +3,7 @@ import { Command, HelpError } from '@prisma/internals';
3
3
  export declare class MigrateDev implements Command {
4
4
  static new(): MigrateDev;
5
5
  private static help;
6
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
6
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
7
7
  private logResetReason;
8
8
  help(error?: string): string | HelpError;
9
9
  }
@@ -3,6 +3,6 @@ import { Command, HelpError } from '@prisma/internals';
3
3
  export declare class MigrateDiff implements Command {
4
4
  static new(): MigrateDiff;
5
5
  private static help;
6
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
6
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
7
7
  help(error?: string): string | HelpError;
8
8
  }
@@ -3,6 +3,6 @@ import { Command, HelpError } from '@prisma/internals';
3
3
  export declare class MigrateReset implements Command {
4
4
  static new(): MigrateReset;
5
5
  private static help;
6
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
6
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
7
7
  help(error?: string): string | HelpError;
8
8
  }
@@ -3,6 +3,6 @@ import { Command, HelpError } from '@prisma/internals';
3
3
  export declare class MigrateResolve implements Command {
4
4
  static new(): MigrateResolve;
5
5
  private static help;
6
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
6
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
7
7
  help(error?: string): string | HelpError;
8
8
  }
@@ -3,6 +3,6 @@ import { Command, HelpError } from '@prisma/internals';
3
3
  export declare class MigrateStatus implements Command {
4
4
  static new(): MigrateStatus;
5
5
  private static help;
6
- parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error>;
6
+ parse(argv: string[], config: PrismaConfigInternal<any>): Promise<string | Error>;
7
7
  help(error?: string): string | HelpError;
8
8
  }
@@ -12,9 +12,9 @@ export { MigrateReset } from './commands/MigrateReset';
12
12
  export { MigrateResolve } from './commands/MigrateResolve';
13
13
  export { MigrateStatus } from './commands/MigrateStatus';
14
14
  export { Migrate } from './Migrate';
15
- export { SchemaEngine } from './SchemaEngine';
15
+ export { SchemaEngineCLI } from './SchemaEngineCLI';
16
+ export { SchemaEngineWasm } from './SchemaEngineWasm';
16
17
  export * from './types';
17
18
  export { default as byline } from './utils/byline';
18
19
  export { getDatabaseVersionSafe } from './utils/getDatabaseVersionSafe';
19
- export { getSchemaPathAndPrint, printSchemaLoadedMessage } from './utils/getSchemaPathAndPrint';
20
20
  export { introspectSql, type IntrospectSqlError, type IntrospectSqlInput, type IntrospectSqlResult, } from './utils/introspectSql';
@@ -1,4 +1,4 @@
1
- import type { SqlQueryOutput } from '@prisma/generator-helper';
1
+ import type { ActiveConnectorType, SqlQueryOutput } from '@prisma/generator';
2
2
  import type { MigrateTypes } from '@prisma/internals';
3
3
  import type { IntrospectionViewDefinition } from './views/handleViewsIO';
4
4
  export interface RpcRequestResponse {
@@ -50,7 +50,7 @@ export type HistoryDiagnostic = {
50
50
  unpersistedMigrationNames: string[];
51
51
  } | {
52
52
  diagnostic: 'historiesDiverge';
53
- lastCommonMigrationName: string;
53
+ lastCommonMigrationName: string | null;
54
54
  unpersistedMigrationNames: string[];
55
55
  unappliedMigrationNames: string[];
56
56
  };
@@ -69,13 +69,13 @@ export declare namespace EngineArgs {
69
69
  * These RPCs need a sourceConfig, therefore a db connection to function
70
70
  */
71
71
  export interface ApplyMigrationsInput {
72
- migrationsDirectoryPath: string;
72
+ migrationsList: MigrateTypes.MigrationList;
73
73
  }
74
74
  export interface CreateMigrationInput {
75
- migrationsDirectoryPath: string;
75
+ migrationsList: MigrateTypes.MigrationList;
76
76
  schema: MigrateTypes.SchemasContainer;
77
77
  draft: boolean;
78
- migrationName?: string;
78
+ migrationName: string;
79
79
  }
80
80
  export interface CreateDatabaseInput {
81
81
  datasource: MigrateTypes.DatasourceParam;
@@ -91,7 +91,8 @@ export declare namespace EngineArgs {
91
91
  export interface IntrospectParams {
92
92
  schema: MigrateTypes.SchemasContainer;
93
93
  baseDirectoryPath: string;
94
- force?: Boolean;
94
+ viewsDirectoryPath: string;
95
+ force?: boolean;
95
96
  compositeTypeDepth?: number;
96
97
  namespaces?: string[];
97
98
  }
@@ -110,24 +111,24 @@ export declare namespace EngineArgs {
110
111
  views: IntrospectionViewDefinition[] | null;
111
112
  }
112
113
  export interface DevDiagnosticInput {
113
- migrationsDirectoryPath: string;
114
+ migrationsList: MigrateTypes.MigrationList;
114
115
  }
115
116
  export interface DiagnoseMigrationHistoryInput {
116
- migrationsDirectoryPath: string;
117
+ migrationsList: MigrateTypes.MigrationList;
117
118
  optInToShadowDatabase: boolean;
118
119
  }
119
120
  export interface EnsureConnectionValidityInput {
120
121
  datasource: MigrateTypes.DatasourceParam;
121
122
  }
122
123
  export interface EvaluateDataLossInput {
123
- migrationsDirectoryPath: string;
124
+ migrationsList: MigrateTypes.MigrationList;
124
125
  schema: MigrateTypes.SchemasContainer;
125
126
  }
126
127
  export interface ListMigrationDirectoriesInput {
127
128
  migrationsDirectoryPath: string;
128
129
  }
129
130
  export interface MarkMigrationAppliedInput {
130
- migrationsDirectoryPath: string;
131
+ migrationsList: MigrateTypes.MigrationList;
131
132
  migrationName: string;
132
133
  }
133
134
  export interface MarkMigrationRolledBackInput {
@@ -139,17 +140,14 @@ export declare namespace EngineArgs {
139
140
  };
140
141
  type MigrateDiffTargetSchemaDatamodel = MigrateTypes.Tagged<'schemaDatamodel', MigrateTypes.SchemasContainer>;
141
142
  type MigrateDiffTargetSchemaDatasource = MigrateTypes.Tagged<'schemaDatasource', MigrateTypes.SchemasWithConfigDir>;
142
- type MigrateDiffTargetMigrations = {
143
- tag: 'migrations';
144
- path: string;
145
- };
143
+ type MigrateDiffTargetMigrations = MigrateTypes.Tagged<'migrations', MigrateTypes.MigrationList>;
146
144
  export type MigrateDiffTarget = MigrateDiffTargetUrl | MigrateDiffTargetEmpty | MigrateDiffTargetSchemaDatamodel | MigrateDiffTargetSchemaDatasource | MigrateDiffTargetMigrations;
147
145
  export interface MigrateDiffInput {
148
146
  from: MigrateDiffTarget;
149
147
  to: MigrateDiffTarget;
150
148
  script: boolean;
151
- shadowDatabaseUrl?: string;
152
- exitCode?: boolean;
149
+ shadowDatabaseUrl: string | null;
150
+ exitCode: boolean | null;
153
151
  }
154
152
  export interface SchemaPushInput {
155
153
  schema: MigrateTypes.SchemasContainer;
@@ -173,10 +171,12 @@ export declare namespace EngineResults {
173
171
  database_name: string;
174
172
  }
175
173
  interface CreateMigrationOutput {
176
- generatedMigrationName: string | null;
177
- }
178
- interface DbExecuteOutput {
174
+ connectorType: ActiveConnectorType;
175
+ generatedMigrationName: string;
176
+ migrationScript: string | null;
177
+ extension: string;
179
178
  }
179
+ type DbExecuteOutput = null;
180
180
  interface DevDiagnosticOutput {
181
181
  action: DevAction;
182
182
  }
@@ -0,0 +1,21 @@
1
+ import type { ActiveConnectorType } from '@prisma/generator';
2
+ import type { MigrateTypes } from '@prisma/internals';
3
+ type CreateMigrationInput = {
4
+ baseDir: string;
5
+ generatedMigrationName: string;
6
+ };
7
+ export declare function createMigration({ baseDir, generatedMigrationName }: CreateMigrationInput): Promise<string>;
8
+ type WriteMigrationScriptInput = {
9
+ baseDir: string;
10
+ migrationName: string;
11
+ extension: string;
12
+ script: string;
13
+ };
14
+ export declare function writeMigrationScript({ baseDir, extension, migrationName, script, }: WriteMigrationScriptInput): Promise<void>;
15
+ type WriteMigrationLockfileInput = {
16
+ baseDir: string;
17
+ connectorType: ActiveConnectorType;
18
+ lockfile: Omit<MigrateTypes.MigrationLockfile, 'content'>;
19
+ };
20
+ export declare function writeMigrationLockfile({ baseDir, connectorType, lockfile }: WriteMigrationLockfileInput): Promise<void>;
21
+ export {};