@prisma/migrate 6.19.0 → 6.20.0-integration-next.1

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 (59) hide show
  1. package/dist/Migrate.js +6 -6
  2. package/dist/SchemaEngineCLI.js +4 -4
  3. package/dist/SchemaEngineWasm.js +4 -4
  4. package/dist/bin.js +30 -31
  5. package/dist/{chunk-3AKRTEIK.js → chunk-4BAGKFIV.js} +10 -11
  6. package/dist/{chunk-TW22Y3AA.js → chunk-6FL2LODV.js} +6 -7
  7. package/dist/{chunk-O35BTK6Y.js → chunk-BB43AVYJ.js} +9 -13
  8. package/dist/{chunk-F2XCBEZ4.js → chunk-BP3VX5NQ.js} +10 -13
  9. package/dist/{chunk-BHJMJSM4.js → chunk-EERZNF42.js} +6 -7
  10. package/dist/{chunk-7TVX3D4W.js → chunk-EVUHOCOP.js} +27 -65
  11. package/dist/{chunk-6ORQRJLP.js → chunk-FBPXMCYK.js} +28 -109
  12. package/dist/{chunk-OP2BDF75.js → chunk-FRY7T46S.js} +10 -11
  13. package/dist/{chunk-22YP3RXZ.js → chunk-GH6IOZTT.js} +7 -7
  14. package/dist/{chunk-Z27SI4AV.js → chunk-GY34KW2I.js} +6 -4
  15. package/dist/{chunk-VV4M6AN7.js → chunk-JX2HIV7V.js} +10 -10
  16. package/dist/{chunk-PHXLQVPT.js → chunk-L7EZFBB4.js} +40 -68
  17. package/dist/{chunk-AXR7LS2N.js → chunk-PEUHUCS4.js} +4 -5
  18. package/dist/{chunk-NB4FRYRQ.js → chunk-PQ3UMDEP.js} +5 -5
  19. package/dist/{chunk-ZTIS675B.js → chunk-QCMPSEBY.js} +138 -205
  20. package/dist/{chunk-J33EXHZB.js → chunk-SFX5KEGP.js} +9 -12
  21. package/dist/{chunk-GSX25HRL.js → chunk-SYWL5XS4.js} +5 -5
  22. package/dist/{chunk-VU5BLQUI.js → chunk-T2ACIU5M.js} +14 -8
  23. package/dist/{chunk-D6LYHB65.js → chunk-V3D2XB5I.js} +37 -29
  24. package/dist/{chunk-D4TRX77Y.js → chunk-WF7UXKO5.js} +6 -9
  25. package/dist/{chunk-QVMYNWAN.js → chunk-XA2JOJS2.js} +157 -70
  26. package/dist/{chunk-R4IWP35Z.js → chunk-Z7WLEGCP.js} +8 -9
  27. package/dist/commands/DbDrop.js +2 -2
  28. package/dist/commands/DbExecute.js +7 -7
  29. package/dist/commands/DbPull.js +8 -9
  30. package/dist/commands/DbPush.js +7 -7
  31. package/dist/commands/DbSeed.js +3 -3
  32. package/dist/commands/MigrateDeploy.js +7 -7
  33. package/dist/commands/MigrateDev.js +8 -8
  34. package/dist/commands/MigrateDiff.js +8 -7
  35. package/dist/commands/MigrateReset.js +8 -8
  36. package/dist/commands/MigrateResolve.js +7 -7
  37. package/dist/commands/MigrateStatus.js +7 -7
  38. package/dist/index.js +36 -37
  39. package/dist/internals/src/cli/getSchema.d.ts +1 -15
  40. package/dist/migrate/src/Migrate.d.ts +1 -2
  41. package/dist/migrate/src/commands/MigrateDiff.d.ts +1 -0
  42. package/dist/migrate/src/utils/introspectSql.d.ts +2 -1
  43. package/dist/migrate/src/utils/seed.d.ts +0 -6
  44. package/dist/open-GFNXULGD.js +593 -0
  45. package/dist/utils/getDatabaseVersionSafe.js +7 -7
  46. package/dist/utils/introspectSql.js +7 -7
  47. package/dist/utils/seed.js +2 -3
  48. package/dist/utils/setupCockroach.js +2 -2
  49. package/dist/utils/setupMSSQL.js +30734 -30124
  50. package/dist/utils/setupMongo.js +2048 -768
  51. package/dist/utils/setupPostgres.js +2 -2
  52. package/dist/utils/spinner.js +3 -3
  53. package/dist/views/handleViewsIO.js +2 -2
  54. package/package.json +11 -11
  55. package/dist/chunk-RR6BKMNO.js +0 -80
  56. package/dist/migrate/src/utils/replaceOrAddDatasource.d.ts +0 -2
  57. package/dist/migrate/src/utils/replaceOrAddDatasource.test.d.ts +0 -1
  58. package/dist/utils/replaceOrAddDatasource.js +0 -25
  59. package/dist/utils/replaceOrAddDatasource.test.js +0 -207
