@prisma/migrate 6.20.0-dev.7 → 6.20.0-dev.9

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 (88) hide show
  1. package/dist/CLI.js +2 -2
  2. package/dist/Migrate.js +4 -8
  3. package/dist/SchemaEngineCLI.js +4 -4
  4. package/dist/SchemaEngineWasm.js +4 -4
  5. package/dist/bin.js +71 -74
  6. package/dist/chunk-3MCWUFUJ.js +169 -0
  7. package/dist/{chunk-O35BTK6Y.js → chunk-7BNYLV6P.js} +7 -14
  8. package/dist/{chunk-F2XCBEZ4.js → chunk-AIUUIREM.js} +27 -53
  9. package/dist/{chunk-74LUB4XX.js → chunk-BRPS327A.js} +23 -45
  10. package/dist/{chunk-7TVX3D4W.js → chunk-CQ6GMT2G.js} +23 -69
  11. package/dist/{chunk-EJG7GKM7.js → chunk-DCXZOUQV.js} +5 -5
  12. package/dist/{chunk-LLO7YF56.js → chunk-DYXUXG3K.js} +7 -7
  13. package/dist/{chunk-GSX25HRL.js → chunk-ENVEA7LT.js} +10 -13
  14. package/dist/{chunk-6ORQRJLP.js → chunk-FEUKQ7J3.js} +38 -132
  15. package/dist/{chunk-BHJMJSM4.js → chunk-IQWOR45L.js} +28 -24
  16. package/dist/{chunk-R4IWP35Z.js → chunk-IVL273O6.js} +20 -20
  17. package/dist/{chunk-PHXLQVPT.js → chunk-L7EZFBB4.js} +40 -68
  18. package/dist/{chunk-3AKRTEIK.js → chunk-N4SBKLAB.js} +24 -23
  19. package/dist/{chunk-NGQA5JTN.js → chunk-OAHBNV3B.js} +5 -5
  20. package/dist/{chunk-22YP3RXZ.js → chunk-OZ26HKM7.js} +7 -7
  21. package/dist/{chunk-AXR7LS2N.js → chunk-PEUHUCS4.js} +4 -5
  22. package/dist/{chunk-TW22Y3AA.js → chunk-QAOWTYGM.js} +31 -32
  23. package/dist/{chunk-2FXU5NZQ.js → chunk-QOPTDDIH.js} +5 -10
  24. package/dist/{chunk-J33EXHZB.js → chunk-S4LY555Z.js} +26 -46
  25. package/dist/{chunk-NB4FRYRQ.js → chunk-TLHUBVSH.js} +6 -6
  26. package/dist/{chunk-Z27SI4AV.js → chunk-TRUKHPCA.js} +20 -15
  27. package/dist/{chunk-D4TRX77Y.js → chunk-WF7UXKO5.js} +6 -9
  28. package/dist/{chunk-ZTIS675B.js → chunk-XFASRSQR.js} +81 -172
  29. package/dist/{chunk-3WC4XD74.js → chunk-XGTVKL4L.js} +11 -4
  30. package/dist/{chunk-VU5BLQUI.js → chunk-ZOT2HSX5.js} +218 -22
  31. package/dist/commands/DbCommand.js +2 -2
  32. package/dist/commands/DbDrop.js +5 -5
  33. package/dist/commands/DbExecute.js +5 -9
  34. package/dist/commands/DbPull.js +10 -16
  35. package/dist/commands/DbPush.js +8 -12
  36. package/dist/commands/DbSeed.js +3 -3
  37. package/dist/commands/MigrateCommand.js +2 -2
  38. package/dist/commands/MigrateDeploy.js +7 -11
  39. package/dist/commands/MigrateDev.js +8 -13
  40. package/dist/commands/MigrateDiff.js +6 -9
  41. package/dist/commands/MigrateReset.js +8 -13
  42. package/dist/commands/MigrateResolve.js +7 -11
  43. package/dist/commands/MigrateStatus.js +7 -11
  44. package/dist/index.js +44 -48
  45. package/dist/internals/src/cli/getSchema.d.ts +1 -15
  46. package/dist/migrate/src/CLI.d.ts +1 -1
  47. package/dist/migrate/src/Migrate.d.ts +2 -3
  48. package/dist/migrate/src/SchemaEngineCLI.d.ts +4 -3
  49. package/dist/migrate/src/commands/DbCommand.d.ts +1 -1
  50. package/dist/migrate/src/commands/DbDrop.d.ts +1 -1
  51. package/dist/migrate/src/commands/DbExecute.d.ts +1 -1
  52. package/dist/migrate/src/commands/DbPull.d.ts +1 -2
  53. package/dist/migrate/src/commands/DbPush.d.ts +1 -1
  54. package/dist/migrate/src/commands/MigrateCommand.d.ts +1 -1
  55. package/dist/migrate/src/commands/MigrateDeploy.d.ts +1 -1
  56. package/dist/migrate/src/commands/MigrateDev.d.ts +1 -1
  57. package/dist/migrate/src/commands/MigrateDiff.d.ts +2 -1
  58. package/dist/migrate/src/commands/MigrateReset.d.ts +1 -1
  59. package/dist/migrate/src/commands/MigrateResolve.d.ts +1 -1
  60. package/dist/migrate/src/commands/MigrateStatus.d.ts +1 -1
  61. package/dist/migrate/src/utils/ensureDatabaseExists.d.ts +9 -5
  62. package/dist/migrate/src/utils/errors.d.ts +3 -0
  63. package/dist/migrate/src/utils/getDatabaseVersionSafe.d.ts +2 -1
  64. package/dist/migrate/src/utils/introspectSql.d.ts +2 -2
  65. package/dist/migrate/src/utils/printDatasource.d.ts +1 -3
  66. package/dist/migrate/src/utils/seed.d.ts +0 -6
  67. package/dist/utils/ensureDatabaseExists.js +6 -6
  68. package/dist/utils/errors.js +8 -7
  69. package/dist/utils/getDatabaseVersionSafe.js +5 -9
  70. package/dist/utils/introspectSql.js +5 -9
  71. package/dist/utils/printDatasource.js +2 -2
  72. package/dist/utils/printDatasources.js +31 -3
  73. package/dist/utils/seed.js +2 -3
  74. package/dist/utils/setupMSSQL.js +18 -3
  75. package/dist/utils/spinner.js +2 -3
  76. package/dist/views/handleViewsIO.js +2 -2
  77. package/package.json +11 -11
  78. package/dist/chunk-AI6DH66U.js +0 -55
  79. package/dist/chunk-D6LYHB65.js +0 -905
  80. package/dist/chunk-RR6BKMNO.js +0 -80
  81. package/dist/chunk-T64SUJ5L.js +0 -46
  82. package/dist/chunk-VV4M6AN7.js +0 -233
  83. package/dist/migrate/src/utils/replaceOrAddDatasource.d.ts +0 -2
  84. package/dist/migrate/src/utils/replaceOrAddDatasource.test.d.ts +0 -1
  85. package/dist/migrate/src/utils/warnDatasourceDriverAdapter.d.ts +0 -2
  86. package/dist/utils/replaceOrAddDatasource.js +0 -25
  87. package/dist/utils/replaceOrAddDatasource.test.js +0 -207
  88. package/dist/utils/warnDatasourceDriverAdapter.js +0 -25
