@prisma/migrate 6.20.0-integration-merge-release-workflows2.1 → 6.20.0-integration-next.4

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 (64) hide show
  1. package/dist/Migrate.js +5 -7
  2. package/dist/SchemaEngineCLI.js +4 -4
  3. package/dist/SchemaEngineWasm.js +4 -4
  4. package/dist/bin.js +59 -62
  5. package/dist/{chunk-TW22Y3AA.js → chunk-272GEALL.js} +19 -23
  6. package/dist/{chunk-NB4FRYRQ.js → chunk-3I675WMS.js} +6 -6
  7. package/dist/{chunk-R4IWP35Z.js → chunk-ANKMSTAX.js} +12 -15
  8. package/dist/{chunk-6ORQRJLP.js → chunk-D7TRYHBP.js} +30 -114
  9. package/dist/{chunk-F2XCBEZ4.js → chunk-EC6XGJS6.js} +16 -45
  10. package/dist/{chunk-7TVX3D4W.js → chunk-F6PHYOSL.js} +27 -65
  11. package/dist/{chunk-OP2BDF75.js → chunk-FRY7T46S.js} +10 -11
  12. package/dist/{chunk-22YP3RXZ.js → chunk-GH6IOZTT.js} +7 -7
  13. package/dist/{chunk-VU5BLQUI.js → chunk-HFRA2WBM.js} +223 -22
  14. package/dist/{chunk-J33EXHZB.js → chunk-HNEFGYLW.js} +15 -38
  15. package/dist/{chunk-74LUB4XX.js → chunk-K4HINZKE.js} +27 -37
  16. package/dist/{chunk-PHXLQVPT.js → chunk-L7EZFBB4.js} +40 -68
  17. package/dist/{chunk-AXR7LS2N.js → chunk-PEUHUCS4.js} +4 -5
  18. package/dist/{chunk-BHJMJSM4.js → chunk-PI5GR2QW.js} +20 -19
  19. package/dist/{chunk-ZTIS675B.js → chunk-PYDC3Q6V.js} +136 -205
  20. package/dist/{chunk-Z27SI4AV.js → chunk-R2N4YKAR.js} +9 -7
  21. package/dist/{chunk-GSX25HRL.js → chunk-SYWL5XS4.js} +5 -5
  22. package/dist/{chunk-D4TRX77Y.js → chunk-WF7UXKO5.js} +6 -9
  23. package/dist/chunk-WHMCFTZO.js +176 -0
  24. package/dist/{chunk-3AKRTEIK.js → chunk-WQKZ5H57.js} +15 -18
  25. package/dist/{chunk-QVMYNWAN.js → chunk-XA2JOJS2.js} +157 -70
  26. package/dist/{chunk-O35BTK6Y.js → chunk-YFUB52PK.js} +9 -13
  27. package/dist/commands/DbDrop.js +3 -3
  28. package/dist/commands/DbExecute.js +6 -8
  29. package/dist/commands/DbPull.js +9 -11
  30. package/dist/commands/DbPush.js +7 -9
  31. package/dist/commands/DbSeed.js +3 -3
  32. package/dist/commands/MigrateDeploy.js +7 -9
  33. package/dist/commands/MigrateDev.js +7 -10
  34. package/dist/commands/MigrateDiff.js +7 -8
  35. package/dist/commands/MigrateReset.js +7 -10
  36. package/dist/commands/MigrateResolve.js +7 -9
  37. package/dist/commands/MigrateStatus.js +7 -9
  38. package/dist/index.js +37 -39
  39. package/dist/internals/src/cli/getSchema.d.ts +1 -15
  40. package/dist/migrate/src/Migrate.d.ts +1 -3
  41. package/dist/migrate/src/commands/MigrateDiff.d.ts +1 -0
  42. package/dist/migrate/src/utils/ensureDatabaseExists.d.ts +9 -3
  43. package/dist/migrate/src/utils/getDatabaseVersionSafe.d.ts +2 -1
  44. package/dist/migrate/src/utils/introspectSql.d.ts +2 -1
  45. package/dist/migrate/src/utils/seed.d.ts +0 -6
  46. package/dist/open-GFNXULGD.js +593 -0
  47. package/dist/utils/ensureDatabaseExists.js +6 -6
  48. package/dist/utils/getDatabaseVersionSafe.js +6 -8
  49. package/dist/utils/introspectSql.js +6 -8
  50. package/dist/utils/seed.js +2 -3
  51. package/dist/utils/setupCockroach.js +2 -2
  52. package/dist/utils/setupMSSQL.js +30734 -30124
  53. package/dist/utils/setupMongo.js +2048 -768
  54. package/dist/utils/setupPostgres.js +2 -2
  55. package/dist/utils/spinner.js +2 -3
  56. package/dist/views/handleViewsIO.js +2 -2
  57. package/package.json +11 -11
  58. package/dist/chunk-D6LYHB65.js +0 -905
  59. package/dist/chunk-RR6BKMNO.js +0 -80
  60. package/dist/chunk-VV4M6AN7.js +0 -233
  61. package/dist/migrate/src/utils/replaceOrAddDatasource.d.ts +0 -2
  62. package/dist/migrate/src/utils/replaceOrAddDatasource.test.d.ts +0 -1
  63. package/dist/utils/replaceOrAddDatasource.js +0 -25
  64. package/dist/utils/replaceOrAddDatasource.test.js +0 -207
