@prisma/migrate 6.6.0-dev.10 → 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 (166) hide show
  1. package/dist/CLI.js +3 -3
  2. package/dist/Migrate.js +9 -6
  3. package/dist/SchemaEngine.js +0 -28
  4. package/dist/SchemaEngineCLI.js +29 -0
  5. package/dist/{utils/getSchemaPathAndPrint.js → SchemaEngineWasm.js} +8 -8
  6. package/dist/bin.js +52 -50
  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-GG54LOYV.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-N4XTKFY6.js → chunk-CLSF7VUT.js} +42 -38
  20. package/dist/{chunk-2B4IAB6L.js → chunk-CNCVJ2IN.js} +377 -532
  21. package/dist/{chunk-IR55GBON.js → chunk-CU5UT2ED.js} +19 -18
  22. package/dist/{chunk-CQZFVAXC.js → chunk-CYEVXXRH.js} +51 -47
  23. package/dist/{chunk-W2SZNLK4.js → chunk-EJG7GKM7.js} +37 -39
  24. package/dist/{chunk-5PSO7BDO.js → chunk-EJUXYFV3.js} +15 -15
  25. package/dist/{chunk-KS7IEA6Z.js → chunk-HIDSEBVV.js} +55 -54
  26. package/dist/{chunk-ZOEKRXDP.js → chunk-I3LT2PO3.js} +35 -57
  27. package/dist/{chunk-N3KYWSX2.js → chunk-IEEJZC3B.js} +56 -49
  28. package/dist/{chunk-MCWCB2AX.js → chunk-IINN7QUV.js} +170 -643
  29. package/dist/chunk-IK3BVD3Y.js +233 -0
  30. package/dist/{chunk-255BRND3.js → chunk-KRQEFTDT.js} +6 -6
  31. package/dist/{chunk-HCBZB4XC.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-WI2A2TQE.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-5GVIOOXU.js → chunk-W5SQWSLC.js} +378 -533
  42. package/dist/{chunk-Q3ZLC44N.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 -7
  48. package/dist/commands/DbPull.js +17 -12
  49. package/dist/commands/DbPush.js +12 -10
  50. package/dist/commands/DbSeed.js +4 -5
  51. package/dist/commands/MigrateCommand.js +3 -3
  52. package/dist/commands/MigrateDeploy.js +14 -12
  53. package/dist/commands/MigrateDev.js +17 -15
  54. package/dist/commands/MigrateDiff.js +13 -10
  55. package/dist/commands/MigrateReset.js +16 -14
  56. package/dist/commands/MigrateResolve.js +12 -10
  57. package/dist/commands/MigrateStatus.js +12 -10
  58. package/dist/index.js +58 -57
  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 +1478 -707
  144. package/dist/utils/setupMongo.js +553 -552
  145. package/dist/utils/setupMysql.js +508 -563
  146. package/dist/utils/setupPostgres.js +3 -3
  147. package/dist/utils/spinner.js +4 -3
  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 +12 -11
  152. package/dist/chunk-GKDFIHM2.js +0 -45
  153. package/dist/chunk-J46BJQHT.js +0 -268
  154. package/dist/chunk-KOF4LGTS.js +0 -1817
  155. package/dist/chunk-YYPMC5FN.js +0 -1407
  156. package/dist/internals/src/get-generators/generatorResolvers/generatorResolvers.d.ts +0 -15
  157. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.d.ts +0 -6
  158. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.d.ts +0 -9
  159. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.d.ts +0 -8
  160. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.d.ts +0 -6
  161. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.d.ts +0 -1
  162. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.d.ts +0 -20
  163. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.d.ts +0 -7
  164. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.d.ts +0 -20
  165. package/dist/internals/src/get-generators/utils/check-feature-flags/checkFeatureFlags.d.ts +0 -8
  166. package/dist/migrate/src/utils/getSchemaPathAndPrint.d.ts +0 -10
@@ -26,17 +26,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_ZOEKRXDP_exports = {};
30
- __export(chunk_ZOEKRXDP_exports, {
29
+ var chunk_I3LT2PO3_exports = {};
30
+ __export(chunk_I3LT2PO3_exports, {
31
31
  EngineError: () => EngineError,
32
- SchemaEngine: () => SchemaEngine
32
+ SchemaEngineCLI: () => SchemaEngineCLI
33
33
  });
34
- module.exports = __toCommonJS(chunk_ZOEKRXDP_exports);
35
- var import_chunk_MATFO4ZW = require("./chunk-MATFO4ZW.js");
34
+ module.exports = __toCommonJS(chunk_I3LT2PO3_exports);
36
35
  var import_chunk_L6KOIJJ5 = require("./chunk-L6KOIJJ5.js");
36
+ var import_chunk_OEWQACEH = require("./chunk-OEWQACEH.js");
37
37
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
38
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
39
- var import_node_path = __toESM(require("node:path"));
40
38
  var import_debug = __toESM(require("@prisma/debug"));
41
39
  var import_internals = require("@prisma/internals");
42
40
  var import_child_process = require("child_process");
@@ -44,34 +42,42 @@ var debugRpc = (0, import_debug.default)("prisma:schemaEngine:rpc");
44
42
  var debugStderr = (0, import_debug.default)("prisma:schemaEngine:stderr");
45
43
  var debugStdin = (0, import_debug.default)("prisma:schemaEngine:stdin");
46
44
  var EngineError = class extends Error {
45
+ code;
47
46
  constructor(message, code) {
48
47
  super(message);
49
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "code");
50
48
  this.code = code;
51
49
  }
52
50
  };
53
51
  (0, import_internals.setClassName)(EngineError, "EngineError");
54
52
  var messageId = 1;
55
- var SchemaEngine = class {
56
- constructor({ debug = false, schemaPath, enabledPreviewFeatures }) {
57
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "debug");
58
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "child");
59
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "schemaPath");
60
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "listeners", {});
61
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "messages", []);
62
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "lastRequest");
63
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "lastError", null);
64
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "initPromise");
65
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "enabledPreviewFeatures");
66
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "latestSchema");
67
- (0, import_chunk_WWAWV7DQ.__publicField)(this, "isRunning", false);
68
- this.schemaPath = schemaPath;
53
+ var SchemaEngineCLI = class _SchemaEngineCLI {
54
+ debug;
55
+ child;
56
+ schemaContext;
57
+ listeners = {};
58
+ /** _All_ the logs from the engine process. */
59
+ messages = [];
60
+ lastRequest;
61
+ /** The fields of the last engine log event with an `ERROR` level. */
62
+ lastError = null;
63
+ initPromise;
64
+ enabledPreviewFeatures;
65
+ // `latestSchema` is set to the latest schema that was used in `introspect()`
66
+ // TODO: remove, it's not used anywhere.
67
+ latestSchema;
68
+ // `isRunning` is set to true when the engine is initialized, and set to false when the engine is stopped
69
+ isRunning = false;
70
+ constructor({ debug = false, schemaContext, enabledPreviewFeatures }) {
71
+ this.schemaContext = schemaContext;
69
72
  if (debug) {
70
73
  import_debug.default.enable("SchemaEngine*");
71
74
  }
72
75
  this.debug = debug;
73
76
  this.enabledPreviewFeatures = enabledPreviewFeatures;
74
77
  }
78
+ static setup(input) {
79
+ return Promise.resolve(new _SchemaEngineCLI(input));
80
+ }
75
81
  //
76
82
  // See JSON-RPC API definition:
77
83
  // https://prisma.github.io/prisma-engines/doc/migration_core/json_rpc/index.html
@@ -160,6 +166,7 @@ var SchemaEngine = class {
160
166
  schema,
161
167
  force = false,
162
168
  baseDirectoryPath,
169
+ viewsDirectoryPath,
163
170
  compositeTypeDepth = -1,
164
171
  // cannot be undefined
165
172
  namespaces
@@ -171,8 +178,7 @@ var SchemaEngine = class {
171
178
  );
172
179
  const { views } = introspectResult;
173
180
  if (views) {
174
- const schemaPath = this.schemaPath ?? import_node_path.default.join(process.cwd(), "prisma");
175
- await (0, import_chunk_MATFO4ZW.handleViewsIO)({ views, schemaPath });
181
+ await (0, import_chunk_OEWQACEH.handleViewsIO)({ views, viewsDirectoryPath });
176
182
  }
177
183
  return introspectResult;
178
184
  } finally {
@@ -191,12 +197,6 @@ var SchemaEngine = class {
191
197
  migrateDiff(args) {
192
198
  return this.runCommand(this.getRPCPayload("diff", args));
193
199
  }
194
- /**
195
- * List the names of the migrations in the migrations directory.
196
- */
197
- listMigrationDirectories(args) {
198
- return this.runCommand(this.getRPCPayload("listMigrationDirectories", args));
199
- }
200
200
  /**
201
201
  * Mark a migration as applied in the migrations table.
202
202
  * There are two possible outcomes:
@@ -297,11 +297,9 @@ var SchemaEngine = class {
297
297
  debugRpc("starting Schema engine with binary: " + binaryPath);
298
298
  const args = [];
299
299
  let projectDir = process.cwd();
300
- if (this.schemaPath) {
301
- const schema = await (0, import_internals.getSchema)(this.schemaPath);
302
- const config = await (0, import_internals.getConfig)({ datamodel: schema });
303
- projectDir = (0, import_internals.getMigrateConfigDir)(config, this.schemaPath);
304
- const schemaArgs = schema.flatMap(([path2]) => ["-d", path2]);
300
+ if (this.schemaContext) {
301
+ projectDir = this.schemaContext.primaryDatasourceDirectory;
302
+ const schemaArgs = this.schemaContext.schemaFiles.flatMap(([path]) => ["-d", path]);
305
303
  args.push(...schemaArgs);
306
304
  }
307
305
  if (this.enabledPreviewFeatures && Array.isArray(this.enabledPreviewFeatures) && this.enabledPreviewFeatures.length > 0) {
@@ -335,18 +333,7 @@ var SchemaEngine = class {
335
333
  const stackTrace = `[EXIT_PANIC]
336
334
  ${processMessages}
337
335
  ${this.lastError?.backtrace ?? ""}`;
338
- exitWithErr(
339
- new import_internals.RustPanic(
340
- serializePanic(engineMessage),
341
- stackTrace,
342
- this.lastRequest,
343
- import_internals.ErrorArea.LIFT_CLI,
344
- /* schemaPath */
345
- this.schemaPath,
346
- /* schema */
347
- this.latestSchema?.files.map((schema) => [schema.path, schema.content])
348
- )
349
- );
336
+ exitWithErr(new import_internals.RustPanic(serializePanic(engineMessage), stackTrace, this.lastRequest, import_internals.ErrorArea.LIFT_CLI));
350
337
  };
