@prisma/migrate 6.6.0-dev.7 → 6.6.0-dev.71

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 (150) hide show
  1. package/dist/CLI.js +3 -3
  2. package/dist/Migrate.js +8 -6
  3. package/dist/SchemaEngine.js +5 -5
  4. package/dist/bin.js +47 -46
  5. package/dist/chunk-23DZXSTI.js +62 -0
  6. package/dist/{chunk-WWAWV7DQ.js → chunk-2ESYSVXG.js} +3 -27
  7. package/dist/{chunk-LKTTJWFT.js → chunk-2R6DII47.js} +5 -5
  8. package/dist/chunk-33LPBNDX.js +1399 -0
  9. package/dist/{chunk-V3ZMNXZC.js → chunk-5LKIRKDL.js} +307 -382
  10. package/dist/{chunk-IR55GBON.js → chunk-5LTDMS3H.js} +18 -18
  11. package/dist/{chunk-LOGAFLCN.js → chunk-5R44VVVX.js} +29 -29
  12. package/dist/{chunk-Q3ZLC44N.js → chunk-63X7FE2R.js} +57 -66
  13. package/dist/{chunk-DJMFXNR4.js → chunk-74LUB4XX.js} +56 -57
  14. package/dist/{chunk-N4XTKFY6.js → chunk-7RM467G7.js} +39 -38
  15. package/dist/{chunk-RP2N6UXA.js → chunk-AI6DH66U.js} +6 -6
  16. package/dist/{chunk-A6PMXMMT.js → chunk-AUGZZ6RT.js} +105 -13
  17. package/dist/{chunk-G2XUUMKH.js → chunk-B4SUSDC2.js} +31 -39
  18. package/dist/{chunk-ZOEKRXDP.js → chunk-D2DGSPW6.js} +29 -55
  19. package/dist/{chunk-W2SZNLK4.js → chunk-EJG7GKM7.js} +37 -39
  20. package/dist/{chunk-5PSO7BDO.js → chunk-EJUXYFV3.js} +15 -15
  21. package/dist/{chunk-HCBZB4XC.js → chunk-FFPSJTA6.js} +53 -52
  22. package/dist/{chunk-P6I3Y7KI.js → chunk-FITBCODR.js} +371 -530
  23. package/dist/{chunk-N3KYWSX2.js → chunk-FZGPSDP7.js} +55 -49
  24. package/dist/{chunk-MCWCB2AX.js → chunk-IINN7QUV.js} +170 -643
  25. package/dist/{chunk-3GHGKOL4.js → chunk-KJGJMCHL.js} +370 -529
  26. package/dist/{chunk-255BRND3.js → chunk-KRQEFTDT.js} +6 -6
  27. package/dist/{chunk-VVKOFN3Y.js → chunk-LLO7YF56.js} +44 -46
  28. package/dist/{chunk-VZ23KD5C.js → chunk-NGQA5JTN.js} +8 -10
  29. package/dist/{chunk-MKK3GSDF.js → chunk-NIKXBMZL.js} +5 -5
  30. package/dist/{chunk-GG54LOYV.js → chunk-O6RQXRWU.js} +45 -44
  31. package/dist/{chunk-MATFO4ZW.js → chunk-OEWQACEH.js} +38 -39
  32. package/dist/{chunk-EGPJABTW.js → chunk-QVMYNWAN.js} +257 -103
  33. package/dist/{chunk-V5TUSOJX.js → chunk-SQKGZVG3.js} +45 -45
  34. package/dist/{chunk-CQZFVAXC.js → chunk-TN7JMNXD.js} +42 -41
  35. package/dist/chunk-URKH6SE2.js +479 -0
  36. package/dist/chunk-V6PVGSDJ.js +76 -0
  37. package/dist/{chunk-DLLXDCI2.js → chunk-VAJ4VX67.js} +5 -6
  38. package/dist/{chunk-OCQGHQED.js → chunk-YBX7R3MT.js} +12 -12
  39. package/dist/{chunk-KS7IEA6Z.js → chunk-YGBJA7QJ.js} +50 -52
  40. package/dist/{chunk-WI2A2TQE.js → chunk-ZJ4IDCRR.js} +90 -91
  41. package/dist/chunk-ZLHWX5PJ.js +883 -0
  42. package/dist/commands/DbCommand.js +3 -3
  43. package/dist/commands/DbDrop.js +4 -5
  44. package/dist/commands/DbExecute.js +9 -7
  45. package/dist/commands/DbPull.js +11 -10
  46. package/dist/commands/DbPush.js +10 -9
  47. package/dist/commands/DbSeed.js +4 -5
  48. package/dist/commands/MigrateCommand.js +3 -3
  49. package/dist/commands/MigrateDeploy.js +12 -11
  50. package/dist/commands/MigrateDev.js +14 -13
  51. package/dist/commands/MigrateDiff.js +12 -10
  52. package/dist/commands/MigrateReset.js +13 -12
  53. package/dist/commands/MigrateResolve.js +10 -9
  54. package/dist/commands/MigrateStatus.js +10 -9
  55. package/dist/index.js +50 -51
  56. package/dist/internals/src/Generator.d.ts +23 -5
  57. package/dist/internals/src/cli/checkUnsupportedDataProxy.d.ts +12 -17
  58. package/dist/internals/src/cli/directoryConfig.d.ts +7 -0
  59. package/dist/internals/src/cli/getSchema.d.ts +3 -28
  60. package/dist/internals/src/cli/hashes.d.ts +1 -2
  61. package/dist/internals/src/cli/schemaContext.d.ts +59 -0
  62. package/dist/internals/src/client/getClientEngineType.d.ts +1 -1
  63. package/dist/internals/src/convertCredentials.d.ts +1 -1
  64. package/dist/internals/src/engine-commands/getConfig.d.ts +1 -5
  65. package/dist/internals/src/engine-commands/getDmmf.d.ts +3 -6
  66. package/dist/internals/src/engine-commands/lintSchema.d.ts +1 -1
  67. package/dist/internals/src/errorReporting.d.ts +0 -1
  68. package/dist/internals/src/get-generators/getGenerators.d.ts +22 -9
  69. package/dist/internals/src/get-generators/utils/binaryTypeToEngineType.d.ts +1 -1
  70. package/dist/internals/src/get-generators/utils/engineTypeToBinaryType.d.ts +1 -1
  71. package/dist/internals/src/get-generators/utils/fixBinaryTargets.d.ts +1 -1
  72. package/dist/internals/src/get-generators/utils/getBinaryPathsByVersion.d.ts +1 -1
  73. package/dist/internals/src/get-generators/utils/getEngineVersionForGenerator.d.ts +1 -1
  74. package/dist/internals/src/get-generators/utils/printGeneratorConfig.d.ts +1 -1
  75. package/dist/internals/src/index.d.ts +7 -7
  76. package/dist/internals/src/migrateTypes.d.ts +63 -0
  77. package/dist/internals/src/panic.d.ts +1 -4
  78. package/dist/internals/src/resolvePkg.d.ts +7 -0
  79. package/dist/internals/src/types.d.ts +1 -1
  80. package/dist/internals/src/utils/extractPreviewFeatures.d.ts +2 -2
  81. package/dist/internals/src/utils/getEnvPaths.d.ts +1 -1
  82. package/dist/internals/src/utils/parseEnvValue.d.ts +1 -1
  83. package/dist/internals/src/utils/schemaFileInput.d.ts +0 -4
  84. package/dist/internals/src/utils/toSchemasContainer.d.ts +2 -3
  85. package/dist/migrate/src/Migrate.d.ts +7 -5
  86. package/dist/migrate/src/SchemaEngine.d.ts +5 -9
  87. package/dist/migrate/src/index.d.ts +0 -1
  88. package/dist/migrate/src/types.d.ts +14 -10
  89. package/dist/migrate/src/utils/createMigration.d.ts +21 -0
  90. package/dist/migrate/src/utils/ensureDatabaseExists.d.ts +4 -6
  91. package/dist/migrate/src/utils/introspectSql.d.ts +3 -2
  92. package/dist/migrate/src/utils/listMigrations.d.ts +9 -0
  93. package/dist/migrate/src/utils/printDatasources.d.ts +1 -1
  94. package/dist/migrate/src/utils/seed.d.ts +0 -2
  95. package/dist/migrate/src/views/handleViewsIO.d.ts +2 -2
  96. package/dist/{multipart-parser-54WEFGGN-NLZG56KM.js → multipart-parser-ASKQAOL4-WZ47HU6G.js} +92 -125
  97. package/dist/{multipart-parser-NDLECNMN.js → multipart-parser-QCI3Y5IB.js} +66 -68
  98. package/dist/types.js +1 -1
  99. package/dist/{typescript-WN4QH2CP.js → typescript-2LKASCMC.js} +33 -33
  100. package/dist/{typescript-AILDXN3I.js → typescript-H3AVJ6KX.js} +32 -32
  101. package/dist/utils/byline.js +1 -1
  102. package/dist/utils/captureStdout.js +3 -3
  103. package/dist/utils/countModelsAndTypes.js +1 -1
  104. package/dist/utils/{getSchemaPathAndPrint.js → createMigration.js} +8 -8
  105. package/dist/utils/customColors.js +1 -1
  106. package/dist/utils/ensureDatabaseExists.js +7 -7
  107. package/dist/utils/errors.js +1 -1
  108. package/dist/utils/flagErrors.js +1 -1
  109. package/dist/utils/getDatabaseVersionSafe.js +5 -5
  110. package/dist/utils/handleEvaluateDataloss.js +1 -1
  111. package/dist/utils/introspectSql.js +5 -5
  112. package/dist/utils/isSchemaEmpty.js +1 -1
  113. package/dist/utils/listMigrations.js +25 -0
  114. package/dist/utils/now.js +1 -1
  115. package/dist/utils/printDatasource.js +1 -1
  116. package/dist/utils/printDatasources.js +5 -5
  117. package/dist/utils/printFiles.js +5 -5
  118. package/dist/utils/printIntrospectedSchema.js +1 -1
  119. package/dist/utils/printMigrationId.js +1 -1
  120. package/dist/utils/promptForMigrationName.js +3 -3
  121. package/dist/utils/removeSchemaFiles.js +1 -1
  122. package/dist/utils/replaceOrAddDatasource.js +1 -1
  123. package/dist/utils/replaceOrAddDatasource.test.js +1 -1
  124. package/dist/utils/saveSchemaFiles.js +1 -1
  125. package/dist/utils/seed.js +4 -7
  126. package/dist/utils/setupCockroach.js +3 -3
  127. package/dist/utils/setupMSSQL.js +1478 -707
  128. package/dist/utils/setupMongo.js +553 -552
  129. package/dist/utils/setupMysql.js +508 -563
  130. package/dist/utils/setupPostgres.js +3 -3
  131. package/dist/utils/spinner.js +4 -3
  132. package/dist/utils/test-handlePanic.js +1 -30
  133. package/dist/utils/unixSocket.js +1 -1
  134. package/dist/views/handleViewsIO.js +3 -3
  135. package/package.json +11 -11
  136. package/dist/chunk-GKDFIHM2.js +0 -45
  137. package/dist/chunk-J46BJQHT.js +0 -268
  138. package/dist/chunk-KOF4LGTS.js +0 -1817
  139. package/dist/chunk-YYPMC5FN.js +0 -1407
  140. package/dist/internals/src/get-generators/generatorResolvers/generatorResolvers.d.ts +0 -15
  141. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.d.ts +0 -6
  142. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.d.ts +0 -9
  143. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.d.ts +0 -8
  144. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.d.ts +0 -6
  145. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.d.ts +0 -1
  146. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.d.ts +0 -20
  147. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.d.ts +0 -7
  148. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.d.ts +0 -20
  149. package/dist/internals/src/get-generators/utils/check-feature-flags/checkFeatureFlags.d.ts +0 -8
  150. 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_D2DGSPW6_exports = {};