@@ -26,24 +26,22 @@ 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_D7TRYHBP_exports = {};
30
+ __export(chunk_D7TRYHBP_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_D7TRYHBP_exports);
34
+ var import_chunk_HFRA2WBM = require("./chunk-HFRA2WBM.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
39
  var import_chunk_AI6DH66U = require("./chunk-AI6DH66U.js");
41
40
  var import_chunk_LGYRZ6CV = require("./chunk-LGYRZ6CV.js");
42
41
  var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
43
42
  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");
43
+ var import_chunk_K4HINZKE = require("./chunk-K4HINZKE.js");
44
+ var import_chunk_WHMCFTZO = require("./chunk-WHMCFTZO.js");
47
45
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
48
46
  var import_debug = __toESM(require("@prisma/debug"));
49
47
  var import_internals = require("@prisma/internals");
@@ -107,26 +105,21 @@ Set composite types introspection depth to 2 levels
107
105
  const args = (0, import_internals.arg)(argv, {
108
106
  "--help": Boolean,
109
107
  "-h": "--help",
110
- "--url": String,
111
108
  "--print": Boolean,
112
109
  "--schema": String,
113
110
  "--config": String,
114
111
  "--schemas": String,
115
112
  "--force": Boolean,
116
- "--composite-type-depth": Number,
113
+ "--composite-type-depth": Number
117
114
  // optional, only on mongodb
118
- "--local-d1": Boolean
119
- // optional, only on cloudflare D1
120
115
  });
121
- const spinnerFactory = (0, import_chunk_VU5BLQUI.createSpinner)(!args["--print"]);
116
+ const spinnerFactory = (0, import_chunk_HFRA2WBM.createSpinner)(!args["--print"]);
122
117
  if (args instanceof Error) {
123
118
  return this.help(args.message);
124
119
  }
125
120
  if (args["--help"]) {
126
121
  return this.help();
127
122
  }
128
- const url = args["--url"];
129
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: !args["--print"], config });
130
123
  const schemaContext = await (0, import_internals.loadSchemaContext)({
131
124
  schemaPathFromArg: args["--schema"],
132
125
  schemaPathFromConfig: config.schema,
@@ -135,113 +128,38 @@ Set composite types introspection depth to 2 levels
135
128
  allowNull: true
136
129
  });
137
130
  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
- });
131
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd, config });
149
132
  const adapter = config.engine === "js" ? await config.adapter() : void 0;
150
133
  if (schemaContext && !args["--print"]) {
151
134
  (0, import_internals.printSchemaLoadedMessage)(schemaContext.loadedFromPathForLogMessages);
152
- (0, import_chunk_2FXU5NZQ.printDatasource)({ datasourceInfo: (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext?.primaryDatasource), adapter });
135
+ (0, import_chunk_2FXU5NZQ.printDatasource)({ datasourceInfo: (0, import_chunk_K4HINZKE.parseDatasourceInfo)(schemaContext?.primaryDatasource, config), adapter });
153
136
  }