@@ -26,24 +26,21 @@ 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_6ORQRJLP_exports = {};
30
- __export(chunk_6ORQRJLP_exports, {
29
+ var chunk_FEUKQ7J3_exports = {};
30
+ __export(chunk_FEUKQ7J3_exports, {
31
31
  DbPull: () => DbPull
32
32
  });
33
- module.exports = __toCommonJS(chunk_6ORQRJLP_exports);
34
- var import_chunk_VU5BLQUI = require("./chunk-VU5BLQUI.js");
33
+ module.exports = __toCommonJS(chunk_FEUKQ7J3_exports);
34
+ var import_chunk_ZOT2HSX5 = require("./chunk-ZOT2HSX5.js");
35
35
  var import_chunk_AHJ2N6BJ = require("./chunk-AHJ2N6BJ.js");
36
36
  var import_chunk_JZ75RIMZ = require("./chunk-JZ75RIMZ.js");
37
- var import_chunk_RR6BKMNO = require("./chunk-RR6BKMNO.js");
38
37
  var import_chunk_RTGQXNX6 = require("./chunk-RTGQXNX6.js");
39
38
  var import_chunk_JFKDSUIE = require("./chunk-JFKDSUIE.js");
40
- var import_chunk_AI6DH66U = require("./chunk-AI6DH66U.js");
41
39
  var import_chunk_LGYRZ6CV = require("./chunk-LGYRZ6CV.js");
42
- var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
43
- var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
44
- var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
45
- var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
46
- var import_chunk_AXR7LS2N = require("./chunk-AXR7LS2N.js");
40
+ var import_chunk_XGTVKL4L = require("./chunk-XGTVKL4L.js");
41
+ var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
42
+ var import_chunk_BRPS327A = require("./chunk-BRPS327A.js");
43
+ var import_chunk_3MCWUFUJ = require("./chunk-3MCWUFUJ.js");
47
44
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
48
45
  var import_debug = __toESM(require("@prisma/debug"));
49
46
  var import_internals = require("@prisma/internals");
@@ -60,6 +57,8 @@ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
60
57
 
61
58
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull [flags/options]
62
59
 
60
+ The datasource URL configuration is read from the Prisma config file (e.g., ${(0, import_chunk_SKRR5WT4.italic)("prisma.config.ts")}).
61
+
63
62
  ${(0, import_chunk_SKRR5WT4.bold)("Flags")}
64
63
 
65
64
  -h, --help Display this help message
@@ -92,156 +91,65 @@ Set composite types introspection depth to 2 levels
92
91
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db pull --composite-type-depth=2
93
92
 
94
93
  `);
95
- urlToDatasource(url, defaultProvider) {
96
- const provider = defaultProvider || (0, import_internals.protocolToConnectorType)(`${url.split(":")[0]}:`);
97
- return (0, import_chunk_AI6DH66U.printDatasources)([
98
- {
99
- config: {},
100
- provider,
101
- name: "db",
102
- url
103
- }
104
- ]);
105
- }
106
- async parse(argv, config) {
94
+ async parse(argv, config, configDir) {
107
95
  const args = (0, import_internals.arg)(argv, {
108
96
  "--help": Boolean,
109
97
  "-h": "--help",
110
- "--url": String,
111
98
  "--print": Boolean,
112
99
  "--schema": String,
113
100
  "--config": String,
114
101
  "--schemas": String,
115
102
  "--force": Boolean,
116
- "--composite-type-depth": Number,
103
+ "--composite-type-depth": Number
117
104
  // optional, only on mongodb
118
- "--local-d1": Boolean
119
- // optional, only on cloudflare D1
120
105
  });
121
- const spinnerFactory = (0, import_chunk_VU5BLQUI.createSpinner)(!args["--print"]);
106
+ const spinnerFactory = (0, import_chunk_ZOT2HSX5.createSpinner)(!args["--print"]);
122
107
  if (args instanceof Error) {
123
108
  return this.help(args.message);
124
109
  }
125
110
  if (args["--help"]) {
126
111
  return this.help();
127
112
  }
128
- const url = args["--url"];
129
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: !args["--print"], config });
130
113
  const schemaContext = await (0, import_internals.loadSchemaContext)({
131
114
  schemaPathFromArg: args["--schema"],
132
115
  schemaPathFromConfig: config.schema,
133
- schemaEngineConfig: config,
134
116
  printLoadMessage: false,
135
117
  allowNull: true
136
118
  });
137
119
  const cmd = "db pull";
138
- (0, import_internals.checkUnsupportedDataProxy)({
139
- cmd,
140
- schemaContext: schemaContext && !url ? schemaContext : void 0,
141
- urls: [url]
142
- });
143
- (0, import_internals.checkUnsupportedSchemaEngineWasm)({
144
- cmd,
145
- config,
146
- args,
147
- flags: ["--url", "--local-d1"]
148
- });
149
- const adapter = config.engine === "js" ? await config.adapter() : void 0;
120
+ const validatedConfig = (0, import_internals.validatePrismaConfigWithDatasource)({ config, cmd });
121
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd, validatedConfig });
150
122
  if (schemaContext && !args["--print"]) {
151
123
  (0, import_internals.printSchemaLoadedMessage)(schemaContext.loadedFromPathForLogMessages);
152
- (0, import_chunk_2FXU5NZQ.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext?.primaryDatasource), adapter });
124
+ (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_BRPS327A.parseDatasourceInfo)(schemaContext?.primaryDatasource, validatedConfig) });
153
125
  }
154
- const fromD1 = Boolean(args["--local-d1"]);
155
- if (!url && !schemaContext && !fromD1) {
156
- throw new import_chunk_3WC4XD74.NoSchemaFoundError();
126
+ if (!schemaContext) {
127
+ throw new import_chunk_XGTVKL4L.NoSchemaFoundError();
157
128
  }
158
- const { firstDatasource, schema, validationWarning } = await (0, import_chunk_AXR7LS2N.z)({ url, schemaContext, fromD1 }).when(
159
- (input) => input.schemaContext !== null,
160
- async (input) => {
161
- const firstDatasource2 = input.schemaContext.primaryDatasource ? input.schemaContext.primaryDatasource : void 0;
162
- if (input.url) {
163
- let providerFromSchema = firstDatasource2?.provider;
164
- if (providerFromSchema === "postgres") {
165
- providerFromSchema = "postgresql";
166
- }
167
- const providerFromUrl = (0, import_internals.protocolToConnectorType)(`${input.url.split(":")[0]}:`);
168
- const schema2 = (0, import_chunk_RR6BKMNO.replaceOrAddDatasource)(
169
- this.urlToDatasource(input.url, providerFromSchema),
170
- input.schemaContext.schemaFiles
171
- );
172
- if (providerFromSchema && providerFromUrl && providerFromSchema !== providerFromUrl && Boolean(providerFromSchema === "cockroachdb" && providerFromUrl === "postgresql") === false) {
173
- throw new Error(
174
- `The database provider found in --url (${providerFromUrl}) is different from the provider found in the Prisma schema (${providerFromSchema}).`
175
- );
176
- }
177
- return { firstDatasource: firstDatasource2, schema: schema2, validationWarning: void 0 };
178
- } else if (input.fromD1) {
179
- const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--from-local-d1" });
180
- const pathToSQLiteFile = import_path.default.relative(input.schemaContext.schemaRootDir, d1Database);
181
- const schema2 = [
182
- ["schema.prisma", this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")]
183
- ];
184
- const config2 = await (0, import_internals.getConfig)({
185
- datamodel: schema2,
186
- ignoreEnvVarErrors: true
187
- });
188
- return { firstDatasource: config2.datasources[0], schema: schema2, validationWarning: void 0 };
189
- } else {
190
- await (0, import_internals.getConfig)({
191
- datamodel: input.schemaContext.schemaFiles,
192
- ignoreEnvVarErrors: false
193
- });
194
- }
195
- return { firstDatasource: firstDatasource2, schema: input.schemaContext.schemaFiles, validationWarning: void 0 };
196
- }
197
- ).when(
198
- (input) => input.fromD1 === true,
199
- async (_) => {
200
- const d1Database = await (0, import_internals.locateLocalCloudflareD1)({ arg: "--from-local-d1" });
201
- const pathToSQLiteFile = import_path.default.relative(process.cwd(), d1Database);
202
- const schemaContent = `generator client {
203
- provider = "prisma-client-js"
204
- }
205
- ${this.urlToDatasource(`file:${pathToSQLiteFile}`, "sqlite")}`;
206
- const schema2 = [["schema.prisma", schemaContent]];
207
- const config2 = await (0, import_internals.getConfig)({
208
- datamodel: schema2,
209
- ignoreEnvVarErrors: true
210
- });
211
- return { firstDatasource: config2.datasources[0], schema: schema2, validationWarning: void 0 };
212
- }
213
- ).when(
214
- (input) => input.url !== void 0,
215
- async (input) => {
216
- (0, import_internals.protocolToConnectorType)(`${input.url.split(":")[0]}:`);
217
- const schema2 = [["schema.prisma", this.urlToDatasource(input.url)]];
218
- const config2 = await (0, import_internals.getConfig)({
219
- datamodel: schema2,
220
- ignoreEnvVarErrors: true
221
- });
222
- return { firstDatasource: config2.datasources[0], schema: schema2, validationWarning: void 0 };
223
- }
224
- ).run();
225
- if (schemaContext) {
226
- const modelRegex = /\s*model\s*(\w+)\s*{/;
227
- const isReintrospection = schemaContext.schemaFiles.some(([_, schema2]) => !!modelRegex.exec(schema2));
228
- if (isReintrospection && !args["--force"] && firstDatasource?.provider === "mongodb") {
229
- throw new Error(`Iterating on one schema using re-introspection with db pull is currently not supported with MongoDB provider.
129
+ const firstDatasource = schemaContext.primaryDatasource;
130
+ const schema = schemaContext.schemaFiles;
131
+ await (0, import_internals.getConfig)({
132
+ datamodel: schema
133
+ });
134
+ const modelRegex = /\s*model\s*(\w+)\s*{/;
135
+ const isReintrospection = schema.some(([_, schema2]) => !!modelRegex.exec(schema2));
136
+ if (isReintrospection && !args["--force"] && firstDatasource?.provider === "mongodb") {
137
+ throw new Error(`Iterating on one schema using re-introspection with db pull is currently not supported with MongoDB provider.
230
138
  You can explicitly ignore and override your current local schema file with ${(0, import_chunk_SKRR5WT4.green)(
231
- (0, import_internals.getCommandWithExecutor)("prisma db pull --force")
232
- )}
139
+ (0, import_internals.getCommandWithExecutor)("prisma db pull --force")
140
+ )}
233
141
  Some information will be lost (relations, comments, mapped fields, @ignore...), follow ${(0, import_internals.link)(
234
- "https://github.com/prisma/prisma/issues/9585"
235
- )} for more info.`);
236
- }
142
+ "https://github.com/prisma/prisma/issues/9585"
143
+ )} for more info.`);
237
144
  }
238
- const migrate = await import_chunk_D6LYHB65.Migrate.setup({
145
+ const migrate = await import_chunk_3MCWUFUJ.Migrate.setup({
239
146
  schemaEngineConfig: config,
240
- schemaContext: schemaContext ?? void 0,
147
+ configDir,
148
+ schemaContext,
241
149
  extensions: config["extensions"]
242
150
  });
243
151
  const engine = migrate.engine;
244
- const basedOn = !args["--url"] && schemaContext?.primaryDatasource ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(schemaContext.loadedFromPathForLogMessages)}` : "";
152
+ const basedOn = firstDatasource ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(schemaContext.loadedFromPathForLogMessages)}` : "";
245
153
  const introspectionSpinner = spinnerFactory(`Introspecting${basedOn}`);
246
154
  const before = Math.round(performance.now());
247
155
  let introspectionSchema = void 0;
@@ -278,7 +186,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("To fix this, you have two options:")}
278
186
  "schema.prisma"
279
187
  )} points to a database that is not empty (it must contain at least one table).
280
188
 
281
- Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
189
+ Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
282
190
  `);