351
338
  switch (code) {
352
339
  case import_internals.SchemaEngineExitCode.Success:
@@ -412,16 +399,7 @@ ${this.lastError?.backtrace ?? ""}`;
412
399
  ${response.error.data?.message ?? ""}`;
413
400
  reject(
414
401
  // Handle error and displays the interactive dialog to send panic error
415
- new import_internals.RustPanic(
416
- message,
417
- stackTrace,
418
- this.lastRequest,
419
- import_internals.ErrorArea.LIFT_CLI,
420
- /* schemaPath */
421
- this.schemaPath,
422
- /* schema */
423
- this.latestSchema?.files.map((schema) => [schema.path, schema.content])
424
- )
402
+ new import_internals.RustPanic(message, stackTrace, this.lastRequest, import_internals.ErrorArea.LIFT_CLI)
425
403
  );
426
404
  } else if (response.error.data?.message) {
427
405
  let message = `${(0, import_chunk_SKRR5WT4.red)((0, import_internals.relativizePathInPSLError)(response.error.data.message))}
@@ -26,14 +26,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_N3KYWSX2_exports = {};
30
- __export(chunk_N3KYWSX2_exports, {
29
+ var chunk_IEEJZC3B_exports = {};
30
+ __export(chunk_IEEJZC3B_exports, {
31
31
  DbExecute: () => DbExecute
32
32
  });
33
- module.exports = __toCommonJS(chunk_N3KYWSX2_exports);
34
- var import_chunk_KOF4LGTS = require("./chunk-KOF4LGTS.js");
33
+ module.exports = __toCommonJS(chunk_IEEJZC3B_exports);
34
+ var import_chunk_YSWLN2IJ = require("./chunk-YSWLN2IJ.js");
35
35
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
36
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
37
36
  var import_internals = require("@prisma/internals");
38
37
  var import_fs = __toESM(require("fs"));
39
38
  var import_path = __toESM(require("path"));
@@ -82,10 +81,48 @@ ${(0, import_chunk_SKRR5WT4.bold)("Flags")}
82
81
 
83
82
  --stdin Use the terminal standard input as the script to be executed`
84
83
  );