154
- const fromD1 = Boolean(args["--local-d1"]);
155
- if (!url && !schemaContext && !fromD1) {
137
+ if (!schemaContext) {
156
138
  throw new import_chunk_3WC4XD74.NoSchemaFoundError();
157
139
  }
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.
140
+ const firstDatasource = schemaContext.primaryDatasource;
141
+ const schema = schemaContext.schemaFiles;
142
+ await (0, import_internals.getConfig)({
143
+ datamodel: schema
144
+ });
145
+ const modelRegex = /\s*model\s*(\w+)\s*{/;
146
+ const isReintrospection = schema.some(([_, schema2]) => !!modelRegex.exec(schema2));
147
+ if (isReintrospection && !args["--force"] && firstDatasource?.provider === "mongodb") {
148
+ throw new Error(`Iterating on one schema using re-introspection with db pull is currently not supported with MongoDB provider.
230
149
  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
- )}
150
+ (0, import_internals.getCommandWithExecutor)("prisma db pull --force")
151
+ )}
233
152
  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
- }
153
+ "https://github.com/prisma/prisma/issues/9585"
154
+ )} for more info.`);
237
155
  }
238
- const migrate = await import_chunk_D6LYHB65.Migrate.setup({
156
+ const migrate = await import_chunk_WHMCFTZO.Migrate.setup({
239
157
  schemaEngineConfig: config,
240
- schemaContext: schemaContext ?? void 0,
158
+ schemaContext,
241
159
  extensions: config["extensions"]
242
160
  });
243
161
  const engine = migrate.engine;
244
- const basedOn = !args["--url"] && schemaContext?.primaryDatasource ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(schemaContext.loadedFromPathForLogMessages)}` : "";
162
+ const basedOn = firstDatasource ? ` based on datasource defined in ${(0, import_chunk_SKRR5WT4.underline)(schemaContext.loadedFromPathForLogMessages)}` : "";
245
163
  const introspectionSpinner = spinnerFactory(`Introspecting${basedOn}`);
246
164
  const before = Math.round(performance.now());
247
165
  let introspectionSchema = void 0;
@@ -278,7 +196,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("To fix this, you have two options:")}
278
196
  "schema.prisma"
279
197
  )} points to a database that is not empty (it must contain at least one table).
280
198
 
281
- Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
199
+ Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
282
200
  `);
283
201
  } else if (e.code === "P1003") {
284
202
  throw new Error(`
@@ -297,7 +215,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("To fix this, you have two options:")}
297
215
  "schema.prisma"
298
216
  )} points to an existing database.
299
217
 
300
- Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
218
+ Then you can run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db pull"))} again.
301
219
  `);
302
220
  } else if (e.code === "P1012") {
303
221
  process.stdout.write("\n");
@@ -337,14 +255,12 @@ Or run this command with the ${(0, import_chunk_SKRR5WT4.green)(
337
255
  modelsAndTypesMessage = `${modelsCountMessage}`;
338
256
  }
339
257
  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
258
  const introspectedSchemaPath = schemaContext?.loadedFromPathForLogMessages || introspectionSchema.files[0].path;
343
259
  introspectionSpinner.success(`Introspected ${modelsAndTypesCountMessage} into ${(0, import_chunk_SKRR5WT4.underline)(
344
260
  import_path.default.relative(process.cwd(), introspectedSchemaPath)
345
261
  )} in ${(0, import_chunk_SKRR5WT4.bold)((0, import_internals.formatms)(Math.round(performance.now()) - before))}
346
262
  ${(0, import_chunk_SKRR5WT4.yellow)(introspectionWarningsMessage)}
347
- ${`Run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma generate"))} to generate Prisma Client.`}${renderValidationWarning}`);
263
+ ${`Run ${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma generate"))} to generate Prisma Client.`}`);
348
264
  }
349
265
  return "";
350
266
  }
@@ -26,20 +26,19 @@ 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_F2XCBEZ4_exports = {};
30
- __export(chunk_F2XCBEZ4_exports, {
29
+ var chunk_EC6XGJS6_exports = {};
30
+ __export(chunk_EC6XGJS6_exports, {
31
31
  MigrateDev: () => MigrateDev
32
32
  });
33
- module.exports = __toCommonJS(chunk_F2XCBEZ4_exports);
33
+ module.exports = __toCommonJS(chunk_EC6XGJS6_exports);
34
34
  var import_chunk_C3722PDA = require("./chunk-C3722PDA.js");
35
35
  var import_chunk_7CQBDP4H = require("./chunk-7CQBDP4H.js");
36
36
  var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
37
37
  var import_chunk_UP6FVCDK = require("./chunk-UP6FVCDK.js");
38
38
  var import_chunk_3WC4XD74 = require("./chunk-3WC4XD74.js");
39
39
  var import_chunk_2FXU5NZQ = require("./chunk-2FXU5NZQ.js");
40
- var import_chunk_74LUB4XX = require("./chunk-74LUB4XX.js");
41
- var import_chunk_PHXLQVPT = require("./chunk-PHXLQVPT.js");
42
- var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
40
+ var import_chunk_K4HINZKE = require("./chunk-K4HINZKE.js");
41
+ var import_chunk_WHMCFTZO = require("./chunk-WHMCFTZO.js");
43
42
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
44
43
  var import_node_path = __toESM(require("node:path"));
45
44
  var import_debug = __toESM(require("@prisma/debug"));
@@ -52,7 +51,7 @@ var MigrateDev = class _MigrateDev {
52
51
  }
53
52
  static help = (0, import_internals.format)(`
54
53
  ${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)
55
-
54
+
56
55
  ${(0, import_chunk_SKRR5WT4.bold)("Usage")}
57
56
 
58
57
  ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate dev [options]
@@ -65,8 +64,6 @@ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
65
64
  -n, --name Name the migration
66
65
  --create-only Create a new migration but do not apply it
67
66
  The migration will be empty if there are no changes in Prisma schema
68
- --skip-generate Skip triggering generators (e.g. Prisma Client)
69
- --skip-seed Skip triggering seed
70
67
 
71
68
  ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
72
69
 
@@ -90,8 +87,6 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
90
87
  "--create-only": Boolean,
91
88
  "--schema": String,
92
89
  "--config": String,
93
- "--skip-generate": Boolean,
94
- "--skip-seed": Boolean,
95
90
  "--telemetry-information": String
96
91
  });
97
92
  if ((0, import_internals.isError)(args)) {
@@ -100,31 +95,31 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
100
95
  if (args["--help"]) {
101
96
  return this.help();
102
97
  }
103
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: true, config });
104
98
  const schemaContext = await (0, import_internals.loadSchemaContext)({
105
99
  schemaPathFromArg: args["--schema"],
106
100
  schemaPathFromConfig: config.schema,
107
101
  schemaEngineConfig: config
108
102
  });
109
103
  const { migrationsDirPath } = (0, import_internals.inferDirectoryConfig)(schemaContext, config);
110
- (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate dev", schemaContext });
111
- const datasourceInfo = (0, import_chunk_74LUB4XX.parseDatasourceInfo)(schemaContext.primaryDatasource);
104
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd: "migrate dev", config });
105
+ const datasourceInfo = (0, import_chunk_K4HINZKE.parseDatasourceInfo)(schemaContext.primaryDatasource, config);
112
106
  const adapter = config.engine === "js" ? await config.adapter() : void 0;
