@prisma/migrate 6.5.0-dev.1 → 6.5.0-dev.3

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 (102) hide show
  1. package/dist/CLI.js +3 -4
  2. package/dist/Migrate.js +6 -7
  3. package/dist/SchemaEngine.js +6 -7
  4. package/dist/bin.js +116 -146
  5. package/dist/{chunk-WOOPRG54.js → chunk-255BRND3.js} +7 -14
  6. package/dist/{chunk-75EIHNAH.js → chunk-2NMFKGXM.js} +5 -6
  7. package/dist/chunk-3WC4XD74.js +98 -0
  8. package/dist/chunk-4EV2RVXY.js +226 -0
  9. package/dist/{chunk-YWWOSXMY.js → chunk-4JQIX6O7.js} +7 -15
  10. package/dist/{chunk-M5YNQ2NP.js → chunk-6DFJIBJX.js} +5 -12
  11. package/dist/{chunk-SGCF5OHF.js → chunk-7CQBDP4H.js} +6 -13
  12. package/dist/{chunk-7IT2ZO3D.js → chunk-AHJ2N6BJ.js} +3 -9
  13. package/dist/chunk-C2PR6JQR.js +266 -0
  14. package/dist/chunk-CTPONE6G.js +65 -0
  15. package/dist/{chunk-DUCG3NRP.js → chunk-D74DU52C.js} +633 -806
  16. package/dist/{chunk-UVNSK22K.js → chunk-DDHPSYC4.js} +122 -130
  17. package/dist/{chunk-CUDKD32S.js → chunk-DIAO4W7O.js} +11 -17
  18. package/dist/{chunk-XJQP3B4W.js → chunk-DJMFXNR4.js} +7 -15
  19. package/dist/{chunk-V5LEZ5BX.js → chunk-DY3QUOB7.js} +634 -807
  20. package/dist/{chunk-YD7GG4WS.js → chunk-FRTPDRF2.js} +66 -74
  21. package/dist/chunk-HIFVDK2U.js +96 -0
  22. package/dist/chunk-I4EY55DC.js +195 -0
  23. package/dist/{chunk-WLJHGKMK.js → chunk-IHDN3L3R.js} +7 -8
  24. package/dist/{chunk-INC2OACE.js → chunk-JFKDSUIE.js} +3 -9
  25. package/dist/{chunk-V7DE6JTG.js → chunk-JZ75RIMZ.js} +3 -9
  26. package/dist/{chunk-AAATUOV6.js → chunk-L6KOIJJ5.js} +53 -59
  27. package/dist/{chunk-GN5BY5N2.js → chunk-LGYRZ6CV.js} +4 -10
  28. package/dist/chunk-LVLRGTYH.js +148 -0
  29. package/dist/{chunk-CQQQ436N.js → chunk-MATFO4ZW.js} +186 -200
  30. package/dist/{chunk-IFCV5MY4.js → chunk-OCQGHQED.js} +5 -11
  31. package/dist/chunk-ORL3LJOT.js +470 -0
  32. package/dist/{chunk-Q7ACZDDT.js → chunk-QOPTDDIH.js} +5 -12
  33. package/dist/chunk-QTAIWPLH.js +78 -0
  34. package/dist/{chunk-35LAJN5S.js → chunk-RP2N6UXA.js} +23 -29
  35. package/dist/chunk-RQFGRXJI.js +174 -0
  36. package/dist/{chunk-QBK5XTJE.js → chunk-RR6BKMNO.js} +3 -9
  37. package/dist/{chunk-ILJRJJ3S.js → chunk-RTGQXNX6.js} +3 -9
  38. package/dist/chunk-SKRR5WT4.js +76 -0
  39. package/dist/chunk-TM3ETZES.js +153 -0
  40. package/dist/{chunk-KPUNMK5W.js → chunk-TWPTG4XS.js} +5 -12
  41. package/dist/{chunk-6QFE3AWR.js → chunk-UP6FVCDK.js} +6 -13
  42. package/dist/{chunk-YKUZUAXA.js → chunk-V3ZMNXZC.js} +16 -23
  43. package/dist/chunk-WLPX3672.js +365 -0
  44. package/dist/chunk-WNH2ACJS.js +122 -0
  45. package/dist/chunk-XSNOKQTD.js +347 -0
  46. package/dist/{chunk-X6XGFLEF.js → chunk-YZVZCC3I.js} +25 -30
  47. package/dist/commands/DbCommand.js +3 -4
  48. package/dist/commands/DbDrop.js +9 -9
  49. package/dist/commands/DbExecute.js +7 -8
  50. package/dist/commands/DbPull.js +18 -19
  51. package/dist/commands/DbPush.js +12 -13
  52. package/dist/commands/DbSeed.js +4 -5
  53. package/dist/commands/MigrateCommand.js +3 -4
  54. package/dist/commands/MigrateDeploy.js +13 -14
  55. package/dist/commands/MigrateDev.js +17 -18
  56. package/dist/commands/MigrateDiff.js +8 -9
  57. package/dist/commands/MigrateReset.js +15 -16
  58. package/dist/commands/MigrateResolve.js +11 -12
  59. package/dist/commands/MigrateStatus.js +11 -12
  60. package/dist/index.js +60 -77
  61. package/dist/{multipart-parser-73VM3J4A.js → multipart-parser-NDLECNMN.js} +527 -561
  62. package/dist/utils/byline.js +5 -6
  63. package/dist/utils/captureStdout.js +2 -3
  64. package/dist/utils/countModelsAndTypes.js +2 -3
  65. package/dist/utils/ensureDatabaseExists.js +8 -9
  66. package/dist/utils/errors.js +8 -9
  67. package/dist/utils/flagErrors.js +5 -5
  68. package/dist/utils/getDatabaseVersionSafe.js +6 -7
  69. package/dist/utils/getSchemaPathAndPrint.js +4 -5
  70. package/dist/utils/handleEvaluateDataloss.js +3 -4
  71. package/dist/utils/introspectSql.js +6 -6
  72. package/dist/utils/isSchemaEmpty.js +2 -3
  73. package/dist/utils/printDatasource.js +3 -4
  74. package/dist/utils/printDatasources.js +3 -4
  75. package/dist/utils/printFiles.js +5 -6
  76. package/dist/utils/printIntrospectedSchema.js +2 -3
  77. package/dist/utils/printMigrationId.js +4 -5
  78. package/dist/utils/promptForMigrationName.js +2 -3
  79. package/dist/utils/removeSchemaFiles.js +2 -3
  80. package/dist/utils/replaceOrAddDatasource.js +2 -3
  81. package/dist/utils/replaceOrAddDatasource.test.js +7 -8
  82. package/dist/utils/saveSchemaFiles.js +2 -3
  83. package/dist/utils/seed.js +6 -7
  84. package/dist/utils/spinner.js +2 -3
  85. package/dist/utils/unixSocket.js +2 -3
  86. package/dist/views/handleViewsIO.js +2 -3
  87. package/package.json +6 -6
  88. package/dist/chunk-26XQQ4AG.js +0 -386
  89. package/dist/chunk-2RSEPJFX.js +0 -165
  90. package/dist/chunk-4B2LXK4R.js +0 -207
  91. package/dist/chunk-4UJBOCZJ.js +0 -130
  92. package/dist/chunk-5HZLCY6X.js +0 -161
  93. package/dist/chunk-6TE2RIPN.js +0 -80
  94. package/dist/chunk-7S3Q4MCN.js +0 -480
  95. package/dist/chunk-AOX7CJAS.js +0 -234
  96. package/dist/chunk-FF3526PX.js +0 -279
  97. package/dist/chunk-FUSFURVP.js +0 -86
  98. package/dist/chunk-GCTCQLOF.js +0 -365
  99. package/dist/chunk-K44VNAFW.js +0 -189
  100. package/dist/chunk-O4BT6W33.js +0 -104
  101. package/dist/chunk-TKAGMA5K.js +0 -72
  102. package/dist/chunk-U374EXYQ.js +0 -106