30
+ __export(chunk_D2DGSPW6_exports, {
31
31
  EngineError: () => EngineError,
32
32
  SchemaEngine: () => SchemaEngine
33
33
  });
34
- module.exports = __toCommonJS(chunk_ZOEKRXDP_exports);
35
- var import_chunk_MATFO4ZW = require("./chunk-MATFO4ZW.js");
34
+ module.exports = __toCommonJS(chunk_D2DGSPW6_exports);
35
+ var import_chunk_OEWQACEH = require("./chunk-OEWQACEH.js");
36
36
  var import_chunk_L6KOIJJ5 = require("./chunk-L6KOIJJ5.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,28 +42,32 @@ 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
53
  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;
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
+ latestSchema;
67
+ // `isRunning` is set to true when the engine is initialized, and set to false when the engine is stopped
68
+ isRunning = false;
69
+ constructor({ debug = false, schemaContext, enabledPreviewFeatures }) {
70
+ this.schemaContext = schemaContext;
69
71
  if (debug) {
70
72
  import_debug.default.enable("SchemaEngine*");
71
73
  }
@@ -160,6 +162,7 @@ var SchemaEngine = class {
160
162
  schema,
161
163
  force = false,
162
164
  baseDirectoryPath,
165
+ viewsDirectoryPath,
163
166
  compositeTypeDepth = -1,
164
167
  // cannot be undefined
165
168
  namespaces
@@ -171,8 +174,7 @@ var SchemaEngine = class {
171
174
  );
172
175
  const { views } = introspectResult;
173
176
  if (views) {
174
- const schemaPath = this.schemaPath ?? import_node_path.default.join(process.cwd(), "prisma");
175
- await (0, import_chunk_MATFO4ZW.handleViewsIO)({ views, schemaPath });
177
+ await (0, import_chunk_OEWQACEH.handleViewsIO)({ views, viewsDirectoryPath });
176
178
  }
177
179
  return introspectResult;
178
180
  } finally {
@@ -191,12 +193,6 @@ var SchemaEngine = class {
191
193
  migrateDiff(args) {
192
194
  return this.runCommand(this.getRPCPayload("diff", args));
193
195
  }
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
196
  /**
201
197
  * Mark a migration as applied in the migrations table.
202
198
  * There are two possible outcomes:
@@ -297,11 +293,9 @@ var SchemaEngine = class {
297
293
  debugRpc("starting Schema engine with binary: " + binaryPath);
298
294
  const args = [];
299
295
  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]);
296
+ if (this.schemaContext) {
297
+ projectDir = this.schemaContext.primaryDatasourceDirectory;
298
+ const schemaArgs = this.schemaContext.schemaFiles.flatMap(([path]) => ["-d", path]);
305
299
  args.push(...schemaArgs);
306
300
  }
307
301
  if (this.enabledPreviewFeatures && Array.isArray(this.enabledPreviewFeatures) && this.enabledPreviewFeatures.length > 0) {
@@ -335,18 +329,7 @@ var SchemaEngine = class {
335
329
  const stackTrace = `[EXIT_PANIC]
336
330
  ${processMessages}
337
331
  ${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
- );
332
+ exitWithErr(new import_internals.RustPanic(serializePanic(engineMessage), stackTrace, this.lastRequest, import_internals.ErrorArea.LIFT_CLI));
350
333
  };
351
334
  switch (code) {
352
335
  case import_internals.SchemaEngineExitCode.Success:
@@ -412,16 +395,7 @@ ${this.lastError?.backtrace ?? ""}`;
412
395
  ${response.error.data?.message ?? ""}`;
413
396
  reject(
414
397
  // 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
- )
398
+ new import_internals.RustPanic(message, stackTrace, this.lastRequest, import_internals.ErrorArea.LIFT_CLI)
425
399
  );
426
400
  } else if (response.error.data?.message) {
427
401
  let message = `${(0, import_chunk_SKRR5WT4.red)((0, import_internals.relativizePathInPSLError)(response.error.data.message))}
@@ -16,52 +16,21 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_W2SZNLK4_exports = {};
20
- __export(chunk_W2SZNLK4_exports, {
19
+ var chunk_EJG7GKM7_exports = {};
20
+ __export(chunk_EJG7GKM7_exports, {
21
21
  DbCommand: () => DbCommand
22
22
  });
23
- module.exports = __toCommonJS(chunk_W2SZNLK4_exports);
23
+ module.exports = __toCommonJS(chunk_EJG7GKM7_exports);
24
24
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
25
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
26
25
  var import_internals = require("@prisma/internals");
27
- var _DbCommand = class _DbCommand2 {
26
+ var DbCommand = class _DbCommand {
28
27
  constructor(cmds) {
29
28
  this.cmds = cmds;
30
29
  }
31
30
  static new(cmds) {
32
- return new _DbCommand2(cmds);
31
+ return new _DbCommand(cmds);
33
32
  }
34
- async parse(argv, config) {
35
- const args = (0, import_internals.arg)(argv, {
36
- "--help": Boolean,
37
- "-h": "--help",
38
- "--config": String,
39
- "--preview-feature": Boolean,
40
- "--telemetry-information": String
41
- });
42
- if ((0, import_internals.isError)(args)) {
43
- return this.help(args.message);
44
- }
45
- if (args._.length === 0 || args["--help"]) {
46
- return this.help();
47
- }
48
- const cmd = this.cmds[args._[0]];
49
- if (cmd) {
50
- const argsForCmd = args["--preview-feature"] ? [...args._.slice(1), `--preview-feature`] : args._.slice(1);
51
- return cmd.parse(argsForCmd, config);
52
- }
53
- return (0, import_internals.unknownCommand)(_DbCommand2.help, args._[0]);
54
- }
55
- help(error) {
56
- if (error) {
57
- return new import_internals.HelpError(`
58
- ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
59
- ${_DbCommand2.help}`);
60
- }
61
- return _DbCommand2.help;
62
- }
63
- };
64
- (0, import_chunk_WWAWV7DQ.__publicField)(_DbCommand, "help", (0, import_internals.format)(`
33
+ static help = (0, import_internals.format)(`
65
34
  ${process.platform === "win32" ? "" : "\u{1F3CB}\uFE0F "}Manage your database schema and lifecycle during development.
66
35
 
67
36
  ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
@@ -93,5 +62,34 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
93
62
 
94
63
  Run \`prisma db execute\`
95
64
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute
96
- `));
97
- var DbCommand = _DbCommand;
65
+ `);
66
+ async parse(argv, config) {
67
+ const args = (0, import_internals.arg)(argv, {
68
+ "--help": Boolean,
69
+ "-h": "--help",
70
+ "--config": String,
71
+ "--preview-feature": Boolean,
72
+ "--telemetry-information": String
73
+ });
74
+ if ((0, import_internals.isError)(args)) {
75
+ return this.help(args.message);
76
+ }
77
+ if (args._.length === 0 || args["--help"]) {
78
+ return this.help();
79
+ }
80
+ const cmd = this.cmds[args._[0]];
81
+ if (cmd) {
82
+ const argsForCmd = args["--preview-feature"] ? [...args._.slice(1), `--preview-feature`] : args._.slice(1);
83
+ return cmd.parse(argsForCmd, config);
84
+ }
85
+ return (0, import_internals.unknownCommand)(_DbCommand.help, args._[0]);
86
+ }
87
+ help(error) {
88
+ if (error) {
89
+ return new import_internals.HelpError(`
90
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
91
+ ${_DbCommand.help}`);
92
+ }
93
+ return _DbCommand.help;
94
+ }
95
+ };
@@ -16,14 +16,14 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_5PSO7BDO_exports = {};
20
- __export(chunk_5PSO7BDO_exports, {
19
+ var chunk_EJUXYFV3_exports = {};
20
+ __export(chunk_EJUXYFV3_exports, {
21
21
  require_ms: () => require_ms,
22
22
  require_src: () => require_src
23
23
  });
24
- module.exports = __toCommonJS(chunk_5PSO7BDO_exports);
25
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
26
- var require_ms = (0, import_chunk_WWAWV7DQ.__commonJS)({
24
+ module.exports = __toCommonJS(chunk_EJUXYFV3_exports);
25
+ var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
26
+ var require_ms = (0, import_chunk_2ESYSVXG.__commonJS)({
27
27
  "../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports, module2) {
28
28
  "use strict";
29
29
  var s = 1e3;
@@ -138,7 +138,7 @@ var require_ms = (0, import_chunk_WWAWV7DQ.__commonJS)({
138
138
  }
139
139
  }
140
140
  });
141
- var require_common = (0, import_chunk_WWAWV7DQ.__commonJS)({
141
+ var require_common = (0, import_chunk_2ESYSVXG.__commonJS)({
142
142
  "../../node_modules/.pnpm/debug@4.4.0/node_modules/debug/src/common.js"(exports, module2) {
143
143
  "use strict";
144
144
  function setup(env) {
@@ -314,7 +314,7 @@ var require_common = (0, import_chunk_WWAWV7DQ.__commonJS)({
314
314
  module2.exports = setup;
315
315
  }
316
316
  });
317
- var require_browser = (0, import_chunk_WWAWV7DQ.__commonJS)({
317
+ var require_browser = (0, import_chunk_2ESYSVXG.__commonJS)({
318
318
  "../../node_modules/.pnpm/debug@4.4.0/node_modules/debug/src/browser.js"(exports, module2) {
319
319
  "use strict";
320
320
  exports.formatArgs = formatArgs;
@@ -483,7 +483,7 @@ var require_browser = (0, import_chunk_WWAWV7DQ.__commonJS)({
483
483
  };
484
484
  }
485
485
  });
486
- var require_has_flag = (0, import_chunk_WWAWV7DQ.__commonJS)({
486
+ var require_has_flag = (0, import_chunk_2ESYSVXG.__commonJS)({
487
487
  "../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module2) {
488
488
  "use strict";
489
489
  module2.exports = (flag, argv = process.argv) => {
@@ -494,11 +494,11 @@ var require_has_flag = (0, import_chunk_WWAWV7DQ.__commonJS)({
494
494
  };
495
495
  }
496
496
  });
497
- var require_supports_color = (0, import_chunk_WWAWV7DQ.__commonJS)({
497
+ var require_supports_color = (0, import_chunk_2ESYSVXG.__commonJS)({
498
498
  "../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js"(exports, module2) {
499
499
  "use strict";
500
- var os = (0, import_chunk_WWAWV7DQ.__require)("os");
501
- var tty = (0, import_chunk_WWAWV7DQ.__require)("tty");
500
+ var os = (0, import_chunk_2ESYSVXG.__require)("os");
501
+ var tty = (0, import_chunk_2ESYSVXG.__require)("tty");
502
502
  var hasFlag = require_has_flag();
503
503
  var { env } = process;
504
504
  var flagForceColor;
@@ -606,11 +606,11 @@ var require_supports_color = (0, import_chunk_WWAWV7DQ.__commonJS)({
606
606
  };
607
607
  }
608
608
  });
609
- var require_node = (0, import_chunk_WWAWV7DQ.__commonJS)({
609
+ var require_node = (0, import_chunk_2ESYSVXG.__commonJS)({
610
610
  "../../node_modules/.pnpm/debug@4.4.0/node_modules/debug/src/node.js"(exports, module2) {
611
611
  "use strict";
612
- var tty = (0, import_chunk_WWAWV7DQ.__require)("tty");
613
- var util = (0, import_chunk_WWAWV7DQ.__require)("util");
612
+ var tty = (0, import_chunk_2ESYSVXG.__require)("tty");
613
+ var util = (0, import_chunk_2ESYSVXG.__require)("util");
614
614
  exports.init = init;
615
615
  exports.log = log;
616
616
  exports.formatArgs = formatArgs;
@@ -779,7 +779,7 @@ var require_node = (0, import_chunk_WWAWV7DQ.__commonJS)({
779
779
  };
780
780
  }
781
781
  });
782
- var require_src = (0, import_chunk_WWAWV7DQ.__commonJS)({
782
+ var require_src = (0, import_chunk_2ESYSVXG.__commonJS)({
783
783
  "../../node_modules/.pnpm/debug@4.4.0/node_modules/debug/src/index.js"(exports, module2) {
784
784
  "use strict";
785
785
  if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
@@ -16,22 +16,53 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_HCBZB4XC_exports = {};
20
- __export(chunk_HCBZB4XC_exports, {
19
+ var chunk_FFPSJTA6_exports = {};
20
+ __export(chunk_FFPSJTA6_exports, {
21
21
  MigrateResolve: () => MigrateResolve
22
22
  });
23
- module.exports = __toCommonJS(chunk_HCBZB4XC_exports);
24
- var import_chunk_KOF4LGTS = require("./chunk-KOF4LGTS.js");
25
- var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
23
+ module.exports = __toCommonJS(chunk_FFPSJTA6_exports);
24
+ var import_chunk_ZLHWX5PJ = require("./chunk-ZLHWX5PJ.js");
26
25
  var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
27
- var import_chunk_DJMFXNR4 = require("./chunk-DJMFXNR4.js");
26
+ var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
28
27
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
29
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
30
28
  var import_internals = require("@prisma/internals");
31
- var _MigrateResolve = class _MigrateResolve2 {
29
+ var MigrateResolve = class _MigrateResolve {
32
30
  static new() {
33
- return new _MigrateResolve2();
31
+ return new _MigrateResolve();
34
32
  }
33
+ static help = (0, import_internals.format)(`
34
+ Resolve issues with database migrations in deployment databases:
35
+ - recover from failed migrations
36
+ - baseline databases when starting to use Prisma Migrate on existing databases
37
+ - reconcile hotfixes done manually on databases with your migration history
38
+
39
+ Run "prisma migrate status" to identify if you need to use resolve.
40
+
41
+ Read more about resolving migration history issues: ${(0, import_internals.link)("https://pris.ly/d/migrate-resolve")}
42
+
43
+ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
44
+
45
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve [options]
46
+
47
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
48
+
49
+ -h, --help Display this help message
50
+ --config Custom path to your Prisma config file
51
+ --schema Custom path to your Prisma schema
52
+ --applied Record a specific migration as applied
53
+ --rolled-back Record a specific migration as rolled back
54
+
55
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
56
+
57
+ Update migrations table, recording a specific migration as applied
58
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --applied 20201231000000_add_users_table
59
+
60
+ Update migrations table, recording a specific migration as rolled back
61
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --rolled-back 20201231000000_add_users_table
62
+
63
+ Specify a schema
64
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --rolled-back 20201231000000_add_users_table --schema=./schema.prisma
65
+ `);
35
66
  async parse(argv, config) {
36
67
  const args = (0, import_internals.arg)(
37
68
  argv,
@@ -49,13 +80,17 @@ var _MigrateResolve = class _MigrateResolve2 {
49
80
  if ((0, import_internals.isError)(args)) {
50
81
  return this.help(args.message);
51
82
  }
52
- await (0, import_internals.checkUnsupportedDataProxy)("migrate resolve", args, config.schema, true);
53
83
  if (args["--help"]) {
54
84
  return this.help();
55
85
  }
56
86
  await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
57
- const { schemaPath } = await (0, import_chunk_GKDFIHM2.getSchemaPathAndPrint)(args["--schema"], config.schema);
58
- (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: await (0, import_chunk_DJMFXNR4.getDatasourceInfo)({ schemaPath }) });
87
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
88
+ schemaPathFromArg: args["--schema"],
89
+ schemaPathFromConfig: config.schema
90
+ });
91
+ const { migrationsDirPath } = (0, import_internals.inferDirectoryConfig)(schemaContext);
92
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate resolve", schemaContext });
93
+ (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource) });
59
94
  if (!args["--applied"] && !args["--rolled-back"]) {
60
95
  throw new Error(
61
96
  `--applied or --rolled-back must be part of the command like:
@@ -73,8 +108,8 @@ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_in
73
108
  )}`
74
109
  );
75
110
  }
76
- await (0, import_chunk_DJMFXNR4.ensureCanConnectToDatabase)(schemaPath);
77
- const migrate = new import_chunk_KOF4LGTS.Migrate(schemaPath);
111
+ await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
112
+ const migrate = new import_chunk_ZLHWX5PJ.Migrate(schemaContext, migrationsDirPath);
78
113
  try {
79
114
  await migrate.markMigrationApplied({
80
115
  migrationId: args["--applied"]
@@ -94,8 +129,8 @@ Migration ${args["--applied"]} marked as applied.
94
129
  )}`
95
130
  );
96
131
  }
97
- await (0, import_chunk_DJMFXNR4.ensureCanConnectToDatabase)(schemaPath);
98
- const migrate = new import_chunk_KOF4LGTS.Migrate(schemaPath);
132
+ await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
133
+ const migrate = new import_chunk_ZLHWX5PJ.Migrate(schemaContext, migrationsDirPath);
99
134
  try {
100
135
  await migrate.markMigrationRolledBack({
101
136
  migrationId: args["--rolled-back"]
@@ -113,42 +148,8 @@ Migration ${args["--rolled-back"]} marked as rolled back.
113
148
  if (error) {
114
149
  return new import_internals.HelpError(`
115
150
  ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
116
- ${_MigrateResolve2.help}`);
151
+ ${_MigrateResolve.help}`);
117
152
  }
118
- return _MigrateResolve2.help;
153
+ return _MigrateResolve.help;
119
154
  }
120
155
  };
121
- (0, import_chunk_WWAWV7DQ.__publicField)(_MigrateResolve, "help", (0, import_internals.format)(`
122
- Resolve issues with database migrations in deployment databases:
123
- - recover from failed migrations
124
- - baseline databases when starting to use Prisma Migrate on existing databases
125
- - reconcile hotfixes done manually on databases with your migration history
126
-
127
- Run "prisma migrate status" to identify if you need to use resolve.
128
-
129
- Read more about resolving migration history issues: ${(0, import_internals.link)("https://pris.ly/d/migrate-resolve")}
130
-
131
- ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
132
-
133
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve [options]
134
-
135
- ${(0, import_chunk_SKRR5WT4.bold)("Options")}
136
-
137
- -h, --help Display this help message
138
- --config Custom path to your Prisma config file
139
- --schema Custom path to your Prisma schema
140
- --applied Record a specific migration as applied
141
- --rolled-back Record a specific migration as rolled back
142
-
143
- ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
144
-
145
- Update migrations table, recording a specific migration as applied
146
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --applied 20201231000000_add_users_table
147
-
148
- Update migrations table, recording a specific migration as rolled back
149
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --rolled-back 20201231000000_add_users_table
150
-
151
- Specify a schema
152
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --rolled-back 20201231000000_add_users_table --schema=./schema.prisma
153
- `));
154
- var MigrateResolve = _MigrateResolve;