@prisma/migrate 6.5.0-dev.1 → 6.5.0-integration-push-zsmplqopwokk.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 (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 +117 -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-YD7GG4WS.js → chunk-FRTPDRF2.js} +66 -74
  20. package/dist/chunk-HIFVDK2U.js +96 -0
  21. package/dist/chunk-I4EY55DC.js +195 -0
  22. package/dist/{chunk-WLJHGKMK.js → chunk-IHDN3L3R.js} +7 -8
  23. package/dist/{chunk-INC2OACE.js → chunk-JFKDSUIE.js} +3 -9
  24. package/dist/{chunk-V7DE6JTG.js → chunk-JZ75RIMZ.js} +3 -9
  25. package/dist/{chunk-AAATUOV6.js → chunk-L6KOIJJ5.js} +53 -59
  26. package/dist/{chunk-GN5BY5N2.js → chunk-LGYRZ6CV.js} +4 -10
  27. package/dist/chunk-LVLRGTYH.js +148 -0
  28. package/dist/{chunk-CQQQ436N.js → chunk-MATFO4ZW.js} +186 -200
  29. package/dist/{chunk-IFCV5MY4.js → chunk-OCQGHQED.js} +5 -11
  30. package/dist/chunk-ORL3LJOT.js +470 -0
  31. package/dist/{chunk-Q7ACZDDT.js → chunk-QOPTDDIH.js} +5 -12
  32. package/dist/chunk-QTAIWPLH.js +78 -0
  33. package/dist/{chunk-35LAJN5S.js → chunk-RP2N6UXA.js} +23 -29
  34. package/dist/chunk-RQFGRXJI.js +174 -0
  35. package/dist/{chunk-QBK5XTJE.js → chunk-RR6BKMNO.js} +3 -9
  36. package/dist/{chunk-ILJRJJ3S.js → chunk-RTGQXNX6.js} +3 -9
  37. package/dist/chunk-SKRR5WT4.js +76 -0
  38. package/dist/chunk-TM3ETZES.js +153 -0
  39. package/dist/{chunk-KPUNMK5W.js → chunk-TWPTG4XS.js} +5 -12
  40. package/dist/{chunk-6QFE3AWR.js → chunk-UP6FVCDK.js} +6 -13
  41. package/dist/{chunk-YKUZUAXA.js → chunk-V3ZMNXZC.js} +16 -23
  42. package/dist/chunk-WLPX3672.js +365 -0
  43. package/dist/chunk-WNH2ACJS.js +122 -0
  44. package/dist/chunk-XSNOKQTD.js +347 -0
  45. package/dist/{chunk-V5LEZ5BX.js → chunk-YAB7USDV.js} +634 -807
  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