85
- var _DbExecute = class _DbExecute2 {
84
+ var DbExecute = class _DbExecute {
86
85
  static new() {
87
- return new _DbExecute2();
86
+ return new _DbExecute();
88
87
  }
88
+ // TODO: This command needs to get proper support for `prisma.config.ts` eventually. Not just taking the schema path
89
+ // from prisma.config.ts but likely to support driver adapters, too?
90
+ // See https://linear.app/prisma-company/issue/ORM-639/prisma-db-execute-support-prismaconfigts-and-driver-adapters
91
+ static help = (0, import_internals.format)(`
92
+ ${process.platform === "win32" ? "" : "\u{1F4DD} "}Execute native commands to your database
93
+
94
+ This command takes as input a datasource, using ${(0, import_chunk_SKRR5WT4.green)(`--url`)} or ${(0, import_chunk_SKRR5WT4.green)(`--schema`)} and a script, using ${(0, import_chunk_SKRR5WT4.green)(
95
+ `--stdin`
96
+ )} or ${(0, import_chunk_SKRR5WT4.green)(`--file`)}.
97
+ The input parameters are mutually exclusive, only 1 of each (datasource & script) must be provided.
98
+
99
+ The output of the command is connector-specific, and is not meant for returning data, but only to report success or failure.
100
+
101
+ On SQL databases, this command takes as input a SQL script.
102
+ The whole script will be sent as a single command to the database.
103
+
104
+ ${(0, import_chunk_SKRR5WT4.italic)(`This command is currently not supported on MongoDB.`)}
105
+
106
+ ${helpOptions}
107
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
108
+
109
+ Execute the content of a SQL script file to the datasource URL taken from the schema
110
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute
111
+ --file ./script.sql \\
112
+ --schema schema.prisma
113
+
114
+ Execute the SQL script from stdin to the datasource URL specified via the \`DATABASE_URL\` environment variable
115
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
116
+ prisma db execute \\
117
+ --stdin \\
118
+ --url="$DATABASE_URL"
119
+
120
+ Like previous example, but exposing the datasource url credentials to your terminal history
121
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
122
+ prisma db execute \\
123
+ --stdin \\
124
+ --url="mysql://root:root@localhost/mydb"
125
+ `);
89
126
  async parse(argv, config) {
90
127
  const args = (0, import_internals.arg)(
91
128
  argv,
@@ -104,7 +141,6 @@ var _DbExecute = class _DbExecute2 {
104
141
  if ((0, import_internals.isError)(args)) {
105
142
  return this.help(args.message);
106
143
  }
107
- await (0, import_internals.checkUnsupportedDataProxy)("db execute", args, config.schema, !args["--url"]);
108
144
  if (args["--help"]) {
109
145
  return this.help();
110
146
  }
@@ -149,19 +185,26 @@ See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExec
149
185
  }
150
186
  let datasourceType;
151
187
  if (args["--url"]) {
188
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd: "db execute", urls: [args["--url"]] });
152
189
  datasourceType = {
153
190
  tag: "url",
154
191
  url: args["--url"]
155
192
  };
156
193
  } else {
157
- const schemaWithPath = await (0, import_internals.getSchemaWithPath)(args["--schema"], config.schema);
158
- const engineConfig = await (0, import_internals.getConfig)({ datamodel: schemaWithPath.schemas });
194
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
195
+ schemaPathFromArg: args["--schema"],
196
+ schemaPathFromConfig: config.schema,
197
+ printLoadMessage: false
198
+ });
199
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd: "db execute", schemaContext });
159
200
  datasourceType = {
160
201
  tag: "schema",
161
- ...(0, import_internals.toSchemasWithConfigDir)(schemaWithPath, engineConfig)
202
+ ...(0, import_internals.toSchemasContainer)(schemaContext.schemaFiles),
203
+ configDir: schemaContext.primaryDatasourceDirectory
162
204
  };
