@prisma/migrate 6.6.0-dev.8 → 6.6.0-dev.80

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-N3KYWSX2.js → chunk-FZGPSDP7.js} +55 -49
  23. package/dist/{chunk-MCWCB2AX.js → chunk-IINN7QUV.js} +170 -643
  24. package/dist/{chunk-255BRND3.js → chunk-KRQEFTDT.js} +6 -6
  25. package/dist/{chunk-VVKOFN3Y.js → chunk-LLO7YF56.js} +44 -46
  26. package/dist/{chunk-VZ23KD5C.js → chunk-NGQA5JTN.js} +8 -10
  27. package/dist/{chunk-MKK3GSDF.js → chunk-NIKXBMZL.js} +5 -5
  28. package/dist/{chunk-GG54LOYV.js → chunk-O6RQXRWU.js} +45 -44
  29. package/dist/{chunk-MATFO4ZW.js → chunk-OEWQACEH.js} +38 -39
  30. package/dist/{chunk-3GHGKOL4.js → chunk-OPKM35BD.js} +370 -529
  31. package/dist/{chunk-EGPJABTW.js → chunk-QVMYNWAN.js} +257 -103
  32. package/dist/{chunk-V5TUSOJX.js → chunk-SQKGZVG3.js} +45 -45
  33. package/dist/{chunk-CQZFVAXC.js → chunk-TN7JMNXD.js} +42 -41
  34. package/dist/chunk-URKH6SE2.js +479 -0
  35. package/dist/chunk-V6PVGSDJ.js +76 -0
  36. package/dist/{chunk-DLLXDCI2.js → chunk-VAJ4VX67.js} +5 -6
  37. package/dist/{chunk-KC5MOJ5I.js → chunk-WU6Z6FMF.js} +371 -530
  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
