@prisma/migrate 6.6.0-dev.1 → 6.6.0-dev.100

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 (169) hide show
  1. package/dist/CLI.js +3 -3
  2. package/dist/Migrate.js +9 -7
  3. package/dist/SchemaEngine.js +0 -28
  4. package/dist/{chunk-RM5LJIEV.js → SchemaEngineCLI.js} +10 -16
  5. package/dist/{utils/getSchemaPathAndPrint.js → SchemaEngineWasm.js} +8 -8
  6. package/dist/bin.js +52 -53
  7. package/dist/chunk-23DZXSTI.js +62 -0
  8. package/dist/{chunk-WWAWV7DQ.js → chunk-2ESYSVXG.js} +3 -27
  9. package/dist/{chunk-LKTTJWFT.js → chunk-2R6DII47.js} +5 -5
  10. package/dist/chunk-33LPBNDX.js +1399 -0
  11. package/dist/{chunk-MKK3GSDF.js → chunk-344G2PKM.js} +9 -9
  12. package/dist/{chunk-V3ZMNXZC.js → chunk-5LKIRKDL.js} +307 -382
  13. package/dist/{chunk-LOGAFLCN.js → chunk-5R44VVVX.js} +29 -29
  14. package/dist/{chunk-DJMFXNR4.js → chunk-74LUB4XX.js} +56 -57
  15. package/dist/{chunk-ZQ3OWSVS.js → chunk-A4FQW4A5.js} +54 -50
  16. package/dist/{chunk-RP2N6UXA.js → chunk-AI6DH66U.js} +6 -6
  17. package/dist/{chunk-A6PMXMMT.js → chunk-AUGZZ6RT.js} +105 -13
  18. package/dist/{chunk-G2XUUMKH.js → chunk-B4SUSDC2.js} +31 -39
  19. package/dist/{chunk-LZOZZRHB.js → chunk-CLSF7VUT.js} +42 -38
  20. package/dist/{chunk-Q7M5ANIE.js → chunk-CNCVJ2IN.js} +379 -534
  21. package/dist/{chunk-IR55GBON.js → chunk-CU5UT2ED.js} +19 -18
  22. package/dist/{chunk-TPJISPJ5.js → chunk-CYEVXXRH.js} +51 -47
  23. package/dist/{chunk-W2SZNLK4.js → chunk-EJG7GKM7.js} +37 -39
  24. package/dist/{chunk-5VDXAE53.js → chunk-EJUXYFV3.js} +26 -16
  25. package/dist/{chunk-X6KW7BYP.js → chunk-HIDSEBVV.js} +55 -54
  26. package/dist/{chunk-ZOEKRXDP.js → chunk-I3LT2PO3.js} +35 -57
  27. package/dist/{chunk-E7OXHCDR.js → chunk-IEEJZC3B.js} +56 -49
  28. package/dist/chunk-IINN7QUV.js +2565 -0
  29. package/dist/chunk-IK3BVD3Y.js +233 -0
  30. package/dist/{chunk-255BRND3.js → chunk-KRQEFTDT.js} +6 -6
  31. package/dist/{chunk-EX2UWGES.js → chunk-KW633S3Y.js} +56 -52
  32. package/dist/{chunk-VVKOFN3Y.js → chunk-LLO7YF56.js} +44 -46
  33. package/dist/{chunk-VZ23KD5C.js → chunk-NGQA5JTN.js} +8 -10
  34. package/dist/{chunk-MATFO4ZW.js → chunk-OEWQACEH.js} +38 -39
  35. package/dist/chunk-PQKZ53DW.js +76 -0
  36. package/dist/{chunk-EGPJABTW.js → chunk-QVMYNWAN.js} +257 -103
  37. package/dist/{chunk-X5N72JHI.js → chunk-SO3VXCZV.js} +93 -92
  38. package/dist/{chunk-V5TUSOJX.js → chunk-SQKGZVG3.js} +45 -45
  39. package/dist/chunk-URKH6SE2.js +479 -0
  40. package/dist/{chunk-DLLXDCI2.js → chunk-VAJ4VX67.js} +5 -6
  41. package/dist/{chunk-POKX77OK.js → chunk-W5SQWSLC.js} +380 -535
  42. package/dist/{chunk-A4BCLP6K.js → chunk-YBS5GSRF.js} +64 -69
  43. package/dist/{chunk-OCQGHQED.js → chunk-YBX7R3MT.js} +12 -12
  44. package/dist/chunk-YSWLN2IJ.js +890 -0
  45. package/dist/commands/DbCommand.js +3 -3
  46. package/dist/commands/DbDrop.js +4 -5
  47. package/dist/commands/DbExecute.js +10 -8
  48. package/dist/commands/DbPull.js +17 -16
  49. package/dist/commands/DbPush.js +12 -11
  50. package/dist/commands/DbSeed.js +4 -5
  51. package/dist/commands/MigrateCommand.js +3 -3
  52. package/dist/commands/MigrateDeploy.js +14 -13
  53. package/dist/commands/MigrateDev.js +17 -16
  54. package/dist/commands/MigrateDiff.js +13 -11
  55. package/dist/commands/MigrateReset.js +16 -15
  56. package/dist/commands/MigrateResolve.js +12 -11
  57. package/dist/commands/MigrateStatus.js +12 -11
  58. package/dist/index.js +58 -60
  59. package/dist/internals/src/Generator.d.ts +23 -5
  60. package/dist/internals/src/WasmSchemaEngineLoader.d.ts +5 -0
  61. package/dist/internals/src/cli/checkUnsupportedDataProxy.d.ts +12 -17
  62. package/dist/internals/src/cli/directoryConfig.d.ts +7 -0
  63. package/dist/internals/src/cli/getSchema.d.ts +3 -28
  64. package/dist/internals/src/cli/hashes.d.ts +1 -2
  65. package/dist/internals/src/cli/schemaContext.d.ts +59 -0
  66. package/dist/internals/src/client/getClientEngineType.d.ts +1 -1
  67. package/dist/internals/src/convertCredentials.d.ts +1 -1
  68. package/dist/internals/src/engine-commands/getConfig.d.ts +1 -5
  69. package/dist/internals/src/engine-commands/getDmmf.d.ts +3 -6
  70. package/dist/internals/src/engine-commands/lintSchema.d.ts +1 -1
  71. package/dist/internals/src/errorReporting.d.ts +0 -1
  72. package/dist/internals/src/get-generators/getGenerators.d.ts +22 -9
  73. package/dist/internals/src/get-generators/utils/binaryTypeToEngineType.d.ts +1 -1
  74. package/dist/internals/src/get-generators/utils/engineTypeToBinaryType.d.ts +1 -1
  75. package/dist/internals/src/get-generators/utils/fixBinaryTargets.d.ts +1 -1
  76. package/dist/internals/src/get-generators/utils/getBinaryPathsByVersion.d.ts +1 -1
  77. package/dist/internals/src/get-generators/utils/getEngineVersionForGenerator.d.ts +1 -1
  78. package/dist/internals/src/get-generators/utils/printGeneratorConfig.d.ts +1 -1
  79. package/dist/internals/src/index.d.ts +9 -8
  80. package/dist/internals/src/migrateTypes.d.ts +63 -0
  81. package/dist/internals/src/panic.d.ts +1 -4
  82. package/dist/internals/src/resolvePkg.d.ts +7 -0
  83. package/dist/internals/src/types.d.ts +1 -1
  84. package/dist/internals/src/utils/extractPreviewFeatures.d.ts +2 -2
  85. package/dist/internals/src/utils/getEnvPaths.d.ts +1 -1
  86. package/dist/internals/src/utils/parseEnvValue.d.ts +1 -1
  87. package/dist/internals/src/utils/schemaFileInput.d.ts +0 -4
  88. package/dist/internals/src/utils/toSchemasContainer.d.ts +2 -3
  89. package/dist/internals/src/wasm.d.ts +3 -1
  90. package/dist/migrate/src/Migrate.d.ts +18 -7
  91. package/dist/migrate/src/SchemaEngine.d.ts +20 -50
  92. package/dist/migrate/src/SchemaEngineCLI.d.ts +139 -0
  93. package/dist/migrate/src/SchemaEngineWasm.d.ts +134 -0
  94. package/dist/migrate/src/commands/DbExecute.d.ts +1 -1
  95. package/dist/migrate/src/commands/DbPull.d.ts +1 -1
  96. package/dist/migrate/src/commands/DbPush.d.ts +1 -1
  97. package/dist/migrate/src/commands/MigrateDeploy.d.ts +1 -1
  98. package/dist/migrate/src/commands/MigrateDev.d.ts +1 -1
  99. package/dist/migrate/src/commands/MigrateDiff.d.ts +1 -1
  100. package/dist/migrate/src/commands/MigrateReset.d.ts +1 -1
  101. package/dist/migrate/src/commands/MigrateResolve.d.ts +1 -1
  102. package/dist/migrate/src/commands/MigrateStatus.d.ts +1 -1
  103. package/dist/migrate/src/index.d.ts +2 -2
  104. package/dist/migrate/src/types.d.ts +19 -19
  105. package/dist/migrate/src/utils/createMigration.d.ts +21 -0
  106. package/dist/migrate/src/utils/ensureDatabaseExists.d.ts +4 -6
  107. package/dist/migrate/src/utils/introspectSql.d.ts +3 -2
  108. package/dist/migrate/src/utils/listMigrations.d.ts +9 -0
  109. package/dist/migrate/src/utils/printDatasources.d.ts +1 -1
  110. package/dist/migrate/src/utils/seed.d.ts +0 -2
  111. package/dist/migrate/src/views/handleViewsIO.d.ts +2 -2
  112. package/dist/{multipart-parser-54WEFGGN-NLZG56KM.js → multipart-parser-ASKQAOL4-WZ47HU6G.js} +92 -125
  113. package/dist/{multipart-parser-NDLECNMN.js → multipart-parser-QCI3Y5IB.js} +66 -68
  114. package/dist/types.js +1 -1
  115. package/dist/{typescript-WN4QH2CP.js → typescript-2LKASCMC.js} +33 -33
  116. package/dist/{typescript-AILDXN3I.js → typescript-H3AVJ6KX.js} +32 -32
  117. package/dist/utils/byline.js +1 -1
  118. package/dist/utils/captureStdout.js +3 -3
  119. package/dist/utils/countModelsAndTypes.js +1 -1
  120. package/dist/utils/createMigration.js +27 -0
  121. package/dist/utils/customColors.js +1 -1
  122. package/dist/utils/ensureDatabaseExists.js +7 -7
  123. package/dist/utils/errors.js +1 -1
  124. package/dist/utils/flagErrors.js +1 -1
  125. package/dist/utils/getDatabaseVersionSafe.js +10 -5
  126. package/dist/utils/handleEvaluateDataloss.js +1 -1
  127. package/dist/utils/introspectSql.js +10 -5
  128. package/dist/utils/isSchemaEmpty.js +1 -1
  129. package/dist/utils/listMigrations.js +25 -0
  130. package/dist/utils/now.js +1 -1
  131. package/dist/utils/printDatasource.js +1 -1
  132. package/dist/utils/printDatasources.js +5 -5
  133. package/dist/utils/printFiles.js +5 -5
  134. package/dist/utils/printIntrospectedSchema.js +1 -1
  135. package/dist/utils/printMigrationId.js +1 -1
  136. package/dist/utils/promptForMigrationName.js +3 -3
  137. package/dist/utils/removeSchemaFiles.js +1 -1
  138. package/dist/utils/replaceOrAddDatasource.js +1 -1
  139. package/dist/utils/replaceOrAddDatasource.test.js +1 -1
  140. package/dist/utils/saveSchemaFiles.js +1 -1
  141. package/dist/utils/seed.js +4 -7
  142. package/dist/utils/setupCockroach.js +3 -3
  143. package/dist/utils/setupMSSQL.js +1583 -710
  144. package/dist/utils/setupMongo.js +6563 -5984
  145. package/dist/utils/setupMysql.js +508 -563
  146. package/dist/utils/setupPostgres.js +3 -3
  147. package/dist/utils/spinner.js +4 -7
  148. package/dist/utils/test-handlePanic.js +1 -30
  149. package/dist/utils/unixSocket.js +1 -1
  150. package/dist/views/handleViewsIO.js +3 -3
  151. package/package.json +15 -14
  152. package/dist/chunk-6C7ESGWY.js +0 -1184
  153. package/dist/chunk-DIAO4W7O.js +0 -5774
  154. package/dist/chunk-GKDFIHM2.js +0 -45
  155. package/dist/chunk-J46BJQHT.js +0 -268
  156. package/dist/chunk-KXMACMQC.js +0 -660
  157. package/dist/chunk-YUCPBDWV.js +0 -131
  158. package/dist/chunk-YYPMC5FN.js +0 -1407
  159. package/dist/internals/src/get-generators/generatorResolvers/generatorResolvers.d.ts +0 -15
  160. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.d.ts +0 -6
  161. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.d.ts +0 -9
  162. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.d.ts +0 -8
  163. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.d.ts +0 -6
  164. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.d.ts +0 -1
  165. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.d.ts +0 -20
  166. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.d.ts +0 -7
  167. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.d.ts +0 -20
  168. package/dist/internals/src/get-generators/utils/check-feature-flags/checkFeatureFlags.d.ts +0 -8
  169. package/dist/migrate/src/utils/getSchemaPathAndPrint.d.ts +0 -10