113
107
  (0, import_chunk_2FXU5NZQ.printDatasource)({ datasourceInfo, adapter });
114
108
  process.stdout.write("\n");
115
109
  (0, import_internals.validate)({ schemas: schemaContext.schemaFiles });
116
- let wasDbCreated;
117
- if (!adapter) {
118
- wasDbCreated = await (0, import_chunk_74LUB4XX.ensureDatabaseExists)(schemaContext.primaryDatasource);
119
- if (wasDbCreated) {
120
- process.stdout.write(wasDbCreated + "\n\n");
121
- }
110
+ const successMessage = await (0, import_chunk_K4HINZKE.ensureDatabaseExists)(
111
+ schemaContext.primaryDatasourceDirectory,
112
+ (0, import_internals.getSchemaDatasourceProvider)(schemaContext),
113
+ config
114
+ );
115
+ if (successMessage) {
116
+ process.stdout.write(successMessage + "\n\n");
122
117
  }
123
118
  const schemaFilter = {
124
119
  externalTables: config.tables?.external ?? [],
125
120
  externalEnums: config.enums?.external ?? []
126
121
  };
127
- const migrate = await import_chunk_D6LYHB65.Migrate.setup({
122
+ const migrate = await import_chunk_WHMCFTZO.Migrate.setup({
128
123
  schemaEngineConfig: config,
129
124
  migrationsDirPath,
130
125
  schemaContext,
@@ -280,30 +275,6 @@ ${(0, import_chunk_SKRR5WT4.green)("Your database is now in sync with your schem
280
275
  `
281
276
  );
282
277
  }
283
- if (!process.env.PRISMA_MIGRATE_SKIP_GENERATE && !args["--skip-generate"]) {
284
- await migrate.tryToRunGenerate(datasourceInfo);
285
- process.stdout.write("\n");
286
- }
287
- if (wasDbCreated && !process.env.PRISMA_MIGRATE_SKIP_SEED && !args["--skip-seed"]) {
288
- try {
289
- const seedCommandFromPrismaConfig = config.migrations?.seed;
290
- const seedCommandFromPkgJson = await (0, import_chunk_PHXLQVPT.getSeedCommandFromPackageJson)(process.cwd());
291
- const seedCommand = seedCommandFromPrismaConfig ?? seedCommandFromPkgJson;
292
- if (seedCommand) {
293
- process.stdout.write("\n");
294
- const successfulSeeding = await (0, import_chunk_PHXLQVPT.executeSeedCommand)({ commandFromConfig: seedCommand });
295
- if (successfulSeeding) {
296
- process.stdout.write(`
297
- ${process.platform === "win32" ? "" : "\u{1F331} "}The seed command has been executed.
298
- `);
299
- } else {
300
- process.exit(1);
301
- }
302
- }
303
- } catch (e) {
304
- console.error(e);
305
- }
306
- }
307
278
  return "";
308
279
  }
309
280
  logResetReason({ datasourceInfo, reason }) {
@@ -26,12 +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_7TVX3D4W_exports = {};
30
- __export(chunk_7TVX3D4W_exports, {
29
+ var chunk_F6PHYOSL_exports = {};
30
+ __export(chunk_F6PHYOSL_exports, {
31
31
  DbExecute: () => DbExecute
32
32
  });
33
- module.exports = __toCommonJS(chunk_7TVX3D4W_exports);
34
- var import_chunk_D6LYHB65 = require("./chunk-D6LYHB65.js");
33
+ module.exports = __toCommonJS(chunk_F6PHYOSL_exports);
34
+ var import_chunk_WHMCFTZO = require("./chunk-WHMCFTZO.js");
35
35
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
36
36
  var import_consumers = __toESM(require("node:stream/consumers"));
37
37
  var import_internals = require("@prisma/internals");
@@ -47,9 +47,7 @@ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
47
47
  -h, --help Display this help message
48
48
  --config Custom path to your Prisma config file
49
49
 
50
- ${(0, import_chunk_SKRR5WT4.italic)("Datasource input, only 1 must be provided:")}
51
- --url URL of the datasource to run the command on
52
- --schema Path to your Prisma schema file to take the datasource URL from
50
+ Datasource configuration is read from ${(0, import_chunk_SKRR5WT4.italic)("prisma.config.ts")}.
53
51
 
54
52
  ${(0, import_chunk_SKRR5WT4.italic)("Script input, only 1 must be provided:")}
55
53
  --file Path to a file. The content will be sent as the script to be executed
@@ -68,11 +66,11 @@ var DbExecute = class _DbExecute {
68
66
  static help = (0, import_internals.format)(`
69
67
  ${process.platform === "win32" ? "" : "\u{1F4DD} "}Execute native commands to your database
70
68
 
71
- This command takes as input a datasource, using ${(0, import_chunk_SKRR5WT4.green)(`--url`)} or ${(0, import_chunk_SKRR5WT4.green)(`--schema`)} and a script, using ${(0, import_chunk_SKRR5WT4.green)(
69
+ This command takes as input a datasource defined in ${(0, import_chunk_SKRR5WT4.italic)("prisma.config.ts")} and a script, using ${(0, import_chunk_SKRR5WT4.green)(
72
70
  `--stdin`
73
71
  )} or ${(0, import_chunk_SKRR5WT4.green)(`--file`)}.
74
- The input parameters are mutually exclusive, only 1 of each (datasource & script) must be provided.
75
-
72
+ The script input parameters are mutually exclusive, only 1 must be provided.
73
+
76
74
  The output of the command is connector-specific, and is not meant for returning data, but only to report success or failure.
77
75
 
78
76
  On SQL databases, this command takes as input a SQL script.
@@ -82,23 +80,14 @@ ${(0, import_chunk_SKRR5WT4.italic)(`This command is currently not supported on
82
80
 
83
81
  ${helpOptions}
84
82
  ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
85
-
86
- Execute the content of a SQL script file to the datasource URL taken from the schema
87
- ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute
88
- --file ./script.sql \\
89
- --schema schema.prisma
90
83
 
91
- Execute the SQL script from stdin to the datasource URL specified via the \`DATABASE_URL\` environment variable
92
- ${(0, import_chunk_SKRR5WT4.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
93
- prisma db execute \\
94
- --stdin \\
95
- --url="$DATABASE_URL"
84
+ Execute the content of a SQL script file using the datasource configured in prisma.config.ts
85
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma db execute --file ./script.sql
96
86
 
97
- Like previous example, but exposing the datasource url credentials to your terminal history
87
+ Execute the SQL script from stdin using the configured datasource
98
88
  ${(0, import_chunk_SKRR5WT4.dim)("$")} echo 'TRUNCATE TABLE dev;' | \\
99
89
  prisma db execute \\
100
- --stdin \\
101
- --url="mysql://root:root@localhost/mydb"
90
+ --stdin
102
91
  `);
103
92
  async parse(argv, config) {
104
93
  const args = (0, import_internals.arg)(
@@ -109,8 +98,6 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
109
98
  "--config": String,
110
99
  "--stdin": Boolean,
111
100
  "--file": String,
112
- "--schema": String,
113
- "--url": String,
114
101
  "--telemetry-information": String
115
102
  },
116
103
  false
@@ -121,33 +108,15 @@ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
121
108
  if (args["--help"]) {
122
109
  return this.help();
123
110
  }
124
- await (0, import_internals.loadEnvFile)({ schemaPath: args["--schema"], printMessage: false, config });
125
111
  const cmd = "db execute";
126
- (0, import_internals.checkUnsupportedSchemaEngineWasm)({
127
- cmd,
128
- config,
129
- args,
130
- flags: ["--url"]
131
- });
132
112
  if (args["--stdin"] && args["--file"]) {
133
113
  throw new Error(
134
- `--stdin and --file cannot be used at the same time. Only 1 must be provided.
114
+ `--stdin and --file cannot be used at the same time. Only 1 must be provided.
135
115
  See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
136
116
  );
137
117
  } else if (!args["--stdin"] && !args["--file"]) {
138
118
  throw new Error(
139
119
  `Either --stdin or --file must be provided.
140
- See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
141
- );
142
- }
143
- if (args["--url"] && args["--schema"]) {
144
- throw new Error(
145
- `--url and --schema cannot be used at the same time. Only 1 must be provided.
146
- See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
147
- );
148
- } else if (!args["--url"] && !args["--schema"]) {
149
- throw new Error(
150
- `Either --url or --schema must be provided.
151
120
  See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
152
121
  );
153
122
  }
@@ -167,28 +136,21 @@ See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExec
167
136
  if (args["--stdin"]) {
168
137
  script = await import_consumers.default.text(process.stdin);
169
138
  }
170
- let datasourceType;
171
- if (args["--url"]) {
172
- (0, import_internals.checkUnsupportedDataProxy)({ cmd, urls: [args["--url"]] });
173
- datasourceType = {
174
- tag: "url",
175
- url: args["--url"]
176
- };
177
- } else {
178
- const schemaContext = await (0, import_internals.loadSchemaContext)({
179
- schemaPathFromArg: args["--schema"],
180
- schemaPathFromConfig: config.schema,
181
- schemaEngineConfig: config,
182
- printLoadMessage: false
183
- });
184
- (0, import_internals.checkUnsupportedDataProxy)({ cmd, schemaContext });
185
- datasourceType = {
186
- tag: "schema",
187
- ...(0, import_internals.toSchemasContainer)(schemaContext.schemaFiles),
188
- configDir: schemaContext.primaryDatasourceDirectory
189
- };
139
+ if (config.engine === "js") {
140
+ throw new Error('engine: "js" is not yet supported in `db execute`.');
141
+ }
142
+ if (config.engine !== "classic" || !config.datasource?.url) {
143
+ throw new Error(
144
+ `A datasource URL must be provided via prisma.config.ts.
145
+ See \`${(0, import_chunk_SKRR5WT4.green)((0, import_internals.getCommandWithExecutor)("prisma db execute -h"))}\``
146
+ );
190
147
  }
191
- const migrate = await import_chunk_D6LYHB65.Migrate.setup({ schemaEngineConfig: config, extensions: config["extensions"] });
148
+ (0, import_internals.checkUnsupportedDataProxy)({ cmd, config });
149
+ const datasourceType = {
150
+ tag: "url",
151
+ url: config.datasource.url
152
+ };
153
+ const migrate = await import_chunk_WHMCFTZO.Migrate.setup({ schemaEngineConfig: config, extensions: config["extensions"] });
192
154
  try {
193
155
  await migrate.engine.dbExecute({
194
156
  script,
@@ -16,13 +16,12 @@ 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_OP2BDF75_exports = {};
20
- __export(chunk_OP2BDF75_exports, {
19
+ var chunk_FRY7T46S_exports = {};
20
+ __export(chunk_FRY7T46S_exports, {
21
21
  require_ms: () => require_ms,
22
- require_src: () => require_src,
23
- require_supports_color: () => require_supports_color
22
+ require_src: () => require_src
24
23
  });
25
- module.exports = __toCommonJS(chunk_OP2BDF75_exports);
24
+ module.exports = __toCommonJS(chunk_FRY7T46S_exports);
26
25
  var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
27
26
  var require_ms = (0, import_chunk_2ESYSVXG.__commonJS)({
28
27
  "../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports, module2) {
@@ -140,7 +139,7 @@ var require_ms = (0, import_chunk_2ESYSVXG.__commonJS)({
140
139
  }
141
140
  });
142
141
  var require_common = (0, import_chunk_2ESYSVXG.__commonJS)({
143
- "../../node_modules/.pnpm/debug@4.4.0/node_modules/debug/src/common.js"(exports, module2) {
142
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports, module2) {
144
143
  "use strict";
145
144
  function setup(env) {
146
145
  createDebug.debug = createDebug;
@@ -242,7 +241,7 @@ var require_common = (0, import_chunk_2ESYSVXG.__commonJS)({
242
241
  createDebug.namespaces = namespaces;
243
242
  createDebug.names = [];
244
243
  createDebug.skips = [];
245
- const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(" ", ",").split(",").filter(Boolean);
244
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
246
245
  for (const ns of split) {
247
246
  if (ns[0] === "-") {
248
247
  createDebug.skips.push(ns.slice(1));
@@ -316,7 +315,7 @@ var require_common = (0, import_chunk_2ESYSVXG.__commonJS)({
316
315
  }
317
316
  });
318
317
  var require_browser = (0, import_chunk_2ESYSVXG.__commonJS)({
319
- "../../node_modules/.pnpm/debug@4.4.0/node_modules/debug/src/browser.js"(exports, module2) {
318
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports, module2) {
320
319
  "use strict";
321
320
  exports.formatArgs = formatArgs;
322
321
  exports.save = save;
@@ -459,7 +458,7 @@ var require_browser = (0, import_chunk_2ESYSVXG.__commonJS)({
459
458
  function load() {
460
459
  let r;
461
460
  try {
462
- r = exports.storage.getItem("debug");
461
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
463
462
  } catch (error) {
464
463
  }
465
464
  if (!r && typeof process !== "undefined" && "env" in process) {
@@ -608,7 +607,7 @@ var require_supports_color = (0, import_chunk_2ESYSVXG.__commonJS)({
608
607
  }
609
608
  });
610
609
  var require_node = (0, import_chunk_2ESYSVXG.__commonJS)({
611
- "../../node_modules/.pnpm/debug@4.4.0/node_modules/debug/src/node.js"(exports, module2) {
610
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports, module2) {
612
611
  "use strict";
613
612
  var tty = (0, import_chunk_2ESYSVXG.__require)("tty");
614
613
  var util = (0, import_chunk_2ESYSVXG.__require)("util");
@@ -781,7 +780,7 @@ var require_node = (0, import_chunk_2ESYSVXG.__commonJS)({
781
780
  }
782
781
  });
783
782
  var require_src = (0, import_chunk_2ESYSVXG.__commonJS)({
784
- "../../node_modules/.pnpm/debug@4.4.0/node_modules/debug/src/index.js"(exports, module2) {
783
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports, module2) {
785
784
  "use strict";
786
785
  if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
787
786
  module2.exports = require_browser();
@@ -26,13 +26,13 @@ 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_22YP3RXZ_exports = {};
30
- __export(chunk_22YP3RXZ_exports, {
29
+ var chunk_GH6IOZTT_exports = {};
30
+ __export(chunk_GH6IOZTT_exports, {
31
31
  SchemaEngineWasm: () => SchemaEngineWasm
32
32
  });
33
- module.exports = __toCommonJS(chunk_22YP3RXZ_exports);
34
- var import_chunk_GSX25HRL = require("./chunk-GSX25HRL.js");
35
- var import_chunk_AXR7LS2N = require("./chunk-AXR7LS2N.js");
33
+ module.exports = __toCommonJS(chunk_GH6IOZTT_exports);
34
+ var import_chunk_SYWL5XS4 = require("./chunk-SYWL5XS4.js");
35
+ var import_chunk_PEUHUCS4 = require("./chunk-PEUHUCS4.js");
36
36
  var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
37
37
  var import_debug = __toESM(require("@prisma/debug"));
38
38
  var import_internals = require("@prisma/internals");
@@ -83,7 +83,7 @@ var SchemaEngineWasm = class _SchemaEngineWasm {
83
83
  const { message, stack } = (0, import_internals.getWasmError)(e);
84
84
  throw new import_internals.RustPanic(serializePanic(message), stack, command, import_internals.ErrorArea.LIFT_CLI);
85
85
  } else if ("code" in error) {
86
- throw new import_chunk_GSX25HRL.EngineError((0, import_chunk_SKRR5WT4.red)(`${error.code}
86
+ throw new import_chunk_SYWL5XS4.EngineError((0, import_chunk_SKRR5WT4.red)(`${error.code}
87
87
 
88
88
  ${(0, import_internals.relativizePathInPSLError)(error.message)}
89
89
  `), error.code);
@@ -189,7 +189,7 @@ ${(0, import_internals.relativizePathInPSLError)(error.message)}
189
189
  });
190
190
  const { views } = introspectResult;
191
191
  if (views) {
192
- await (0, import_chunk_AXR7LS2N.handleViewsIO)({ views, viewsDirectoryPath });
192
+ await (0, import_chunk_PEUHUCS4.handleViewsIO)({ views, viewsDirectoryPath });
193
193
  }
194
194
  return introspectResult;
195
195
  }