163
205
  }
164
- const migrate = new import_chunk_KOF4LGTS.Migrate();
206
+ const adapter = await config.migrate?.adapter(process.env);
207
+ const migrate = await import_chunk_YSWLN2IJ.Migrate.setup({ adapter });
165
208
  try {
166
209
  await migrate.engine.dbExecute({
167
210
  script,
@@ -179,42 +222,6 @@ ${error}
179
222
 
180
223
  ${helpOptions}`);
181
224
  }
182
- return _DbExecute2.help;
225
+ return _DbExecute.help;
183
226
  }
184
227
  };
185
- (0, import_chunk_WWAWV7DQ.__publicField)(_DbExecute, "help", (0, import_internals.format)(`
186
- ${process.platform === "win32" ? "" : "\u{1F4DD} "}Execute native commands to your database
187
-
188
- This command takes as input a datasource, using ${(0, import_chunk_SKRR5WT4.green)(`--url`)} or ${(0, import_chunk_SKRR5WT4.green)(`--schema`)} and a script, using ${(0, import_chunk_SKRR5WT4.green)(
189
- `--stdin`
190
- )} or ${(0, import_chunk_SKRR5WT4.green)(`--file`)}.
191
- The input parameters are mutually exclusive, only 1 of each (datasource & script) must be provided.
192
-
193
- The output of the command is connector-specific, and is not meant for returning data, but only to report success or failure.
194
-
195
- On SQL databases, this command takes as input a SQL script.
196
- The whole script will be sent as a single command to the database.
197
-
198
- ${(0, import_chunk_SKRR5WT4.italic)(`This command is currently not supported on MongoDB.`)}
199
-
200
- ${helpOptions}
201
- ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
202
-
203
- Execute the content of a SQL script file to the datasource URL taken from the schema
204
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute
205
- --file ./script.sql \\
206
- --schema schema.prisma
207
-
208
- Execute the SQL script from stdin to the datasource URL specified via the \`DATABASE_URL\` environment variable
209
- ${(0, import_chunk_SKRR5WT4.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
210
- prisma db execute \\
211
- --stdin \\
212
- --url="$DATABASE_URL"
213
-
214
- Like previous example, but exposing the datasource url credentials to your terminal history
215
- ${(0, import_chunk_SKRR5WT4.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
216
- prisma db execute \\
217
- --stdin \\
218
- --url="mysql://root:root@localhost/mydb"
219
- `));
220
- var DbExecute = _DbExecute;