@@ -0,0 +1,233 @@
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_IK3BVD3Y_exports = {};
30
+ __export(chunk_IK3BVD3Y_exports, {
31
+ SchemaEngineWasm: () => SchemaEngineWasm
32
+ });
33
+ module.exports = __toCommonJS(chunk_IK3BVD3Y_exports);
34
+ var import_chunk_OEWQACEH = require("./chunk-OEWQACEH.js");
35
+ var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
36
+ var import_debug = __toESM(require("@prisma/debug"));
37
+ var import_internals = require("@prisma/internals");
38
+ var SchemaEngineWasm = class _SchemaEngineWasm {
39
+ engine;
40
+ // TODO: forward initial schema to the Wasm engine
41
+ schemaContext;
42
+ // TODO: forward enabled preview features to the Wasm engine
43
+ enabledPreviewFeatures;
44
+ // `isRunning` is set to true when the engine is initialized, and set to false when the engine is stopped
45
+ isRunning = false;
46
+ constructor({ debug = false, enabledPreviewFeatures, schemaContext, engine }) {
47
+ this.schemaContext = schemaContext;
48
+ this.enabledPreviewFeatures = enabledPreviewFeatures;
49
+ if (debug) {
50
+ import_debug.default.enable("SchemaEngine*");
51
+ }
52
+ this.engine = engine;
53
+ }
54
+ static async setup({ adapter, ...rest }) {
55
+ const engine = await import_internals.wasmSchemaEngineLoader.loadSchemaEngine(adapter);
56
+ return new _SchemaEngineWasm({ ...rest, engine });
57
+ }
58
+ runCommand(command, input) {
59
+ this.isRunning = true;
60
+ try {
61
+ return this.engine[command](input);
62
+ } catch (error) {
63
+ const e = error;
64
+ console.error("[schema-engine] error on command %s:\n%s", command, e);
65
+ if ((0, import_internals.isWasmPanic)(e)) {
66
+ const { message, stack } = (0, import_internals.getWasmError)(e);
67
+ throw new import_internals.RustPanic(serializePanic(message), stack, command, import_internals.ErrorArea.LIFT_CLI);
68
+ }
69
+ throw e;
70
+ }
71
+ }
72
+ /**
73
+ * Apply the migrations from the migrations directory to the database.
74
+ * This is the command behind prisma migrate deploy.
75
+ */
76
+ applyMigrations(input) {
77
+ return this.runCommand("applyMigrations", input);
78
+ }
79
+ /**
80
+ * Create the next migration in the migrations history.
81
+ * If draft is false and there are no unexecutable steps, it will also apply the newly created migration.
82
+ * Note: This will use the shadow database on the connectors where we need one.
83
+ */
84
+ createMigration(input) {
85
+ return this.runCommand("createMigration", input);
86
+ }
87
+ /**
88
+ * Execute a database script directly on the specified live database.
89
+ * Note that this may not be defined on all connectors.
90
+ */
91
+ async dbExecute(input) {
92
+ await this.runCommand("dbExecute", input);
93
+ return null;
94
+ }
95
+ /**
96
+ * Make the Schema engine panic. Only useful to test client error handling.
97
+ */
98
+ async debugPanic() {
99
+ this.runCommand("debugPanic", void 0);
100
+ return Promise.resolve(null);
101
+ }
102
+ /**
103
+ * The method called at the beginning of migrate dev to decide the course of action,
104
+ * based on the current state of the workspace.
105
+ * It acts as a wrapper around diagnoseMigrationHistory.
106
+ * Its role is to interpret the diagnostic output,
107
+ * and translate it to a concrete action to be performed by the CLI.
108
+ */
109
+ devDiagnostic(input) {
110
+ return this.runCommand("devDiagnostic", input);
111
+ }
112
+ /**
113
+ * Read the contents of the migrations directory and the migrations table, and returns their relative statuses.
114
+ * At this stage, the Schema engine only reads,
115
+ * it does not write to the database nor the migrations directory, nor does it use a shadow database.
116
+ */
117
+ diagnoseMigrationHistory(input) {
118
+ return this.runCommand("diagnoseMigrationHistory", input);
119
+ }
120
+ /**
121
+ * Make sure the Schema engine can connect to the database from the Prisma schema.
122
+ */
123
+ async ensureConnectionValidity(input) {
124
+ await this.runCommand("ensureConnectionValidity", input);
125
+ }
126
+ /**
127
+ * Development command for migrations.
128
+ * Evaluate the data loss induced by the next migration the engine would generate on the main database.
129
+ */
130
+ evaluateDataLoss(input) {
131
+ return this.runCommand("evaluateDataLoss", input);
132
+ }
133
+ /**
134
+ * Get the database version for error reporting.
135
+ * If no argument is given, the version of the database associated to the Prisma schema provided
136
+ * in the constructor will be returned.
137
+ */
138
+ getDatabaseVersion(input) {
139
+ return this.runCommand("version", input);
140
+ }
141
+ /**
142
+ * Given a Prisma schema, introspect the database definitions and update the schema with the results.
143
+ * `compositeTypeDepth` is optional, and only required for MongoDB.
144
+ */
145
+ async introspect({
146
+ schema,
147
+ force = false,
148
+ baseDirectoryPath,
149
+ viewsDirectoryPath,
150
+ compositeTypeDepth = -1,
151
+ namespaces
152
+ }) {
153
+ const introspectResult = await this.runCommand("introspect", {
154
+ schema,
155
+ force,
156
+ compositeTypeDepth,
157
+ namespaces: namespaces ?? null,
158
+ baseDirectoryPath
159
+ });
160
+ const { views } = introspectResult;
161
+ if (views) {
162
+ await (0, import_chunk_OEWQACEH.handleViewsIO)({ views, viewsDirectoryPath });
163
+ }
164
+ return introspectResult;
165
+ }
166
+ /**
167
+ * Compares two databases schemas from two arbitrary sources,
168
+ * and display the difference as either a human-readable summary,
169
+ * or an executable script that can be passed to dbExecute.
170
+ * Connection to a shadow database is only necessary when either the from or the to params is a migrations directory.
171
+ * Diffs have a direction. Which source is from and which is to matters.
172
+ * The resulting diff should be thought of as a migration from the schema in `args.from` to the schema in `args.to`.
173
+ * By default, we output a human-readable diff. If you want an executable script, pass the "script": true param.
174
+ */
175
+ async migrateDiff(input) {
176
+ const { stdout, ...rest } = await this.runCommand("diff", input);
177
+ if (stdout) {
178
+ process.stdout.write(stdout + "\n");
179
+ }
180
+ return rest;
181
+ }
182
+ /**
183
+ * Mark a migration as applied in the migrations table.
184
+ * There are two possible outcomes:
185
+ * - The migration is already in the table, but in a failed state. In this case, we will mark it as rolled back, then create a new entry.
186
+ * - The migration is not in the table. We will create a new entry in the migrations table. The started_at and finished_at will be the same.
187
+ * If it is already applied, we return a user-facing error.
188
+ */
189
+ async markMigrationApplied(input) {
190
+ await this.runCommand("markMigrationApplied", input);
191
+ }
192
+ /**
193
+ * Mark an existing failed migration as rolled back in the migrations table. It will still be there, but ignored for all purposes except as audit trail.
194
+ */
195
+ async markMigrationRolledBack(input) {
196
+ await this.runCommand("markMigrationRolledBack", input);
197
+ }
198
+ /**
199
+ * Try to make the database empty: no data and no schema.
200
+ * On most connectors, this is implemented by dropping and recreating the database.
201
+ * If that fails (most likely because of insufficient permissions),
202
+ * the engine attempts a “best effort reset” by inspecting the contents of the database and dropping them individually.
203
+ * Drop and recreate the database. The migrations will not be applied, as it would overlap with applyMigrations.
204
+ */
205
+ async reset() {
206
+ await this.runCommand("reset", void 0);
207
+ }
208
+ /**
209
+ * The command behind db push.
210
+ */
211
+ schemaPush(input) {
212
+ return this.runCommand("schemaPush", input);
213
+ }
214
+ /**
215
+ * SQL introspection that powers TypedSQL feature
216
+ * @param args
217
+ * @returns
218
+ */
219
+ introspectSql(input) {
220
+ return this.runCommand("introspectSql", input);
221
+ }
222
+ /**
223
+ * Stop the engine.
224
+ */
225
+ stop() {
226
+ this.isRunning = false;
227
+ this.engine.free();
228
+ }
229
+ };
230
+ function serializePanic(log) {
231
+ return `${(0, import_chunk_SKRR5WT4.red)((0, import_chunk_SKRR5WT4.bold)("Error in Schema engine.\nReason: "))}${log}
232
+ `;
233
+ }
@@ -16,16 +16,16 @@ 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_255BRND3_exports = {};
20
- __export(chunk_255BRND3_exports, {
19
+ var chunk_KRQEFTDT_exports = {};
20
+ __export(chunk_KRQEFTDT_exports, {
21
21
  printFiles: () => printFiles,
22
22
  printFilesFromMigrationIds: () => printFilesFromMigrationIds
23
23
  });
24
- module.exports = __toCommonJS(chunk_255BRND3_exports);
24
+ module.exports = __toCommonJS(chunk_KRQEFTDT_exports);
25
25
  var import_chunk_UP6FVCDK = require("./chunk-UP6FVCDK.js");
26
- var import_chunk_LKTTJWFT = require("./chunk-LKTTJWFT.js");
27
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
28
- var import_indent_string = (0, import_chunk_WWAWV7DQ.__toESM)((0, import_chunk_LKTTJWFT.require_indent_string)());
26
+ var import_chunk_2R6DII47 = require("./chunk-2R6DII47.js");
27
+ var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
28
+ var import_indent_string = (0, import_chunk_2ESYSVXG.__toESM)((0, import_chunk_2R6DII47.require_indent_string)());
29
29
  function printFiles(printPath, files) {
30
30
  const fileNames = Object.keys(files);
31
31
  const folders = printPath.split("/");
@@ -16,22 +16,53 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_EX2UWGES_exports = {};
20
- __export(chunk_EX2UWGES_exports, {
19
+ var chunk_KW633S3Y_exports = {};
20
+ __export(chunk_KW633S3Y_exports, {
21
21
  MigrateResolve: () => MigrateResolve
22
22
  });
23
- module.exports = __toCommonJS(chunk_EX2UWGES_exports);
24
- var import_chunk_KXMACMQC = require("./chunk-KXMACMQC.js");
25
- var import_chunk_GKDFIHM2 = require("./chunk-GKDFIHM2.js");
23
+ module.exports = __toCommonJS(chunk_KW633S3Y_exports);
26
24
  var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
27
- var import_chunk_DJMFXNR4 = require("./chunk-DJMFXNR4.js");
25
+ var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
26
+ var import_chunk_YSWLN2IJ = require("./chunk-YSWLN2IJ.js");
28
27
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
29
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
30
28
  var import_internals = require("@prisma/internals");
31
- var _MigrateResolve = class _MigrateResolve2 {
29
+ var MigrateResolve = class _MigrateResolve {
32
30
  static new() {
33
- return new _MigrateResolve2();
31
+ return new _MigrateResolve();
34
32
  }
33
+ static help = (0, import_internals.format)(`
34
+ Resolve issues with database migrations in deployment databases:
35
+ - recover from failed migrations
36
+ - baseline databases when starting to use Prisma Migrate on existing databases
37
+ - reconcile hotfixes done manually on databases with your migration history
38
+
39
+ Run "prisma migrate status" to identify if you need to use resolve.
40
+
41
+ Read more about resolving migration history issues: ${(0, import_internals.link)("https://pris.ly/d/migrate-resolve")}
42
+
43
+ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
44
+
45
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve [options]
46
+
47
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
48
+
49
+ -h, --help Display this help message
50
+ --config Custom path to your Prisma config file
51
+ --schema Custom path to your Prisma schema
52
+ --applied Record a specific migration as applied
53
+ --rolled-back Record a specific migration as rolled back
54
+
55
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
56
+
57
+ Update migrations table, recording a specific migration as applied
58
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --applied 20201231000000_add_users_table
59
+
60
+ Update migrations table, recording a specific migration as rolled back
61
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --rolled-back 20201231000000_add_users_table
62
+
63
+ Specify a schema
64
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --rolled-back 20201231000000_add_users_table --schema=./schema.prisma
65
+ `);
35
66
  async parse(argv, config) {
36
67
  const args = (0, import_internals.arg)(
37
68
  argv,
@@ -49,13 +80,17 @@ var _MigrateResolve = class _MigrateResolve2 {
49
80
  if ((0, import_internals.isError)(args)) {
50
81
  return this.help(args.message);
51
82
  }
52
- await (0, import_internals.checkUnsupportedDataProxy)("migrate resolve", args, config.schema, true);
53
83
  if (args["--help"]) {
54
84
  return this.help();
55
85
  }
56
86
  await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
57
- const { schemaPath } = await (0, import_chunk_GKDFIHM2.getSchemaPathAndPrint)(args["--schema"], config.schema);
58
- (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: await (0, import_chunk_DJMFXNR4.getDatasourceInfo)({ schemaPath }) });
87
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
88
+ schemaPathFromArg: args["--schema"],
89
+ schemaPathFromConfig: config.schema
90
+ });
91
+ const { migrationsDirPath } = (0, import_internals.inferDirectoryConfig)(schemaContext);
92
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate resolve", schemaContext });
93
+ (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource) });
59
94
  if (!args["--applied"] && !args["--rolled-back"]) {
60
95
  throw new Error(
61
96
  `--applied or --rolled-back must be part of the command like:
@@ -73,8 +108,11 @@ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_in
73
108
  )}`
74
109
  );
75
110
  }
76
- await (0, import_chunk_DJMFXNR4.ensureCanConnectToDatabase)(schemaPath);
77
- const migrate = new import_chunk_KXMACMQC.Migrate(schemaPath);
111
+ const adapter = await config.migrate?.adapter(process.env);
112
+ if (!adapter) {
113
+ await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
114
+ }
115
+ const migrate = await import_chunk_YSWLN2IJ.Migrate.setup({ adapter, migrationsDirPath, schemaContext });
78
116
  try {
79
117
  await migrate.markMigrationApplied({
80
118
  migrationId: args["--applied"]
@@ -94,8 +132,8 @@ Migration ${args["--applied"]} marked as applied.
94
132
  )}`
95
133
  );
96
134
  }
97
- await (0, import_chunk_DJMFXNR4.ensureCanConnectToDatabase)(schemaPath);
98
- const migrate = new import_chunk_KXMACMQC.Migrate(schemaPath);
135
+ await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
136
+ const migrate = await import_chunk_YSWLN2IJ.Migrate.setup({ adapter: void 0, migrationsDirPath, schemaContext });
99
137
  try {
100
138
  await migrate.markMigrationRolledBack({
101
139
  migrationId: args["--rolled-back"]
@@ -113,42 +151,8 @@ Migration ${args["--rolled-back"]} marked as rolled back.
113
151
  if (error) {
114
152
  return new import_internals.HelpError(`
115
153
  ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
116
- ${_MigrateResolve2.help}`);
154
+ ${_MigrateResolve.help}`);
117
155
  }
118
- return _MigrateResolve2.help;
156
+ return _MigrateResolve.help;
119
157
  }
120
158
  };
121
- (0, import_chunk_WWAWV7DQ.__publicField)(_MigrateResolve, "help", (0, import_internals.format)(`
122
- Resolve issues with database migrations in deployment databases:
123
- - recover from failed migrations
124
- - baseline databases when starting to use Prisma Migrate on existing databases
125
- - reconcile hotfixes done manually on databases with your migration history
126
-
127
- Run "prisma migrate status" to identify if you need to use resolve.
128
-
129
- Read more about resolving migration history issues: ${(0, import_internals.link)("https://pris.ly/d/migrate-resolve")}
130
-
131
- ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
132
-
133
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve [options]
134
-
135
- ${(0, import_chunk_SKRR5WT4.bold)("Options")}
136
-
137
- -h, --help Display this help message
138
- --config Custom path to your Prisma config file
139
- --schema Custom path to your Prisma schema
140
- --applied Record a specific migration as applied
141
- --rolled-back Record a specific migration as rolled back
142
-
143
- ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
144
-
145
- Update migrations table, recording a specific migration as applied
146
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --applied 20201231000000_add_users_table
147
-
148
- Update migrations table, recording a specific migration as rolled back
149
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --rolled-back 20201231000000_add_users_table
150
-
151
- Specify a schema
152
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate resolve --rolled-back 20201231000000_add_users_table --schema=./schema.prisma
153
- `));
154
- var MigrateResolve = _MigrateResolve;
@@ -16,59 +16,21 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_VVKOFN3Y_exports = {};
20
- __export(chunk_VVKOFN3Y_exports, {
19
+ var chunk_LLO7YF56_exports = {};
20
+ __export(chunk_LLO7YF56_exports, {
21
21
  MigrateCommand: () => MigrateCommand
22
22
  });
23
- module.exports = __toCommonJS(chunk_VVKOFN3Y_exports);
23
+ module.exports = __toCommonJS(chunk_LLO7YF56_exports);
24
24
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
25
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
26
25
  var import_internals = require("@prisma/internals");
27
- var _MigrateCommand = class _MigrateCommand2 {
26
+ var MigrateCommand = class _MigrateCommand {
28
27
  constructor(cmds) {
29
28
  this.cmds = cmds;
30
29
  }
31
30
  static new(cmds) {
32
- return new _MigrateCommand2(cmds);
31
+ return new _MigrateCommand(cmds);
33
32
  }
34
- async parse(argv, config) {
35
- const args = (0, import_internals.arg)(argv, {
36
- "--help": Boolean,
37
- "-h": "--help",
38
- "--config": String,
39
- "--preview-feature": Boolean,
40
- "--telemetry-information": String
41
- });
42
- if ((0, import_internals.isError)(args)) {
43
- return this.help(args.message);
44
- }
45
- if (args._.length === 0 || args["--help"]) {
46
- return this.help();
47
- }
48
- const commandName = args._[0];
49
- const cmd = this.cmds[commandName];
50
- if (cmd) {
51
- let argsForCmd;
52
- if (commandName === "diff") {
53
- argsForCmd = args["--preview-feature"] ? [...args._.slice(1), `--preview-feature`] : args._.slice(1);
54
- } else {
55
- const filteredArgs = args._.filter((item) => item !== "--preview-feature");
56
- argsForCmd = filteredArgs.slice(1);
57
- }
58
- return cmd.parse(argsForCmd, config);
59
- }
60
- return (0, import_internals.unknownCommand)(_MigrateCommand2.help, commandName);
61
- }
62
- help(error) {
63
- if (error) {
64
- return new import_internals.HelpError(`
65
- ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
66
- ${_MigrateCommand2.help}`);
67
- }
68
- return _MigrateCommand2.help;
69
- }
70
- };
71
- (0, import_chunk_WWAWV7DQ.__publicField)(_MigrateCommand, "help", (0, import_internals.format)(`
33
+ static help = (0, import_internals.format)(`
72
34
  Update the database schema with migrations
73
35
 
74
36
  ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
@@ -119,5 +81,41 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
119
81
  --from-url "$DATABASE_URL" \\
120
82
  --to-url "postgresql://login:password@localhost:5432/db" \\
121
83
  --script
122
- `));
123
- var MigrateCommand = _MigrateCommand;
84
+ `);
85
+ async parse(argv, config) {
86
+ const args = (0, import_internals.arg)(argv, {
87
+ "--help": Boolean,
88
+ "-h": "--help",
89
+ "--config": String,
90
+ "--preview-feature": Boolean,
91
+ "--telemetry-information": String
92
+ });
93
+ if ((0, import_internals.isError)(args)) {
94
+ return this.help(args.message);
95
+ }
96
+ if (args._.length === 0 || args["--help"]) {
97
+ return this.help();
98
+ }
99
+ const commandName = args._[0];
100
+ const cmd = this.cmds[commandName];
101
+ if (cmd) {
102
+ let argsForCmd;
103
+ if (commandName === "diff") {
104
+ argsForCmd = args["--preview-feature"] ? [...args._.slice(1), `--preview-feature`] : args._.slice(1);
105
+ } else {
106
+ const filteredArgs = args._.filter((item) => item !== "--preview-feature");
107
+ argsForCmd = filteredArgs.slice(1);
108
+ }
109
+ return cmd.parse(argsForCmd, config);
110
+ }
111
+ return (0, import_internals.unknownCommand)(_MigrateCommand.help, commandName);
112
+ }
113
+ help(error) {
114
+ if (error) {
115
+ return new import_internals.HelpError(`
116
+ ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
117
+ ${_MigrateCommand.help}`);
118
+ }
119
+ return _MigrateCommand.help;
120
+ }
121
+ };
@@ -16,20 +16,19 @@ 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_VZ23KD5C_exports = {};
20
- __export(chunk_VZ23KD5C_exports, {
19
+ var chunk_NGQA5JTN_exports = {};
20
+ __export(chunk_NGQA5JTN_exports, {
21
21
  CLI: () => CLI
22
22
  });
23
- module.exports = __toCommonJS(chunk_VZ23KD5C_exports);
23
+ module.exports = __toCommonJS(chunk_NGQA5JTN_exports);
24
24
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
25
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
26
25
  var import_internals = require("@prisma/internals");
27
- var _CLI = class _CLI2 {
26
+ var CLI = class _CLI {
28
27
  constructor(cmds) {
29
28
  this.cmds = cmds;
30
29
  }
31
30
  static new(cmds) {
32
- return new _CLI2(cmds);
31
+ return new _CLI(cmds);
33
32
  }
34
33
  async parse(argv, config) {
35
34
  const args = (0, import_internals.arg)(argv, {
@@ -70,10 +69,9 @@ var _CLI = class _CLI2 {
70
69
  if (error) {
71
70
  return new import_internals.HelpError(`
72
71
  ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.red)(`!`))} ${error}
73
- ${_CLI2.help}`);
72
+ ${_CLI.help}`);
74
73
  }
75
- return _CLI2.help;
74
+ return _CLI.help;
76
75
  }
76
+ static help = (0, import_internals.format)(`This is the internal CLI for @prisma/migrate`);
77
77
  };
78
- (0, import_chunk_WWAWV7DQ.__publicField)(_CLI, "help", (0, import_internals.format)(`This is the internal CLI for @prisma/migrate`));
79
- var CLI = _CLI;