@@ -16,15 +16,15 @@ 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_OCQGHQED_exports = {};
20
- __export(chunk_OCQGHQED_exports, {
19
+ var chunk_YBX7R3MT_exports = {};
20
+ __export(chunk_YBX7R3MT_exports, {
21
21
  getMigrationName: () => getMigrationName
22
22
  });
23
- module.exports = __toCommonJS(chunk_OCQGHQED_exports);
24
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
23
+ module.exports = __toCommonJS(chunk_YBX7R3MT_exports);
24
+ var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
25
25
  var import_internals = require("@prisma/internals");
26
26
  var import_prompts = require("prompts");
27
- var require_escape_string_regexp = (0, import_chunk_WWAWV7DQ.__commonJS)({
27
+ var require_escape_string_regexp = (0, import_chunk_2ESYSVXG.__commonJS)({
28
28
  "../../node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js"(exports, module2) {
29
29
  "use strict";
30
30
  module2.exports = (string) => {
@@ -35,7 +35,7 @@ var require_escape_string_regexp = (0, import_chunk_WWAWV7DQ.__commonJS)({
35
35
  };
36
36
  }
37
37
  });
38
- var require_lodash = (0, import_chunk_WWAWV7DQ.__commonJS)({
38
+ var require_lodash = (0, import_chunk_2ESYSVXG.__commonJS)({
39
39
  "../../node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.js"(exports, module2) {
40
40
  "use strict";
41
41
  var INFINITY = 1 / 0;
@@ -279,7 +279,7 @@ var require_lodash = (0, import_chunk_WWAWV7DQ.__commonJS)({
279
279
  module2.exports = deburr;
280
280
  }
281
281
  });
282
- var require_escape_string_regexp2 = (0, import_chunk_WWAWV7DQ.__commonJS)({
282
+ var require_escape_string_regexp2 = (0, import_chunk_2ESYSVXG.__commonJS)({
283
283
  "../../node_modules/.pnpm/escape-string-regexp@2.0.0/node_modules/escape-string-regexp/index.js"(exports, module2) {
284
284
  "use strict";
285
285
  var matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
@@ -291,7 +291,7 @@ var require_escape_string_regexp2 = (0, import_chunk_WWAWV7DQ.__commonJS)({
291
291
  };
292
292
  }
293
293
  });
294
- var require_replacements = (0, import_chunk_WWAWV7DQ.__commonJS)({
294
+ var require_replacements = (0, import_chunk_2ESYSVXG.__commonJS)({
295
295
  "../../node_modules/.pnpm/@sindresorhus+transliterate@0.1.2/node_modules/@sindresorhus/transliterate/replacements.js"(exports, module2) {
296
296
  "use strict";
297
297
  module2.exports = [
@@ -1067,7 +1067,7 @@ var require_replacements = (0, import_chunk_WWAWV7DQ.__commonJS)({
1067
1067
  ];
1068
1068
  }
1069
1069
  });
1070
- var require_transliterate = (0, import_chunk_WWAWV7DQ.__commonJS)({
1070
+ var require_transliterate = (0, import_chunk_2ESYSVXG.__commonJS)({
1071
1071
  "../../node_modules/.pnpm/@sindresorhus+transliterate@0.1.2/node_modules/@sindresorhus/transliterate/index.js"(exports, module2) {
1072
1072
  "use strict";
1073
1073
  var deburr = require_lodash();
@@ -1098,7 +1098,7 @@ var require_transliterate = (0, import_chunk_WWAWV7DQ.__commonJS)({
1098
1098
  };
1099
1099
  }
1100
1100
  });
1101
- var require_overridable_replacements = (0, import_chunk_WWAWV7DQ.__commonJS)({
1101
+ var require_overridable_replacements = (0, import_chunk_2ESYSVXG.__commonJS)({
1102
1102
  "../../node_modules/.pnpm/@sindresorhus+slugify@1.1.2/node_modules/@sindresorhus/slugify/overridable-replacements.js"(exports, module2) {
1103
1103
  "use strict";
1104
1104
  module2.exports = [
@@ -1108,7 +1108,7 @@ var require_overridable_replacements = (0, import_chunk_WWAWV7DQ.__commonJS)({
1108
1108
  ];
1109
1109
  }
1110
1110
  });
1111
- var require_slugify = (0, import_chunk_WWAWV7DQ.__commonJS)({
1111
+ var require_slugify = (0, import_chunk_2ESYSVXG.__commonJS)({
1112
1112
  "../../node_modules/.pnpm/@sindresorhus+slugify@1.1.2/node_modules/@sindresorhus/slugify/index.js"(exports, module2) {
1113
1113
  "use strict";
1114
1114
  var escapeStringRegexp = require_escape_string_regexp();
@@ -1183,7 +1183,7 @@ var require_slugify = (0, import_chunk_WWAWV7DQ.__commonJS)({
1183
1183
  module2.exports.counter = counter;
1184
1184
  }
1185
1185
  });
1186
- var import_slugify = (0, import_chunk_WWAWV7DQ.__toESM)(require_slugify());
1186
+ var import_slugify = (0, import_chunk_2ESYSVXG.__toESM)(require_slugify());
1187
1187
  async function getMigrationName(name) {
1188
1188
  const maxMigrationNameLength = 200;
1189
1189
  if (name) {
@@ -26,26 +26,51 @@ 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_KS7IEA6Z_exports = {};
30
- __export(chunk_KS7IEA6Z_exports, {
29
+ var chunk_YGBJA7QJ_exports = {};
30
+ __export(chunk_YGBJA7QJ_exports, {
31
31
  MigrateReset: () => MigrateReset
32
32
  });
33
- module.exports = __toCommonJS(chunk_KS7IEA6Z_exports);
34
- var import_chunk_V3ZMNXZC = require("./chunk-V3ZMNXZC.js");
35
- var import_chunk_255BRND3 = require("./chunk-255BRND3.js");
36
- var import_chunk_KOF4LGTS = require("./chunk-KOF4LGTS.js");
33
+ module.exports = __toCommonJS(chunk_YGBJA7QJ_exports);
34
+ var import_chunk_5LKIRKDL = require("./chunk-5LKIRKDL.js");
35
+ var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
36
+ var import_chunk_ZLHWX5PJ = require("./chunk-ZLHWX5PJ.js");
37
37
  var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
38
- var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
39
38
  var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
40
- var import_chunk_DJMFXNR4 = require("./chunk-DJMFXNR4.js");
39
+ var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
41
40
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
42
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
43
41
  var import_internals = require("@prisma/internals");
44
42
  var import_prompts = __toESM(require("prompts"));
45
- var _MigrateReset = class _MigrateReset2 {
43
+ var MigrateReset = class _MigrateReset {
46
44
  static new() {
47
- return new _MigrateReset2();
45
+ return new _MigrateReset();
48
46
  }
47
+ static help = (0, import_internals.format)(`
48
+ Reset your database and apply all migrations, all data will be lost
49
+
50
+ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
51
+
52
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate reset [options]
53
+
54
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
55
+
56
+ -h, --help Display this help message
57
+ --config Custom path to your Prisma config file
58
+ --schema Custom path to your Prisma schema
59
+ --skip-generate Skip triggering generators (e.g. Prisma Client)
60
+ --skip-seed Skip triggering seed
61
+ -f, --force Skip the confirmation prompt
62
+
63
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
64
+
65
+ Reset your database and apply all migrations, all data will be lost
66
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate reset
67
+
68
+ Specify a schema
69
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate reset --schema=./schema.prisma
70
+
71
+ Use --force to skip the confirmation prompt
72
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate reset --force
73
+ `);
49
74
  async parse(argv, config) {
50
75
  const args = (0, import_internals.arg)(argv, {
51
76
  "--help": Boolean,
@@ -61,15 +86,19 @@ var _MigrateReset = class _MigrateReset2 {
61
86
  if ((0, import_internals.isError)(args)) {
62
87
  return this.help(args.message);
63
88
  }
64
- await (0, import_internals.checkUnsupportedDataProxy)("migrate reset", args, config.schema, true);
65
89
  if (args["--help"]) {
66
90
  return this.help();
67
91
  }
68
92
  await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
69
- const { schemaPath } = await (0, import_chunk_GKDFIHM2.getSchemaPathAndPrint)(args["--schema"], config.schema);
70
- const datasourceInfo = await (0, import_chunk_DJMFXNR4.getDatasourceInfo)({ schemaPath });
93
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
94
+ schemaPathFromArg: args["--schema"],
95
+ schemaPathFromConfig: config.schema
96
+ });
97
+ const { migrationsDirPath } = (0, import_internals.inferDirectoryConfig)(schemaContext);
98
+ const datasourceInfo = (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource);
71
99
  (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo });
72
- const wasDbCreated = await (0, import_chunk_DJMFXNR4.ensureDatabaseExists)("create", schemaPath);
100
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate reset", schemaContext });
101
+ const wasDbCreated = await (0, import_chunk_74LUB4XX.ensureDatabaseExists)(schemaContext.primaryDatasource);
73
102
  if (wasDbCreated) {
74
103
  process.stdout.write("\n" + wasDbCreated + "\n");
75
104
  }
@@ -89,7 +118,7 @@ var _MigrateReset = class _MigrateReset2 {
89
118
  process.exit(130);
90
119
  }
91
120
  }
92
- const migrate = new import_chunk_KOF4LGTS.Migrate(schemaPath);
121
+ const migrate = new import_chunk_ZLHWX5PJ.Migrate(schemaContext, migrationsDirPath);
93
122
  let migrationIds;
94
123
  try {
95
124
  await migrate.reset();
@@ -108,7 +137,7 @@ var _MigrateReset = class _MigrateReset2 {
108
137
 
109
138
  The following migration(s) have been applied:
110
139
 
111
- ${(0, import_chunk_255BRND3.printFilesFromMigrationIds)("migrations", migrationIds, {
140
+ ${(0, import_chunk_KRQEFTDT.printFilesFromMigrationIds)("migrations", migrationIds, {
112
141
  "migration.sql": ""
113
142
  })}
114
143
  `
@@ -118,10 +147,10 @@ ${(0, import_chunk_255BRND3.printFilesFromMigrationIds)("migrations", migrationI
118
147
  await migrate.tryToRunGenerate(datasourceInfo);
119
148
  }
120
149
  if (!process.env.PRISMA_MIGRATE_SKIP_SEED && !args["--skip-seed"]) {
121
- const seedCommandFromPkgJson = await (0, import_chunk_V3ZMNXZC.getSeedCommandFromPackageJson)(process.cwd());
150
+ const seedCommandFromPkgJson = await (0, import_chunk_5LKIRKDL.getSeedCommandFromPackageJson)(process.cwd());
122
151
  if (seedCommandFromPkgJson) {
123
152
  process.stdout.write("\n");
124
- const successfulSeeding = await (0, import_chunk_V3ZMNXZC.executeSeedCommand)({ commandFromConfig: seedCommandFromPkgJson });
153
+ const successfulSeeding = await (0, import_chunk_5LKIRKDL.executeSeedCommand)({ commandFromConfig: seedCommandFromPkgJson });
125
154
  if (successfulSeeding) {
126
155
  process.stdout.write(`
127
156
  ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.
@@ -129,9 +158,6 @@ ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been ex
129
158
  } else {
130
159
  process.exit(1);
131
160
  }
132
- } else {
133
- const { schemaPath: schemaPath2 } = await (0, import_internals.getSchemaWithPath)(args["--schema"], config.schema);
134
- await (0, import_chunk_V3ZMNXZC.verifySeedConfigAndReturnMessage)(schemaPath2);
135
161
  }
136
162
  }
137
163
  return ``;
@@ -140,36 +166,8 @@ ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been ex
140
166
  if (error) {
141
167
  return new import_internals.HelpError(`
142
168
  ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
143
- ${_MigrateReset2.help}`);
169
+ ${_MigrateReset.help}`);
144
170
  }
145
- return _MigrateReset2.help;
171
+ return _MigrateReset.help;
146
172
  }
147
173
  };
148
- (0, import_chunk_WWAWV7DQ.__publicField)(_MigrateReset, "help", (0, import_internals.format)(`
149
- Reset your database and apply all migrations, all data will be lost
150
-
151
- ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
152
-
153
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate reset [options]
154
-
155
- ${(0, import_chunk_SKRR5WT4.bold)("Options")}
156
-
157
- -h, --help Display this help message
158
- --config Custom path to your Prisma config file
159
- --schema Custom path to your Prisma schema
160
- --skip-generate Skip triggering generators (e.g. Prisma Client)
161
- --skip-seed Skip triggering seed
162
- -f, --force Skip the confirmation prompt
163
-
164
- ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
165
-
166
- Reset your database and apply all migrations, all data will be lost
167
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate reset
168
-
169
- Specify a schema
170
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate reset --schema=./schema.prisma
171
-
172
- Use --force to skip the confirmation prompt
173
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate reset --force
174
- `));
175
- var MigrateReset = _MigrateReset;
@@ -26,37 +26,75 @@ 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_WI2A2TQE_exports = {};
30
- __export(chunk_WI2A2TQE_exports, {
29
+ var chunk_ZJ4IDCRR_exports = {};
30
+ __export(chunk_ZJ4IDCRR_exports, {
31
31
  DbPull: () => DbPull
32
32
  });
33
- module.exports = __toCommonJS(chunk_WI2A2TQE_exports);
34
- var import_chunk_MCWCB2AX = require("./chunk-MCWCB2AX.js");
33
+ module.exports = __toCommonJS(chunk_ZJ4IDCRR_exports);
34
+ var import_chunk_IINN7QUV = require("./chunk-IINN7QUV.js");
35
+ var import_chunk_RR6BKMNO = require("./chunk-RR6BKMNO.js");
35
36
  var import_chunk_RTGQXNX6 = require("./chunk-RTGQXNX6.js");
36
- var import_chunk_RP2N6UXA = require("./chunk-RP2N6UXA.js");
37
+ var import_chunk_AI6DH66U = require("./chunk-AI6DH66U.js");
37
38
  var import_chunk_AHJ2N6BJ = require("./chunk-AHJ2N6BJ.js");
38
39
  var import_chunk_JZ75RIMZ = require("./chunk-JZ75RIMZ.js");
39
- var import_chunk_RR6BKMNO = require("./chunk-RR6BKMNO.js");
40
40
  var import_chunk_JFKDSUIE = require("./chunk-JFKDSUIE.js");
41
41
  var import_chunk_LGYRZ6CV = require("./chunk-LGYRZ6CV.js");
42
- var import_chunk_ZOEKRXDP = require("./chunk-ZOEKRXDP.js");
43
- var import_chunk_MATFO4ZW = require("./chunk-MATFO4ZW.js");
42
+ var import_chunk_D2DGSPW6 = require("./chunk-D2DGSPW6.js");
43
+ var import_chunk_OEWQACEH = require("./chunk-OEWQACEH.js");
44
44
  var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
45
45
  var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
46
- var import_chunk_DJMFXNR4 = require("./chunk-DJMFXNR4.js");
46
+ var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
47
47
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
48
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
49
48
  var import_debug = __toESM(require("@prisma/debug"));
50
49
  var import_internals = require("@prisma/internals");
51
50
  var import_path = __toESM(require("path"));
52
51
  var debug = (0, import_debug.default)("prisma:db:pull");
53
- var _DbPull = class _DbPull2 {
52
+ var DbPull = class _DbPull {
54
53
  static new() {
55
- return new _DbPull2();
54
+ return new _DbPull();
56
55
  }
56
+ static help = (0, import_internals.format)(`
57
+ Pull the state from the database to the Prisma schema using introspection
58
+
59
+ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
60
+
61
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull [flags/options]
62
+
63
+ ${(0, import_chunk_SKRR5WT4.bold)("Flags")}
64
+
65
+ -h, --help Display this help message
66
+ --force Ignore current Prisma schema file
67
+ --print Print the introspected Prisma schema to stdout
68
+
69
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
70
+
71
+ --config Custom path to your Prisma config file
72
+ --schema Custom path to your Prisma schema
73
+ --composite-type-depth Specify the depth for introspecting composite types (e.g. Embedded Documents in MongoDB)
74
+ Number, default is -1 for infinite depth, 0 = off
75
+ --schemas Specify the database schemas to introspect. This overrides the schemas defined in the datasource block of your Prisma schema.
76
+ --local-d1 Generate a Prisma schema from a local Cloudflare D1 database
77
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
78
+
79
+ With an existing Prisma schema
80
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull
81
+
82
+ Or specify a Prisma schema path
83
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --schema=./schema.prisma
84
+
85
+ Instead of saving the result to the filesystem, you can also print it to stdout
86
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --print
87
+
88
+ Overwrite the current schema with the introspected schema instead of enriching it
89
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --force
90
+
91
+ Set composite types introspection depth to 2 levels
92
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --composite-type-depth=2
93
+
94
+ `);
57
95
  urlToDatasource(url, defaultProvider) {
58
96
  const provider = defaultProvider || (0, import_internals.protocolToConnectorType)(`${url.split(":")[0]}:`);
59
- return (0, import_chunk_RP2N6UXA.printDatasources)([
97
+ return (0, import_chunk_AI6DH66U.printDatasources)([
60
98
  {
61
99
  config: {},
62
100
  provider,
@@ -80,47 +118,49 @@ var _DbPull = class _DbPull2 {
80
118
  "--local-d1": Boolean
81
119
  // optional, only on cloudflare D1
82
120
  });
83
- const spinnerFactory = (0, import_chunk_MCWCB2AX.createSpinner)(!args["--print"]);
121
+ const spinnerFactory = (0, import_chunk_IINN7QUV.createSpinner)(!args["--print"]);
84
122
  if (args instanceof Error) {
85
123
  return this.help(args.message);
86
124
  }
87
- await (0, import_internals.checkUnsupportedDataProxy)("db pull", args, config.schema, !args["--url"]);
88
125
  if (args["--help"]) {
89
126
  return this.help();
90
127
  }
91
128
  const url = args["--url"];
92
- const schemaPathResult = await (0, import_internals.getSchemaWithPathOptional)(args["--schema"], config.schema);
93
- let schemaPath = schemaPathResult?.schemaPath ?? null;
94
- const rootDir = schemaPathResult?.schemaRootDir ?? process.cwd();
95
- debug("schemaPathResult", schemaPathResult);
96
- if (schemaPath && !args["--print"]) {
97
- process.stdout.write((0, import_chunk_SKRR5WT4.dim)(`Prisma schema loaded from ${import_path.default.relative(process.cwd(), schemaPath)}`) + "\n");
98
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
99
- (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: await (0, import_chunk_DJMFXNR4.getDatasourceInfo)({ schemaPath }) });
100
- } else {
101
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: false, config });
129
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: !args["--print"], config });
130
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
131
+ schemaPathFromArg: args["--schema"],
132
+ schemaPathFromConfig: config.schema,
133
+ printLoadMessage: false,
134
+ allowNull: true
135
+ });
136
+ (0, import_internals.checkUnsupportedDataProxy)({
137
+ cmd: "db pull",
138
+ schemaContext: schemaContext && !url ? schemaContext : void 0,
139
+ urls: [url]
140
+ });
141
+ if (schemaContext && !args["--print"]) {
142
+ process.stdout.write((0, import_chunk_SKRR5WT4.dim)(`Prisma schema loaded from ${schemaContext.loadedFromPathForLogMessages}`) + "\n");
143
+ (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext?.primaryDatasource) });
102
144
  }
103
145
  const fromD1 = Boolean(args["--local-d1"]);
104
- if (!url && !schemaPath && !fromD1) {
146
+ if (!url && !schemaContext && !fromD1) {
105
147
  throw new import_chunk_3WC4XD74.NoSchemaFoundError();
106
148
  }
107
- const { firstDatasource, schema, validationWarning } = await (0, import_chunk_MATFO4ZW.z)({ url, schemaPath, fromD1 }).when(
108
- (input) => input.schemaPath !== null,
149
+ const { firstDatasource, schema, validationWarning } = await (0, import_chunk_OEWQACEH.z)({ url, schemaContext, fromD1 }).when(
150
+ (input) => input.schemaContext !== null,
109
151
  async (input) => {
110
- const rawSchema = await (0, import_internals.getSchema)(input.schemaPath, config.schema);
111
- const engineConfig = await (0, import_internals.getConfig)({
112
- datamodel: rawSchema,
113
- ignoreEnvVarErrors: true
114
- });
115
- const previewFeatures = engineConfig.generators.find(({ name }) => name === "client")?.previewFeatures;
116
- const firstDatasource2 = engineConfig.datasources[0] ? engineConfig.datasources[0] : void 0;
152
+ const previewFeatures = input.schemaContext.generators.find(({ name }) => name === "client")?.previewFeatures;
153
+ const firstDatasource2 = input.schemaContext.primaryDatasource ? input.schemaContext.primaryDatasource : void 0;
117
154
  if (input.url) {
118
155
  let providerFromSchema = firstDatasource2?.provider;
119
156
  if (providerFromSchema === "postgres") {
120
157
  providerFromSchema = "postgresql";
121
158
  }
122
159
  const providerFromUrl = (0, import_internals.protocolToConnectorType)(`${input.url.split(":")[0]}:`);
123
- const schema2 = (0, import_chunk_RR6BKMNO.replaceOrAddDatasource)(this.urlToDatasource(input.url, providerFromSchema), rawSchema);
160
+ const schema2 = (0, import_chunk_RR6BKMNO.replaceOrAddDatasource)(
161
+ this.urlToDatasource(input.url, providerFromSchema),
162
+ input.schemaContext.schemaFiles
163
+ );
124
164
  if (providerFromSchema && providerFromUrl && providerFromSchema !== providerFromUrl && Boolean(providerFromSchema === "cockroachdb" && providerFromUrl === "postgresql") === false) {
125
165
  throw new Error(
126
166
  `The database provider found in --url (${providerFromUrl}) is different from the provider found in the Prisma schema (${providerFromSchema}).`
@@ -129,7 +169,7 @@ var _DbPull = class _DbPull2 {
129
169
  return { firstDatasource: firstDatasource2, schema: schema2, validationWarning: void 0 };
130
170
  } else if (input.fromD1) {
131
171
  const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--from-local-d1" });
132
- const pathToSQLiteFile = import_path.default.relative(import_path.default.dirname(input.schemaPath), d1Database);
172
+ const pathToSQLiteFile = import_path.default.relative(input.schemaContext.schemaRootDir, d1Database);
133
173
  const schema2 = [
134
174
  ["schema.prisma", this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")]
135
175
  ];
@@ -151,11 +191,11 @@ var _DbPull = class _DbPull2 {
151
191
  }
152
192
  } else {
153
193
  await (0, import_internals.getConfig)({
154
- datamodel: rawSchema,
194
+ datamodel: input.schemaContext.schemaFiles,
155
195
  ignoreEnvVarErrors: false
156
196
  });
157
197
  }
158
- return { firstDatasource: firstDatasource2, schema: rawSchema, validationWarning: void 0 };
198
+ return { firstDatasource: firstDatasource2, schema: input.schemaContext.schemaFiles, validationWarning: void 0 };
159
199
  }
160
200
  ).when(
161
201
  (input) => input.fromD1 === true,
@@ -186,10 +226,9 @@ ${this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")}`;
186
226
  return { firstDatasource: config2.datasources[0], schema: schema2, validationWarning: void 0 };
187
227
  }
188
228
  ).run();
189
- if (schemaPath) {
190
- const schemas = await (0, import_internals.getSchema)(args["--schema"], config.schema);
229
+ if (schemaContext) {
191
230
  const modelRegex = /\s*model\s*(\w+)\s*{/;
192
- const isReintrospection = schemas.some(([_, schema2]) => !!modelRegex.exec(schema2));
231
+ const isReintrospection = schemaContext.schemaFiles.some(([_, schema2]) => !!modelRegex.exec(schema2));
193
232
  if (isReintrospection && !args["--force"] && firstDatasource?.provider === "mongodb") {
194
233
  throw new Error(`Iterating on one schema using re-introspection with db pull is currently not supported with MongoDB provider.
195
234
  You can explicitly ignore and override your current local schema file with ${(0, import_chunk_SKRR5WT4.green)(
@@ -200,18 +239,18 @@ Some information will be lost (relations, comments, mapped fields, @ignore...),
200
239
  )} for more info.`);
201
240
  }
202
241
  }
203
- const engine = new import_chunk_ZOEKRXDP.SchemaEngine({
204
- schemaPath: schemaPath ?? void 0
205
- });
206
- const basedOn = !args["--url"] && schemaPath ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(import_path.default.relative(process.cwd(), schemaPath))}` : "";
242
+ const engine = new import_chunk_D2DGSPW6.SchemaEngine({ schemaContext: schemaContext ?? void 0 });
243
+ const basedOn = !args["--url"] && schemaContext?.primaryDatasource ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(schemaContext.loadedFromPathForLogMessages)}` : "";
207
244
  const introspectionSpinner = spinnerFactory(`Introspecting${basedOn}`);
208
245
  const before = Math.round(performance.now());
209
246
  let introspectionSchema = void 0;
210
247
  let introspectionWarnings;
211
248
  try {
249
+ const directoryConfig = (0, import_internals.inferDirectoryConfig)(schemaContext);
212
250
  const introspectionResult = await engine.introspect({
213
251
  schema: (0, import_internals.toSchemasContainer)(schema),
214
- baseDirectoryPath: rootDir,
252
+ baseDirectoryPath: schemaContext?.schemaRootDir ?? process.cwd(),
253
+ viewsDirectoryPath: directoryConfig.viewsDirPath,
215
254
  force: args["--force"],
216
255
  compositeTypeDepth: args["--composite-type-depth"],
217
256
  namespaces: args["--schemas"]?.split(",")
@@ -283,7 +322,6 @@ Or run this command with the ${(0, import_chunk_SKRR5WT4.green)(
283
322
  console.error(introspectionWarningsMessage.replace(/(\n)/gm, "\n// "));
284
323
  }
285
324
  } else {
286
- schemaPath = schemaPath || "schema.prisma";
287
325
  if (args["--force"]) {
288
326
  await (0, import_chunk_JZ75RIMZ.removeSchemaFiles)(schema);
289
327
  }
@@ -300,8 +338,9 @@ Or run this command with the ${(0, import_chunk_SKRR5WT4.green)(
300
338
  const modelsAndTypesCountMessage = modelsCount + typesCount > 1 ? `${modelsAndTypesMessage} and wrote them` : `${modelsAndTypesMessage} and wrote it`;
301
339
  const renderValidationWarning = validationWarning ? `
302
340
  ${(0, import_chunk_SKRR5WT4.yellow)(validationWarning)}` : "";
341
+ const introspectedSchemaPath = schemaContext?.loadedFromPathForLogMessages || introspectionSchema.files[0].path;
303
342
  introspectionSpinner.success(`Introspected ${modelsAndTypesCountMessage} into ${(0, import_chunk_SKRR5WT4.underline)(
304
- import_path.default.relative(process.cwd(), schemaPath)
343
+ import_path.default.relative(process.cwd(), introspectedSchemaPath)
305
344
  )} in ${(0, import_chunk_SKRR5WT4.bold)((0, import_internals.formatms)(Math.round(performance.now()) - before))}
306
345
  ${(0, import_chunk_SKRR5WT4.yellow)(introspectionWarningsMessage)}
307
346
  ${`Run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma generate"))} to generate Prisma Client.`}${renderValidationWarning}`);
@@ -319,48 +358,8 @@ ${warnings}`;
319
358
  if (error) {
320
359
  return new import_internals.HelpError(`
321
360
  ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
322
- ${_DbPull2.help}`);
361
+ ${_DbPull.help}`);
323
362
  }
324
- return _DbPull2.help;
363
+ return _DbPull.help;
325
364
  }
326
365
  };
327
- (0, import_chunk_WWAWV7DQ.__publicField)(_DbPull, "help", (0, import_internals.format)(`
328
- Pull the state from the database to the Prisma schema using introspection
329
-
330
- ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
331
-
332
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull [flags/options]
333
-
334
- ${(0, import_chunk_SKRR5WT4.bold)("Flags")}
335
-
336
- -h, --help Display this help message
337
- --force Ignore current Prisma schema file
338
- --print Print the introspected Prisma schema to stdout
339
-
340
- ${(0, import_chunk_SKRR5WT4.bold)("Options")}
341
-
342
- --config Custom path to your Prisma config file
343
- --schema Custom path to your Prisma schema
344
- --composite-type-depth Specify the depth for introspecting composite types (e.g. Embedded Documents in MongoDB)
345
- Number, default is -1 for infinite depth, 0 = off
346
- --schemas Specify the database schemas to introspect. This overrides the schemas defined in the datasource block of your Prisma schema.
347
- --local-d1 Generate a Prisma schema from a local Cloudflare D1 database
348
- ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
349
-
350
- With an existing Prisma schema
351
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull
352
-
353
- Or specify a Prisma schema path
354
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --schema=./schema.prisma
355
-
356
- Instead of saving the result to the filesystem, you can also print it to stdout
357
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --print
358
-
359
- Overwrite the current schema with the introspected schema instead of enriching it
360
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --force
361
-
362
- Set composite types introspection depth to 2 levels
363
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --composite-type-depth=2
364
-
365
- `));
366
- var DbPull = _DbPull;