@@ -0,0 +1,347 @@
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_XSNOKQTD_exports = {};
30
+ __export(chunk_XSNOKQTD_exports, {
31
+ MigrateDev: () => MigrateDev
32
+ });
33
+ module.exports = __toCommonJS(chunk_XSNOKQTD_exports);
34
+ var import_chunk_OCQGHQED = require("./chunk-OCQGHQED.js");
35
+ var import_chunk_7CQBDP4H = require("./chunk-7CQBDP4H.js");
36
+ var import_chunk_V3ZMNXZC = require("./chunk-V3ZMNXZC.js");
37
+ var import_chunk_255BRND3 = require("./chunk-255BRND3.js");
38
+ var import_chunk_UP6FVCDK = require("./chunk-UP6FVCDK.js");
39
+ var import_chunk_DDHPSYC4 = require("./chunk-DDHPSYC4.js");
40
+ var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
41
+ var import_chunk_6DFJIBJX = require("./chunk-6DFJIBJX.js");
42
+ var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
43
+ var import_chunk_DJMFXNR4 = require("./chunk-DJMFXNR4.js");
44
+ var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
45
+ var import_debug = __toESM(require("@prisma/debug"));
46
+ var import_internals = require("@prisma/internals");
47
+ var import_prompts = __toESM(require("prompts"));
48
+ var debug = (0, import_debug.default)("prisma:migrate:dev");
49
+ var _MigrateDev = class _MigrateDev2 {
50
+ static new() {
51
+ return new _MigrateDev2();
52
+ }
53
+ async parse(argv, config) {
54
+ const args = (0, import_internals.arg)(argv, {
55
+ "--help": Boolean,
56
+ "-h": "--help",
57
+ "--name": String,
58
+ "-n": "--name",
59
+ // '--force': Boolean,
60
+ // '-f': '--force',
61
+ "--create-only": Boolean,
62
+ "--schema": String,
63
+ "--config": String,
64
+ "--skip-generate": Boolean,
65
+ "--skip-seed": Boolean,
66
+ "--telemetry-information": String
67
+ });
68
+ if ((0, import_internals.isError)(args)) {
69
+ return this.help(args.message);
70
+ }
71
+ await (0, import_internals.checkUnsupportedDataProxy)("migrate dev", args, config.schema, true);
72
+ if (args["--help"]) {
73
+ return this.help();
74
+ }
75
+ await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
76
+ const { schemaPath, schemas } = await (0, import_chunk_6DFJIBJX.getSchemaPathAndPrint)(args["--schema"], config.schema);
77
+ const datasourceInfo = await (0, import_chunk_DJMFXNR4.getDatasourceInfo)({ schemaPath });
78
+ (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo });
79
+ process.stdout.write("\n");
80
+ (0, import_internals.validate)({
81
+ schemas
82
+ });
83
+ await (0, import_internals.getConfig)({
84
+ datamodel: schemas,
85
+ ignoreEnvVarErrors: false
86
+ });
87
+ const wasDbCreated = await (0, import_chunk_DJMFXNR4.ensureDatabaseExists)("create", schemaPath);
88
+ if (wasDbCreated) {
89
+ process.stdout.write(wasDbCreated + "\n\n");
90
+ }
91
+ const migrate = new import_chunk_DDHPSYC4.Migrate(schemaPath);
92
+ let devDiagnostic;
93
+ try {
94
+ devDiagnostic = await migrate.devDiagnostic();
95
+ debug({ devDiagnostic: JSON.stringify(devDiagnostic, null, 2) });
96
+ } catch (e) {
97
+ migrate.stop();
98
+ throw e;
99
+ }
100
+ const migrationIdsApplied = [];
101
+ if (devDiagnostic.action.tag === "reset") {
102
+ if (!args["--force"]) {
103
+ if (!(0, import_internals.canPrompt)()) {
104
+ migrate.stop();
105
+ throw new import_chunk_3WC4XD74.MigrateDevEnvNonInteractiveError();
106
+ }
107
+ const confirmedReset = await this.confirmReset({
108
+ datasourceInfo,
109
+ reason: devDiagnostic.action.reason
110
+ });
111
+ process.stdout.write("\n");
112
+ if (!confirmedReset) {
113
+ process.stdout.write("Reset cancelled.\n");
114
+ migrate.stop();
115
+ process.exit(130);
116
+ }
117
+ }
118
+ try {
119
+ await migrate.reset();
120
+ } catch (e) {
121
+ migrate.stop();
122
+ throw e;
123
+ }
124
+ }
125
+ try {
126
+ const { appliedMigrationNames } = await migrate.applyMigrations();
127
+ migrationIdsApplied.push(...appliedMigrationNames);
128
+ if (appliedMigrationNames.length > 0) {
129
+ process.stdout.write(
130
+ `
131
+ The following migration(s) have been applied:
132
+
133
+ ${(0, import_chunk_255BRND3.printFilesFromMigrationIds)(
134
+ "migrations",
135
+ appliedMigrationNames,
136
+ {
137
+ "migration.sql": ""
138
+ }
139
+ )}
140
+ `
141
+ );
142
+ }
143
+ } catch (e) {
144
+ migrate.stop();
145
+ throw e;
146
+ }
147
+ let evaluateDataLossResult;
148
+ try {
149
+ evaluateDataLossResult = await migrate.evaluateDataLoss();
150
+ debug({ evaluateDataLossResult });
151
+ } catch (e) {
152
+ migrate.stop();
153
+ throw e;
154
+ }
155
+ const unexecutableStepsError = (0, import_chunk_7CQBDP4H.handleUnexecutableSteps)(
156
+ evaluateDataLossResult.unexecutableSteps,
157
+ args["--create-only"]
158
+ );
159
+ if (unexecutableStepsError) {
160
+ migrate.stop();
161
+ throw new Error(unexecutableStepsError);
162
+ }
163
+ if (evaluateDataLossResult.warnings && evaluateDataLossResult.warnings.length > 0) {
164
+ process.stdout.write((0, import_chunk_SKRR5WT4.bold)(`
165
+ \u26A0\uFE0F Warnings for the current datasource:
166
+
167
+ `));
168
+ for (const warning of evaluateDataLossResult.warnings) {
169
+ process.stdout.write(` \u2022 ${warning.message}
170
+ `);
171
+ }
172
+ process.stdout.write("\n");
173
+ if (!args["--force"]) {
174
+ if (!(0, import_internals.canPrompt)()) {
175
+ migrate.stop();
176
+ throw new import_chunk_3WC4XD74.MigrateDevEnvNonInteractiveError();
177
+ }
178
+ const message = args["--create-only"] ? "Are you sure you want to create this migration?" : "Are you sure you want to create and apply this migration?";
179
+ const confirmation = await (0, import_prompts.default)({
180
+ type: "confirm",
181
+ name: "value",
182
+ message
183
+ });
184
+ if (!confirmation.value) {
185
+ process.stdout.write("Migration cancelled.\n");
186
+ migrate.stop();
187
+ process.exit(130);
188
+ }
189
+ }
190
+ }
191
+ let migrationName = void 0;
192
+ if (evaluateDataLossResult.migrationSteps > 0 || args["--create-only"]) {
193
+ const getMigrationNameResult = await (0, import_chunk_OCQGHQED.getMigrationName)(args["--name"]);
194
+ if (getMigrationNameResult.userCancelled) {
195
+ process.stdout.write(getMigrationNameResult.userCancelled + "\n");
196
+ migrate.stop();
197
+ process.exit(130);
198
+ } else {
199
+ migrationName = getMigrationNameResult.name;
200
+ }
201
+ }
202
+ let migrationIds;
203
+ try {
204
+ const createMigrationResult = await migrate.createMigration({
205
+ migrationsDirectoryPath: migrate.migrationsDirectoryPath,
206
+ migrationName: migrationName || "",
207
+ draft: args["--create-only"] ? true : false,
208
+ schema: (0, import_internals.toSchemasContainer)((await migrate.getPrismaSchema()).schemas)
209
+ });
210
+ debug({ createMigrationResult });
211
+ if (args["--create-only"]) {
212
+ migrate.stop();
213
+ return `Prisma Migrate created the following migration without applying it ${(0, import_chunk_UP6FVCDK.printMigrationId)(
214
+ createMigrationResult.generatedMigrationName
215
+ )}
216
+
217
+ You can now edit it and apply it by running ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma migrate dev"))}.`;
218
+ }
219
+ const { appliedMigrationNames } = await migrate.applyMigrations();
220
+ migrationIds = appliedMigrationNames;
221
+ } finally {
222
+ migrate.stop();
223
+ }
224
+ migrationIdsApplied.length > 0 && process.stdout.write("\n");
225
+ if (migrationIds.length === 0) {
226
+ if (migrationIdsApplied.length > 0) {
227
+ process.stdout.write(`${(0, import_chunk_SKRR5WT4.green)("Your database is now in sync with your schema.")}
228
+ `);
229
+ } else {
230
+ process.stdout.write(`Already in sync, no schema change or pending migration was found.
231
+ `);
232
+ }
233
+ } else {
234
+ process.stdout.write(
235
+ `
236
+ The following migration(s) have been created and applied from new schema changes:
237
+
238
+ ${(0, import_chunk_255BRND3.printFilesFromMigrationIds)(
239
+ "migrations",
240
+ migrationIds,
241
+ {
242
+ "migration.sql": ""
243
+ }
244
+ )}
245
+
246
+ ${(0, import_chunk_SKRR5WT4.green)("Your database is now in sync with your schema.")}
247
+ `
248
+ );
249
+ }
250
+ if (!process.env.PRISMA_MIGRATE_SKIP_GENERATE && !args["--skip-generate"]) {
251
+ await migrate.tryToRunGenerate(datasourceInfo);
252
+ process.stdout.write("\n");
253
+ }
254
+ if ((wasDbCreated || devDiagnostic.action.tag === "reset") && !process.env.PRISMA_MIGRATE_SKIP_SEED && !args["--skip-seed"]) {
255
+ try {
256
+ const seedCommandFromPkgJson = await (0, import_chunk_V3ZMNXZC.getSeedCommandFromPackageJson)(process.cwd());
257
+ if (seedCommandFromPkgJson) {
258
+ process.stdout.write("\n");
259
+ const successfulSeeding = await (0, import_chunk_V3ZMNXZC.executeSeedCommand)({ commandFromConfig: seedCommandFromPkgJson });
260
+ if (successfulSeeding) {
261
+ process.stdout.write(`
262
+ ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.
263
+ `);
264
+ } else {
265
+ process.exit(1);
266
+ }
267
+ } else {
268
+ const { schemaPath: schemaPath2 } = await (0, import_internals.getSchemaWithPath)(args["--schema"], config.schema);
269
+ await (0, import_chunk_V3ZMNXZC.verifySeedConfigAndReturnMessage)(schemaPath2);
270
+ }
271
+ } catch (e) {
272
+ console.error(e);
273
+ }
274
+ }
275
+ return "";
276
+ }
277
+ async confirmReset({
278
+ datasourceInfo,
279
+ reason
280
+ }) {
281
+ process.stdout.write(reason + "\n");
282
+ let messageFirstLine = "";
283
+ if (["PostgreSQL", "SQL Server"].includes(datasourceInfo.prettyProvider)) {
284
+ if (datasourceInfo.schemas?.length) {
285
+ messageFirstLine = `We need to reset the following schemas: "${datasourceInfo.schemas.join(", ")}"`;
286
+ } else if (datasourceInfo.schema) {
287
+ messageFirstLine = `We need to reset the "${datasourceInfo.schema}" schema`;
288
+ } else {
289
+ messageFirstLine = `We need to reset the database schema`;
290
+ }
291
+ } else {
292
+ messageFirstLine = `We need to reset the ${datasourceInfo.prettyProvider} database "${datasourceInfo.dbName}"`;
293
+ }
294
+ if (datasourceInfo.dbLocation) {
295
+ messageFirstLine += ` at "${datasourceInfo.dbLocation}"`;
296
+ }
297
+ const messageForPrompt = `${messageFirstLine}
298
+ Do you want to continue? ${(0, import_chunk_SKRR5WT4.red)("All data will be lost")}.`;
299
+ if (Boolean(import_prompts.default._injected?.length) === true) {
300
+ process.stdout.write(messageForPrompt + "\n");
301
+ }
302
+ const confirmation = await (0, import_prompts.default)({
303
+ type: "confirm",
304
+ name: "value",
305
+ message: messageForPrompt
306
+ });
307
+ return confirmation.value;
308
+ }
309
+ help(error) {
310
+ if (error) {
311
+ return new import_internals.HelpError(`
312
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
313
+ ${_MigrateDev2.help}`);
314
+ }
315
+ return _MigrateDev2.help;
316
+ }
317
+ };
318
+ _MigrateDev.help = (0, import_internals.format)(`
319
+ ${process.platform === "win32" ? "" : "\u{1F3CB}\uFE0F "}Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client)
320
+
321
+ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
322
+
323
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev [options]
324
+
325
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
326
+
327
+ -h, --help Display this help message
328
+ --config Custom path to your Prisma config file
329
+ --schema Custom path to your Prisma schema
330
+ -n, --name Name the migration
331
+ --create-only Create a new migration but do not apply it
332
+ The migration will be empty if there are no changes in Prisma schema
333
+ --skip-generate Skip triggering generators (e.g. Prisma Client)
334
+ --skip-seed Skip triggering seed
335
+
336
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
337
+
338
+ Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client)
339
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev
340
+
341
+ Specify a schema
342
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev --schema=./schema.prisma
343
+
344
+ Create a migration without applying it
345
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev --create-only
346
+ `);
347
+ var MigrateDev = _MigrateDev;