283
191
  } else if (e.code === "P1003") {
284
192
  throw new Error(`
@@ -297,7 +205,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("To fix this, you have two options:")}
297
205
  "schema.prisma"
298
206
  )} points to an existing database.
299
207
 
300
- Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
208
+ Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
301
209
  `);
302
210
  } else if (e.code === "P1012") {
303
211
  process.stdout.write("\n");
@@ -337,14 +245,12 @@ Or run this command with the ${(0, import_chunk_SKRR5WT4.green)(
337
245
  modelsAndTypesMessage = `${modelsCountMessage}`;
338
246
  }
339
247
  const modelsAndTypesCountMessage = modelsCount + typesCount > 1 ? `${modelsAndTypesMessage} and wrote them` : `${modelsAndTypesMessage} and wrote it`;
340
- const renderValidationWarning = validationWarning ? `
341
- ${(0, import_chunk_SKRR5WT4.yellow)(validationWarning)}` : "";
342
248
  const introspectedSchemaPath = schemaContext?.loadedFromPathForLogMessages || introspectionSchema.files[0].path;
343
249
  introspectionSpinner.success(`Introspected ${modelsAndTypesCountMessage} into ${(0, import_chunk_SKRR5WT4.underline)(
344
250
  import_path.default.relative(process.cwd(), introspectedSchemaPath)
345
251
  )} in ${(0, import_chunk_SKRR5WT4.bold)((0, import_internals.formatms)(Math.round(performance.now()) - before))}
346
252
  ${(0, import_chunk_SKRR5WT4.yellow)(introspectionWarningsMessage)}
347
- ${`Run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma generate"))} to generate Prisma Client.`}${renderValidationWarning}`);
253
+ ${`Run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma generate"))} to generate Prisma Client.`}`);
348
254
  }
349
255
  return "";
350
256
  }
@@ -26,15 +26,15 @@ 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_BHJMJSM4_exports = {};
30
- __export(chunk_BHJMJSM4_exports, {
29
+ var chunk_IQWOR45L_exports = {};
30
+ __export(chunk_IQWOR45L_exports, {
31
31
  MigrateDeploy: () => MigrateDeploy
32
32
  });
33
- module.exports = __toCommonJS(chunk_BHJMJSM4_exports);
33
+ module.exports = __toCommonJS(chunk_IQWOR45L_exports);
34
34
  var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
35
- var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
36
- var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
37
- var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
35
+ var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
36
+ var import_chunk_BRPS327A = require("./chunk-BRPS327A.js");
37
+ var import_chunk_3MCWUFUJ = require("./chunk-3MCWUFUJ.js");
38
38
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
39
39
  var import_debug = __toESM(require("@prisma/debug"));
40
40
  var import_internals = require("@prisma/internals");
@@ -50,6 +50,8 @@ ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
50
50
 
51
51
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate deploy [options]
52
52
 
53
+ The datasource URL configuration is read from the Prisma config file (e.g., ${(0, import_chunk_SKRR5WT4.italic)("prisma.config.ts")}).
54
+
53
55
  ${(0, import_chunk_SKRR5WT4.bold)("Options")}
54
56
 
55
57
  -h, --help Display this help message
@@ -65,7 +67,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
65
67
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate deploy --schema=./schema.prisma
66
68
 
67
69
  `);
68
- async parse(argv, config) {
70
+ async parse(argv, config, configDir) {
69
71
  const args = (0, import_internals.arg)(
70
72
  argv,
71
73
  {
@@ -83,37 +85,39 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
83
85
  if (args["--help"]) {
84
86
  return this.help();
85
87
  }
86
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
87
88
  const schemaContext = await (0, import_internals.loadSchemaContext)({
88
89
  schemaPathFromArg: args["--schema"],
89
- schemaPathFromConfig: config.schema,
90
- schemaEngineConfig: config
90
+ schemaPathFromConfig: config.schema
91
91
  });
92
92
  const { migrationsDirPath } = (0, import_internals.inferDirectoryConfig)(schemaContext, config);
93
- (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate deploy", schemaContext });
94
- const adapter = config.engine === "js" ? await config.adapter() : void 0;
95
- (0, import_chunk_2FXU5NZQ.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource), adapter });
93
+ const cmd = "migrate deploy";
94
+ const validatedConfig = (0, import_internals.validatePrismaConfigWithDatasource)({ config, cmd });
95
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd, validatedConfig });
96
+ (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_BRPS327A.parseDatasourceInfo)(schemaContext.primaryDatasource, validatedConfig) });
96
97
  const schemaFilter = {
97
98
  externalTables: config.tables?.external ?? [],
98
99
  externalEnums: config.enums?.external ?? []
99
100
  };
100
- const migrate = await import_chunk_D6LYHB65.Migrate.setup({
101
+ const migrate = await import_chunk_3MCWUFUJ.Migrate.setup({
101
102
  schemaEngineConfig: config,
103
+ configDir,
102
104
  migrationsDirPath,
103
105
  schemaContext,
104
106
  schemaFilter,
105
107
  extensions: config["extensions"]
106
108
  });
107
- if (!adapter) {
108
- try {
109
- const wasDbCreated = await (0, import_chunk_74LUB4XX.ensureDatabaseExists)(schemaContext.primaryDatasource);
110
- if (wasDbCreated) {
111
- process.stdout.write("\n" + wasDbCreated + "\n");
112
- }
113
- } catch (e) {
114
- process.stdout.write("\n");
115
- throw e;
109
+ try {
110
+ const successMessage = await (0, import_chunk_BRPS327A.ensureDatabaseExists)(
111
+ configDir,
112
+ (0, import_internals.getSchemaDatasourceProvider)(schemaContext),
113
+ validatedConfig
114
+ );
115
+ if (successMessage) {
116
+ process.stdout.write("\n" + successMessage + "\n");
116
117
  }
118
+ } catch (e) {
119
+ process.stdout.write("\n");
120
+ throw e;
117
121
  }
118
122
  const listMigrationDirectoriesResult = await migrate.listMigrationDirectories();
119
123
  debug({ listMigrationDirectoriesResult });
@@ -149,7 +153,7 @@ ${(0, import_chunk_KRQEFTDT.printFilesFromMigrationIds)(
149
153
  "migration.sql": ""
150
154
  }
151
155
  )}
152
-
156
+
153
157
  ${(0, import_chunk_SKRR5WT4.green)("All migrations have been successfully applied.")}`;
154
158
  }
155
159
  }
@@ -26,14 +26,14 @@ 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_R4IWP35Z_exports = {};
30
- __export(chunk_R4IWP35Z_exports, {
29
+ var chunk_IVL273O6_exports = {};
30
+ __export(chunk_IVL273O6_exports, {
31
31
  MigrateStatus: () => MigrateStatus
32
32
  });
33
- module.exports = __toCommonJS(chunk_R4IWP35Z_exports);
34
- var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
35
- var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
36
- var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
33
+ module.exports = __toCommonJS(chunk_IVL273O6_exports);
34
+ var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
35
+ var import_chunk_BRPS327A = require("./chunk-BRPS327A.js");
36
+ var import_chunk_3MCWUFUJ = require("./chunk-3MCWUFUJ.js");
37
37
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
38
38
  var import_debug = __toESM(require("@prisma/debug"));
39
39
  var import_internals = require("@prisma/internals");
@@ -48,7 +48,9 @@ Check the status of your database migrations
48
48
  ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
49
49
 
50
50
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate status [options]
51
-
51
+
52
+ The datasource URL configuration is read from the Prisma config file (e.g., ${(0, import_chunk_SKRR5WT4.italic)("prisma.config.ts")}).
53
+
52
54
  ${(0, import_chunk_SKRR5WT4.bold)("Options")}
53
55
 
54
56
  -h, --help Display this help message
@@ -63,7 +65,7 @@ Check the status of your database migrations
63
65
  Specify a schema
64
66
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate status --schema=./schema.prisma
65
67
  `);
66
- async parse(argv, config) {
68
+ async parse(argv, config, configDir) {
67
69
  const args = (0, import_internals.arg)(
68
70
  argv,
69
71
  {
@@ -81,30 +83,28 @@ Check the status of your database migrations
81
83
  if (args["--help"]) {
82
84
  return this.help();
83
85
  }
84
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
85
86
  const schemaContext = await (0, import_internals.loadSchemaContext)({
86
87
  schemaPathFromArg: args["--schema"],
87
- schemaPathFromConfig: config.schema,
88
- schemaEngineConfig: config
88
+ schemaPathFromConfig: config.schema
89
89
  });
90
90
  const { migrationsDirPath } = (0, import_internals.inferDirectoryConfig)(schemaContext, config);
91
- const adapter = config.engine === "js" ? await config.adapter() : void 0;
92
- (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate status", schemaContext });
93
- (0, import_chunk_2FXU5NZQ.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource), adapter });
91
+ const cmd = "migrate status";
92
+ const validatedConfig = (0, import_internals.validatePrismaConfigWithDatasource)({ config, cmd });
93
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd, validatedConfig });
94
+ (0, import_chunk_QOPTDDIH.printDatasource)({ datasourceInfo: (0, import_chunk_BRPS327A.parseDatasourceInfo)(schemaContext.primaryDatasource, validatedConfig) });
94
95
  const schemaFilter = {
95
96
  externalTables: config.tables?.external ?? [],
96
97
  externalEnums: config.enums?.external ?? []
97
98
  };
98
- const migrate = await import_chunk_D6LYHB65.Migrate.setup({
99
+ const migrate = await import_chunk_3MCWUFUJ.Migrate.setup({
99
100
  schemaEngineConfig: config,
101
+ configDir,
100
102
  migrationsDirPath,
101
103
  schemaContext,
102
104
  schemaFilter,
103
105
  extensions: config["extensions"]
104
106
  });
105
- if (!adapter) {
106
- await (0, import_chunk_74LUB4XX.ensureCanConnectToDatabase)(schemaContext.primaryDatasource);
107
- }
107
+ await (0, import_chunk_BRPS327A.ensureCanConnectToDatabase)(configDir, validatedConfig);
108
108
  let diagnoseResult;
109
109
  let listMigrationDirectoriesResult;
110
110
  try {
@@ -155,7 +155,7 @@ ${diagnoseResult.history.unpersistedMigrationNames.join("\n")}`);
155
155
  if (!diagnoseResult.hasMigrationsTable) {
156
156
  if (listMigrationDirectoriesResult.migrations.length === 0) {
157
157
  console.error(`The current database is not managed by Prisma Migrate.
158
-
158
+
159
159
  Read more about how to baseline an existing production database:
160
160
  ${(0, import_internals.link)("https://pris.ly/d/migrate-baseline")}`);
161
161
  process.exit(1);
@@ -182,7 +182,7 @@ During development if the failed migration(s) have not been deployed to a produc
182
182
  `
183
183
  );
184
184
  console.error(`The failed migration(s) can be marked as rolled back or applied:
185
-
185
+
186
186
  - If you rolled back the migration(s) manually:
187
187
  ${(0, import_chunk_SKRR5WT4.bold)((0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)(`prisma migrate resolve --rolled-back "${failedMigrations[0]}"`)))}
188
188