@@ -26,20 +26,20 @@ 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_ZTIS675B_exports = {};
30
- __export(chunk_ZTIS675B_exports, {
31
- MigrateDiff: () => MigrateDiff
29
+ var chunk_QCMPSEBY_exports = {};
30
+ __export(chunk_QCMPSEBY_exports, {
31
+ MigrateDiff: () => MigrateDiff,
32
+ getRemovedTargetParameterHint: () => getRemovedTargetParameterHint
32
33
  });
33
- module.exports = __toCommonJS(chunk_ZTIS675B_exports);
34
+ module.exports = __toCommonJS(chunk_QCMPSEBY_exports);
34
35
  var import_chunk_VAJ4VX67 = require("./chunk-VAJ4VX67.js");
35
- var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
36
+ var import_chunk_V3D2XB5I = require("./chunk-V3D2XB5I.js");
36
37
  var import_chunk_GGA2F64G = require("./chunk-GGA2F64G.js");
37
38
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
38
39
  var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
39
40
  var import_debug = __toESM(require("@prisma/debug"));
40
41
  var import_internals = require("@prisma/internals");
41
42
  var import_path = __toESM(require("path"));
42
- var import_config = require("@prisma/config");
43
43
  var import_debug2 = require("@prisma/debug");
44
44
  var import_fs = __toESM(require("fs"));
45
45
  var import_path2 = __toESM(require("path"));
@@ -1117,7 +1117,7 @@ var require_tree_walker = (0, import_chunk_2ESYSVXG.__commonJS)({
1117
1117
  }
1118
1118
  });
1119
1119
  var require_path = (0, import_chunk_2ESYSVXG.__commonJS)({
1120
- "../../node_modules/.pnpm/minimatch@5.1.0/node_modules/minimatch/lib/path.js"(exports, module2) {
1120
+ "../../node_modules/.pnpm/minimatch@5.1.6/node_modules/minimatch/lib/path.js"(exports, module2) {
1121
1121
  "use strict";
1122
1122
  var isWindows = typeof process === "object" && process && process.platform === "win32";
1123
1123
  module2.exports = isWindows ? { sep: "\\" } : { sep: "/" };
@@ -1180,7 +1180,7 @@ var require_balanced_match = (0, import_chunk_2ESYSVXG.__commonJS)({
1180
1180
  }
1181
1181
  });
1182
1182
  var require_brace_expansion = (0, import_chunk_2ESYSVXG.__commonJS)({
1183
- "../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports, module2) {
1183
+ "../../node_modules/.pnpm/brace-expansion@2.0.2/node_modules/brace-expansion/index.js"(exports, module2) {
1184
1184
  "use strict";
1185
1185
  var balanced = require_balanced_match();
1186
1186
  module2.exports = expandTop;
@@ -1255,7 +1255,7 @@ var require_brace_expansion = (0, import_chunk_2ESYSVXG.__commonJS)({
1255
1255
  var isSequence = isNumericSequence || isAlphaSequence;
1256
1256
  var isOptions = m.body.indexOf(",") >= 0;
1257
1257
  if (!isSequence && !isOptions) {
1258
- if (m.post.match(/,.*\}/)) {
1258
+ if (m.post.match(/,(?!,).*\}/)) {
1259
1259
  str = m.pre + "{" + m.body + escClose + m.post;
1260
1260
  return expand(str);
1261
1261
  }
@@ -1329,7 +1329,7 @@ var require_brace_expansion = (0, import_chunk_2ESYSVXG.__commonJS)({
1329
1329
  }
1330
1330
  });
1331
1331
  var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1332
- "../../node_modules/.pnpm/minimatch@5.1.0/node_modules/minimatch/minimatch.js"(exports, module2) {
1332
+ "../../node_modules/.pnpm/minimatch@5.1.6/node_modules/minimatch/minimatch.js"(exports, module2) {
1333
1333
  "use strict";
1334
1334
  var minimatch = module2.exports = (p, pattern, options = {}) => {
1335
1335
  assertValidPattern(pattern);
@@ -1416,7 +1416,9 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1416
1416
  return list;
1417
1417
  };
1418
1418
  var globUnescape = (s) => s.replace(/\\(.)/g, "$1");
1419
+ var charUnescape = (s) => s.replace(/\\([^-\]])/g, "$1");
1419
1420
  var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1421
+ var braExpEscape = (s) => s.replace(/[[\]\\]/g, "\\$&");
1420
1422
  var Minimatch = class {
1421
1423
  constructor(pattern, options) {
1422
1424
  assertValidPattern(pattern);
@@ -1469,7 +1471,7 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1469
1471
  negate = !negate;
1470
1472
  negateOffset++;
1471
1473
  }
1472
- if (negateOffset) this.pattern = pattern.substr(negateOffset);
1474
+ if (negateOffset) this.pattern = pattern.slice(negateOffset);
1473
1475
  this.negate = negate;
1474
1476
  }
1475
1477
  // set partial to true to test if, for example,
@@ -1555,7 +1557,7 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1555
1557
  }
1556
1558
  if (pattern === "") return "";
1557
1559
  let re = "";
1558
- let hasMagic = !!options.nocase;
1560
+ let hasMagic = false;
1559
1561
  let escaping = false;
1560
1562
  const patternListStack = [];
1561
1563
  const negativeLists = [];
@@ -1566,7 +1568,10 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1566
1568
  let cs;
1567
1569
  let pl;
1568
1570
  let sp;
1569
- const patternStart = pattern.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
1571
+ let dotTravAllowed = pattern.charAt(0) === ".";
1572
+ let dotFileAllowed = options.dot || dotTravAllowed;
1573
+ const patternStart = () => dotTravAllowed ? "" : dotFileAllowed ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
1574
+ const subPatternStart = (p) => p.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
1570
1575
  const clearStateChar = () => {
1571
1576
  if (stateChar) {
1572
1577
  switch (stateChar) {
@@ -1605,6 +1610,10 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1605
1610
  return false;
1606
1611
  }
1607
1612
  case "\\":
1613
+ if (inClass && pattern.charAt(i + 1) === "-") {
1614
+ re += c;
1615
+ continue;
1616
+ }
1608
1617
  clearStateChar();
1609
1618
  escaping = true;
1610
1619
  continue;
@@ -1627,7 +1636,7 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1627
1636
  stateChar = c;
1628
1637
  if (options.noext) clearStateChar();
1629
1638
  continue;
1630
- case "(":
1639
+ case "(": {
1631
1640
  if (inClass) {
1632
1641
  re += "(";
1633
1642
  continue;
@@ -1636,39 +1645,54 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1636
1645
  re += "\\(";
1637
1646
  continue;
1638
1647
  }
1639
- patternListStack.push({
1648
+ const plEntry = {
1640
1649
  type: stateChar,
1641
1650
  start: i - 1,
1642
1651
  reStart: re.length,
1643
1652
  open: plTypes[stateChar].open,
1644
1653
  close: plTypes[stateChar].close
1645
- });
1646
- re += stateChar === "!" ? "(?:(?!(?:" : "(?:";
1654
+ };
1655
+ this.debug(this.pattern, " ", plEntry);
1656
+ patternListStack.push(plEntry);
1657
+ re += plEntry.open;
1658
+ if (plEntry.start === 0 && plEntry.type !== "!") {
1659
+ dotTravAllowed = true;
1660
+ re += subPatternStart(pattern.slice(i + 1));
1661
+ }
1647
1662
  this.debug("plType %j %j", stateChar, re);
1648
1663
  stateChar = false;
1649
1664
  continue;
1650
- case ")":
1651
- if (inClass || !patternListStack.length) {
1665
+ }
1666
+ case ")": {
1667
+ const plEntry = patternListStack[patternListStack.length - 1];
1668
+ if (inClass || !plEntry) {
1652
1669
  re += "\\)";
1653
1670
  continue;
1654
1671
  }
1672
+ patternListStack.pop();
1655
1673
  clearStateChar();
1656
1674
  hasMagic = true;
1657
- pl = patternListStack.pop();
1675
+ pl = plEntry;
1658
1676
  re += pl.close;
1659
1677
  if (pl.type === "!") {
1660
- negativeLists.push(pl);
1678
+ negativeLists.push(Object.assign(pl, { reEnd: re.length }));
1661
1679
  }
1662
- pl.reEnd = re.length;
1663
1680
  continue;
1664
- case "|":
1665
- if (inClass || !patternListStack.length) {
1681
+ }
1682
+ case "|": {
1683
+ const plEntry = patternListStack[patternListStack.length - 1];
1684
+ if (inClass || !plEntry) {
1666
1685
  re += "\\|";
1667
1686
  continue;
1668
1687
  }
1669
1688
  clearStateChar();
1670
1689
  re += "|";
1690
+ if (plEntry.start === 0 && plEntry.type !== "!") {
1691
+ dotTravAllowed = true;
1692
+ re += subPatternStart(pattern.slice(i + 1));
1693
+ }
1671
1694
  continue;
1695
+ }
1672
1696
  // these are mostly the same in regexp and glob
1673
1697
  case "[":
1674
1698
  clearStateChar();
@@ -1688,17 +1712,13 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1688
1712
  }
1689
1713
  cs = pattern.substring(classStart + 1, i);
1690
1714
  try {
1691
- RegExp("[" + cs + "]");
1715
+ RegExp("[" + braExpEscape(charUnescape(cs)) + "]");
1716
+ re += c;
1692
1717
  } catch (er) {
1693
- sp = this.parse(cs, SUBPARSE);
1694
- re = re.substr(0, reClassStart) + "\\[" + sp[0] + "\\]";
1695
- hasMagic = hasMagic || sp[1];
1696
- inClass = false;
1697
- continue;
1718
+ re = re.substring(0, reClassStart) + "(?:$.)";
1698
1719
  }
1699
1720
  hasMagic = true;
1700
1721
  inClass = false;
1701
- re += c;
1702
1722
  continue;
1703
1723
  default:
1704
1724
  clearStateChar();
@@ -1710,9 +1730,9 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1710
1730
  }
1711
1731
  }
1712
1732
  if (inClass) {
1713
- cs = pattern.substr(classStart + 1);
1733
+ cs = pattern.slice(classStart + 1);
1714
1734
  sp = this.parse(cs, SUBPARSE);
1715
- re = re.substr(0, reClassStart) + "\\[" + sp[0];
1735
+ re = re.substring(0, reClassStart) + "\\[" + sp[0];
1716
1736
  hasMagic = hasMagic || sp[1];
1717
1737
  }
1718
1738
  for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
@@ -1741,24 +1761,28 @@ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1741
1761
  const nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
1742
1762
  let nlAfter = re.slice(nl.reEnd);
1743
1763
  const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter;
1744
- const openParensBefore = nlBefore.split("(").length - 1;
1764
+ const closeParensBefore = nlBefore.split(")").length;
1765
+ const openParensBefore = nlBefore.split("(").length - closeParensBefore;
1745
1766
  let cleanAfter = nlAfter;
1746
1767
  for (let i = 0; i < openParensBefore; i++) {
1747
1768
  cleanAfter = cleanAfter.replace(/\)[+*?]?/, "");
1748
1769
  }
1749
1770
  nlAfter = cleanAfter;
1750
- const dollar = nlAfter === "" && isSub !== SUBPARSE ? "$" : "";
1771
+ const dollar = nlAfter === "" && isSub !== SUBPARSE ? "(?:$|\\/)" : "";
1751
1772
  re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
1752
1773
  }
1753
1774
  if (re !== "" && hasMagic) {
1754
1775
  re = "(?=.)" + re;
1755
1776
  }
1756
1777
  if (addPatternStart) {
1757
- re = patternStart + re;
1778
+ re = patternStart() + re;
1758
1779
  }
1759
1780
  if (isSub === SUBPARSE) {
1760
1781
  return [re, hasMagic];
1761
1782
  }
1783
+ if (options.nocase && !hasMagic) {
1784
+ hasMagic = pattern.toUpperCase() !== pattern.toLowerCase();
1785
+ }
1762
1786
  if (!hasMagic) {
1763
1787
  return globUnescape(pattern);
1764
1788
  }
@@ -4939,7 +4963,7 @@ var require_ensure = (0, import_chunk_2ESYSVXG.__commonJS)({
4939
4963
  }
4940
4964
  });
4941
4965
  var require_utils2 = (0, import_chunk_2ESYSVXG.__commonJS)({
4942
- "../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/utils.js"(exports, module2) {
4966
+ "../../node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/utils.js"(exports, module2) {
4943
4967
  "use strict";
4944
4968
  function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
4945
4969
  const EOF = finalEOL ? EOL : "";
@@ -4954,7 +4978,7 @@ var require_utils2 = (0, import_chunk_2ESYSVXG.__commonJS)({
4954
4978
  }
4955
4979
  });
4956
4980
  var require_jsonfile = (0, import_chunk_2ESYSVXG.__commonJS)({
4957
- "../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/index.js"(exports, module2) {
4981
+ "../../node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/index.js"(exports, module2) {
4958
4982
  "use strict";
4959
4983
  var _fs;
4960
4984
  try {
@@ -5016,13 +5040,12 @@ var require_jsonfile = (0, import_chunk_2ESYSVXG.__commonJS)({
5016
5040
  const str = stringify(obj, options);
5017
5041
  return fs3.writeFileSync(file, str, options);
5018
5042
  }
5019
- var jsonfile = {
5043
+ module2.exports = {
5020
5044
  readFile: readFile2,
5021
5045
  readFileSync,
5022
5046
  writeFile,
5023
5047
  writeFileSync
5024
5048
  };
5025
- module2.exports = jsonfile;
5026
5049
  }
5027
5050
  });
5028
5051
  var require_jsonfile2 = (0, import_chunk_2ESYSVXG.__commonJS)({
@@ -5569,10 +5592,6 @@ async function getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfi
5569
5592
  if (prismaConfigResult.ok) {
5570
5593
  return prismaConfigResult;
5571
5594
  }
5572
- const pkgJsonResult = await getSchemaFromPackageJson(cwd);
5573
- if (pkgJsonResult.ok) {
5574
- return pkgJsonResult;
5575
- }
5576
5595
  const defaultResult = await getDefaultSchema(cwd);
5577
5596
  if (defaultResult.ok) {
5578
5597
  return defaultResult;
@@ -5629,36 +5648,6 @@ async function readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig) {
5629
5648
  }
5630
5649
  return schemaResult;
5631
5650
  }
5632
- async function getSchemaFromPackageJson(cwd) {
5633
- const prismaConfig = await (0, import_config.loadConfigFromPackageJson)(cwd);
5634
- debug("prismaConfig", prismaConfig);
5635
- if (!prismaConfig || !prismaConfig.config?.schema) {
5636
- return { ok: false, error: { kind: "PackageJsonNotConfigured" } };
5637
- }
5638
- const schemaPathFromPkgJson = prismaConfig.config.schema;
5639
- if (typeof schemaPathFromPkgJson !== "string") {
5640
- throw new Error(
5641
- `Provided schema path \`${schemaPathFromPkgJson}\` from \`${import_path2.default.relative(
5642
- cwd,
5643
- prismaConfig.loadedFromFile
5644
- )}\` must be of type string`
5645
- );
5646
- }
5647
- const absoluteSchemaPath = import_path2.default.isAbsolute(schemaPathFromPkgJson) ? schemaPathFromPkgJson : import_path2.default.resolve(import_path2.default.dirname(prismaConfig.loadedFromFile), schemaPathFromPkgJson);
5648
- const lookupResult = await readSchemaFromFileOrDirectory(absoluteSchemaPath);
5649
- if (!lookupResult.ok) {
5650
- throw new Error(
5651
- `Could not load schema from \`${import_path2.default.relative(
5652
- cwd,
5653
- absoluteSchemaPath
5654
- )}\` provided by "prisma.schema" config of \`${import_path2.default.relative(
5655
- cwd,
5656
- prismaConfig.loadedFromFile
5657
- )}\`: ${renderLookupError(lookupResult.error)}`
5658
- );
5659
- }
5660
- return lookupResult;
5661
- }
5662
5651
  async function getDefaultSchema(cwd, failures = []) {
5663
5652
  const lookupPaths = [import_path2.default.join(cwd, "schema.prisma"), import_path2.default.join(cwd, "prisma", "schema.prisma")];
5664
5653
  for (const path3 of lookupPaths) {
@@ -5691,26 +5680,17 @@ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
5691
5680
  -o, --output Writes to a file instead of stdout
5692
5681
 
5693
5682
  ${(0, import_chunk_SKRR5WT4.italic)("From and To inputs (1 `--from-...` and 1 `--to-...` must be provided):")}
5694
- --from-url A datasource URL
5695
- --to-url
5696
-
5697
5683
  --from-empty Flag to assume from or to is an empty datamodel
5698
5684
  --to-empty
5699
5685
 
5700
- --from-schema-datamodel Path to a Prisma schema file, uses the ${(0, import_chunk_SKRR5WT4.italic)("datamodel")} for the diff
5701
- --to-schema-datamodel
5702
-
5703
- --from-schema-datasource Path to a Prisma schema file, uses the ${(0, import_chunk_SKRR5WT4.italic)("datasource url")} for the diff
5704
- --to-schema-datasource
5686
+ --from-schema Path to a Prisma schema file, uses the ${(0, import_chunk_SKRR5WT4.italic)("datamodel")} for the diff
5687
+ --to-schema
5705
5688
 
5706
5689
  --from-migrations Path to the Prisma Migrate migrations directory
5707
5690
  --to-migrations
5708
5691
 
5709
- --from-local-d1 Automatically locate the local Cloudflare D1 database
5710
- --to-local-d1
5711
-
5712
- ${(0, import_chunk_SKRR5WT4.italic)("Shadow database (only required if using --from-migrations or --to-migrations):")}
5713
- --shadow-database-url URL for the shadow database
5692
+ --from-config-datasource Flag to use the datasource from the Prisma config file
5693
+ --to-config-datasource
5714
5694
 
5715
5695
  ${(0, import_chunk_SKRR5WT4.bold)("Flags")}
5716
5696
 
@@ -5731,7 +5711,7 @@ The command takes a source ${(0, import_chunk_SKRR5WT4.green)(`--from-...`)} and
5731
5711
  The source and destination must use the same provider,
5732
5712
  e.g. a diff using 2 different providers like PostgreSQL and SQLite is not supported.
5733
5713
 
5734
- It compares the source with the destination to generate a diff.
5714
+ It compares the source with the destination to generate a diff.
5735
5715
  The diff can be interpreted as generating a migration that brings the source schema (from) to the shape of the destination schema (to).
5736
5716
  The default output is a human readable diff, it can be rendered as SQL using \`--script\` on SQL databases.
5737
5717
 
@@ -5739,47 +5719,26 @@ See the documentation for more information ${(0, import_internals.link)("https:/
5739
5719
 
5740
5720
  ${helpOptions}
5741
5721
  ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
5742
-
5743
- From database to database as summary
5744
- e.g. compare two live databases
5745
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
5746
- --from-url "$DATABASE_URL" \\
5747
- --to-url "postgresql://login:password@localhost:5432/db2"
5748
-
5749
- From a live database to a Prisma datamodel
5722
+
5723
+ From the configured database to a Prisma datamodel
5750
5724
  e.g. roll forward after a migration failed in the middle
5751
5725
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
5752
- --shadow-database-url "$SHADOW_DB" \\
5753
- --from-url "$PROD_DB" \\
5754
- --to-schema-datamodel=next_datamodel.prisma \\
5755
- --script
5756
-
5757
- From a live database to a datamodel
5758
- e.g. roll backward after a migration failed in the middle
5759
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
5760
- --shadow-database-url "$SHADOW_DB" \\
5761
- --from-url "$PROD_DB" \\
5762
- --to-schema-datamodel=previous_datamodel.prisma \\
5726
+ --from-config-datasource \\
5727
+ --to-schema=next_datamodel.prisma \\
5763
5728
  --script
5764
5729
 
5765
- From a local D1 database to a datamodel
5730
+ From a peisma datamodel to the configured database
5731
+ e.g. roll forward after a migration failed in the middle
5766
5732
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
5767
- --from-local-d1 \\
5768
- --to-schema-datamodel=./prisma/schema.prisma \\
5733
+ --from-schema=next_datamodel.prisma \\
5734
+ --to-config-datasource \\
5769
5735
  --script
5770
5736
 
5771
- From a Prisma datamodel to a local D1 database
5772
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
5773
- --from-schema-datamodel=./prisma/schema.prisma \\
5774
- --to-local-d1 \\
5775
- --script
5776
-
5777
- From a Prisma Migrate \`migrations\` directory to another database
5737
+ From a Prisma Migrate \`migrations\` directory to the configured database
5778
5738
  e.g. generate a migration for a hotfix already applied on production
5779
5739
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
5780
- --shadow-database-url "$SHADOW_DB" \\
5781
5740
  --from-migrations ./migrations \\
5782
- --to-url "$PROD_DB" \\
5741
+ --to-config-datasource \\
5783
5742
  --script
5784
5743
 
5785
5744
  Execute the --script output with \`prisma db execute\` using bash pipe \`|\`
@@ -5804,54 +5763,43 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
5804
5763
  "-o": "--output",
5805
5764
  // From
5806
5765
  "--from-empty": Boolean,
5807
- "--from-schema-datasource": String,
5808
- "--from-schema-datamodel": String,
5809
- "--from-url": String,
5766
+ "--from-config-datasource": Boolean,
5767
+ "--from-schema": String,
5810
5768
  "--from-migrations": String,
5811
- "--from-local-d1": Boolean,
5812
5769
  // To
5813
5770
  "--to-empty": Boolean,
5814
- "--to-schema-datasource": String,
5815
- "--to-schema-datamodel": String,
5816
- "--to-url": String,
5771
+ "--to-config-datasource": Boolean,
5772
+ "--to-schema": String,
5817
5773
  "--to-migrations": String,
5818
- "--to-local-d1": Boolean,
5819
5774
  // Others
5820
- "--shadow-database-url": String,
5821
5775
  "--script": Boolean,
5822
5776
  "--exit-code": Boolean,
5823
5777
  "--telemetry-information": String,
5824
- "--config": String
5778
+ "--config": String,
5779
+ // Removed, but parsed to show help error
5780
+ "--from-url": String,
5781
+ "--to-url": String,
5782
+ "--from-schema-datasource": String,
5783
+ "--to-schema-datasource": String,
5784
+ "--from-schema-datamodel": String,
5785
+ "--to-schema-datamodel": String,
5786
+ "--from-local-d1": Boolean,
5787
+ "--to-local-d1": Boolean
5825
5788
  },
5826
5789
  false
5827
5790
  );
5828
5791
  if ((0, import_internals.isError)(args)) {
5829
5792
  return this.help(args.message);
5830
5793
  }
5831
- const cmd = "migrate diff";
5832
- (0, import_internals.checkUnsupportedDataProxy)({
5833
- cmd,
5834
- urls: [args["--to-url"], args["--from-url"], args["--shadow-database-url"]]
5835
- });
5836
- (0, import_internals.checkUnsupportedSchemaEngineWasm)({
5837
- cmd,
5838
- config,
5839
- args,
5840
- flags: [
5841
- "--from-url",
5842
- "--to-url",
5843
- "--from-schema-datasource",
5844
- "--to-schema-datasource",
5845
- "--shadow-database-url",
5846
- "--to-local-d1",
5847
- "--from-local-d1"
5848
- ]
5849
- });
5850
5794
  if (args["--help"]) {
5851
5795
  return this.help();
5852
5796
  }
5853
- const numberOfFromParameterProvided = Number(Boolean(args["--from-empty"])) + Number(Boolean(args["--from-schema-datasource"])) + Number(Boolean(args["--from-schema-datamodel"])) + Number(Boolean(args["--from-url"])) + Number(Boolean(args["--from-migrations"])) + Number(Boolean(args["--from-local-d1"]));
5854
- const numberOfToParameterProvided = Number(Boolean(args["--to-empty"])) + Number(Boolean(args["--to-schema-datasource"])) + Number(Boolean(args["--to-schema-datamodel"])) + Number(Boolean(args["--to-url"])) + Number(Boolean(args["--to-migrations"])) + Number(Boolean(args["--to-local-d1"]));
5797
+ const removedTargetParameterHint = Object.keys(args).map(getRemovedTargetParameterHint).find((msg) => msg !== void 0);
5798
+ if (removedTargetParameterHint) {
5799
+ return this.help(removedTargetParameterHint);
5800
+ }
5801
+ const numberOfFromParameterProvided = Number(Boolean(args["--from-empty"])) + Number(Boolean(args["--from-config-datasource"])) + Number(Boolean(args["--from-schema"])) + Number(Boolean(args["--from-migrations"]));
5802
+ const numberOfToParameterProvided = Number(Boolean(args["--to-empty"])) + Number(Boolean(args["--to-config-datasource"])) + Number(Boolean(args["--to-schema"])) + Number(Boolean(args["--to-migrations"]));
5855
5803
  if (numberOfFromParameterProvided !== 1 || numberOfToParameterProvided !== 1) {
5856
5804
  const errorMessages = [];
5857
5805
  if (numberOfFromParameterProvided !== 1) {
@@ -5862,52 +5810,33 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
5862
5810
  }
5863
5811
  return this.help(`${errorMessages.join("\n")}`);
5864
5812
  }
5865
- if (args["--shadow-database-url"] && (args["--from-local-d1"] || args["--to-local-d1"])) {
5866
- return this.help(
5867
- `The flag \`--shadow-database-url\` is not compatible with \`--from-local-d1\` or \`--to-local-d1\`.`
5868
- );
5869
- }
5870
5813
  let from;
5871
5814
  if (args["--from-empty"]) {
5872
5815
  from = {
5873
5816
  tag: "empty"
5874
5817
  };
5875
- } else if (args["--from-schema-datasource"]) {
5876
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--from-schema-datasource"], printMessage: false, config });
5877
- const schemaContext = await (0, import_internals.loadSchemaContext)({
5878
- schemaPathFromArg: args["--from-schema-datasource"],
5879
- schemaPathArgumentName: "--from-schema-datasource",
5880
- schemaEngineConfig: config,
5881
- printLoadMessage: false
5882
- });
5883
- (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate diff", schemaContext });
5884
- from = {
5885
- tag: "schemaDatasource",
5886
- ...(0, import_internals.toSchemasWithConfigDir)(schemaContext)
5887
- };
5888
- } else if (args["--from-schema-datamodel"]) {
5889
- const schema = await getSchemaWithPath(import_path.default.resolve(args["--from-schema-datamodel"]), config.schema, {
5890
- argumentName: "--from-schema-datamodel"
5818
+ } else if (args["--from-schema"]) {
5819
+ const schema = await getSchemaWithPath(import_path.default.resolve(args["--from-schema"]), config.schema, {
5820
+ argumentName: "--from-schema"
5891
5821
  });
5892
5822
  from = {
5893
5823
  tag: "schemaDatamodel",
5894
5824
  ...(0, import_internals.toSchemasContainer)(schema.schemas)
5895
5825
  };
5896
- } else if (args["--from-url"]) {
5897
- from = {
5898
- tag: "url",
5899
- url: args["--from-url"]
5900
- };
5901
5826
  } else if (args["--from-migrations"]) {
5902
5827
  from = {
5903
5828
  tag: "migrations",
5904
5829
  ...await (0, import_chunk_GGA2F64G.listMigrations)(args["--from-migrations"], config.migrations?.initShadowDb ?? "")
5905
5830
  };
5906
- } else if (args["--from-local-d1"]) {
5907
- const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--from-local-d1" });
5831
+ } else if (args["--from-config-datasource"]) {
5832
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
5833
+ schemaPathFromConfig: config.schema,
5834
+ schemaEngineConfig: config,
5835
+ printLoadMessage: false
5836
+ });
5908
5837
  from = {
5909
- tag: "url",
5910
- url: `file:${d1Database}`
5838
+ tag: "schemaDatasource",
5839
+ ...(0, import_internals.toSchemasWithConfigDir)(schemaContext)
5911
5840
  };
5912
5841
  }
5913
5842
  let to;
@@ -5915,48 +5844,35 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
5915
5844
  to = {
5916
5845
  tag: "empty"
5917
5846
  };
5918
- } else if (args["--to-schema-datasource"]) {
5919
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--to-schema-datasource"], printMessage: false, config });
5920
- const schemaContext = await (0, import_internals.loadSchemaContext)({
5921
- schemaPathFromArg: args["--to-schema-datasource"],
5922
- schemaPathArgumentName: "--to-schema-datasource",
5923
- printLoadMessage: false
5924
- });
5925
- (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate diff", schemaContext });
5926
- to = {
5927
- tag: "schemaDatasource",
5928
- ...(0, import_internals.toSchemasWithConfigDir)(schemaContext)
5929
- };
5930
- } else if (args["--to-schema-datamodel"]) {
5931
- const schema = await getSchemaWithPath(import_path.default.resolve(args["--to-schema-datamodel"]), config.schema, {
5932
- argumentName: "--to-schema-datamodel"
5847
+ } else if (args["--to-schema"]) {
5848
+ const schema = await getSchemaWithPath(import_path.default.resolve(args["--to-schema"]), config.schema, {
5849
+ argumentName: "--to-schema"
5933
5850
  });
5934
5851
  to = {
5935
5852
  tag: "schemaDatamodel",
5936
5853
  ...(0, import_internals.toSchemasContainer)(schema.schemas)
5937
5854
  };
5938
- } else if (args["--to-url"]) {
5939
- to = {
5940
- tag: "url",
5941
- url: args["--to-url"]
5942
- };
5943
5855
  } else if (args["--to-migrations"]) {
5944
5856
  to = {
5945
5857
  tag: "migrations",
5946
5858
  ...await (0, import_chunk_GGA2F64G.listMigrations)(args["--to-migrations"], config.migrations?.initShadowDb ?? "")
5947
5859
  };
5948
- } else if (args["--to-local-d1"]) {
5949
- const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--to-local-d1" });
5860
+ } else if (args["--to-config-datasource"]) {
5861
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
5862
+ schemaPathFromConfig: config.schema,
5863
+ schemaEngineConfig: config,
5864
+ printLoadMessage: false
5865
+ });
5950
5866
  to = {
5951
- tag: "url",
5952
- url: `file:${d1Database}`
5867
+ tag: "schemaDatasource",
5868
+ ...(0, import_internals.toSchemasWithConfigDir)(schemaContext)
5953
5869
  };
5954
5870
  }
5955
5871
  const schemaFilter = {
5956
5872
  externalTables: config.tables?.external ?? [],
5957
5873
  externalEnums: config.enums?.external ?? []
5958
5874
  };
5959
- const migrate = await import_chunk_D6LYHB65.Migrate.setup({
5875
+ const migrate = await import_chunk_V3D2XB5I.Migrate.setup({
5960
5876
  schemaEngineConfig: config,
5961
5877
  schemaFilter,
5962
5878
  extensions: config["extensions"]
@@ -6006,3 +5922,20 @@ ${helpOptions}`);
6006
5922
  return _MigrateDiff.help;
6007
5923
  }
6008
5924
  };
5925
+ function getRemovedTargetParameterHint(parameter) {
5926
+ switch (parameter) {
5927
+ case "--from-url":
5928
+ case "--to-url":
5929
+ case "--from-schema-datasource":
5930
+ case "--to-schema-datasource":
5931
+ return `\`${parameter}\` was removed. Please use \`--[from/to]-config-datasource\` in combination with a Prisma config file that contains the appropriate datasource instead.`;
5932
+ case "--from-schema-datamodel":
5933
+ case "--to-schema-datamodel":
5934
+ return `\`${parameter}\` was removed. Please use \`--[from/to]-schema\` instead.`;
5935
+ case "--from-local-d1":
5936
+ case "--to-local-d1":
5937
+ return `\`${parameter}\` was removed. Please use \`--[from/to]-config-datasource\` in combination with a Prisma config file that contains the appropriate datasource instead. The \`@prisma/adapter-d1\` package exposes a \`listLocalDatabases()\` helper function to help you locate your local D1 databases. You can use the paths returned from that function to construct your datasource URL(s).`;
5938
+ default:
5939
+ return;
5940
+ }
5941
+ }