@@ -16,14 +16,13 @@ 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_YD7GG4WS_exports = {};
20
- __export(chunk_YD7GG4WS_exports, {
21
- DbSeed: () => DbSeed,
22
- init_DbSeed: () => init_DbSeed
19
+ var chunk_FRTPDRF2_exports = {};
20
+ __export(chunk_FRTPDRF2_exports, {
21
+ DbSeed: () => DbSeed
23
22
  });
24
- module.exports = __toCommonJS(chunk_YD7GG4WS_exports);
25
- var import_chunk_YKUZUAXA = require("./chunk-YKUZUAXA.js");
26
- var import_chunk_6TE2RIPN = require("./chunk-6TE2RIPN.js");
23
+ module.exports = __toCommonJS(chunk_FRTPDRF2_exports);
24
+ var import_chunk_V3ZMNXZC = require("./chunk-V3ZMNXZC.js");
25
+ var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
27
26
  var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
28
27
  var import_internals = require("@prisma/internals");
29
28
  var require_arg = (0, import_chunk_WWAWV7DQ.__commonJS)({
@@ -169,84 +168,77 @@ var require_arg = (0, import_chunk_WWAWV7DQ.__commonJS)({
169
168
  module2.exports = arg2;
170
169
  }
171
170
  });
172
- var import_arg, _DbSeed, DbSeed;
173
- var init_DbSeed = (0, import_chunk_WWAWV7DQ.__esm)({
174
- "src/commands/DbSeed.ts"() {
175
- import_arg = (0, import_chunk_WWAWV7DQ.__toESM)(require_arg());
176
- (0, import_chunk_6TE2RIPN.init_colors)();
177
- (0, import_chunk_YKUZUAXA.init_seed)();
178
- _DbSeed = class _DbSeed2 {
179
- static new() {
180
- return new _DbSeed2();
181
- }
182
- async parse(argv, config) {
183
- const args = (0, import_internals.arg)(
184
- argv,
185
- {
186
- "--help": Boolean,
187
- "-h": "--help",
188
- "--schema": String,
189
- "--config": String,
190
- "--telemetry-information": String
191
- },
192
- false
193
- );
194
- if ((0, import_internals.isError)(args)) {
195
- if (args instanceof import_arg.ArgError && args.code === "ARG_UNKNOWN_OPTION") {
196
- throw new Error(`${args.message}
171
+ var import_arg = (0, import_chunk_WWAWV7DQ.__toESM)(require_arg());
172
+ var _DbSeed = class _DbSeed2 {
173
+ static new() {
174
+ return new _DbSeed2();
175
+ }
176
+ async parse(argv, config) {
177
+ const args = (0, import_internals.arg)(
178
+ argv,
179
+ {
180
+ "--help": Boolean,
181
+ "-h": "--help",
182
+ "--schema": String,
183
+ "--config": String,
184
+ "--telemetry-information": String
185
+ },
186
+ false
187
+ );
188
+ if ((0, import_internals.isError)(args)) {
189
+ if (args instanceof import_arg.ArgError && args.code === "ARG_UNKNOWN_OPTION") {
190
+ throw new Error(`${args.message}
197
191
  Did you mean to pass these as arguments to your seed script? If so, add a -- separator before them:
198
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db seed -- --arg1 value1 --arg2 value2`);
199
- }
200
- return this.help(args.message);
201
- }
202
- if (args["--help"]) {
203
- return this.help();
204
- }
205
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
206
- const seedCommandFromPkgJson = await (0, import_chunk_YKUZUAXA.getSeedCommandFromPackageJson)(process.cwd());
207
- if (!seedCommandFromPkgJson) {
208
- const schemaResult = await (0, import_internals.getSchemaWithPath)(args["--schema"], config.schema);
209
- const message = await (0, import_chunk_YKUZUAXA.verifySeedConfigAndReturnMessage)(schemaResult?.schemaPath ?? null);
210
- if (message) {
211
- throw new Error(message);
212
- }
213
- return ``;
214
- }
215
- const extraArgs = args._.join(" ");
216
- const successfulSeeding = await (0, import_chunk_YKUZUAXA.executeSeedCommand)({ commandFromConfig: seedCommandFromPkgJson, extraArgs });
217
- if (successfulSeeding) {
218
- return `
219
- ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.`;
220
- } else {
221
- process.exit(1);
222
- }
192
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed -- --arg1 value1 --arg2 value2`);
223
193
  }
224
- help(error) {
225
- if (error) {
226
- return new import_internals.HelpError(`
227
- ${(0, import_chunk_6TE2RIPN.bold)((0, import_chunk_6TE2RIPN.red)(`!`))} ${error}
228
- ${_DbSeed2.help}`);
229
- }
230
- return _DbSeed2.help;
194
+ return this.help(args.message);
195
+ }
196
+ if (args["--help"]) {
197
+ return this.help();
198
+ }
199
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
200
+ const seedCommandFromPkgJson = await (0, import_chunk_V3ZMNXZC.getSeedCommandFromPackageJson)(process.cwd());
201
+ if (!seedCommandFromPkgJson) {
202
+ const schemaResult = await (0, import_internals.getSchemaWithPath)(args["--schema"], config.schema);
203
+ const message = await (0, import_chunk_V3ZMNXZC.verifySeedConfigAndReturnMessage)(schemaResult?.schemaPath ?? null);
204
+ if (message) {
205
+ throw new Error(message);
231
206
  }
232
- };
233
- _DbSeed.help = (0, import_internals.format)(`
207
+ return ``;
208
+ }
209
+ const extraArgs = args._.join(" ");
210
+ const successfulSeeding = await (0, import_chunk_V3ZMNXZC.executeSeedCommand)({ commandFromConfig: seedCommandFromPkgJson, extraArgs });
211
+ if (successfulSeeding) {
212
+ return `
213
+ ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.`;
214
+ } else {
215
+ process.exit(1);
216
+ }
217
+ }
218
+ help(error) {
219
+ if (error) {
220
+ return new import_internals.HelpError(`
221
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
222
+ ${_DbSeed2.help}`);
223
+ }
224
+ return _DbSeed2.help;
225
+ }
226
+ };
227
+ _DbSeed.help = (0, import_internals.format)(`
234
228
  ${process.platform === "win32" ? "" : "\u{1F64C} "}Seed your database
235
229
 
236
- ${(0, import_chunk_6TE2RIPN.bold)("Usage")}
230
+ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
237
231
 
238
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db seed [options]
232
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed [options]
239
233
 
240
- ${(0, import_chunk_6TE2RIPN.bold)("Options")}
234
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
241
235
 
242
236
  -h, --help Display this help message
243
237
  --config Custom path to your Prisma config file
244
238
 
245
- ${(0, import_chunk_6TE2RIPN.bold)("Examples")}
239
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
246
240
 
247
241
  Passing extra arguments to the seed command
248
- ${(0, import_chunk_6TE2RIPN.dim)("$")} prisma db seed -- --arg1 value1 --arg2 value2
242
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed -- --arg1 value1 --arg2 value2
249
243
  `);
250
- DbSeed = _DbSeed;
251
- }
252
- });
244
+ var DbSeed = _DbSeed;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var chunk_HIFVDK2U_exports = {};
20
+ __export(chunk_HIFVDK2U_exports, {
21
+ DbCommand: () => DbCommand
22
+ });
23
+ module.exports = __toCommonJS(chunk_HIFVDK2U_exports);
24
+ var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
25
+ var import_internals = require("@prisma/internals");
26
+ var _DbCommand = class _DbCommand2 {
27
+ constructor(cmds) {
28
+ this.cmds = cmds;
29
+ }
30
+ static new(cmds) {
31
+ return new _DbCommand2(cmds);
32
+ }
33
+ async parse(argv, config) {
34
+ const args = (0, import_internals.arg)(argv, {
35
+ "--help": Boolean,
36
+ "-h": "--help",
37
+ "--config": String,
38
+ "--preview-feature": Boolean,
39
+ "--telemetry-information": String
40
+ });
41
+ if ((0, import_internals.isError)(args)) {
42
+ return this.help(args.message);
43
+ }
44
+ if (args._.length === 0 || args["--help"]) {
45
+ return this.help();
46
+ }
47
+ const cmd = this.cmds[args._[0]];
48
+ if (cmd) {
49
+ const argsForCmd = args["--preview-feature"] ? [...args._.slice(1), `--preview-feature`] : args._.slice(1);
50
+ return cmd.parse(argsForCmd, config);
51
+ }
52
+ return (0, import_internals.unknownCommand)(_DbCommand2.help, args._[0]);
53
+ }
54
+ help(error) {
55
+ if (error) {
56
+ return new import_internals.HelpError(`
57
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
58
+ ${_DbCommand2.help}`);
59
+ }
60
+ return _DbCommand2.help;
61
+ }
62
+ };
63
+ _DbCommand.help = (0, import_internals.format)(`
64
+ ${process.platform === "win32" ? "" : "\u{1F3CB}\uFE0F "}Manage your database schema and lifecycle during development.
65
+
66
+ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
67
+
68
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db [command] [options]
69
+
70
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
71
+
72
+ -h, --help Display this help message
73
+ --config Custom path to your Prisma config file
74
+ --schema Custom path to your Prisma schema
75
+
76
+ ${(0, import_chunk_SKRR5WT4.bold)("Commands")}
77
+ pull Pull the state from the database to the Prisma schema using introspection
78
+ push Push the state from Prisma schema to the database during prototyping
79
+ seed Seed your database
80
+ execute Execute native commands to your database
81
+
82
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
83
+
84
+ Run \`prisma db pull\`
85
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull
86
+
87
+ Run \`prisma db push\`
88
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db push
89
+
90
+ Run \`prisma db seed\`
91
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db seed
92
+
93
+ Run \`prisma db execute\`
94
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute
95
+ `);
96
+ var DbCommand = _DbCommand;
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_I4EY55DC_exports = {};
30
+ __export(chunk_I4EY55DC_exports, {
31
+ MigrateStatus: () => MigrateStatus
32
+ });
33
+ module.exports = __toCommonJS(chunk_I4EY55DC_exports);
34
+ var import_chunk_DDHPSYC4 = require("./chunk-DDHPSYC4.js");
35
+ var import_chunk_6DFJIBJX = require("./chunk-6DFJIBJX.js");
36
+ var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
37
+ var import_chunk_DJMFXNR4 = require("./chunk-DJMFXNR4.js");
38
+ var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
39
+ var import_debug = __toESM(require("@prisma/debug"));
40
+ var import_internals = require("@prisma/internals");
41
+ var debug = (0, import_debug.default)("prisma:migrate:status");
42
+ var _MigrateStatus = class _MigrateStatus2 {
43
+ static new() {
44
+ return new _MigrateStatus2();
45
+ }
46
+ async parse(argv, config) {
47
+ const args = (0, import_internals.arg)(
48
+ argv,
49
+ {
50
+ "--help": Boolean,
51
+ "-h": "--help",
52
+ "--schema": String,
53
+ "--config": String,
54
+ "--telemetry-information": String
55
+ },
56
+ false
57
+ );
58
+ if ((0, import_internals.isError)(args)) {
59
+ return this.help(args.message);
60
+ }
61
+ await (0, import_internals.checkUnsupportedDataProxy)("migrate status", args, config.schema, true);
62
+ if (args["--help"]) {
63
+ return this.help();
64
+ }
65
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
66
+ const { schemaPath } = await (0, import_chunk_6DFJIBJX.getSchemaPathAndPrint)(args["--schema"], config.schema);
67
+ (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: await (0, import_chunk_DJMFXNR4.getDatasourceInfo)({ schemaPath }) });
68
+ const migrate = new import_chunk_DDHPSYC4.Migrate(schemaPath);
69
+ await (0, import_chunk_DJMFXNR4.ensureCanConnectToDatabase)(schemaPath);
70
+ let diagnoseResult;
71
+ let listMigrationDirectoriesResult;
72
+ try {
73
+ diagnoseResult = await migrate.diagnoseMigrationHistory({
74
+ optInToShadowDatabase: false
75
+ });
76
+ debug({ diagnoseResult: JSON.stringify(diagnoseResult, null, 2) });
77
+ listMigrationDirectoriesResult = await migrate.listMigrationDirectories();
78
+ debug({ listMigrationDirectoriesResult });
79
+ } finally {
80
+ migrate.stop();
81
+ }
82
+ process.stdout.write("\n");
83
+ if (listMigrationDirectoriesResult.migrations.length > 0) {
84
+ const migrations = listMigrationDirectoriesResult.migrations;
85
+ process.stdout.write(
86
+ `${migrations.length} migration${migrations.length > 1 ? "s" : ""} found in prisma/migrations
87
+ `
88
+ );
89
+ } else {
90
+ process.stdout.write(`No migration found in prisma/migrations
91
+ `);
92
+ }
93
+ let unappliedMigrations = [];
94
+ if (diagnoseResult.history?.diagnostic === "databaseIsBehind") {
95
+ unappliedMigrations = diagnoseResult.history.unappliedMigrationNames;
96
+ process.stdout.write(
97
+ `Following migration${unappliedMigrations.length > 1 ? "s" : ""} have not yet been applied:
98
+ ${unappliedMigrations.join("\n")}
99
+
100
+ To apply migrations in development run ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)(`prisma migrate dev`)))}.
101
+ To apply migrations in production run ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)(`prisma migrate deploy`)))}.
102
+ `
103
+ );
104
+ process.exit(1);
105
+ } else if (diagnoseResult.history?.diagnostic === "historiesDiverge") {
106
+ console.error(`Your local migration history and the migrations table from your database are different:
107
+
108
+ The last common migration is: ${diagnoseResult.history.lastCommonMigrationName}
109
+
110
+ The migration${diagnoseResult.history.unappliedMigrationNames.length > 1 ? "s" : ""} have not yet been applied:
111
+ ${diagnoseResult.history.unappliedMigrationNames.join("\n")}
112
+
113
+ The migration${diagnoseResult.history.unpersistedMigrationNames.length > 1 ? "s" : ""} from the database are not found locally in prisma/migrations:
114
+ ${diagnoseResult.history.unpersistedMigrationNames.join("\n")}`);
115
+ process.exit(1);
116
+ }
117
+ if (!diagnoseResult.hasMigrationsTable) {
118
+ if (listMigrationDirectoriesResult.migrations.length === 0) {
119
+ console.error(`The current database is not managed by Prisma Migrate.
120
+
121
+ Read more about how to baseline an existing production database:
122
+ ${(0, import_internals.link)("https://pris.ly/d/migrate-baseline")}`);
123
+ process.exit(1);
124
+ } else {
125
+ const migrationId = listMigrationDirectoriesResult.migrations.shift();
126
+ console.error(`The current database is not managed by Prisma Migrate.
127
+
128
+ If you want to keep the current database structure and data and create new migrations, baseline this database with the migration "${migrationId}":
129
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)(`prisma migrate resolve --applied "${migrationId}"`)))}
130
+
131
+ Read more about how to baseline an existing production database:
132
+ https://pris.ly/d/migrate-baseline`);
133
+ process.exit(1);
134
+ }
135
+ } else if (diagnoseResult.failedMigrationNames.length > 0) {
136
+ const failedMigrations = diagnoseResult.failedMigrationNames;
137
+ console.error(
138
+ `Following migration${failedMigrations.length > 1 ? "s" : ""} have failed:
139
+ ${failedMigrations.join("\n")}
140
+
141
+ During development if the failed migration(s) have not been deployed to a production database you can then fix the migration(s) and run ${(0, import_chunk_SKRR5WT4.bold)(
142
+ (0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)(`prisma migrate dev`))
143
+ )}.
144
+ `
145
+ );
146
+ console.error(`The failed migration(s) can be marked as rolled back or applied:
147
+
148
+ - If you rolled back the migration(s) manually:
149
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)(`prisma migrate resolve --rolled-back "${failedMigrations[0]}"`)))}
150
+
151
+ - If you fixed the database manually (hotfix):
152
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)(`prisma migrate resolve --applied "${failedMigrations[0]}"`)))}
153
+
154
+ Read more about how to resolve migration issues in a production database:
155
+ ${(0, import_internals.link)("https://pris.ly/d/migrate-resolve")}`);
156
+ process.exit(1);
157
+ } else {
158
+ process.stdout.write("\n");
159
+ if (unappliedMigrations.length === 0) {
160
+ return `Database schema is up to date!`;
161
+ }
162
+ }
163
+ return "";
164
+ }
165
+ help(error) {
166
+ if (error) {
167
+ return new import_internals.HelpError(`
168
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
169
+ ${_MigrateStatus2.help}`);
170
+ }
171
+ return _MigrateStatus2.help;
172
+ }
173
+ };
174
+ _MigrateStatus.help = (0, import_internals.format)(`
175
+ Check the status of your database migrations
176
+
177
+ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
178
+
179
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate status [options]
180
+
181
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
182
+
183
+ -h, --help Display this help message
184
+ --config Custom path to your Prisma config file
185
+ --schema Custom path to your Prisma schema
186
+
187
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
188
+
189
+ Check the status of your database migrations
190
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate status
191
+
192
+ Specify a schema
193
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate status --schema=./schema.prisma
194
+ `);
195
+ var MigrateStatus = _MigrateStatus;
@@ -16,19 +16,18 @@ 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_WLJHGKMK_exports = {};
20
- __export(chunk_WLJHGKMK_exports, {
19
+ var chunk_IHDN3L3R_exports = {};
20
+ __export(chunk_IHDN3L3R_exports, {
21
21
  EarlyAccessFlagError: () => EarlyAccessFlagError,
22
22
  ExperimentalFlagError: () => ExperimentalFlagError,
23
23
  PreviewFlagError: () => PreviewFlagError
24
24
  });
25
- module.exports = __toCommonJS(chunk_WLJHGKMK_exports);
26
- var import_chunk_6TE2RIPN = require("./chunk-6TE2RIPN.js");
25
+ module.exports = __toCommonJS(chunk_IHDN3L3R_exports);
26
+ var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
27
27
  var import_internals = require("@prisma/internals");
28
- (0, import_chunk_6TE2RIPN.init_colors)();
29
28
  var ExperimentalFlagError = class extends Error {
30
29
  constructor() {
31
- super(`Please provide the ${(0, import_chunk_6TE2RIPN.green)("--experimental")} flag to use this command.`);
30
+ super(`Please provide the ${(0, import_chunk_SKRR5WT4.green)("--experimental")} flag to use this command.`);
32
31
  }
33
32
  };
34
33
  (0, import_internals.setClassName)(ExperimentalFlagError, "ExperimentalFlagError");
@@ -36,7 +35,7 @@ var PreviewFlagError = class extends Error {
36
35
  constructor() {
37
36
  super(
38
37
  `This feature is currently in Preview. There may be bugs and it's not recommended to use it in production environments.
39
- Please provide the ${(0, import_chunk_6TE2RIPN.green)("--preview-feature")} flag to use this command.`
38
+ Please provide the ${(0, import_chunk_SKRR5WT4.green)("--preview-feature")} flag to use this command.`
40
39
  );
41
40
  }
42
41
  };
@@ -45,7 +44,7 @@ var EarlyAccessFlagError = class extends Error {
45
44
  constructor() {
46
45
  super(
47
46
  `This feature is currently in Early Access. There may be bugs and it's not recommended to use it in production environments.
48
- Please provide the ${(0, import_chunk_6TE2RIPN.green)("--early-access")} flag to use this command.`
47
+ Please provide the ${(0, import_chunk_SKRR5WT4.green)("--early-access")} flag to use this command.`
49
48
  );
50
49
  }
51
50
  };
@@ -16,20 +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_INC2OACE_exports = {};
20
- __export(chunk_INC2OACE_exports, {
21
- init_isSchemaEmpty: () => init_isSchemaEmpty,
19
+ var chunk_JFKDSUIE_exports = {};
20
+ __export(chunk_JFKDSUIE_exports, {
22
21
  isSchemaEmpty: () => isSchemaEmpty
23
22
  });
24
- module.exports = __toCommonJS(chunk_INC2OACE_exports);
25
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
23
+ module.exports = __toCommonJS(chunk_JFKDSUIE_exports);
26
24
  function isSchemaEmpty(schemas) {
27
25
  if (!schemas) {
28
26
  return true;
29
27
  }
30
28
  return schemas.files.every((schema) => schema.content.trim() === "");
31
29
  }
32
- var init_isSchemaEmpty = (0, import_chunk_WWAWV7DQ.__esm)({
33
- "src/utils/isSchemaEmpty.ts"() {
34
- }
35
- });
@@ -26,18 +26,12 @@ 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_V7DE6JTG_exports = {};
30
- __export(chunk_V7DE6JTG_exports, {
31
- init_removeSchemaFiles: () => init_removeSchemaFiles,
29
+ var chunk_JZ75RIMZ_exports = {};
30
+ __export(chunk_JZ75RIMZ_exports, {
32
31
  removeSchemaFiles: () => removeSchemaFiles
33
32
  });
34
- module.exports = __toCommonJS(chunk_V7DE6JTG_exports);
35
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
33
+ module.exports = __toCommonJS(chunk_JZ75RIMZ_exports);
36
34
  var import_promises = __toESM(require("node:fs/promises"));
37
35
  async function removeSchemaFiles(files) {
38
36
  await Promise.all(files.map(([path]) => import_promises.default.rm(path)));
39
37
  }
40
- var init_removeSchemaFiles = (0, import_chunk_WWAWV7DQ.__esm)({
41
- "src/utils/removeSchemaFiles.ts"() {
42
- }
43
- });